Skip to content

Commit be81c8a

Browse files
Daniel KiperMatt Fleming
authored andcommitted
xen: Put EFI machinery in place
This patch enables EFI usage under Xen dom0. Standard EFI Linux Kernel infrastructure cannot be used because it requires direct access to EFI data and code. However, in dom0 case it is not possible because above mentioned EFI stuff is fully owned and controlled by Xen hypervisor. In this case all calls from dom0 to EFI must be requested via special hypercall which in turn executes relevant EFI code in behalf of dom0. When dom0 kernel boots it checks for EFI availability on a machine. If it is detected then artificial EFI system table is filled. Native EFI callas are replaced by functions which mimics them by calling relevant hypercall. Later pointer to EFI system table is passed to standard EFI machinery and it continues EFI subsystem initialization taking into account that there is no direct access to EFI boot services, runtime, tables, structures, etc. After that system runs as usual. This patch is based on Jan Beulich and Tang Liang work. Signed-off-by: Jan Beulich <jbeulich@suse.com> Signed-off-by: Tang Liang <liang.tang@oracle.com> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com> Reviewed-by: David Vrabel <david.vrabel@citrix.com> Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com Signed-off-by: Matt Fleming <matt.fleming@intel.com>
1 parent bf1e3ae commit be81c8a

5 files changed

Lines changed: 401 additions & 0 deletions

File tree

‎arch/x86/xen/enlighten.c‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <linux/gfp.h>
3333
#include <linux/memblock.h>
3434
#include <linux/edd.h>
35+
#include <linux/efi.h>
3536

3637
#include <xen/xen.h>
3738
#include <xen/events.h>
@@ -1520,6 +1521,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
15201521
{
15211522
struct physdev_set_iopl set_iopl;
15221523
int rc;
1524+
efi_system_table_t *efi_systab_xen;
15231525

15241526
if (!xen_start_info)
15251527
return;
@@ -1715,6 +1717,19 @@ asmlinkage __visible void __init xen_start_kernel(void)
17151717

17161718
xen_setup_runstate_info(0);
17171719

1720+
efi_systab_xen = xen_efi_probe();
1721+
1722+
if (efi_systab_xen) {
1723+
strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
1724+
sizeof(boot_params.efi_info.efi_loader_signature));
1725+
boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
1726+
boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
1727+
1728+
set_bit(EFI_BOOT, &efi.flags);
1729+
set_bit(EFI_PARAVIRT, &efi.flags);
1730+
set_bit(EFI_64BIT, &efi.flags);
1731+
}
1732+
17181733
/* Start the world */
17191734
#ifdef CONFIG_X86_32
17201735
i386_start_kernel();

‎drivers/xen/Kconfig‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,8 @@ config XEN_MCE_LOG
240240
config XEN_HAVE_PVMMU
241241
bool
242242

243+
config XEN_EFI
244+
def_bool y
245+
depends on X86_64 && EFI
246+
243247
endmenu

‎drivers/xen/Makefile‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ obj-y += xenbus/
99
nostackp := $(call cc-option, -fno-stack-protector)
1010
CFLAGS_features.o := $(nostackp)
1111

12+
CFLAGS_efi.o += -fshort-wchar
13+
1214
dom0-$(CONFIG_PCI) += pci.o
1315
dom0-$(CONFIG_USB_SUPPORT) += dbgp.o
1416
dom0-$(CONFIG_ACPI) += acpi.o $(xen-pad-y)
@@ -33,6 +35,7 @@ obj-$(CONFIG_XEN_STUB) += xen-stub.o
3335
obj-$(CONFIG_XEN_ACPI_HOTPLUG_MEMORY) += xen-acpi-memhotplug.o
3436
obj-$(CONFIG_XEN_ACPI_HOTPLUG_CPU) += xen-acpi-cpuhotplug.o
3537
obj-$(CONFIG_XEN_ACPI_PROCESSOR) += xen-acpi-processor.o
38+
obj-$(CONFIG_XEN_EFI) += efi.o
3639
xen-evtchn-y := evtchn.o
3740
xen-gntdev-y := gntdev.o
3841
xen-gntalloc-y := gntalloc.o

0 commit comments

Comments
 (0)