From patchwork Fri Sep 16 16:38:21 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: 9336207 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 1A3E460839 for ; Fri, 16 Sep 2016 16:41:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B5832A039 for ; Fri, 16 Sep 2016 16:41:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F33F72A03F; Fri, 16 Sep 2016 16:41:44 +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 1ADBD2A039 for ; Fri, 16 Sep 2016 16:41:43 +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 1bkwA9-0002ji-Sa; Fri, 16 Sep 2016 16:38:53 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bkwA7-0002h9-Po for xen-devel@lists.xenproject.org; Fri, 16 Sep 2016 16:38:51 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id 5F/76-04595-B102CD75; Fri, 16 Sep 2016 16:38:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphkeJIrShJLcpLzFFi42KZM10+UFdK4U6 4wcUX/Bbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bLw/EFv+QqTkyawtzAOEuqi5GLQ0hgMpPE i4PvmLoYOYGc34wSj9+VQtgbGSUu3TODKOpmlJixcCcbRKJI4uvR94xdjBwcbAImEm9WOYLUi Aj0MUrcPvqXEcRhFtjKJLG15xIjSIOwgKfE9bkfmEEaWARUJRZ2B4CEeQXcJf5cPwdWIiEgJ7 Ftyx6wmZxA8Z5zmRCr3CSWrF/LBFFiLNH+9iLbBEb+BYwMqxjVi1OLylKLdC30kooy0zNKchM zc3QNDcz0clOLixPTU3MSk4r1kvNzNzECQ4cBCHYwzr7sf4hRkoNJSZS3uPB2uBBfUn5KZUZi cUZ8UWlOavEhRhkODiUJ3jL5O+FCgkWp6akVaZk5wCCGSUtw8CiJ8CqApHmLCxJzizPTIVKnG BWlxHmzQBICIImM0jy4NljkXGKUlRLmZQQ6RIinILUoN7MEVf4VozgHo5Iw72M5oCk8mXklcN NfAS1mAlq8etZtkMUliQgpqQZG8R/KyT32kVNkjKZx5yRNEboimyJV7G79N6sjfc6ujq32k3s m/+pbd/ijuCXP7uzy9e53KyanuPc9WJ/NeCW1j0ll9pUyr38Pop3PXeCwbmvTaXjyTq989+S/ SZfvuRlPNZ4SrtTC+W3LgpX+0Zev3Qjr5crL2z7x7QO3I/H3eXfOWDYvZYaOEktxRqKhFnNRc SIAA6iriZcCAAA= X-Env-Sender: konrad@char.us.oracle.com X-Msg-Ref: server-6.tower-27.messagelabs.com!1474043928!59816204!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 43513 invoked from network); 16 Sep 2016 16:38:49 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-6.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 16 Sep 2016 16:38:49 -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 u8GGcbS4030502 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 16 Sep 2016 16:38:37 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id u8GGcaHW006856 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 16 Sep 2016 16:38:36 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u8GGcZ2v006148; 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:35 -0700 Received: by char.us.oracle.com (Postfix, from userid 1000) id 2BD6F6A0E0C; 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:21 -0400 Message-Id: <1474043908-12101-10-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: 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 v4 09/16] 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. v4: Rebase on top of "livepatch/tests: Make .livepatch.depends be read-only" --- xen/test/Makefile | 2 +- xen/test/livepatch/Makefile | 12 ++++++++++-- xen/test/livepatch/xen_hello_world_func.c | 8 +++++++- 3 files changed, 18 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 48ff843..5db4d9c 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,8 +61,9 @@ $(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,alloc,load,readonly,data,contents -S $@.bin $@ + --rename-section=.data=.livepatch.depends -S $@.bin $@ rm -f $@.bin # @@ -65,7 +73,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,alloc,load,readonly,data,contents -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"; }