From patchwork Thu Aug 25 13:37:31 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: 9299347 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 E3B3A60459 for ; Thu, 25 Aug 2016 13:40:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D400429334 for ; Thu, 25 Aug 2016 13:40:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C49B129335; Thu, 25 Aug 2016 13:40:08 +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 9962529332 for ; Thu, 25 Aug 2016 13:40:06 +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 1bcurF-0001CY-OG; Thu, 25 Aug 2016 13:38:13 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcurE-00018Z-Ab for xen-devel@lists.xenproject.org; Thu, 25 Aug 2016 13:38:12 +0000 Received: from [85.158.137.68] by server-1.bemta-3.messagelabs.com id B4/CD-17152-3C4FEB75; Thu, 25 Aug 2016 13:38:11 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRWlGSWpSXmKPExsUyZ7p8oO7hL/v CDZ59Z7H4vmUykwOjx+EPV1gCGKNYM/OS8isSWDNOt65gKvguU3Gm06+BcYtEFyMnh5DAZCaJ 5U80IexvjBJHu0sg7I2MEk2fcroYuYDsaYwSv+5tZOli5OBgEzCReLPKESQuItDHKHH46CZmE IdZYCuTxNaeS4wg3cICnhIHL1xkBrFZBFQl7i5bzwJi8wq4S7TvPMgGMkhCQF7i2e16kDAnUP h3w2Y2iMVuEt8vdYCVSwgYS7S/vcg2gZFvASPDKkb14tSistQiXUO9pKLM9IyS3MTMHF1DA2O 93NTi4sT01JzEpGK95PzcTYzAEGEAgh2Myz86HWKU5GBSEuXVXrEvXIgvKT+lMiOxOCO+qDQn tfgQowwHh5IEr+pnoJxgUWp6akVaZg4wWGHSEhw8SiK8ZiBp3uKCxNzizHSI1ClGRSlx3iqQh ABIIqM0D64NFiGXGGWlhHkZgQ4R4ilILcrNLEGVf8UozsGoJMy7D2QKT2ZeCdz0V0CLmYAWt9 zfDbK4JBEhJdXAaJRhM9vawkhoed8/tut+klmcqt9KFXuWMN4okNfTLlh7w/8Up0//mjK9vrJ jv8sYbSaIJ79IND0g99DErZllT03VdP5ZEbfqAn793n/YegHXz0nKN9Z/WLf39uIN/aydSzYV N5geiJbe4WF9ZI7np5DmXeuffNoYO49j50bW4zeMds5m6z+bocRSnJFoqMVcVJwIANkgdJmLA gAA X-Env-Sender: konrad.wilk@oracle.com X-Msg-Ref: server-11.tower-31.messagelabs.com!1472132289!31085263!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 36072 invoked from network); 25 Aug 2016 13:38:10 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-11.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 25 Aug 2016 13:38:10 -0000 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u7PDbxk4030632 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Aug 2016 13:38:00 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id u7PDbx1w009597 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 25 Aug 2016 13:37:59 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u7PDbwJ5025956; Thu, 25 Aug 2016 13:37:58 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:57 -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:31 -0400 Message-Id: <1472132255-23470-17-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: aserv0022.oracle.com [141.146.126.234] Cc: Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Tim Deegan , Jan Beulich , Ian Jackson Subject: [Xen-devel] [PATCH v2 16/20] livepatch: tests: Make them compile under ARM64 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 We need to two things: 1) Wrap the platform-specific objcopy parameters in defines The input and output parameters for $(OBJCOPY) are different based on the platforms. As such provide them in the OBJCOPY_MAGIC define and use that. 2) The alternative is a bit different and there are no exceptions under ARM (but there are under ARM 64). Also use one of the first config options for the CPU field feature. We are not yet attempting to build them under ARM32 so that is still ifdefed out. Signed-off-by: Konrad Rzeszutek Wilk --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc: Wei Liu v1: First submission v2: Corrected description by Julien Add #ifeq instead of #else for ARM case. --- xen/test/Makefile | 2 +- xen/test/livepatch/Makefile | 11 +++++++++-- xen/test/livepatch/xen_hello_world_func.c | 8 +++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/xen/test/Makefile b/xen/test/Makefile index 8c53040..95c1755 100644 --- a/xen/test/Makefile +++ b/xen/test/Makefile @@ -1,6 +1,6 @@ .PHONY: tests tests: -ifeq ($(XEN_TARGET_ARCH),x86_64) +ifneq $(XEN_TARGET_ARCH),arm32) $(MAKE) -f $(BASEDIR)/Rules.mk -C livepatch livepatch endif diff --git a/xen/test/livepatch/Makefile b/xen/test/livepatch/Makefile index 23dff1d..ce09e1d 100644 --- a/xen/test/livepatch/Makefile +++ b/xen/test/livepatch/Makefile @@ -1,5 +1,12 @@ include $(XEN_ROOT)/Config.mk +ifeq ($(XEN_TARGET_ARCH),x86_64) +OBJCOPY_MAGIC := -I binary -O elf64-x86-64 -B i386:x86-64 +endif +ifeq ($(XEN_TARGET_ARCH),arm64) +OBJCOPY_MAGIC := -I binary -O elf64-littleaarch64 -B aarch64 +endif + CODE_ADDR=$(shell nm --defined $(1) | grep $(2) | awk '{print "0x"$$1}') CODE_SZ=$(shell nm --defined -S $(1) | grep $(2) | awk '{ print "0x"$$2}') @@ -54,7 +61,7 @@ $(LIVEPATCH): xen_hello_world_func.o xen_hello_world.o note.o .PHONY: note.o note.o: $(OBJCOPY) -O binary --only-section=.note.gnu.build-id $(BASEDIR)/xen-syms $@.bin - $(OBJCOPY) -I binary -O elf64-x86-64 -B i386:x86-64 \ + $(OBJCOPY) $(OBJCOPY_MAGIC) \ --rename-section=.data=.livepatch.depends -S $@.bin $@ rm -f $@.bin @@ -65,7 +72,7 @@ note.o: .PHONY: hello_world_note.o hello_world_note.o: $(LIVEPATCH) $(OBJCOPY) -O binary --only-section=.note.gnu.build-id $(LIVEPATCH) $@.bin - $(OBJCOPY) -I binary -O elf64-x86-64 -B i386:x86-64 \ + $(OBJCOPY) $(OBJCOPY_MAGIC) \ --rename-section=.data=.livepatch.depends -S $@.bin $@ rm -f $@.bin diff --git a/xen/test/livepatch/xen_hello_world_func.c b/xen/test/livepatch/xen_hello_world_func.c index 03d6b84..a357ebf 100644 --- a/xen/test/livepatch/xen_hello_world_func.c +++ b/xen/test/livepatch/xen_hello_world_func.c @@ -6,14 +6,17 @@ #include #include +#ifdef CONFIG_X86 #include #include static unsigned long *non_canonical_addr = (unsigned long *)0xdead000000000000ULL; +#endif /* Our replacement function for xen_extra_version. */ const char *xen_hello_world(void) { +#ifdef CONFIG_X86 unsigned long tmp; int rc; @@ -24,7 +27,10 @@ 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)); +#endif return "Hello World"; }