From patchwork Fri Aug 5 23:04:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kiper X-Patchwork-Id: 9265763 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 E35CE60839 for ; Fri, 5 Aug 2016 23:07:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEA4428462 for ; Fri, 5 Aug 2016 23:07:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF2312848E; Fri, 5 Aug 2016 23:07:55 +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 B8ACC28462 for ; Fri, 5 Aug 2016 23:07:54 +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 1bVoBu-0003cY-0p; Fri, 05 Aug 2016 23:06:10 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bVoBs-0003aW-Bo for xen-devel@lists.xenproject.org; Fri, 05 Aug 2016 23:06:08 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id 07/C2-30284-FDB15A75; Fri, 05 Aug 2016 23:06:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLLMWRWlGSWpSXmKPExsUyZ7p8oO596aX hBt9msVt83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBlbbr9jKXihUvFi5SvmBsZ5cl2MXBxCAu1M Eg/W7GKCcD4zSmw48pIdwtnAKHF59zYWCGcio8TXdT3MXYycHGwCOhIXvzxkB7FFBJQk7q2aD NbOLHCUSeL/5MesXYwcHMIClhIfb0mA1LAIqEp0bjzABGLzCrhLvHw3nxXElhBQlOh+NoENxO YEis/b+BzMFhJwk/jYDVNjLNH+9iLbBEa+BYwMqxg1ilOLylKLdA3N9JKKMtMzSnITM3N0DQ1 M9XJTi4sT01NzEpOK9ZLzczcxAoOFAQh2MJ4/7XmIUZKDSUmU9/zlJeFCfEn5KZUZicUZ8UWl OanFhxhlODiUJHinSi0NFxIsSk1PrUjLzAGGLUxagoNHSYR3Fkiat7ggMbc4Mx0idYpRUUqc1 xUkIQCSyCjNg2uDxcolRlkpYV5GoEOEeApSi3IzS1DlXzGKczAqCUOM58nMK4Gb/gpoMRPQ4o 9WS0AWlyQipKQaGM2CnH5NzNnP6fhf+obvinX6858+sV/Mkvr9y0Sna6wbLW6+KzHd2q/cEXc xlSs2vPzUD8NTXNlavS+Mqnf8j/0WZnc7ieXo6nePC9Z2TznMy6+nPP/EdaXddyr1TOZHzdv/ y6K2IVO8emvF25mVJbx/L1lKfLOy/KHf3VvkV/Q28xnvj9cCTUosxRmJhlrMRcWJAAhqkTiQA gAA X-Env-Sender: daniel.kiper@oracle.com X-Msg-Ref: server-3.tower-206.messagelabs.com!1470438365!49571439!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.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 61979 invoked from network); 5 Aug 2016 23:06:06 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-3.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 5 Aug 2016 23:06:06 -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 u75N5t3Z015960 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 5 Aug 2016 23:05:56 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id u75N5r4x020029 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 5 Aug 2016 23:05:54 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u75N5qP6010413; Fri, 5 Aug 2016 23:05:52 GMT Received: from olila.local.net-space.pl (/10.175.255.156) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 05 Aug 2016 16:05:52 -0700 From: Daniel Kiper To: xen-devel@lists.xenproject.org Date: Sat, 6 Aug 2016 01:04:37 +0200 Message-Id: <1470438282-4226-15-git-send-email-daniel.kiper@oracle.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1470438282-4226-1-git-send-email-daniel.kiper@oracle.com> References: <1470438282-4226-1-git-send-email-daniel.kiper@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Cc: jgross@suse.com, sstabellini@kernel.org, andrew.cooper3@citrix.com, cardoe@cardoe.com, pgnet.dev@gmail.com, ning.sun@intel.com, david.vrabel@citrix.com, jbeulich@suse.com, qiaowei.ren@intel.com, richard.l.maliszewski@intel.com, gang.wei@intel.com, fu.wei@linaro.org Subject: [Xen-devel] [PATCH v4 14/19] efi: build xen.gz with EFI code 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 Build xen.gz with EFI code. We need this to support multiboot2 protocol on EFI platforms. If we wish to load non-ELF file using multiboot (v1) or multiboot2 then it must contain "linear" (or "flat") representation of code and data. This is requirement of both boot protocols. Currently, PE file contains many sections which are not "linear" (one after another without any holes) or even do not have representation in a file (e.g. BSS). From EFI point of view everything is OK and works. However, this file layout cannot be properly interpreted by multiboot protocols family. In theory there is a chance that we could build proper PE file (from multiboot protocols POV) using current build system. However, it means that xen.efi further diverge from Xen ELF file (in terms of contents and build method). On the other hand ELF has all needed properties. So, it means that this is good starting point for further development. Additionally, I think that this is also good starting point for further xen.efi code and build optimizations. It looks that there is a chance that finally we can generate xen.efi directly from Xen ELF using just simple objcopy or other tool. This way we will have one Xen binary which can be loaded by three boot protocols: EFI native loader, multiboot (v1) and multiboot2. Signed-off-by: Daniel Kiper --- v4 - suggestions/fixes: - functions should return -ENOSYS instead of -EOPNOTSUPP if EFI runtime services are not available (suggested by Jan Beulich), - remove stale bits from xen/arch/x86/Makefile (suggested by Jan Beulich). v3 - suggestions/fixes: - check for EFI platform in EFI code (suggested by Jan Beulich), - fix Makefiles (suggested by Jan Beulich), - improve commit message (suggested by Jan Beulich). v2 - suggestions/fixes: - build EFI code only if it is supported in a given build environment (suggested by Jan Beulich). --- xen/arch/x86/Makefile | 2 +- xen/arch/x86/efi/Makefile | 11 +++-------- xen/common/efi/boot.c | 3 +++ xen/common/efi/runtime.c | 6 ++++++ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index b18f033..71ec34e 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -211,7 +211,7 @@ efi/mkreloc: efi/mkreloc.c clean:: rm -f asm-offsets.s *.lds boot/*.o boot/*~ boot/core boot/mkelf32 rm -f $(BASEDIR)/.xen-syms.[0-9]* boot/.*.d - rm -f $(BASEDIR)/.xen.efi.[0-9]* efi/*.o efi/.*.d efi/*.efi efi/disabled efi/mkreloc + rm -f $(BASEDIR)/.xen.efi.[0-9]* efi/*.efi efi/disabled efi/mkreloc rm -f boot/reloc.S boot/reloc.lnk boot/reloc.bin rm -f note.o $(MAKE) -f $(BASEDIR)/Rules.mk -C test clean diff --git a/xen/arch/x86/efi/Makefile b/xen/arch/x86/efi/Makefile index 5099430..2a7d3e5 100644 --- a/xen/arch/x86/efi/Makefile +++ b/xen/arch/x86/efi/Makefile @@ -1,14 +1,9 @@ CFLAGS += -fshort-wchar -obj-y += stub.o - -create = test -e $(1) || touch -t 199901010000 $(1) - efi := y$(shell rm -f disabled) efi := $(if $(efi),$(shell $(CC) $(filter-out $(CFLAGS-y) .%.d,$(CFLAGS)) -c check.c 2>disabled && echo y)) efi := $(if $(efi),$(shell $(LD) -mi386pep --subsystem=10 -o check.efi check.o 2>disabled && echo y)) -efi := $(if $(efi),$(shell rm disabled)y,$(shell $(call create,boot.init.o); $(call create,runtime.o))) +efi := $(if $(efi),$(shell rm disabled)y) -extra-$(efi) += boot.init.o relocs-dummy.o runtime.o compat.o - -stub.o: $(extra-y) +obj-y := stub.o +obj-$(efi) := boot.init.o compat.o relocs-dummy.o runtime.o diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 95cb25f..884d818 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -1248,6 +1248,9 @@ void __init efi_init_memory(void) } *extra, *extra_head = NULL; #endif + if ( !efi_enabled(EFI_BOOT) ) + return; + printk(XENLOG_INFO "EFI memory map:%s\n", map_bs ? " (mapping BootServices)" : ""); for ( i = 0; i < efi_memmap_size; i += efi_mdesc_size ) diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c index 900c011..7a1bfc6 100644 --- a/xen/common/efi/runtime.c +++ b/xen/common/efi/runtime.c @@ -158,6 +158,9 @@ int efi_get_info(uint32_t idx, union xenpf_efi_info *info) { unsigned int i, n; + if ( !efi_enabled(EFI_BOOT) ) + return -ENOSYS; + switch ( idx ) { case XEN_FW_EFI_VERSION: @@ -292,6 +295,9 @@ int efi_runtime_call(struct xenpf_efi_runtime_call *op) EFI_STATUS status = EFI_NOT_STARTED; int rc = 0; + if ( !efi_enabled(EFI_RS) ) + return -ENOSYS; + switch ( op->function ) { case XEN_EFI_get_time: