From patchwork Fri Sep 16 16:38:26 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: 9336187 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 67A3260839 for ; Fri, 16 Sep 2016 16:41:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5810B2A039 for ; Fri, 16 Sep 2016 16:41:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CD862A03C; Fri, 16 Sep 2016 16:41:30 +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 D022A2A039 for ; Fri, 16 Sep 2016 16:41:29 +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 1bkwA6-0002fh-Io; Fri, 16 Sep 2016 16:38:50 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bkwA4-0002eN-P5 for xen-devel@lists.xenproject.org; Fri, 16 Sep 2016 16:38:48 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id 3E/71-03271-7102CD75; Fri, 16 Sep 2016 16:38:47 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjkeJIrShJLcpLzFFi42LpnVTnqiuucCf cYM4+VYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPf2+NMBRukK458bGJuYLwl1sXIxSEkMJFJ YtLcOexdjJxAzm9GiT+XhCESGxklWi9vZIJwuhkl2nauZ4GoKpL429DO2sXIwcEmYCLxZpUjS I2IQB+jxO2jfxlBapgFjCQmN74DqxcWCJDo+fmDDaSeRUBV4sJpcZAwr4C7xJE3z1hBbAkBOY ltW/YwgpRwAsV7zmVCbHKTWLJ+LRNEiaHE541LmScw8i9gZFjFqFGcWlSWWqRraKiXVJSZnlG Sm5iZo2toYKyXm1pcnJiempOYVKyXnJ+7iREYPgxAsINx9W+nQ4ySHExKorzFhbfDhfiS8lMq MxKLM+KLSnNSiw8xynBwKEnwfpW7Ey4kWJSanlqRlpkDDGSYtAQHj5II72KQNG9xQWJucWY6R OoUo6KUOG8NSEIAJJFRmgfXBoueS4yyUsK8jECHCPEUpBblZpagyr9iFOdgVBLmfQwyhSczrw Ru+iugxUxAi1fPug2yuCQRISXVwLjcPtDWYrfqjBu3fgW0Hb/yfwPzxIM1t2Z65wZn3gs6Xd4 WULGWne2r1LUbctlp9325d0v/D8vTi0vkfuentmKL3/ES0/vCPquXGHyxfR23wN/JfVfHPPkg Xt9mpv/XP/PMYI9M8U+4Wb5q2k7mhTXNpy4pnDoYaJeQ7LSC6ZWCa97bQruc3UosxRmJhlrMR cWJALic73OZAgAA X-Env-Sender: konrad@char.us.oracle.com X-Msg-Ref: server-8.tower-31.messagelabs.com!1474043925!61231762!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 54245 invoked from network); 16 Sep 2016 16:38:47 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-8.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 16 Sep 2016 16:38:47 -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 u8GGcZ94001701 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 16 Sep 2016 16:38:36 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u8GGcZ5s031980 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 16 Sep 2016 16:38:35 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u8GGcZ4q006138; Fri, 16 Sep 2016 16:38:35 GMT Received: from char.us.oracle.com (/10.137.176.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 16 Sep 2016 09:38:34 -0700 Received: by char.us.oracle.com (Postfix, from userid 1000) id A30D86A0E1B; Fri, 16 Sep 2016 12:38:33 -0400 (EDT) From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, konrad@kernel.org, ross.lagerwall@citrix.com, julien.grall@arm.com, sstabellini@kernel.org Date: Fri, 16 Sep 2016 12:38:26 -0400 Message-Id: <1474043908-12101-15-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1474043908-12101-1-git-send-email-konrad.wilk@oracle.com> References: <1474043908-12101-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: userv0022.oracle.com [156.151.31.74] Cc: Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v4 14/16] livepatch, arm[32|64]: Share arch_livepatch_revert_jmp 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 It is exactly the same in both platforms. No functional change. Signed-off-by: Konrad Rzeszutek Wilk Acked-by: Julien Grall --- 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/ --- xen/arch/arm/arm32/livepatch.c | 19 +------------------ xen/arch/arm/arm64/livepatch.c | 19 +------------------ xen/arch/arm/livepatch.c | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 36 deletions(-) diff --git a/xen/arch/arm/arm32/livepatch.c b/xen/arch/arm/arm32/livepatch.c index 6ad0ce5..606a00c 100644 --- a/xen/arch/arm/arm32/livepatch.c +++ b/xen/arch/arm/arm32/livepatch.c @@ -66,24 +66,7 @@ void arch_livepatch_apply_jmp(struct livepatch_func *func) clean_and_invalidate_dcache_va_range(func->old_addr, sizeof(*new_ptr) * len); } -void arch_livepatch_revert_jmp(const struct livepatch_func *func) -{ - uint32_t *new_ptr; - unsigned int i, len; - - new_ptr = func->old_addr - (void *)_start + vmap_of_xen_text; - len = livepatch_insn_len(func) / sizeof(uint32_t); - for ( i = 0; i < len; i++ ) - { - uint32_t insn; - - memcpy(&insn, func->opaque + (i * sizeof(uint32_t)), ARCH_PATCH_INSN_SIZE); - /* PATCH! */ - *(new_ptr + i) = insn; - } - - clean_and_invalidate_dcache_va_range(func->old_addr, sizeof(*new_ptr) * len); -} +/* arch_livepatch_revert_jmp shared with 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 d53fe59..89d061e 100644 --- a/xen/arch/arm/arm64/livepatch.c +++ b/xen/arch/arm/arm64/livepatch.c @@ -53,24 +53,7 @@ void arch_livepatch_apply_jmp(struct livepatch_func *func) clean_and_invalidate_dcache_va_range(new_ptr, sizeof(*new_ptr) * len); } -void arch_livepatch_revert_jmp(const struct livepatch_func *func) -{ - uint32_t *new_ptr; - unsigned int i, len; - - new_ptr = func->old_addr - (void *)_start + vmap_of_xen_text; - len = livepatch_insn_len(func) / sizeof(uint32_t); - for ( i = 0; i < len; i++ ) - { - uint32_t insn; - - memcpy(&insn, func->opaque + (i * sizeof(uint32_t)), ARCH_PATCH_INSN_SIZE); - /* PATCH! */ - *(new_ptr + i) = insn; - } - - clean_and_invalidate_dcache_va_range(func->old_addr, sizeof(*new_ptr) * len); -} +/* arch_livepatch_revert_jmp shared with ARM32. */ 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 9c198e9..c77030e 100644 --- a/xen/arch/arm/livepatch.c +++ b/xen/arch/arm/livepatch.c @@ -69,6 +69,25 @@ int arch_livepatch_verify_func(const struct livepatch_func *func) return 0; } +void arch_livepatch_revert_jmp(const struct livepatch_func *func) +{ + uint32_t *new_ptr; + unsigned int i, len; + + new_ptr = func->old_addr - (void *)_start + vmap_of_xen_text; + len = livepatch_insn_len(func) / sizeof(uint32_t); + for ( i = 0; i < len; i++ ) + { + uint32_t insn; + + memcpy(&insn, func->opaque + (i * sizeof(uint32_t)), ARCH_PATCH_INSN_SIZE); + /* PATCH! */ + *(new_ptr + i) = insn; + } + + clean_and_invalidate_dcache_va_range(new_ptr, sizeof(*new_ptr) * len); +} + void arch_livepatch_post_action(void) { /* arch_livepatch_revive has nuked the instruction cache. */