From: Daniel Kiper <daniel.kiper@oracle.com>
To: xen-devel@lists.xenproject.org, grub-devel@gnu.org
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,
	qiaowei.ren@intel.com, richard.l.maliszewski@intel.com,
	gang.wei@intel.com, fu.wei@linaro.org
Subject: [PATCH 05/18] efi: split efi_enabled to efi_platform and efi_loader
Date: Fri, 30 Jan 2015 18:54:09 +0100	[thread overview]
Message-ID: <1422640462-28103-6-git-send-email-daniel.kiper@oracle.com> (raw)
In-Reply-To: <1422640462-28103-1-git-send-email-daniel.kiper@oracle.com>
We need more fine grained knowledge about EFI environment and check
for EFI platform and EFI loader separately to properly support
multiboot2 protocol. In general Xen loaded by this protocol uses
memory mappings and loaded modules in simliar way to Xen loaded
by multiboot (v1) protocol. Hence, split efi_enabled to efi_platform
and efi_loader.
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 xen/arch/x86/dmi_scan.c    |    4 ++--
 xen/arch/x86/domain_page.c |    2 +-
 xen/arch/x86/efi/stub.c    |    5 +++--
 xen/arch/x86/mpparse.c     |    4 ++--
 xen/arch/x86/setup.c       |    8 ++++----
 xen/arch/x86/time.c        |    2 +-
 xen/common/efi/boot.c      |    5 +++++
 xen/common/efi/runtime.c   |    5 +++--
 xen/drivers/acpi/osl.c     |    2 +-
 xen/include/xen/efi.h      |    6 +++++-
 10 files changed, 27 insertions(+), 16 deletions(-)
diff --git a/xen/arch/x86/dmi_scan.c b/xen/arch/x86/dmi_scan.c
index 500133a..63b976c 100644
--- a/xen/arch/x86/dmi_scan.c
+++ b/xen/arch/x86/dmi_scan.c
@@ -150,7 +150,7 @@ int __init dmi_get_table(u32 *base, u32 *len)
 	struct dmi_eps eps;
 	char __iomem *p, *q;
 
