From patchwork Fri Apr 15 12:33:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kiper X-Patchwork-Id: 8850801 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 17C359FBEA for ; Fri, 15 Apr 2016 12:36:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2A9A1202EB for ; Fri, 15 Apr 2016 12:36:43 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id C0EB220373 for ; Fri, 15 Apr 2016 12:36:41 +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 1ar2xN-0005eq-1R; Fri, 15 Apr 2016 12:34:41 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ar2xL-0005dT-PX for xen-devel@lists.xenproject.org; Fri, 15 Apr 2016 12:34:39 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 23/9C-18833-FDFD0175; Fri, 15 Apr 2016 12:34:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNLMWRWlGSWpSXmKPExsXSO6nOVffefYF wg977uhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8b/1ousBZPlKh6t/c7cwHhdoouRi0NIoINJ YsXNHSxdjJxAzhdGifPfIyASGxglXp/8xA7hTGSUWPq7iRmkik1AR+Lil4fsILaIgJLEvVWTm UCKmAXOM0lM67wMNkpYwFLi5SEIm0VAVaL9xmY2EJtXwEPi+pFLYIMkBBQlup9NAItzAsVXdz YB1XMAbXOX+DdVBKLEWKJvVh/LBEa+BYwMqxjVi1OLylKLdI31kooy0zNKchMzc3QNDcz0clO LixPTU3MSk4r1kvNzNzECA4UBCHYwdvxzOsQoycGkJMo7d69AuBBfUn5KZUZicUZ8UWlOavEh RhkODiUJ3if3gHKCRanpqRVpmTnAkIVJS3DwKInwvgRJ8xYXJOYWZ6ZDpE4xKkqJ874HSQiAJ DJK8+DaYHFyiVFWSpiXEegQIZ6C1KLczBJU+VeM4hyMSsK8r0Gm8GTmlcBNfwW0mAlocdk7Xp DFJYkIKakGxorYrHSGz9UtuTwZO95cKQnL4RLc7rRzssnM6KqVky7fyvWNfap0qP/7zTXhie2 hr/4sqGz+0eh+5Z6/7M3Km/qRO52kJ8lIdfya5qFbyjhVLjn3zkyZ3ae8Y0TnCiUmFBdUBZva VVleclggdKvhQfifzvU2xhPundrR/3sBw5xV+wta8poNlFiKMxINtZiLihMBDkp7+I4CAAA= X-Env-Sender: daniel.kiper@oracle.com X-Msg-Ref: server-14.tower-21.messagelabs.com!1460723677!9521781!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.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31593 invoked from network); 15 Apr 2016 12:34:38 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-14.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 15 Apr 2016 12:34:38 -0000 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u3FCYBAt027404 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 15 Apr 2016 12:34:11 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u3FCYAdZ028326 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 15 Apr 2016 12:34:11 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u3FCYAiG009930; Fri, 15 Apr 2016 12:34:10 GMT Received: from olila.local.net-space.pl (/10.175.160.106) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 15 Apr 2016 05:34:09 -0700 From: Daniel Kiper To: xen-devel@lists.xenproject.org Date: Fri, 15 Apr 2016 14:33:11 +0200 Message-Id: <1460723596-13261-12-git-send-email-daniel.kiper@oracle.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1460723596-13261-1-git-send-email-daniel.kiper@oracle.com> References: <1460723596-13261-1-git-send-email-daniel.kiper@oracle.com> X-Source-IP: aserv0021.oracle.com [141.146.126.233] Cc: jgross@suse.com, andrew.cooper3@citrix.com, stefano.stabellini@eu.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 v3 11/16] 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org 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 --- 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/efi/Makefile | 11 +++-------- xen/common/efi/boot.c | 3 +++ xen/common/efi/runtime.c | 6 ++++++ 3 files changed, 12 insertions(+), 8 deletions(-) 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 f006575..d10c0ab 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -1244,6 +1244,9 @@ void __init efi_init_memory(void) } *extra, *extra_head = NULL; #endif + if ( !efi_enabled(EFI_PLATFORM) ) + 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 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: