From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZHC6G-000614-EX for mharc-grub-devel@gnu.org; Mon, 20 Jul 2015 10:31:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHC68-0005jO-Ej for grub-devel@gnu.org; Mon, 20 Jul 2015 10:31:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZHC65-0001Iu-2I for grub-devel@gnu.org; Mon, 20 Jul 2015 10:31:16 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:21175) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHC64-0001Ii-Qc for grub-devel@gnu.org; Mon, 20 Jul 2015 10:31:12 -0400 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 t6KEV24u011398 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 20 Jul 2015 14:31:02 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id t6KEV1ec019320 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 20 Jul 2015 14:31:02 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id t6KEUEt0027654; Mon, 20 Jul 2015 14:30:30 GMT Received: from olila.local.net-space.pl (/10.175.255.176) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 20 Jul 2015 07:30:13 -0700 From: Daniel Kiper To: xen-devel@lists.xenproject.org, grub-devel@gnu.org Subject: [PATCH v2 10/23] efi: build xen.gz with EFI code Date: Mon, 20 Jul 2015 16:29:05 +0200 Message-Id: <1437402558-7313-11-git-send-email-daniel.kiper@oracle.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1437402558-7313-1-git-send-email-daniel.kiper@oracle.com> References: <1437402558-7313-1-git-send-email-daniel.kiper@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 Cc: jgross@suse.com, keir@xen.org, ian.campbell@citrix.com, andrew.cooper3@citrix.com, stefano.stabellini@eu.citrix.com, roy.franz@linaro.org, ning.sun@intel.com, david.vrabel@citrix.com, jbeulich@suse.com, phcoder@gmail.com, wei.liu2@citrix.com, qiaowei.ren@intel.com, richard.l.maliszewski@intel.com, gang.wei@intel.com, fu.wei@linaro.org X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jul 2015 14:31:22 -0000 Build xen.gz with EFI code. We need this to support multiboot2 protocol on EFI platforms. If we wish to load not ELF file using multiboot (v1) or multiboot2 then it must contain "linear" (or "flat") representation of code and data. 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). In theory there is a chance that we could build proper PE file using current build system. However, it means that xen.efi further diverge from xen ELF file (in terms of contents and build method). ELF have 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. Signed-off-by: Daniel Kiper --- v2 - suggestions/fixes: - build EFI code only if it is supported in a given build environment (suggested by Jan Beulich). --- xen/arch/x86/Makefile | 13 +++++-------- xen/arch/x86/efi/Makefile | 16 +++++++++------- xen/arch/x86/mm.c | 3 ++- xen/common/efi/runtime.c | 6 ++++++ 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 5f24951..0335445 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -80,7 +80,7 @@ ALL_OBJS := $(BASEDIR)/arch/x86/boot/built_in.o $(BASEDIR)/arch/x86/efi/built_in ifeq ($(lto),y) # Gather all LTO objects together -prelink_lto.o: $(ALL_OBJS) +prelink_lto.o: $(ALL_OBJS) efi/relocs-dummy.o $(LD_LTO) -r -o $@ $^ prelink-efi_lto.o: $(ALL_OBJS) efi/runtime.o efi/compat.o @@ -90,14 +90,14 @@ prelink-efi_lto.o: $(ALL_OBJS) efi/runtime.o efi/compat.o prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o $(LD) $(LDFLAGS) -r -o $@ $^ -prelink-efi.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink-efi_lto.o efi/boot.init.o +prelink-efi.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink-efi_lto.o $(guard) $(LD) $(LDFLAGS) -r -o $@ $^ else -prelink.o: $(ALL_OBJS) +prelink.o: $(ALL_OBJS) efi/relocs-dummy.o $(LD) $(LDFLAGS) -r -o $@ $^ -prelink-efi.o: $(ALL_OBJS) efi/boot.init.o efi/runtime.o efi/compat.o - $(guard) $(LD) $(LDFLAGS) -r -o $@ $(filter-out %/efi/built_in.o,$^) +prelink-efi.o: $(ALL_OBJS) + $(guard) $(LD) $(LDFLAGS) -r -o $@ $^ endif $(BASEDIR)/common/symbols-dummy.o: @@ -146,9 +146,6 @@ $(TARGET).efi: prelink-efi.o efi.lds efi/relocs-dummy.o $(BASEDIR)/common/symbol if $(guard) false; then rm -f $@; echo 'EFI support disabled'; fi rm -f $(@D)/.$(@F).[0-9]* -efi/boot.init.o efi/runtime.o efi/compat.o: $(BASEDIR)/arch/x86/efi/built_in.o -efi/boot.init.o efi/runtime.o efi/compat.o: ; - asm-offsets.s: $(TARGET_SUBARCH)/asm-offsets.c $(CC) $(filter-out -flto,$(CFLAGS)) -S -o $@ $< diff --git a/xen/arch/x86/efi/Makefile b/xen/arch/x86/efi/Makefile index 1daa7ac..b1e8883 100644 --- a/xen/arch/x86/efi/Makefile +++ b/xen/arch/x86/efi/Makefile @@ -1,14 +1,16 @@ CFLAGS += -fshort-wchar -obj-y += stub.o - -create = test -e $(1) || touch -t 199901010000 $(1) - efi := $(filter y,$(x86_64)$(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 +extra-y += relocs-dummy.o -stub.o: $(extra-y) +ifeq ($(efi),y) +obj-y += boot.init.o +obj-y += compat.o +obj-y += runtime.o +else +obj-y += stub.o +endif diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 342414f..cef2eb6 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -344,7 +344,8 @@ void __init arch_init_memory(void) subarch_init_memory(); - efi_init_memory(); + if ( efi_enabled(EFI_PLATFORM) ) + efi_init_memory(); mem_sharing_init(); diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c index aa064e7..3eb21c1 100644 --- a/xen/common/efi/runtime.c +++ b/xen/common/efi/runtime.c @@ -167,6 +167,9 @@ int efi_get_info(uint32_t idx, union xenpf_efi_info *info) { unsigned int i, n; + if ( !efi_enabled(EFI_PLATFORM) ) + return -EOPNOTSUPP; + switch ( idx ) { case XEN_FW_EFI_VERSION: @@ -301,6 +304,9 @@ int efi_runtime_call(struct xenpf_efi_runtime_call *op) EFI_STATUS status = EFI_NOT_STARTED; int rc = 0; + if ( !efi_enabled(EFI_PLATFORM) ) + return -EOPNOTSUPP; + switch ( op->function ) { case XEN_EFI_get_time: -- 1.7.10.4