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

[Xen-changelog] [xen staging] guest/pvh: fix handling of multiboot module list



commit c6aae55786e138951daf25e14709895d8c166948
Author:     Roger Pau Monné <roger.pau@xxxxxxxxxx>
AuthorDate: Mon Nov 12 17:13:57 2018 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Nov 12 17:13:57 2018 +0100

    guest/pvh: fix handling of multiboot module list
    
    When booting Xen as a PVH guest the data in the PVH start info
    structure is copied over to a multiboot structure and a module list
    array that resides in the .init section of the Xen image. The
    resulting multiboot module list is then handed to the generic boot
    process using the physical address in mbi->mods_addr.
    
    This works fine as long as the Xen image doesn't relocate itself, if
    there's such a relocation the physical addresses of multiboot module
    list is no longer valid.
    
    Fix this by handing the virtual address of the module list to the
    generic boot process instead of it's physical address.
    
    Reported-by: Sergey Dyasli <sergey.dyasli@xxxxxxxxxx>
    Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/guest/pvh-boot.c        | 20 ++++++++++----------
 xen/arch/x86/setup.c                 |  7 ++++---
 xen/include/asm-x86/guest/pvh-boot.h |  5 ++---
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/xen/arch/x86/guest/pvh-boot.c b/xen/arch/x86/guest/pvh-boot.c
index 6e81b32b92..544775eeb4 100644
--- a/xen/arch/x86/guest/pvh-boot.c
+++ b/xen/arch/x86/guest/pvh-boot.c
@@ -35,11 +35,11 @@ static multiboot_info_t __initdata pvh_mbi;
 static module_t __initdata pvh_mbi_mods[8];
 static const char *__initdata pvh_loader = "PVH Directboot";
 
-static void __init convert_pvh_info(void)
+static void __init convert_pvh_info(multiboot_info_t **mbi,
+                                    module_t **mod)
 {
     const struct hvm_start_info *pvh_info = __va(pvh_start_info_pa);
     const struct hvm_modlist_entry *entry;
-    module_t *mod;
     unsigned int i;
 
     if ( pvh_info->magic != XEN_HVM_START_MAGIC_VALUE )
@@ -68,20 +68,22 @@ static void __init convert_pvh_info(void)
     pvh_mbi.mods_count = pvh_info->nr_modules;
     pvh_mbi.mods_addr = __pa(pvh_mbi_mods);
 
-    mod = pvh_mbi_mods;
     entry = __va(pvh_info->modlist_paddr);
     for ( i = 0; i < pvh_info->nr_modules; i++ )
     {
         BUG_ON(entry[i].paddr >> 32);
         BUG_ON(entry[i].cmdline_paddr >> 32);
 
-        mod[i].mod_start = entry[i].paddr;
-        mod[i].mod_end   = entry[i].paddr + entry[i].size;
-        mod[i].string    = entry[i].cmdline_paddr;
+        pvh_mbi_mods[i].mod_start = entry[i].paddr;
+        pvh_mbi_mods[i].mod_end   = entry[i].paddr + entry[i].size;
+        pvh_mbi_mods[i].string    = entry[i].cmdline_paddr;
     }
 
     BUG_ON(!pvh_info->rsdp_paddr);
     rsdp_hint = pvh_info->rsdp_paddr;
+
+    *mbi = &pvh_mbi;
+    *mod = pvh_mbi_mods;
 }
 
 static void __init get_memory_map(void)
@@ -98,16 +100,14 @@ static void __init get_memory_map(void)
     sanitize_e820_map(e820_raw.map, &e820_raw.nr_map);
 }
 
-multiboot_info_t *__init pvh_init(void)
+void __init pvh_init(multiboot_info_t **mbi, module_t **mod)
 {
-    convert_pvh_info();
+    convert_pvh_info(mbi, mod);
 
     probe_hypervisor();
     ASSERT(xen_guest);
 
     get_memory_map();
-
-    return &pvh_mbi;
 }
 
 void __init pvh_print_info(void)
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 55a288f332..9cbff22fb3 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -719,12 +719,13 @@ void __init noreturn __start_xen(unsigned long mbi_p)
          */
         opt_console_xen = -1;
         ASSERT(mbi_p == 0);
-        mbi = pvh_init();
+        pvh_init(&mbi, &mod);
     }
     else
+    {
         mbi = __va(mbi_p);
-
-    mod = __va(mbi->mods_addr);
+        mod = __va(mbi->mods_addr);
+    }
 
     loader = (mbi->flags & MBI_LOADERNAME)
         ? (char *)__va(mbi->boot_loader_name) : "unknown";
diff --git a/xen/include/asm-x86/guest/pvh-boot.h 
b/xen/include/asm-x86/guest/pvh-boot.h
index 1b429f9401..b8a76c4eed 100644
--- a/xen/include/asm-x86/guest/pvh-boot.h
+++ b/xen/include/asm-x86/guest/pvh-boot.h
@@ -25,17 +25,16 @@
 
 extern bool pvh_boot;
 
-multiboot_info_t *pvh_init(void);
+void pvh_init(multiboot_info_t **mbi, module_t **mod);
 void pvh_print_info(void);
 
 #else
 
 #define pvh_boot 0
 
-static inline multiboot_info_t *pvh_init(void)
+static inline void pvh_init(multiboot_info_t **mbi, module_t **mod)
 {
     ASSERT_UNREACHABLE();
-    return NULL;
 }
 
 static inline void pvh_print_info(void)
--
generated by git-patchbot for /home/xen/git/xen.git#staging

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

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