From: Boris Ostrovsky <boris.ostrov...@oracle.com>

Signed-off-by: Boris Ostrovsky <boris.ostrov...@oracle.com>
Signed-off-by: Maran Wilson <maran.wil...@oracle.com>
---
 tools/libxc/xc_dom_x86.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
index 0b65dab..b46bd1d 100644
--- a/tools/libxc/xc_dom_x86.c
+++ b/tools/libxc/xc_dom_x86.c
@@ -35,6 +35,8 @@
 #include <xen/arch-x86/hvm/start_info.h>
 #include <xen/io/protocols.h>
 
+#include <xen-tools/libs.h>
+
 #include "xg_private.h"
 #include "xc_dom.h"
 #include "xenctrl.h"
@@ -640,6 +642,8 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom)
             dom->cmdline_size = ROUNDUP(strlen(dom->cmdline) + 1, 8);
             start_info_size += dom->cmdline_size;
         }
+
+        start_info_size += dom->e820_entries * sizeof(*(dom->e820));
     }
     else
     {
@@ -1666,7 +1670,7 @@ static int bootlate_hvm(struct xc_dom_image *dom)
     uint32_t domid = dom->guest_domid;
     xc_interface *xch = dom->xch;
     struct hvm_start_info *start_info;
-    size_t start_info_size;
+    size_t start_info_size, modsize;
     struct hvm_modlist_entry *modlist;
     unsigned int i;
 
@@ -1693,6 +1697,8 @@ static int bootlate_hvm(struct xc_dom_image *dom)
 
     if ( !dom->device_model )
     {
+        struct hvm_memmap_table_entry *memmap;
+
         if ( dom->cmdline )
         {
             char *cmdline = (void*)(start_info + 1);
@@ -1718,6 +1724,27 @@ static int bootlate_hvm(struct xc_dom_image *dom)
 
         /* ACPI module 0 is the RSDP */
         start_info->rsdp_paddr = dom->acpi_modules[0].guest_addr_out ? : 0;
+
+        /*
+         * Check a couple of XEN_HVM_MEMMAP_TYPEs to verify consistency with
+         * their corresponding e820 numerical values.
+         */
+        BUILD_BUG_ON(XEN_HVM_MEMMAP_TYPE_RAM != E820_RAM);
+        BUILD_BUG_ON(XEN_HVM_MEMMAP_TYPE_ACPI != E820_ACPI);
+
+        modsize = HVMLOADER_MODULE_MAX_COUNT *
+            (sizeof(*modlist) + HVMLOADER_MODULE_CMDLINE_SIZE);
+        memmap = (void*)modlist + modsize;
+
+        start_info->memmap_paddr = (dom->start_info_seg.pfn << PAGE_SHIFT) +
+                            ((uintptr_t)modlist - (uintptr_t)start_info) + 
modsize;
+        start_info->memmap_entries = dom->e820_entries;
+        for ( i = 0; i < dom->e820_entries; i++ )
+        {
+            memmap[i].addr = dom->e820[i].addr;
+            memmap[i].size = dom->e820[i].size;
+            memmap[i].type = dom->e820[i].type;
+        }
     }
     else
     {
@@ -1732,6 +1759,7 @@ static int bootlate_hvm(struct xc_dom_image *dom)
     }
 
     start_info->magic = XEN_HVM_START_MAGIC_VALUE;
+    start_info->version = 1;
 
     munmap(start_info, start_info_size);
 
-- 
1.8.3.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to