From patchwork Wed Sep 21 17:32:33 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: 9344001 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 C01966077A for ; Wed, 21 Sep 2016 17:35:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE3B82A83D for ; Wed, 21 Sep 2016 17:35:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A30262A846; Wed, 21 Sep 2016 17:35:27 +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 359E02A83D for ; Wed, 21 Sep 2016 17:35:27 +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 1bmlOc-00043Q-Hb; Wed, 21 Sep 2016 17:33:22 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bmlOb-00040c-Cd for xen-devel@lists.xenproject.org; Wed, 21 Sep 2016 17:33:21 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id CA/98-28857-064C2E75; Wed, 21 Sep 2016 17:33:20 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNLMWRWlGSWpSXmKPExsUyZ7p8oG7CkUf hBnfbOCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxVDbcYCx5KVSx5cpe5gbFJrIuRi0NIoI1J 4teFvewQzjdGibcvZrNAOBsZJR5efssM4cxilFg3fxVTFyMHB5uAicSbVY4gcRGBPkaJjVd/s 3UxcnIwCxhJTG58xwJiCwv4SDxdt4URxGYRUJX4/budCcTmFXCX+Lv4KBvIHAkBeYlnt+tBwp xA4TuPjjCD2EICbhJ3+x+ygtgSAoYSpx9uY5zAyLeAkWEVo3pxalFZapGuuV5SUWZ6RkluYma OrqGBmV5uanFxYnpqTmJSsV5yfu4mRmCgMADBDsaZl/0PMUpyMCmJ8nZveRQuxJeUn1KZkVic EV9UmpNafIhRhoNDSYK39zBQTrAoNT21Ii0zBxiyMGkJDh4lEd6ZIGne4oLE3OLMdIjUKUZFK XFeD5CEAEgiozQPrg0WJ5cYZaWEeRmBDhHiKUgtys0sQZV/xSjOwagkzKsGMoUnM68EbvoroM VMQIu3/HwAsrgkESEl1cDY2dy+eqnO9jUfmOMPb979QPBCRu6tuSEeX6dYnHnXe0h819UzmsY 7miwenV6hHd99LcjnwIkndYnBC6yO+/wuDuW6xBOWJPX+s7/YMTk3+UVKDnuXqe8QLuo12rAo nuNX7fXDL8WUna+2sj4+tTtIeInK+eef093eNs8s/rLU8czeXo0J87qNlFiKMxINtZiLihMBg pMBT44CAAA= X-Env-Sender: konrad.wilk@oracle.com X-Msg-Ref: server-13.tower-21.messagelabs.com!1474479198!34420201!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 41898 invoked from network); 21 Sep 2016 17:33:19 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-13.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 21 Sep 2016 17:33:19 -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 u8LHX9lA022172 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 21 Sep 2016 17:33:09 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 u8LHX8Ma015991 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 21 Sep 2016 17:33:09 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u8LHX8dW015259; Wed, 21 Sep 2016 17:33:08 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:08 -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:33 -0400 Message-Id: <1474479154-20991-16-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: userv0021.oracle.com [156.151.31.71] Cc: Konrad Rzeszutek Wilk Subject: [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: , 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. 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// --- xen/arch/arm/arm32/livepatch.c | 17 +---------------- xen/arch/arm/arm64/livepatch.c | 17 +---------------- xen/arch/arm/livepatch.c | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 32 deletions(-) diff --git a/xen/arch/arm/arm32/livepatch.c b/xen/arch/arm/arm32/livepatch.c index 3f47326..7e600f2 100644 --- a/xen/arch/arm/arm32/livepatch.c +++ b/xen/arch/arm/arm32/livepatch.c @@ -74,22 +74,7 @@ void arch_livepatch_apply(struct livepatch_func *func) clean_and_invalidate_dcache_va_range(func->new_addr, func->new_size); } -void arch_livepatch_revert(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; - } -} +/* 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 ea8044d..a7a292f 100644 --- a/xen/arch/arm/arm64/livepatch.c +++ b/xen/arch/arm/arm64/livepatch.c @@ -61,22 +61,7 @@ void arch_livepatch_apply(struct livepatch_func *func) clean_and_invalidate_dcache_va_range(func->new_addr, func->new_size); } -void arch_livepatch_revert(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; - } -} +/* 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 6ee7081..2d62a24 100644 --- a/xen/arch/arm/livepatch.c +++ b/xen/arch/arm/livepatch.c @@ -69,6 +69,23 @@ 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 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; + } +} + void arch_livepatch_post_action(void) { /* arch_livepatch_revive has nuked the instruction cache. */