From patchwork Fri Sep 23 16:15:32 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: 9348445 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 38EE3607F2 for ; Fri, 23 Sep 2016 16:17:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 287FE2AC15 for ; Fri, 23 Sep 2016 16:17:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1AE1C2AC4E; Fri, 23 Sep 2016 16:17:45 +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 9E9932AC15 for ; Fri, 23 Sep 2016 16:17:44 +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 1bnT8f-00031N-Q5; Fri, 23 Sep 2016 16:15:49 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bnT8e-00030t-4F for xen-devel@lists.xenproject.org; Fri, 23 Sep 2016 16:15:48 +0000 Received: from [85.158.137.68] by server-1.bemta-3.messagelabs.com id F0/19-17152-33555E75; Fri, 23 Sep 2016 16:15:47 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHIsWRWlGSWpSXmKPExsXSO6nOVdc49Gm 4wfIXLBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bJxauZCnqlK67M2cPawLhQvIuRk0NIoI1J 4tZHyy5GLiD7G6PE4+7zLBDORkaJ5vuLWSGcbkaJpvV72SBaiiTu333PDGKzCKhKzLr5GSjOw cEmYCLxZpUjSFhEQE+ia00zWAmzQLbEmunzWUFsYYFAif93mxhBbF4Bc4l9XS+YIOZvY5SY9P cwC0RCUOLkzCcsEM1aEjf+vWQCmc8sIC2x/B8HSJhTwE7i+6Rp7CC2qICyxOL+HrDTJAQMJU4 /3MY4gVFoFpJJs5BMmoUwaQEj8ypGjeLUorLUIl1DU72kosz0jJLcxMwcXUMDY73c1OLixPTU nMSkYr3k/NxNjMBwZgCCHYxrtnseYpTkYFIS5VVyexouxJeUn1KZkVicEV9UmpNafIhRhoNDS YLXwQAoJ1iUmp5akZaZA4wsmLQEB4+SCG9VCFCat7ggMbc4Mx0idYpRUUqc1wIkIQCSyCjNg2 uDRfMlRlkpYV5GoEOEeApSi3IzS1DlXzGKczAqCfNqgUzhycwrgZv+CmgxE9Dib3eegCwuSUR ISTUwNtg+1XzMGKFeq6+h46697/ibiO4+6a/JAZUd864mT77qukp766M2z+sHFHIkmvuClfS7 mB//ClWqb9plfSHg9c/td8MMby+0fBCaELrgTMzhKYbzdm++aHrox7eFT0R/L3Y+tfyFnNaUE 2nbXnnF/70kxNVwr++UWtzX1GNcbHNOvEg3FHq+TImlOCPRUIu5qDgRALG5nW7hAgAA X-Env-Sender: konrad.wilk@oracle.com X-Msg-Ref: server-11.tower-31.messagelabs.com!1474647344!31496409!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 4739 invoked from network); 23 Sep 2016 16:15:46 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-11.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 23 Sep 2016 16:15:46 -0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u8NGFYSX020342 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 23 Sep 2016 16:15:35 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u8NGFYMP011942 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 23 Sep 2016 16:15:34 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u8NGFXja028458; Fri, 23 Sep 2016 16:15:33 GMT Received: from char.us.oracle.com (/10.137.176.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 23 Sep 2016 09:15:33 -0700 Received: by char.us.oracle.com (Postfix, from userid 1000) id 7331E6A0DEF; Fri, 23 Sep 2016 12:15:32 -0400 (EDT) Date: Fri, 23 Sep 2016 12:15:32 -0400 From: Konrad Rzeszutek Wilk To: Ross Lagerwall Message-ID: <20160923161532.GH25028@char.us.oracle.com> References: <1474479154-20991-1-git-send-email-konrad.wilk@oracle.com> <1474479154-20991-16-git-send-email-konrad.wilk@oracle.com> <8ab8a703-832a-408d-57a9-f4a2a4590ebe@citrix.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <8ab8a703-832a-408d-57a9-f4a2a4590ebe@citrix.com> User-Agent: Mutt/1.6.2 (2016-07-01) X-Source-IP: userv0021.oracle.com [156.151.31.71] Cc: julien.grall@arm.com, sstabellini@kernel.org, xen-devel@lists.xenproject.org Subject: Re: [Xen-devel] [PATCH v5 15/16] livepatch, arm[32|64]: Share arch_livepatch_revert 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 > Same as previously, can this not be done with a simple memcpy? Done! From caaf99c75f28486737c21f1fc5f584b67e088f35 Mon Sep 17 00:00:00 2001 From: Konrad Rzeszutek Wilk Date: Fri, 23 Sep 2016 11:25:12 -0400 Subject: [PATCH v6] livepatch, arm[32|64]: Share arch_livepatch_revert It is exactly the same in both platforms. No functional change. Acked-by: Julien Grall Signed-off-by: Konrad Rzeszutek Wilk --- Cc: Julien Grall Cc: Stefano Stabellini v3: New submission. v4: s/arch_livepatch_insn_len/livepatch_insn_len/ s/PATCH_INSN_SIZE/ARCH_PATCH_INSN_SIZE/ v5: Added Julien's Acked-by. Fixed comments. - Rebase on top "livepatch: Drop _jmp from arch_livepatch_[apply,revert]_jmp" - s/_jmp// v6: - Rebase on top ARM64 and ARM32 implementations which now have clean_and_invalidate_dcache_va_range on new_ptr. --- xen/arch/arm/arm32/livepatch.c | 13 +------------ xen/arch/arm/arm64/livepatch.c | 13 +------------ xen/arch/arm/livepatch.c | 13 +++++++++++++ 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/xen/arch/arm/arm32/livepatch.c b/xen/arch/arm/arm32/livepatch.c index d9a8caa..a7fd5e2 100644 --- a/xen/arch/arm/arm32/livepatch.c +++ b/xen/arch/arm/arm32/livepatch.c @@ -75,18 +75,7 @@ void arch_livepatch_apply(struct livepatch_func *func) clean_and_invalidate_dcache_va_range(new_ptr, sizeof (*new_ptr) * len); } -void arch_livepatch_revert(const struct livepatch_func *func) -{ - uint32_t *new_ptr; - unsigned int len; - - new_ptr = func->old_addr - (void *)_start + vmap_of_xen_text; - - len = livepatch_insn_len(func); - memcpy(new_ptr, func->opaque, len); - - clean_and_invalidate_dcache_va_range(new_ptr, len); -} +/* arch_livepatch_revert shared with ARM 32/ARM 64. */ int arch_livepatch_verify_elf(const struct livepatch_elf *elf) { diff --git a/xen/arch/arm/arm64/livepatch.c b/xen/arch/arm/arm64/livepatch.c index 558acb9..dae64f5 100644 --- a/xen/arch/arm/arm64/livepatch.c +++ b/xen/arch/arm/arm64/livepatch.c @@ -62,18 +62,7 @@ void arch_livepatch_apply(struct livepatch_func *func) clean_and_invalidate_dcache_va_range(new_ptr, sizeof (*new_ptr) * len); } -void arch_livepatch_revert(const struct livepatch_func *func) -{ - uint32_t *new_ptr; - unsigned int len; - - new_ptr = func->old_addr - (void *)_start + vmap_of_xen_text; - - len = livepatch_insn_len(func); - memcpy(new_ptr, func->opaque, len); - - clean_and_invalidate_dcache_va_range(new_ptr, len); -} +/* arch_livepatch_revert shared with ARM 32/ARM 64. */ int arch_livepatch_verify_elf(const struct livepatch_elf *elf) { diff --git a/xen/arch/arm/livepatch.c b/xen/arch/arm/livepatch.c index dfa285c..de95e54 100644 --- a/xen/arch/arm/livepatch.c +++ b/xen/arch/arm/livepatch.c @@ -69,6 +69,19 @@ int arch_livepatch_verify_func(const struct livepatch_func *func) return 0; } +void arch_livepatch_revert(const struct livepatch_func *func) +{ + uint32_t *new_ptr; + unsigned int len; + + new_ptr = func->old_addr - (void *)_start + vmap_of_xen_text; + + len = livepatch_insn_len(func); + memcpy(new_ptr, func->opaque, len); + + clean_and_invalidate_dcache_va_range(new_ptr, len); +} + void arch_livepatch_post_action(void) { /* arch_livepatch_revive has nuked the instruction cache. */