From patchwork Sun Sep 11 20:35:19 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: 9325571 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 F2ABF6048B for ; Sun, 11 Sep 2016 20:38:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1878284EF for ; Sun, 11 Sep 2016 20:38:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D61E128AB5; Sun, 11 Sep 2016 20:38:18 +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 0CBA8284EF for ; Sun, 11 Sep 2016 20:38:14 +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 1bjBTq-00020W-Nx; Sun, 11 Sep 2016 20:35:58 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bjBTq-0001wj-0b for xen-devel@lists.xenproject.org; Sun, 11 Sep 2016 20:35:58 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id B9/6A-27438-D20C5D75; Sun, 11 Sep 2016 20:35:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNLMWRWlGSWpSXmKPExsXSO6nOVVf3wNV wg7ud3Bbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aSrslsBStlKz7c2cPYwHhPoouRi0NIoI1J YsGO1SwQzjdGiYvzW6CcjYwS6zZOh3ImMEo8PN7L2sXIwcEmYCLxZpUjSFxEoI1R4tuJrewgD rPAXCaJ/qvPmboYOTmEBTwlJs/ewAZiswioSvzb3QQW5xVwl5h7oIsFZJCEgLzEs9v1IGFOoP DGOe/BwkICbhIneoxBwhIChhKnH25jnMDIt4CRYRWjenFqUVlqka6JXlJRZnpGSW5iZo6uoYG ZXm5qcXFiempOYlKxXnJ+7iZGYKAwAMEOxu7L/ocYJTmYlER5/RdcDRfiS8pPqcxILM6ILyrN SS0+xCjDwaEkwXt6H1BOsCg1PbUiLTMHGLIwaQkOHiUR3r8gad7igsTc4sx0iNQpRkUpcd4vI AkBkERGaR5cGyxOLjHKSgnzMgIdIsRTkFqUm1mCKv+KUZyDUUmY9wTIFJ7MvBK46a+AFjMBLX 669TLI4pJEhJRUA+Py93f3/BP9ydQQPGHy1VC9Sza+bWxsZmtmBetHLp16Sz29/HuXWufif4e 1vpdbGF0slOE5lVVqHRd3b7ZMnT9TwVvGzBtWAY92uOnXyT65aiqSu1g8bqW836YoneRn28tj 1vV/XRqmXXTw1OVpP489url7f/2+P8cSX/Ln9B0MLljjyHmn8qMSS3FGoqEWc1FxIgBrB9TRj gIAAA== X-Env-Sender: konrad.wilk@oracle.com X-Msg-Ref: server-3.tower-21.messagelabs.com!1473626155!32096253!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 52942 invoked from network); 11 Sep 2016 20:35:56 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-3.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 11 Sep 2016 20:35:56 -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 u8BKZmiL004862 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 11 Sep 2016 20:35:49 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u8BKZlhB029148 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 11 Sep 2016 20:35:48 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u8BKZkc3030394; Sun, 11 Sep 2016 20:35:47 GMT Received: from localhost.localdomain.com (/209.6.196.81) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 11 Sep 2016 13:35:46 -0700 From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, konrad@kernel.org, julien.grall@arm.com, sstabellini@kernel.org, ross.lagerwall@citrix.com Date: Sun, 11 Sep 2016 16:35:19 -0400 Message-Id: <1473626125-13683-13-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1473626125-13683-1-git-send-email-konrad.wilk@oracle.com> References: <1473626125-13683-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] Cc: Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , andrew.cooper3@citrix.com, Tim Deegan , Jan Beulich , Ian Jackson Subject: [Xen-devel] [PATCH v3 12/18] 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. v3: Moved 'asm(alter..)' by one space to the left. --- 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..6f53ab4 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"; }