From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZOsdN-0008FA-RH for mharc-grub-devel@gnu.org; Mon, 10 Aug 2015 15:21:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOsdL-0008EK-47 for grub-devel@gnu.org; Mon, 10 Aug 2015 15:21:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZOsdG-0005IO-RS for grub-devel@gnu.org; Mon, 10 Aug 2015 15:21:19 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:27360) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOsdG-0005II-HG for grub-devel@gnu.org; Mon, 10 Aug 2015 15:21:14 -0400 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 t7AJL4Pw006936 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 10 Aug 2015 19:21:04 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 t7AJL3q9031873 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 10 Aug 2015 19:21:03 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 t7AJL2ZA026926; Mon, 10 Aug 2015 19:21:02 GMT Received: from l.oracle.com (/10.137.176.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 10 Aug 2015 12:21:01 -0700 Received: by l.oracle.com (Postfix, from userid 1000) id C48FF6A3C73; Mon, 10 Aug 2015 15:20:59 -0400 (EDT) Date: Mon, 10 Aug 2015 15:20:59 -0400 From: Konrad Rzeszutek Wilk To: Daniel Kiper Subject: Re: [Xen-devel] [PATCH v2 09/23] efi: create efi_enabled() Message-ID: <20150810192059.GF13576@l.oracle.com> References: <1437402558-7313-1-git-send-email-daniel.kiper@oracle.com> <1437402558-7313-10-git-send-email-daniel.kiper@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1437402558-7313-10-git-send-email-daniel.kiper@oracle.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 156.151.31.81 Cc: jgross@suse.com, grub-devel@gnu.org, keir@xen.org, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, andrew.cooper3@citrix.com, gang.wei@intel.com, roy.franz@linaro.org, ning.sun@intel.com, david.vrabel@citrix.com, jbeulich@suse.com, phcoder@gmail.com, xen-devel@lists.xenproject.org, wei.liu2@citrix.com, richard.l.maliszewski@intel.com, qiaowei.ren@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, 10 Aug 2015 19:21:21 -0000 On Mon, Jul 20, 2015 at 04:29:04PM +0200, Daniel Kiper wrote: > 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 similar way to Xen loaded > by multiboot (v1) protocol. Hence, create efi_enabled() which > checks available features in efi.flags. This patch only defines > EFI_PLATFORM feature which is equal to old efi_enabled == 1. > Following patch will define EFI_LOADER feature accordingly. > > Suggested-by: Jan Beulich > Signed-off-by: Daniel Kiper Reviewed-by: Konrad Rzeszutek Wilk > --- > xen/arch/x86/dmi_scan.c | 4 ++-- > xen/arch/x86/domain_page.c | 2 +- > xen/arch/x86/efi/stub.c | 11 ++++++++--- > xen/arch/x86/mpparse.c | 4 ++-- > xen/arch/x86/setup.c | 10 +++++----- > xen/arch/x86/shutdown.c | 2 +- > xen/arch/x86/time.c | 2 +- > xen/arch/x86/xen.lds.S | 2 -- > xen/common/efi/boot.c | 4 ++++ > xen/common/efi/runtime.c | 17 +++++++---------- > xen/drivers/acpi/osl.c | 2 +- > xen/include/xen/efi.h | 16 ++++++++++++++-- > 12 files changed, 46 insertions(+), 30 deletions(-) > > diff --git a/xen/arch/x86/dmi_scan.c b/xen/arch/x86/dmi_scan.c > index 269168c..95c5a77 100644 > --- a/xen/arch/x86/dmi_scan.c > +++ b/xen/arch/x86/dmi_scan.c > @@ -229,7 +229,7 @@ const char *__init dmi_get_table(paddr_t *base, u32 *len) > { > static unsigned int __initdata instance; > > - if (efi_enabled) { > + if (efi_enabled(EFI_PLATFORM)) { > if (efi_smbios3_size && !(instance & 1)) { > *base = efi_smbios3_address; > *len = efi_smbios3_size; > @@ -693,7 +693,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_enabled(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 d86f8fe..fdf0d8a 100644 > --- a/xen/arch/x86/domain_page.c > +++ b/xen/arch/x86/domain_page.c > @@ -36,7 +36,7 @@ static inline struct vcpu *mapcache_current_vcpu(void) > * domain's page tables but current may point at another domain's VCPU. > * Return NULL as though current is not properly set up yet. > */ > - if ( efi_enabled && efi_rs_using_pgtables() ) > + if ( efi_enabled(EFI_PLATFORM) && efi_rs_using_pgtables() ) > return NULL; > > /* > diff --git a/xen/arch/x86/efi/stub.c b/xen/arch/x86/efi/stub.c > index 07c2bd0..c5ae369 100644 > --- a/xen/arch/x86/efi/stub.c > +++ b/xen/arch/x86/efi/stub.c > @@ -4,9 +4,14 @@ > #include > #include > > -#ifndef efi_enabled > -const bool_t efi_enabled = 0; > -#endif > +struct efi __read_mostly efi = { > + .flags = 0, /* Initialized later. */ > + .acpi = EFI_INVALID_TABLE_ADDR, > + .acpi20 = EFI_INVALID_TABLE_ADDR, > + .mps = EFI_INVALID_TABLE_ADDR, > + .smbios = EFI_INVALID_TABLE_ADDR, > + .smbios3 = EFI_INVALID_TABLE_ADDR > +}; > > void __init efi_init_memory(void) { } > > diff --git a/xen/arch/x86/mpparse.c b/xen/arch/x86/mpparse.c > index 8609f4a..5223579 100644 > --- a/xen/arch/x86/mpparse.c > +++ b/xen/arch/x86/mpparse.c > @@ -557,7 +557,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_enabled(EFI_PLATFORM)) > clear_fixmap(FIX_EFI_MPF); > } > > @@ -715,7 +715,7 @@ void __init find_smp_config (void) > { > unsigned int address; > > - if (efi_enabled) { > + if (efi_enabled(EFI_PLATFORM)) { > efi_check_config(); > return; > } > diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c > index ff34670..bce708c 100644 > --- a/xen/arch/x86/setup.c > +++ b/xen/arch/x86/setup.c > @@ -444,8 +444,8 @@ 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 ) > + /* vga_console_info is filled directly on EFI platform. */ > + if ( efi_enabled(EFI_PLATFORM) ) > return; > > if ( (bvi->orig_video_isVGA == 1) && (bvi->orig_video_mode == 3) ) > @@ -695,7 +695,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) > if ( !(mbi->flags & MBI_MODULES) || (mbi->mods_count == 0) ) > panic("dom0 kernel not specified. Check bootloader configuration."); > > - if ( efi_enabled ) > + if ( efi_enabled(EFI_PLATFORM) ) > { > set_pdx_range(xen_phys_start >> PAGE_SHIFT, > (xen_phys_start + BOOTSTRAP_MAP_BASE) >> PAGE_SHIFT); > @@ -806,7 +806,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_enabled(EFI_PLATFORM) && i < mbi->mods_count; i++ ) > { > if ( mod[i].mod_start & (PAGE_SIZE - 1) ) > panic("Bootloader didn't honor module alignment request."); > @@ -994,7 +994,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_enabled(EFI_PLATFORM) ? mbi->mem_upper : __pa(&_start), > __pa(&_end)); > > /* Late kexec reservation (dynamic start address). */ > diff --git a/xen/arch/x86/shutdown.c b/xen/arch/x86/shutdown.c > index 0e1499d..79dcd16 100644 > --- a/xen/arch/x86/shutdown.c > +++ b/xen/arch/x86/shutdown.c > @@ -116,7 +116,7 @@ void machine_halt(void) > static void default_reboot_type(void) > { > if ( reboot_type == BOOT_INVALID ) > - reboot_type = efi_enabled ? BOOT_EFI > + reboot_type = efi_enabled(EFI_PLATFORM) ? BOOT_EFI > : acpi_disabled ? BOOT_KBD > : BOOT_ACPI; > } > diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c > index bbb7e6c..11e7e11 100644 > --- a/xen/arch/x86/time.c > +++ b/xen/arch/x86/time.c > @@ -690,7 +690,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_enabled(EFI_PLATFORM) ) > { > res = efi_get_time(); > if ( res ) > diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S > index 3e1f2af..87f3e83 100644 > --- a/xen/arch/x86/xen.lds.S > +++ b/xen/arch/x86/xen.lds.S > @@ -191,8 +191,6 @@ SECTIONS > .pad : { > . = ALIGN(MB(16)); > } :text > -#else > - efi = .; > #endif > > /* Sections to be discarded */ > diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c > index 75a939f..1f188fe 100644 > --- a/xen/common/efi/boot.c > +++ b/xen/common/efi/boot.c > @@ -717,6 +717,10 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) > char *option_str; > bool_t use_cfg_file; > > +#ifndef CONFIG_ARM /* Disabled until runtime services implemented. */ > + set_bit(EFI_PLATFORM, &efi.flags); > +#endif > + > efi_ih = ImageHandle; > efi_bs = SystemTable->BootServices; > efi_bs_revision = efi_bs->Hdr.Revision; > diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c > index ae87557..aa064e7 100644 > --- a/xen/common/efi/runtime.c > +++ b/xen/common/efi/runtime.c > @@ -10,14 +10,10 @@ DEFINE_XEN_GUEST_HANDLE(CHAR16); > > #ifndef COMPAT > > -#ifdef CONFIG_ARM /* Disabled until runtime services implemented */ > -const bool_t efi_enabled = 0; > -#else > +#ifndef CONFIG_ARM > # include > # include > # include > - > -const bool_t efi_enabled = 1; > #endif > > unsigned int __read_mostly efi_num_ct; > @@ -42,11 +38,12 @@ UINT64 __read_mostly efi_boot_remain_var_store_size; > UINT64 __read_mostly efi_boot_max_var_size; > > struct efi __read_mostly efi = { > - .acpi = EFI_INVALID_TABLE_ADDR, > - .acpi20 = EFI_INVALID_TABLE_ADDR, > - .mps = EFI_INVALID_TABLE_ADDR, > - .smbios = EFI_INVALID_TABLE_ADDR, > - .smbios3 = EFI_INVALID_TABLE_ADDR, > + .flags = 0, /* Initialized later. */ > + .acpi = EFI_INVALID_TABLE_ADDR, > + .acpi20 = EFI_INVALID_TABLE_ADDR, > + .mps = EFI_INVALID_TABLE_ADDR, > + .smbios = EFI_INVALID_TABLE_ADDR, > + .smbios3 = EFI_INVALID_TABLE_ADDR > }; > > const struct efi_pci_rom *__read_mostly efi_pci_roms; > diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c > index 4c09859..f4f6628 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_enabled(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 e74dad1..318bbec 100644 > --- a/xen/include/xen/efi.h > +++ b/xen/include/xen/efi.h > @@ -2,15 +2,17 @@ > #define __XEN_EFI_H__ > > #ifndef __ASSEMBLY__ > +#include > #include > #endif > > -extern const bool_t efi_enabled; > - > #define EFI_INVALID_TABLE_ADDR (~0UL) > > +#define EFI_PLATFORM 0 > + > /* Add fields here only if they need to be referenced from non-EFI code. */ > struct efi { > + unsigned long flags; > unsigned long mps; /* MPS table */ > unsigned long acpi; /* ACPI table (IA64 ext 0.71) */ > unsigned long acpi20; /* ACPI table (ACPI 2.0) */ > @@ -40,6 +42,16 @@ int efi_runtime_call(struct xenpf_efi_runtime_call *); > int efi_compat_get_info(uint32_t idx, union compat_pf_efi_info *); > int efi_compat_runtime_call(struct compat_pf_efi_runtime_call *); > > +/* > + * Test whether the above EFI_* bits are enabled. > + * > + * Stolen from Linux Kernel. > + */ > +static inline bool_t efi_enabled(int feature) > +{ > + return test_bit(feature, &efi.flags) != 0; > +} > + > #endif /* !__ASSEMBLY__ */ > > #endif /* __XEN_EFI_H__ */ > -- > 1.7.10.4 > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel