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

[Xen-devel] [PATCH v2 09/23] vixen: modify the e820 table to advertise HVM special pages as RAM



From: Anthony Liguori <aliguori@xxxxxxxxxx>

In order to be able to assign the Xenstore page into the Vixen guest,
we need struct page_info's to exist.  We do this by modifying the
e820 table early in boot and then using the badpages handling to
prevent these pages from being added to the xenheap.

Since these pages exist in a somewhat weird state in Xen, we need
to relax permission checking too in order to be able to assign them
to the guest.

Signed-off-by: Anthony Liguori <aliguori@xxxxxxxxxx>
---
v1 -> v2
 - lay the ground work to use hvm_info_table to determine range
---
 xen/arch/x86/e820.c               | 11 +++++++++++
 xen/arch/x86/guest/vixen.c        |  9 +++++++++
 xen/arch/x86/mm.c                 |  3 ++-
 xen/common/page_alloc.c           |  7 +++++++
 xen/include/asm-x86/guest/vixen.h |  2 ++
 5 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/e820.c b/xen/arch/x86/e820.c
index 7c572ba..78ab8db 100644
--- a/xen/arch/x86/e820.c
+++ b/xen/arch/x86/e820.c
@@ -9,6 +9,7 @@
 #include <asm/processor.h>
 #include <asm/mtrr.h>
 #include <asm/msr.h>
+#include <asm/guest/vixen.h>
 
 /*
  * opt_mem: Limit maximum address of physical RAM.
@@ -698,6 +699,16 @@ unsigned long __init init_e820(const char *str, struct 
e820map *raw)
         print_e820_memory_map(raw->map, raw->nr_map);
     }
 
+    if ( is_vixen() )
+    {
+        unsigned long start_pfn, end_pfn;
+
+        vixen_get_reserved_mem(&start_pfn, &end_pfn);
+
+        /* Pretend that passed through special pages are RAM */
+        e820_change_range_type(raw, start_pfn << XEN_PAGE_SHIFT,
+                               end_pfn << XEN_PAGE_SHIFT, E820_RESERVED, 
E820_RAM);
+    }
     machine_specific_memory_setup(raw);
 
     printk("%s RAM map:\n", str);
diff --git a/xen/arch/x86/guest/vixen.c b/xen/arch/x86/guest/vixen.c
index c0a81dd..cacbe69 100644
--- a/xen/arch/x86/guest/vixen.c
+++ b/xen/arch/x86/guest/vixen.c
@@ -23,6 +23,7 @@
 
 static int in_vixen;
 static int vixen_domid = 1;
+static uint32_t vixen_reserved_mem_pgstart = 0xfeff0000;
 
 integer_param("vixen_domid", vixen_domid);
 
@@ -35,3 +36,11 @@ int vixen_get_domid(void)
 {
     return vixen_domid;
 }
+
+void vixen_get_reserved_mem(unsigned long *start_pfn, unsigned long *end_pfn)
+{
+    *start_pfn = vixen_reserved_mem_pgstart >> XEN_PAGE_SHIFT;
+
+    /* This is part of the Xen ABI */
+    *end_pfn   = 0x100000;
+}
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index a56f875..f0260ea 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -122,6 +122,7 @@
 #include <asm/fixmap.h>
 #include <asm/io_apic.h>
 #include <asm/pci.h>
+#include <asm/guest.h>
 
 #include <asm/hvm/grant_table.h>
 #include <asm/pv/grant_table.h>
@@ -945,7 +946,7 @@ get_page_from_l1e(
             case 0:
                 break;
             case 1:
-                if ( !is_hardware_domain(l1e_owner) )
+                if ( !is_vixen() && !is_hardware_domain(l1e_owner) )
                     break;
                 /* fallthrough */
             case -1:
diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index c0c2d82..35a433d 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -303,6 +303,13 @@ void __init init_boot_pages(paddr_t ps, paddr_t pe)
             badpage++;
         }
     }
+
+    if ( is_vixen() ) {
+        unsigned long start_pfn, end_pfn;
+
+        vixen_get_reserved_mem(&start_pfn, &end_pfn);
+        bootmem_region_zap(start_pfn, end_pfn);
+    }
 #endif
 
     /* Check new pages against the bad-page list. */
diff --git a/xen/include/asm-x86/guest/vixen.h 
b/xen/include/asm-x86/guest/vixen.h
index 4e80b76..fb8e871 100644
--- a/xen/include/asm-x86/guest/vixen.h
+++ b/xen/include/asm-x86/guest/vixen.h
@@ -72,4 +72,6 @@ bool is_vixen(void);
 
 int vixen_get_domid(void);
 
+void vixen_get_reserved_mem(unsigned long *start_pfn, unsigned long *end_pfn);
+
 #endif
-- 
1.9.1


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

 


Rackspace

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