From patchwork Wed Sep 21 17:32:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek Wilk X-Patchwork-Id: 9343999 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E3BBB6077A for ; Wed, 21 Sep 2016 17:35:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1DF12A83D for ; Wed, 21 Sep 2016 17:35:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C69F62A846; Wed, 21 Sep 2016 17:35:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6A4B72A83D for ; Wed, 21 Sep 2016 17:35:26 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bmlP9-0004eb-9r; Wed, 21 Sep 2016 17:33:55 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bmlP8-0004di-Kn for xen-devel@lists.xenproject.org; Wed, 21 Sep 2016 17:33:54 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id F4/21-13744-284C2E75; Wed, 21 Sep 2016 17:33:54 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRWlGSWpSXmKPExsXSO6nOVbfxyKN wgwf98hbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8a/rxsZC5rEK95f/8jYwHhAuIuRi0NIYCKT xNtV79kgnC+MEtP6G6GcjYwSL/7NY+9i5ARyZjFKdNzQ7GLk4GATMJF4s8oRpEZEoI9RYuPV3 2wgNcwgzr7TzCA1wgIhEo/bhEHCLAKqEq/XvmIFsXkF3CWu9/9jBSmREJCXeHa7HiTMCRS+8+ gIM8QmN4m7/Q/ByiUEDCU+b1zKPIGRbwEjwypGjeLUorLUIl1jA72kosz0jJLcxMwcXUMDM73 c1OLixPTUnMSkYr3k/NxNjMAwYQCCHYx/1wYeYpTkYFIS5e3e8ihciC8pP6UyI7E4I76oNCe1 +BCjDAeHkgRv72GgnGBRanpqRVpmDjBgYdISHDxKIrwzQdK8xQWJucWZ6RCpU4yKUuK8HiAJA ZBERmkeXBssSi4xykoJ8zICHSLEU5BalJtZgir/ilGcg1FJmDcWZApPZl4J3PRXQIuZgBZv+f kAZHFJIkJKqoExYtqk+zMF7pn1NEyyeLc70u/rneVLfiY7Nq1pd+i6b3Pon7P4nSN3g3fzn1c Osv5tYsutkHNecJ3m486EG/9fXVlmbW7Tqid0cOOeDRsSZn7w0Vq1f0natq3OZ7gLTMoDKmYk Lli7QObQH/l7L5SX8d3lubJvUjXz1ImJCxZxM/YvWfGpSbWrQImlOCPRUIu5qDgRAHDwXhCNA gAA X-Env-Sender: konrad.wilk@oracle.com X-Msg-Ref: server-4.tower-27.messagelabs.com!1474479231!59686462!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33916 invoked from network); 21 Sep 2016 17:33:53 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-4.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 21 Sep 2016 17:33:53 -0000 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u8LHXDLP024431 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Sep 2016 17:33:13 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u8LHXDE0017543 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 21 Sep 2016 17:33:13 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u8LHX6rJ016486; Wed, 21 Sep 2016 17:33:12 GMT Received: from localhost.localdomain.localdomain (/172.58.216.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Sep 2016 10:33:01 -0700 From: Konrad Rzeszutek Wilk To: konrad@kernel.org, xen-devel@lists.xenproject.org, ross.lagerwall@citrix.com, sstabellini@kernel.org, julien.grall@arm.com Date: Wed, 21 Sep 2016 13:32:28 -0400 Message-Id: <1474479154-20991-11-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1474479154-20991-1-git-send-email-konrad.wilk@oracle.com> References: <1474479154-20991-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: userv0022.oracle.com [156.151.31.74] Cc: Andrew Cooper , Jan Beulich , Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v5 10/16] livepatch: x86, ARM, alternative: Expose FEATURE_LIVEPATCH X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP To use as a common way of testing alternative patching for livepatches. Both architectures have this FEATURE and the test-cases can piggyback on that. Suggested-by: Julien Grall Signed-off-by: Konrad Rzeszutek Wilk Acked-by: Julien Grall Reviewed-by: Ross Lagerwall --- Cc: Julien Grall Cc: Stefano Stabellini Cc: Jan Beulich Cc: Andrew Cooper v3: New submission v4: Move the LIVEPATCH_FEATURE to asm-x86/livepatch.h v5: Reorder the patch to be before " livepatch: tests: Make them compile under ARM64" Always expose FEATURE_LIVEPATCH on ARM. --- xen/arch/arm/livepatch.c | 3 +++ xen/include/asm-arm/cpufeature.h | 3 ++- xen/include/asm-x86/livepatch.h | 1 + xen/test/livepatch/xen_hello_world_func.c | 3 ++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/livepatch.c b/xen/arch/arm/livepatch.c index 5a99ab5..7855bc5 100644 --- a/xen/arch/arm/livepatch.c +++ b/xen/arch/arm/livepatch.c @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -177,6 +178,8 @@ void __init arch_livepatch_init(void) end = (void *)LIVEPATCH_VMAP_END; vm_init_type(VMAP_XEN, start, end); + + cpus_set_cap(LIVEPATCH_FEATURE); } /* diff --git a/xen/include/asm-arm/cpufeature.h b/xen/include/asm-arm/cpufeature.h index 66e930f..af60fe3 100644 --- a/xen/include/asm-arm/cpufeature.h +++ b/xen/include/asm-arm/cpufeature.h @@ -39,8 +39,9 @@ #define ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE 1 #define ARM32_WORKAROUND_766422 2 #define ARM64_WORKAROUND_834220 3 +#define LIVEPATCH_FEATURE 4 -#define ARM_NCAPS 4 +#define ARM_NCAPS 5 #ifndef __ASSEMBLY__ diff --git a/xen/include/asm-x86/livepatch.h b/xen/include/asm-x86/livepatch.h index 7dfc2e7..00aefd2 100644 --- a/xen/include/asm-x86/livepatch.h +++ b/xen/include/asm-x86/livepatch.h @@ -10,6 +10,7 @@ #define ARCH_PATCH_INSN_SIZE 5 #define ARCH_LIVEPATCH_RANGE SZ_2G +#define LIVEPATCH_FEATURE X86_FEATURE_ALWAYS #endif /* __XEN_X86_LIVEPATCH_H__ */ diff --git a/xen/test/livepatch/xen_hello_world_func.c b/xen/test/livepatch/xen_hello_world_func.c index 03d6b84..0321f3e 100644 --- a/xen/test/livepatch/xen_hello_world_func.c +++ b/xen/test/livepatch/xen_hello_world_func.c @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -17,7 +18,7 @@ const char *xen_hello_world(void) unsigned long tmp; int rc; - alternative(ASM_NOP8, ASM_NOP1, X86_FEATURE_LM); + alternative(ASM_NOP8, ASM_NOP1, LIVEPATCH_FEATURE); /* * Any BUG, or WARN_ON will contain symbol and payload name. Furthermore * exceptions will be caught and processed properly.