From patchwork Thu Aug 25 13:37:18 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: 9299369 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 0661A60459 for ; Thu, 25 Aug 2016 13:40:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC66629332 for ; Thu, 25 Aug 2016 13:40:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0C0229335; Thu, 25 Aug 2016 13:40:25 +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 7711C29332 for ; Thu, 25 Aug 2016 13:40:25 +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 1bcurA-00011K-4U; Thu, 25 Aug 2016 13:38:08 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcur9-0000wi-EO for xen-devel@lists.xenproject.org; Thu, 25 Aug 2016 13:38:07 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id 05/7E-27438-EB4FEB75; Thu, 25 Aug 2016 13:38:06 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNLMWRWlGSWpSXmKPExsUyZ7p8oO6+L/v CDVY+Frb4vmUykwOjx+EPV1gCGKNYM/OS8isSWDP+X+9kK1gjVdHSd52pgfGDaBcjF4eQwEQm ie2HLzJBOL8ZJaatPM0M4WxklJg0ZxIjhDONUaLx/mTWLkYODjYBE4k3qxxB4iICfYwSh49uA urg5GAGcfadBrOFBaIlrjbfYAGxWQRUJeYf38wIYvMKuEns+L6RGWSOhIC8xLPb9SBhTgF3id 8Nm9lAbCGgku+XOsBaJQQMJT5vXMo8gZFvASPDKkb14tSistQiXTO9pKLM9IyS3MTMHF1DAzO 93NTi4sT01JzEpGK95PzcTYzAQGEAgh2M8074H2KU5GBSEuXVXrEvXIgvKT+lMiOxOCO+qDQn tfgQowwHh5IE75TPQDnBotT01Iq0zBxgyMKkJTh4lER4X4GkeYsLEnOLM9MhUqcYFaXEeatAE gIgiYzSPLg2WJxcYpSVEuZlBDpEiKcgtSg3swRV/hWjOAejkjDvPpApPJl5JXDTXwEtZgJa3H J/N8jikkSElFQDo9+3kC3LzovdarN21+sVYxPVrTcK+mKw7Ij1iVx3B9aKnSZn326Y+3Und/f h7APS7BJ8K/1m/Dgy29DjyebH29xNy0w3Wc7e9/TNAXs701nlDenrq01+nn9py/t4W9uUKYp8 odNfTw+sfZ+3hOUrz3N+7t+ygYUiJ0qetuziz/s9a7bTgU4RcSWW4oxEQy3mouJEAOrEmyOOA gAA X-Env-Sender: konrad.wilk@oracle.com X-Msg-Ref: server-15.tower-21.messagelabs.com!1472132284!30042101!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 64025 invoked from network); 25 Aug 2016 13:38:06 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-15.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 25 Aug 2016 13:38:06 -0000 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u7PDbmbp030496 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Aug 2016 13:37:48 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 u7PDbmo5010134 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Aug 2016 13:37:48 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u7PDbl7D017588; Thu, 25 Aug 2016 13:37:47 GMT Received: from localhost.event.rightround.com (/75.98.193.200) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 25 Aug 2016 06:37:47 -0700 From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, konrad@kernel.org, ross.lagerwall@citrix.com, sstabellini@kernel.org, julien.grall@arm.com Date: Thu, 25 Aug 2016 09:37:18 -0400 Message-Id: <1472132255-23470-4-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1472132255-23470-1-git-send-email-konrad.wilk@oracle.com> References: <1472132255-23470-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 v2 03/20] x86/arm64: Expose the ALT_[ORIG|REPL]_PTR macros to header files. 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 That way common code can use the same macro to access the most common attributes without much #ifdef. Take advantage of it right away in the livepatch code. Note: on ARM we use tabs to conform to the style of the file. Acked-by: Jan Beulich Signed-off-by: Konrad Rzeszutek Wilk Acked-by: Julien Grall --- Cc: Stefano Stabellini Cc: Julien Grall Cc: Jan Beulich Cc: Andrew Cooper v1: First submission v2: Added Jan's Ack Added extra set of paranetheses for __ALT_PTR (x86 & ARM) Used tabs instead of spaces on ARM header file. --- xen/arch/arm/alternative.c | 4 ---- xen/common/livepatch.c | 4 ++-- xen/include/asm-arm/alternative.h | 5 +++++ xen/include/asm-x86/alternative.h | 4 ++++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/alternative.c b/xen/arch/arm/alternative.c index 8ee5a11..bf4101c 100644 --- a/xen/arch/arm/alternative.c +++ b/xen/arch/arm/alternative.c @@ -32,10 +32,6 @@ #include #include -#define __ALT_PTR(a,f) (u32 *)((void *)&(a)->f + (a)->f) -#define ALT_ORIG_PTR(a) __ALT_PTR(a, orig_offset) -#define ALT_REPL_PTR(a) __ALT_PTR(a, alt_offset) - extern const struct alt_instr __alt_instructions[], __alt_instructions_end[]; struct alt_region { diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c index 528c0c9..774a51d 100644 --- a/xen/common/livepatch.c +++ b/xen/common/livepatch.c @@ -702,8 +702,8 @@ static int prepare_payload(struct payload *payload, for ( a = start; a < end; a++ ) { - const void *instr = &a->instr_offset + a->instr_offset; - const void *replacement = &a->repl_offset + a->repl_offset; + const void *instr = ALT_ORIG_PTR(a); + const void *replacement = ALT_REPL_PTR(a); if ( (instr < region->start && instr >= region->end) || (replacement < region->start && replacement >= region->end) ) diff --git a/xen/include/asm-arm/alternative.h b/xen/include/asm-arm/alternative.h index 4287bac..f25d3a7 100644 --- a/xen/include/asm-arm/alternative.h +++ b/xen/include/asm-arm/alternative.h @@ -21,6 +21,11 @@ struct alt_instr { u8 alt_len; /* size of new instruction(s), <= orig_len */ }; +/* Xen: helpers used by common code. */ +#define __ALT_PTR(a,f) ((u32 *)((void *)&(a)->f + (a)->f)) +#define ALT_ORIG_PTR(a) __ALT_PTR(a, orig_offset) +#define ALT_REPL_PTR(a) __ALT_PTR(a, alt_offset) + void __init apply_alternatives_all(void); int apply_alternatives(void *start, size_t length); diff --git a/xen/include/asm-x86/alternative.h b/xen/include/asm-x86/alternative.h index acaeded..de807c8 100644 --- a/xen/include/asm-x86/alternative.h +++ b/xen/include/asm-x86/alternative.h @@ -23,6 +23,10 @@ struct alt_instr { u8 replacementlen; /* length of new instruction, <= instrlen */ }; +#define __ALT_PTR(a,f) ((u8 *)((void *)&(a)->f + (a)->f)) +#define ALT_ORIG_PTR(a) __ALT_PTR(a, instr_offset) +#define ALT_REPL_PTR(a) __ALT_PTR(a, repl_offset) + extern void add_nops(void *insns, unsigned int len); /* Similar to apply_alternatives except it can be run with IRQs enabled. */ extern void apply_alternatives_nocheck(struct alt_instr *start,