-	if (efi_enabled) {
+	if (efi_platform) {
 		if (!efi_dmi_size)
 			return -1;
 		*base = efi_dmi_address;
@@ -516,7 +516,7 @@ static void __init dmi_decode(struct dmi_header *dm)
 
 void __init dmi_scan_machine(void)
 {
-	if ((!efi_enabled ? dmi_iterate(dmi_decode) :
+	if ((!efi_platform ? dmi_iterate(dmi_decode) :
 	                    dmi_efi_iterate(dmi_decode)) == 0)
  		dmi_check_system(dmi_blacklist);
 	else
diff --git a/xen/arch/x86/domain_page.c b/xen/arch/x86/domain_page.c
index 158a164..5d4564c 100644
--- a/xen/arch/x86/domain_page.c
+++ b/xen/arch/x86/domain_page.c
@@ -45,7 +45,7 @@ static inline struct vcpu *mapcache_current_vcpu(void)
             sync_local_execstate();
         /* We must now be running on the idle page table. */
         ASSERT((cr3 = read_cr3()) == __pa(idle_pg_table) ||
-               (efi_enabled && cr3 == efi_rs_page_table()));
+               (efi_platform && cr3 == efi_rs_page_table()));
     }
 
     return v;
diff --git a/xen/arch/x86/efi/stub.c b/xen/arch/x86/efi/stub.c
index b8f49f8..5060e6f 100644
--- a/xen/arch/x86/efi/stub.c
+++ b/xen/arch/x86/efi/stub.c
@@ -3,8 +3,9 @@
 #include <xen/init.h>
 #include <xen/lib.h>
 
-#ifndef efi_enabled
-const bool_t efi_enabled = 0;
+#ifndef efi_platform
+bool_t efi_platform = 0;
+bool_t efi_loader = 0;
 #endif
 
 void __init efi_init_memory(void) { }
diff --git a/xen/arch/x86/mpparse.c b/xen/arch/x86/mpparse.c
index a38e016..c4e3041 100644
--- a/xen/arch/x86/mpparse.c
+++ b/xen/arch/x86/mpparse.c
@@ -540,7 +540,7 @@ static inline void __init construct_default_ISA_mptable(int mpc_default_type)
 
 static __init void efi_unmap_mpf(void)
 {
-	if (efi_enabled)
+	if (efi_platform)
 		__set_fixmap(FIX_EFI_MPF, 0, 0);
 }
 
@@ -698,7 +698,7 @@ void __init find_smp_config (void)
 {
 	unsigned int address;
 
-	if (efi_enabled) {
+	if (efi_platform) {
 		efi_check_config();
 		return;
 	}
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index c27c49c..711fdb0 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -431,7 +431,7 @@ static void __init parse_video_info(void)
     struct boot_video_info *bvi = &bootsym(boot_vid_info);
 
     /* The EFI loader fills vga_console_info directly. */
-    if ( efi_enabled )
+    if ( efi_platform )
         return;
 
     if ( (bvi->orig_video_isVGA == 1) && (bvi->orig_video_mode == 3) )
@@ -663,7 +663,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
     if ( ((unsigned long)cpu0_stack & (STACK_SIZE-1)) != 0 )
         panic("Misaligned CPU0 stack.");
 
-    if ( efi_enabled )
+    if ( efi_loader )
     {
         set_pdx_range(xen_phys_start >> PAGE_SHIFT,
                       (xen_phys_start + BOOTSTRAP_MAP_BASE) >> PAGE_SHIFT);
@@ -774,7 +774,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
      * we can relocate the dom0 kernel and other multiboot modules. Also, on
      * x86/64, we relocate Xen to higher memory.
      */
-    for ( i = 0; !efi_enabled && i < mbi->mods_count; i++ )
+    for ( i = 0; !efi_loader && i < mbi->mods_count; i++ )
     {
         if ( mod[i].mod_start & (PAGE_SIZE - 1) )
             panic("Bootloader didn't honor module alignment request.");
@@ -962,7 +962,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
 
     if ( !xen_phys_start )
         panic("Not enough memory to relocate Xen.");
-    reserve_e820_ram(&boot_e820, efi_enabled ? mbi->mem_upper : __pa(&_start),
+    reserve_e820_ram(&boot_e820, efi_loader ? mbi->mem_upper : __pa(&_start),
                      __pa(&_end));
 
     /* Late kexec reservation (dynamic start address). */
diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index 74c01e3..cdd17cb 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -689,7 +689,7 @@ static unsigned long get_cmos_time(void)
     static bool_t __read_mostly cmos_rtc_probe;
     boolean_param("cmos-rtc-probe", cmos_rtc_probe);
 
-    if ( efi_enabled )
+    if ( efi_platform )
     {
         res = efi_get_time();
         if ( res )
diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index ac6881e..8aafcfd 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -708,6 +708,11 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
     char *option_str;
     bool_t use_cfg_file;
 
+#ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
+    efi_platform = 1;
+    efi_loader = 1;
+#endif
+
     efi_ih = ImageHandle;
     efi_bs = SystemTable->BootServices;
     efi_rs = SystemTable->RuntimeServices;
diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
index c840e08..b229c69 100644
--- a/xen/common/efi/runtime.c
+++ b/xen/common/efi/runtime.c
@@ -11,13 +11,14 @@ DEFINE_XEN_GUEST_HANDLE(CHAR16);
 #ifndef COMPAT
 
 #ifdef CONFIG_ARM  /* Disabled until runtime services implemented */
-const bool_t efi_enabled = 0;
+const bool_t efi_platform = 0;
 #else
 # include <asm/i387.h>
 # include <asm/xstate.h>
 # include <public/platform.h>
 
-const bool_t efi_enabled = 1;
+bool_t efi_platform = 0;
+bool_t efi_loader = 0;
 #endif
 
 unsigned int __read_mostly efi_num_ct;
diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
index 93c983c..b066459 100644
--- a/xen/drivers/acpi/osl.c
+++ b/xen/drivers/acpi/osl.c
@@ -66,7 +66,7 @@ void __init acpi_os_vprintf(const char *fmt, va_list args)
 
 acpi_physical_address __init acpi_os_get_root_pointer(void)
 {
-	if (efi_enabled) {
+	if (efi_platform) {
 		if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
 			return efi.acpi20;
 		else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
diff --git a/xen/include/xen/efi.h b/xen/include/xen/efi.h
index 5e02724..54cd390 100644
--- a/xen/include/xen/efi.h
+++ b/xen/include/xen/efi.h
@@ -5,7 +5,11 @@
 #include <xen/types.h>
 #endif
 
-extern const bool_t efi_enabled;
+/* If true then Xen runs on EFI platform. */
+extern bool_t efi_platform;
+
+/* If true then Xen was loaded by native EFI loader as PE application. */
+extern bool_t efi_loader;
 
 #define EFI_INVALID_TABLE_ADDR (~0UL)
 
-- 
1.7.10.4
next prev parent reply	other threads:[~2015-01-30 17:55 UTC|newest]
Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-30 17:54 [PATCH 00/18] x86: multiboot2 protocol support Daniel Kiper
2015-01-30 17:54 ` [PATCH 01/18] x86/boot/reloc: mask out MBI_BOOTDEV from mbi flags Daniel Kiper
2015-01-30 17:59   ` [Xen-devel] " Andrew Cooper
2015-01-30 17:54 ` [PATCH 02/18] x86/boot/reloc: create generic alloc and copy functions Daniel Kiper
2015-01-30 18:02   ` Andrew Cooper
2015-02-03 10:13   ` Jan Beulich
2015-01-30 17:54 ` [PATCH 03/18] x86/boot: use %ecx instead of %eax Daniel Kiper
2015-02-03 10:02   ` Jan Beulich
2015-02-03 17:43     ` Daniel Kiper
2015-01-30 17:54 ` [PATCH 04/18] xen/x86: add multiboot2 protocol support Daniel Kiper
2015-01-30 18:11   ` Andrew Cooper
2015-02-20 16:06   ` Jan Beulich
2015-03-27 10:56     ` Daniel Kiper
2015-03-27 11:20       ` Jan Beulich
2015-03-27 12:22         ` Daniel Kiper
2015-03-27 12:42           ` Jan Beulich
2015-01-30 17:54 ` Daniel Kiper [this message]
2015-02-20 16:17   ` [PATCH 05/18] efi: split efi_enabled to efi_platform and efi_loader Jan Beulich
2015-03-27 13:32     ` Daniel Kiper
2015-03-27 13:43       ` Jan Beulich
2015-03-27 13:53         ` Andrew Cooper
2015-03-27 14:04           ` Jan Beulich
2015-03-27 14:09             ` Lennart Sorensen
2015-03-27 14:19               ` [Xen-devel] " Jan Beulich
2015-03-27 14:21                 ` Lennart Sorensen
2015-03-02 17:21   ` Stefano Stabellini
2015-03-02 18:43     ` Roy Franz
2015-03-02 23:40       ` Roy Franz
2015-03-03  8:49         ` Jan Beulich
2015-01-30 17:54 ` [PATCH 06/18] x86: remove commented out stale references to efi_enabled Daniel Kiper
2015-01-30 17:54 ` [PATCH 07/18] efi: run EFI specific code on EFI platform only Daniel Kiper
2015-02-20 16:47   ` Jan Beulich
2015-01-30 17:54 ` [PATCH 08/18] efi: build xen.gz with EFI code Daniel Kiper
2015-03-02 16:14   ` Jan Beulich
2015-03-27 11:14     ` Daniel Kiper
2015-03-27 11:46       ` Jan Beulich
2015-03-27 11:54         ` Andrew Cooper
2015-01-30 17:54 ` [PATCH 09/18] efi: create efi_init() Daniel Kiper
2015-01-30 17:54 ` [PATCH 10/18] efi: create efi_console_set_mode() Daniel Kiper
2015-01-30 17:54 ` [PATCH 11/18] efi: create efi_get_gop() Daniel Kiper
2015-01-30 17:54 ` [PATCH 12/18] efi: create efi_find_gop_mode() Daniel Kiper
2015-01-30 17:54 ` [PATCH 13/18] efi: create efi_tables() Daniel Kiper
2015-01-30 17:54 ` [PATCH 14/18] efi: create efi_variables() Daniel Kiper
2015-01-30 17:54 ` [PATCH 15/18] efi: create efi_set_gop_mode() Daniel Kiper
2015-01-30 17:54 ` [PATCH 16/18] efi: create efi_exit_boot() Daniel Kiper
2015-03-02 16:45   ` Jan Beulich
2015-03-27 12:00     ` Daniel Kiper
2015-03-27 12:10       ` Jan Beulich
2015-03-27 12:43         ` Daniel Kiper
2015-03-27 13:17           ` Ian Campbell
2015-01-30 17:54 ` [PATCH 17/18] x86/efi: create new early memory allocator Daniel Kiper
2015-03-02 17:23   ` Jan Beulich
2015-03-02 20:25     ` Roy Franz
2015-03-03  8:04       ` Jan Beulich
2015-03-03  9:39         ` Daniel Kiper
2015-03-27 12:57     ` Daniel Kiper
2015-03-27 13:35       ` Jan Beulich
2015-03-27 14:28         ` Daniel Kiper
2015-01-30 17:54 ` [PATCH 18/18] x86: add multiboot2 protocol support for EFI platforms Daniel Kiper
2015-01-30 19:06   ` Andrew Cooper
2015-01-30 23:43     ` Daniel Kiper
2015-01-31  0:47       ` Andrew Cooper
2015-02-10 21:27   ` Daniel Kiper
2015-02-10 22:41     ` Andrew Cooper
2015-02-11  8:20     ` Jan Beulich
2015-02-14 17:23       ` Andrei Borzenkov
2015-02-15 21:00         ` Daniel Kiper
2015-03-17 10:32   ` Jan Beulich
2015-03-17 12:47     ` Daniel Kiper
2015-03-27 13:06     ` Daniel Kiper
2015-03-27 13:36       ` Jan Beulich
2015-03-27 14:26         ` Daniel Kiper
2015-03-27 14:34           ` Jan Beulich
2015-03-27 14:57             ` Daniel Kiper
2015-03-27 15:06               ` Jan Beulich
2015-03-27 15:10                 ` Daniel Kiper
2015-01-30 18:04 ` [PATCH 00/18] x86: multiboot2 protocol support Daniel Kiper
2015-01-31  7:22 ` João Jerónimo
2015-02-02  9:28 ` Jan Beulich
2015-02-03 17:14   ` Daniel Kiper
2015-02-04  9:04     ` Andrew Cooper
2015-02-04  9:51       ` Jan Beulich
2015-02-05 10:59         ` Andrew Cooper
2015-02-05 11:50         ` Vladimir 'phcoder' Serbinenko
2015-02-05 12:00           ` Jan Beulich
2015-02-09 17:59 ` Daniel Kiper
2015-02-10  9:05   ` Jan Beulich
2015-03-03 12:10 ` Ian Campbell
2015-03-03 12:36   ` Daniel Kiper
2015-03-03 12:39     ` Ian Campbell
2015-03-03 12:51       ` Daniel Kiper
2015-03-27 10:59 ` Daniel Kiper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox
  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):
  git send-email \
    --in-reply-to=1422640462-28103-6-git-send-email-daniel.kiper@oracle.com \
    --to=daniel.kiper@oracle.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=david.vrabel@citrix.com \
    --cc=fu.wei@linaro.org \
    --cc=gang.wei@intel.com \
    --cc=grub-devel@gnu.org \
    --cc=ian.campbell@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=jgross@suse.com \
    --cc=keir@xen.org \
    --cc=ning.sun@intel.com \
    --cc=phcoder@gmail.com \
    --cc=qiaowei.ren@intel.com \
    --cc=richard.l.maliszewski@intel.com \
    --cc=roy.franz@linaro.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY
  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
  Be sure your reply has a Subject: header at the top and a blank line
  before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).