From patchwork Wed Sep 7 04:05:08 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: 9318165 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 4A9ED60752 for ; Wed, 7 Sep 2016 04:08:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B99A29002 for ; Wed, 7 Sep 2016 04:08:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FCD429004; Wed, 7 Sep 2016 04:08:19 +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 954D229002 for ; Wed, 7 Sep 2016 04:08:18 +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 1bhU75-0004Gs-By; Wed, 07 Sep 2016 04:05:27 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bhU74-0004Gm-1x for xen-devel@lists.xenproject.org; Wed, 07 Sep 2016 04:05:26 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id 89/A5-29563-5029FC75; Wed, 07 Sep 2016 04:05:25 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHIsWRWlGSWpSXmKPExsUyZ7p8oC7LpPP hBmv/K1l83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBm7vx9gL/gvWzFh7WeWBsa5kl2MXBxCAq1M EquaVjNBOJ8ZJa5tegnlbGCUWNg1kxXC6WaU2L3uHEsXIyeQUySxvXESI4jNIqAi0f/jF3MXI wcHm4CJxJtVjiBhEQFlid5fv1lAepkFtjJKLOqbxQSSEBZwkPj7bjNYL6+AmcScvfOgtu1kkn g3s50FIiEocXLmEzCbWUBL4sY/kJM4gGxpieX/OEBMTgF7ibMnRUAqRIF2Le7vYQOxJQQMJU4 /3MY4gVFoFpJBs5AMmoUwaAEj8ypG9eLUorLUIl1LvaSizPSMktzEzBxdQwMzvdzU4uLE9NSc xKRiveT83E2MwHBmAIIdjHc3BRxilORgUhLlVQs8Fy7El5SfUpmRWJwRX1Sak1p8iFGGg0NJg jd4wvlwIcGi1PTUirTMHGBkwaQlOHiURHhXgaR5iwsSc4sz0yFSpxgVpcR5tUASAiCJjNI8uD ZYNF9ilJUS5mUEOkSIpyC1KDezBFX+FaM4B6OSMG8jyBSezLwSuOmvgBYzAS1et/s0yOKSRIS UVANj93qNHUfe87BzJOpfnFnM4PSzSXNehszxGTZX1rOtb7wfd4p3bkJNl9EfzseJcyOkDknF 3l0ZXPh6zpbfTYun8iY8nGZjdnqeoWz9ChPn+BlB+93yfFdaOB/5cPL4h+YfM3j3Zi+Pru68p CCX/fHm+YPXBCyN5oreL+O/Ml+JOeqMZXIfP8MVJZbijERDLeai4kQAYXRpv+ECAAA= X-Env-Sender: konrad.wilk@oracle.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1473221123!31936866!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 10020 invoked from network); 7 Sep 2016 04:05:24 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-5.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 7 Sep 2016 04:05:24 -0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u8745DMM002394 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 7 Sep 2016 04:05:15 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u8745Cmp012455 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 7 Sep 2016 04:05:12 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u87459Pr018804; Wed, 7 Sep 2016 04:05:10 GMT Received: from char.us.oracle.com (/10.137.176.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 06 Sep 2016 21:05:09 -0700 Received: by char.us.oracle.com (Postfix, from userid 1000) id A98F46A0DC2; Wed, 7 Sep 2016 00:05:08 -0400 (EDT) Date: Wed, 7 Sep 2016 00:05:08 -0400 From: Konrad Rzeszutek Wilk To: Jan Beulich Message-ID: <20160907040508.GA7629@char.us.oracle.com> References: <1472132255-23470-1-git-send-email-konrad.wilk@oracle.com> <20160831150651.GG8290@char.us.oracle.com> <1ea514e1-1bf7-6029-311d-c7798af8e424@arm.com> <25ec381c-3ca5-c06c-d95f-bdbbd24917cb@citrix.com> <57C719D6020000780010A933@prv-mh.provo.novell.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <57C719D6020000780010A933@prv-mh.provo.novell.com> User-Agent: Mutt/1.6.2 (2016-07-01) X-Source-IP: userv0021.oracle.com [156.151.31.71] Cc: Andrew Cooper , Julien Grall , sstabellini@kernel.org, xen-devel@lists.xenproject.org, ross.lagerwall@citrix.com Subject: Re: [Xen-devel] [PATCH v2] Livepatch for ARM 64 and 32. 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Wed, Aug 31, 2016 at 09:54:30AM -0600, Jan Beulich wrote: > >>> On 31.08.16 at 17:24, wrote: > > On 31/08/16 16:09, Julien Grall wrote: > >> On 31/08/16 16:06, Konrad Rzeszutek Wilk wrote: > >>> So you are thinking of exposing this 'xen feature bits' that Andrew > >>> mention > >>> to be on ARM as well. > >> > >> I only chat with Andrew about it and I have not looked at the code, so > >> I can't tell how it is on x86. I was just thinking to add LIVEPATCH > >> bit in cpufeature.h for now and be worry later when cpufeature will be > >> exposed to the toolstack for ARM. > > > > Sorry - I have forgotten what exactly the purpose of this bit needs to > > be, and therefore which bit of x86 I point you at. > > I'm pretty sure talk here is about X86_FEATURE_ALWAYS. Which is X86_FEATURE_LM, which is what we have in the test-case - and that 'lm' part is exposed to the toolstack. Anyhow I believe Julien was thinking something like this: (Would be nice if we could do arch-independent NOPs) diff --git a/xen/arch/arm/livepatch.c b/xen/arch/arm/livepatch.c index a076982..549f908 100644 --- a/xen/arch/arm/livepatch.c +++ b/xen/arch/arm/livepatch.c @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -167,6 +168,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/alternative.h b/xen/include/asm-arm/alternative.h index 9f88fd9..074ff63 100644 --- a/xen/include/asm-arm/alternative.h +++ b/xen/include/asm-arm/alternative.h @@ -165,6 +165,8 @@ static inline int apply_alternatives(void *start, size_t lenght) return 0; } +#define ALTERNATIVE(oldinstr, newinstr, ...) "" + #endif #endif /* __ASM_ALTERNATIVE_H */ diff --git a/xen/include/asm-arm/cpufeature.h b/xen/include/asm-arm/cpufeature.h index 66e930f..19e768b 100644 --- a/xen/include/asm-arm/cpufeature.h +++ b/xen/include/asm-arm/cpufeature.h @@ -40,7 +40,12 @@ #define ARM32_WORKAROUND_766422 2 #define ARM64_WORKAROUND_834220 3 +#ifdef CONFIG_LIVEPATCH +#define LIVEPATCH_FEATURE 4 +#define ARM_NCAPS 5 +#else #define ARM_NCAPS 4 +#endif #ifndef __ASSEMBLY__ diff --git a/xen/include/asm-x86/cpufeature.h b/xen/include/asm-x86/cpufeature.h index bcdf5d6..404dd91 100644 --- a/xen/include/asm-x86/cpufeature.h +++ b/xen/include/asm-x86/cpufeature.h @@ -34,6 +34,7 @@ XEN_CPUFEATURE(MFENCE_RDTSC, (FSCAPINTS+0)*32+ 9) /* MFENCE synchronizes RDTS /* An alias of a feature we know is always going to be present. */ #define X86_FEATURE_ALWAYS X86_FEATURE_LM +#define LIVEPATCH_FEATURE X86_FEATURE_ALWAYS #if !defined(__ASSEMBLY__) && !defined(X86_FEATURES_ONLY) #include diff --git a/xen/test/livepatch/xen_hello_world_func.c b/xen/test/livepatch/xen_hello_world_func.c index 6f53ab4..6b41a55 100644 --- a/xen/test/livepatch/xen_hello_world_func.c +++ b/xen/test/livepatch/xen_hello_world_func.c @@ -20,7 +20,6 @@ const char *xen_hello_world(void) unsigned long tmp; int rc; - alternative(ASM_NOP8, ASM_NOP1, X86_FEATURE_LM); /* * Any BUG, or WARN_ON will contain symbol and payload name. Furthermore * exceptions will be caught and processed properly. @@ -28,8 +27,11 @@ const char *xen_hello_world(void) rc = __get_user(tmp, non_canonical_addr); BUG_ON(rc != -EFAULT); #endif -#ifdef CONFIG_ARM_64 - asm(ALTERNATIVE("nop", "nop", ARM64_WORKAROUND_CLEAN_CACHE)); +#ifdef CONFIG_ARM + asm(ALTERNATIVE("nop", "nop", LIVEPATCH_FEATURE)); +#endif +#ifdef CONFIG_X86 + asm(ALTERNATIVE(ASM_NOP8, ASM_NOP1, LIVEPATCH_FEATURE); #endif return "Hello World"; }