From patchwork Fri Sep 23 01:33:09 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: 9347281 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 83F9F6077A for ; Fri, 23 Sep 2016 01:35:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C37A2AD07 for ; Fri, 23 Sep 2016 01:35:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F91D2AD1C; Fri, 23 Sep 2016 01:35:50 +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 6F3212AD07 for ; Fri, 23 Sep 2016 01:35:49 +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 1bnFMr-0003vP-9m; Fri, 23 Sep 2016 01:33:33 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bnFMp-0003vG-SE for xen-devel@lists.xenproject.org; Fri, 23 Sep 2016 01:33:31 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id 81/B0-29563-B6684E75; Fri, 23 Sep 2016 01:33:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrMIsWRWlGSWpSXmKPExsXSO6nOVTer7Um 4wbFuOYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPPoS/sBe9MKr7OucfewLhMp4uRi0NIYDKT xKRLt9m6GDmBnL+MEgdWBUEkNjBKXGhoZYFw+hgllp48wwpSxSKgKjH/Wx9QBwcHm4CJxJtVj iBhEQF1iT8XJjCC1DMLfGaS2LvwIDtIQljAV6Lt0S+wXl4BK4neI83MEEM3M0o86lzFDJEQlD g58wkLiM0soCVx499LJpAFzALSEsv/cYCEOQWsJT7u2wZ2qaiAskTDjAdgrRICxhLtby+yTWA UnIVk0iwkk2YhTFrAyLyKUaM4tagstUjX0EAvqSgzPaMkNzEzB8gz08tNLS5OTE/NSUwq1kvO z93ECAxcBiDYwXhvWcAhRkkOJiVR3u6gJ+FCfEn5KZUZicUZ8UWlOanFhxhlODiUJHi1WoFyg kWp6akVaZk5wBiCSUtw8CiJQKR5iwsSc4sz0yFSpxgVpcR5jUASAiCJjNI8uDZY3F5ilJUS5m UEOkSIpyC1KDezBFX+FaM4B6OSMK8FyBSezLwSuOmvgBYzAS3e8vMByOKSRISUVAPjsXuOGe5 i177UpKZtO7XOtcosrEXK+IeW+DNHHh/Hrv+pX/NX7ChJLfS5GWPpkSWWrXkoyv7zzT1HZMua Lb79rQ4+ImfqY/CB6VrNXrM9OQnzdJSFFv34720Rek7RoWRW3KzmZ9cTb59OFezhzqhOWGFjb N3vpDqJsffjrpqi7ysNH4u8+KHEUpyRaKjFXFScCADu8bUI1gIAAA== X-Env-Sender: konrad.wilk@oracle.com X-Msg-Ref: server-15.tower-21.messagelabs.com!1474594409!34537212!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 43960 invoked from network); 23 Sep 2016 01:33:30 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-15.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 23 Sep 2016 01:33:30 -0000 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u8N1XHdx020481 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 Sep 2016 01:33:17 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id u8N1XH6q006033 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 Sep 2016 01:33:17 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u8N1XGLx020876; Fri, 23 Sep 2016 01:33:16 GMT Received: from localhost.localdomain (/10.154.153.189) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Sep 2016 18:33:14 -0700 Date: Thu, 22 Sep 2016 21:33:09 -0400 From: Konrad Rzeszutek Wilk To: Julien Grall Message-ID: <20160923013308.GB29985@localhost.localdomain> References: <1474479154-20991-1-git-send-email-konrad.wilk@oracle.com> <1474479154-20991-12-git-send-email-konrad.wilk@oracle.com> <0a16605b-8da4-131c-e9e7-b9ea645aa1a1@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <0a16605b-8da4-131c-e9e7-b9ea645aa1a1@arm.com> User-Agent: Mutt/1.6.1 (2016-04-27) X-Source-IP: aserv0022.oracle.com [141.146.126.234] Cc: sstabellini@kernel.org, Wei Liu , ross.lagerwall@citrix.com, George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Jan Beulich , xen-devel@lists.xenproject.org Subject: Re: [Xen-devel] [PATCH v5 11/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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP .snip.. > > 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: > I am wondering if there is any way to use the > > -ifeq ($(XEN_TARGET_ARCH),x86_64) > > +ifneq $(XEN_TARGET_ARCH),arm32) > > NIT: I am wondering if you could instead use CONFIG_LIVEPATCH here, so the > tests would only be built when livepatch is enabled. Lets leave it as is and do it in the future. Right now the tests are not compiled by default so not much harm here. But I do agree that somehow exposing the CONFIG_LIVEPATCH and latching it off (in say tests/livepatch/ directory) is a good TODO item.. > > > $(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 $@ > > I am not sure why you added this line. Did you intend to replace the > previous one? Fixed. ..snip.. > > @@ -25,6 +28,10 @@ const char *xen_hello_world(void) > > */ > > rc = __get_user(tmp, non_canonical_addr); > > BUG_ON(rc != -EFAULT); > > +#endif > > +#ifdef CONFIG_ARM_64 > > NIT: I would use: > > #if defined(CONFIG_ARM) && defined(CONFIG_HAS_ALTERNATIVE) > > in order to handle alternative if we decide to add support for ARM32. Done! Here is the updated patch: From c0dac442d15b5f0095b199ab4fff1fc414fb5719 Mon Sep 17 00:00:00 2001 From: Konrad Rzeszutek Wilk Date: Mon, 19 Sep 2016 16:04:55 -0400 Subject: [PATCH v6] livepatch: tests: Make them compile under ARM64 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 (exists only under ARM64 and x86), while and there are no exceptions under ARM at all. We use the LIVEPATCH_FEATURE CPU id feature for ARM similar to how it is done on x86. We are not yet attempting to build them under ARM32 so that is still ifdefed out. Signed-off-by: Konrad Rzeszutek Wilk Acked-by: Julien Grall Reviewed-by: Ross Lagerwall --- 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" Rewrote the commit description 2) a bit. v6: Fixed the note.o --rename-section Replaced CONFIG_ARM_64 with defined(CONFIG_ARM) && defined(CONFIG_HAS_ALTERNATIVE) --- xen/test/Makefile | 2 +- xen/test/livepatch/Makefile | 11 +++++++++-- xen/test/livepatch/xen_hello_world_func.c | 7 +++++++ 3 files changed, 17 insertions(+), 3 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..d844ad4 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,alloc,load,readonly,data,contents -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,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 0321f3e..1518f71 100644 --- a/xen/test/livepatch/xen_hello_world_func.c +++ b/xen/test/livepatch/xen_hello_world_func.c @@ -7,14 +7,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; @@ -25,6 +28,10 @@ const char *xen_hello_world(void) */ rc = __get_user(tmp, non_canonical_addr); BUG_ON(rc != -EFAULT); +#endif +#if defined(CONFIG_ARM) && defined(CONFIG_HAS_ALTERNATIVE) + asm(ALTERNATIVE("nop", "nop", LIVEPATCH_FEATURE)); +#endif return "Hello World"; }