]> xenbits.xen.org Git - xenclient/xen.git/commitdiff
Do a 1:1 map of the host's ACPI_NVS region when we build a hvm guest.
authorJean Guyader <jean.guyader@eu.citrix.com>
Tue, 17 Feb 2009 15:44:26 +0000 (15:44 +0000)
committerJean Guyader <jean.guyader@eu.citrix.com>
Tue, 17 Feb 2009 15:44:26 +0000 (15:44 +0000)
tools/libxc/xc_hvm_build.c
tools/libxc/xc_linux.c
tools/libxc/xc_private.h

index 34546197e8b001c319bb880f74c8dfd30c7ff57d..1253de075f3fafa234980ef9ac95f8b0b9898c1b 100644 (file)
@@ -30,7 +30,8 @@
 #define SPECIALPAGE_IDENT_PT 4
 #define NR_SPECIAL_PAGES     5
 
-static void build_e820map(void *e820_page, unsigned long long mem_size)
+static void build_e820map(void *e820_page, unsigned long long mem_size,
+                         uint32_t domid, int xc_handle)
 {
     struct e820entry *e820entry =
         (struct e820entry *)(((unsigned char *)e820_page) + HVM_E820_OFFSET);
@@ -86,9 +87,7 @@ static void build_e820map(void *e820_page, unsigned long long mem_size)
     e820entry[nr_map].type = E820_RESERVED;
     nr_map++;
 
-    e820entry[nr_map].addr = 0x7D5AE000;
-    e820entry[nr_map].size = 0x2000;
-    e820entry[nr_map].type = E820_NVS;
+    xc_add_acpi_nvs(xc_handle, domid, &e820entry[nr_map]);
     nr_map++;
 
 
@@ -324,7 +323,7 @@ static int setup_guest(int xc_handle,
               HVM_E820_PAGE >> PAGE_SHIFT)) == NULL )
         goto error_out;
     memset(e820_page, 0, PAGE_SIZE);
-    build_e820map(e820_page, v_end);
+    build_e820map(e820_page, v_end, dom, xc_handle);
     munmap(e820_page, PAGE_SIZE);
 
     /* Map and initialise shared_info page. */
index 0c70e99afb002cdc156e3e51a29a9b6da0fa86d5..21959d02af7710f69808938d15f0608e9d79bfc3 100644 (file)
@@ -611,7 +611,42 @@ int xc_get_vgabios(unsigned char        *buf,
 out:
     close(mem);
     return size;
-} 
+}
+
+int xc_add_acpi_nvs(int                        xc_handle,
+                   uint32_t            domid,
+                   struct e820entry    *entry)
+{
+    FILE       *fd;
+    char       line[256];
+    char       *s;
+    uint64_t   begin_addr, end_addr, size;
+
+
+    if ((fd = fopen("/proc/iomem", "r")))
+       return 0;
+
+    while ((fgets(line, 256, fd)))
+       if (strstr(line, "ACPI Non-volatile Storage"))
+       {
+           begin_addr = strtol(line, &s, 16);
+           end_addr = strtol(s + 1, NULL, 16);
+           size = end_addr - begin_addr + 1;
+           entry->addr = begin_addr;
+           entry->size = size;
+           entry->type = E820_NVS;
+
+           xc_domain_memory_mapping(xc_handle, domid,
+                                    begin_addr >> XC_PAGE_SHIFT,
+                                    begin_addr >> XC_PAGE_SHIFT,
+                                    size >> XC_PAGE_SHIFT,
+                                    1);
+           fclose(fd);
+           return 1;
+       }
+    fclose(fd);
+    return 0;
+}
 
 
 /*
index 6e49b749a0b29a0fbc45c49ed3662673f60e1f90..1e140a70226032b03e70c5cf111fd94e65fe9253 100644 (file)
@@ -14,6 +14,7 @@
 #include <sys/ioctl.h>
 
 #include "xenctrl.h"
+#include "xc_e820.h"
 
 #include <xen/sys/privcmd.h>
 
@@ -215,4 +216,8 @@ int xc_flush_mmu_updates(int xc_handle, struct xc_mmu *mmu);
 int read_exact(int fd, void *data, size_t size);
 int write_exact(int fd, const void *data, size_t size);
 
+int xc_add_acpi_nvs(int                        xc_handle,
+                   uint32_t            domid,
+                   struct e820entry    *entry);
+
 #endif /* __XC_PRIVATE_H__ */