[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v1 2/3] EFI/early: Add /map to map EfiBootServicesData and Code



To help on certain platforms to run.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
---
 xen/arch/x86/efi/efi-boot.h | 10 ++++++++--
 xen/common/efi/boot.c       | 28 +++++++++++++++++++++++-----
 xen/common/efi/efi.h        |  2 +-
 xen/common/efi/runtime.c    |  1 +
 4 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index 3a3b4fe..f6a2ba9 100644
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -133,7 +133,8 @@ static void __init 
efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable,
                                                void *map,
                                                UINTN map_size,
                                                UINTN desc_size,
-                                               UINT32 desc_ver)
+                                               UINT32 desc_ver,
+                                               UINT32 map_bootservices)
 {
     struct e820entry *e;
     unsigned int i;
@@ -151,9 +152,14 @@ static void __init 
efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable,
         default:
             type = E820_RESERVED;
             break;
-        case EfiConventionalMemory:
         case EfiBootServicesCode:
         case EfiBootServicesData:
+            if ( map_bootservices )
+            {
+                type = E820_RESERVED;
+                break;
+            }
+        case EfiConventionalMemory:
             if ( !trampoline_phys && desc->PhysicalStart + len <= 0x100000 &&
                  len >= cfg.size && desc->PhysicalStart + len > cfg.addr )
                 cfg.addr = (desc->PhysicalStart + len - cfg.size) & PAGE_MASK;
diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index 40f6334..cf3464b 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -706,7 +706,8 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE 
*SystemTable)
     EFI_GRAPHICS_OUTPUT_PROTOCOL *gop = NULL;
     EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info;
     union string section = { NULL }, name;
-    bool_t base_video = 0, retry, exit_boot_services = 1;
+    bool_t base_video = 0, retry, map_bs = 0;
+    bool_t exit_boot_services = 1;
     char *option_str;
     bool_t use_cfg_file;
 
@@ -755,6 +756,8 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE 
*SystemTable)
                     base_video = 1;
                 else if ( wstrcmp(ptr + 1, L"noexit") == 0 )
                     exit_boot_services = 0;
+                else if ( wstrcmp(ptr + 1, L"map") == 0 )
+                    map_bs = 1;
                 else if ( wstrncmp(ptr + 1, L"cfg=", 4) == 0 )
                     cfg_file_name = ptr + 5;
                 else if ( i + 1 < argc && wstrcmp(ptr + 1, L"cfg") == 0 )
@@ -765,6 +768,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE 
*SystemTable)
                     PrintStr(L"Xen EFI Loader options:\r\n");
                     PrintStr(L"-basevideo   retain current video mode\r\n");
                     PrintStr(L"-noexit      Do not call ExitBootServices\r\n");
+                    PrintStr(L"-map         map EfiBootServices Code and 
Data\r\n");
                     PrintStr(L"-cfg=<file>  specify configuration file\r\n");
                     PrintStr(L"-help, -?    display this help\r\n");
                     blexit(NULL);
@@ -1070,7 +1074,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE 
*SystemTable)
             PrintErrMesg(L"Cannot obtain memory map", status);
 
         efi_arch_process_memory_map(SystemTable, efi_memmap, efi_memmap_size,
-                                    efi_mdesc_size, mdesc_ver);
+                                    efi_mdesc_size, mdesc_ver, map_bs);
 
         efi_arch_pre_exit_boot();
 
@@ -1092,6 +1096,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE 
*SystemTable)
 #endif
     efi_memmap = (void *)efi_memmap + DIRECTMAP_VIRT_START;
     efi_fw_vendor = (void *)efi_fw_vendor + DIRECTMAP_VIRT_START;
+    efi_map = map_bs;
 
     efi_arch_post_exit_boot();
     for( ; ; ); /* not reached */
@@ -1162,20 +1167,31 @@ void __init efi_init_memory(void)
     } *extra, *extra_head = NULL;
 #endif
 
-    printk(XENLOG_INFO "EFI memory map:\n");
+    printk(XENLOG_INFO "EFI memory map: %s\n",
+           efi_map ? "(mapping BootServices)" : "");
     for ( i = 0; i < efi_memmap_size; i += efi_mdesc_size )
     {
         EFI_MEMORY_DESCRIPTOR *desc = efi_memmap + i;
         u64 len = desc->NumberOfPages << EFI_PAGE_SHIFT;
         unsigned long smfn, emfn;
         unsigned int prot = PAGE_HYPERVISOR;
+        unsigned int skip = 1;
 
         printk(XENLOG_INFO " %013" PRIx64 "-%013" PRIx64
                            " type=%u attr=%016" PRIx64 "\n",
                desc->PhysicalStart, desc->PhysicalStart + len - 1,
                desc->Type, desc->Attribute);
 
-        if ( !efi_rs_enable || !(desc->Attribute & EFI_MEMORY_RUNTIME) )
+        if ( desc->Attribute & EFI_MEMORY_RUNTIME )
+            skip = 0;
+
+        if ( desc->Type == 4 && desc->Attribute != 0 && efi_map )
+            skip = 0;
+
+        if ( desc->Type == 3 && desc->Attribute != 0 && efi_map )
+            skip = 0;
+
+        if ( !efi_rs_enable || skip )
             continue;
 
         desc->VirtualStart = INVALID_VIRTUAL_ADDRESS;
@@ -1261,7 +1277,9 @@ void __init efi_init_memory(void)
     {
         const EFI_MEMORY_DESCRIPTOR *desc = efi_memmap + i;
 
-        if ( (desc->Attribute & EFI_MEMORY_RUNTIME) &&
+        if ( ((desc->Attribute & EFI_MEMORY_RUNTIME) ||
+              ((desc->Type == 3 && desc->Attribute != 0 && efi_map ) ||
+               (desc->Type == 4 && desc->Attribute != 0 && efi_map ))) &&
              desc->VirtualStart != INVALID_VIRTUAL_ADDRESS &&
              desc->VirtualStart != desc->PhysicalStart )
             copy_mapping(PFN_DOWN(desc->PhysicalStart),
diff --git a/xen/common/efi/efi.h b/xen/common/efi/efi.h
index c557104..6267020 100644
--- a/xen/common/efi/efi.h
+++ b/xen/common/efi/efi.h
@@ -20,7 +20,7 @@ struct efi_pci_rom {
 extern unsigned int efi_num_ct;
 extern const EFI_CONFIGURATION_TABLE *efi_ct;
 
-extern unsigned int efi_version, efi_fw_revision;
+extern unsigned int efi_version, efi_fw_revision, efi_map;
 extern const CHAR16 *efi_fw_vendor;
 
 extern const EFI_RUNTIME_SERVICES *efi_rs;
diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
index 5ed8b01..f3575c8 100644
--- a/xen/common/efi/runtime.c
+++ b/xen/common/efi/runtime.c
@@ -25,6 +25,7 @@ const EFI_CONFIGURATION_TABLE *__read_mostly efi_ct;
 
 unsigned int __read_mostly efi_version;
 unsigned int __read_mostly efi_fw_revision;
+unsigned int __read_mostly efi_map;
 const CHAR16 *__read_mostly efi_fw_vendor;
 
 const EFI_RUNTIME_SERVICES *__read_mostly efi_rs;
-- 
2.1.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.