]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
Map the domains shared_info at boot
authorAndrew Cooper <andrew.cooper3@citrix.com>
Sun, 1 May 2016 13:47:11 +0000 (14:47 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 22 May 2017 12:21:25 +0000 (13:21 +0100)
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/include/arch/mm.h
arch/x86/include/arch/traps.h
arch/x86/setup.c
include/xen/memory.h

index 4059eba30ebcb30bac6c7acd2c9e1531dae3d1b4..e4b520c83b6da7e992bff3d7d14800c4468b56c2 100644 (file)
@@ -44,7 +44,7 @@ static inline unsigned long virt_to_pfn(const void *va)
 #if defined(CONFIG_PV)
 
 #define m2p ((unsigned long *)MACH2PHYS_VIRT_START)
-extern struct start_info *start_info;
+extern start_info_t *start_info;
 
 static inline void *mfn_to_virt(unsigned long mfn)
 {
index 4808b082eb3b03069cdce873150b63503c3aa871..8965e4be14f31bb12d479fa6d4e8dafd7e1b500a 100644 (file)
@@ -6,6 +6,8 @@
 #include <arch/lib.h>
 #include <arch/page.h>
 
+#include <xen/xen.h>
+
 /*
  * Arch-specific function to initialise the exception entry points, etc.
  */
@@ -52,11 +54,8 @@ static inline unsigned int cpu_regs_ss(const struct cpu_regs *regs)
 extern uint8_t boot_stack[3 * PAGE_SIZE];
 extern uint8_t user_stack[PAGE_SIZE];
 
-#if defined(CONFIG_PV)
-#include <xen/xen.h>
-
-extern struct start_info *start_info;
-#endif
+extern start_info_t *start_info;
+extern shared_info_t shared_info;
 
 #endif /* XTF_X86_TRAPS_H */
 
index bd2a5056973c65431da9c332218f0391858cc190..657b5a1bfd621dcd3778c7d806feff2175faabc8 100644 (file)
@@ -7,6 +7,7 @@
 #include <arch/desc.h>
 #include <arch/lib.h>
 #include <arch/mm.h>
+#include <arch/symbolic-const.h>
 #include <arch/traps.h>
 
 /*
@@ -32,6 +33,8 @@ const char environment_description[] = ENVIRONMENT_DESCRIPTION;
 start_info_t *start_info = NULL;
 #endif
 
+shared_info_t shared_info __page_aligned_bss;
+
 static void collect_cpuid(cpuid_count_fn_t cpuid_fn)
 {
     unsigned int tmp, eax, ebx, ecx, edx, addr = 0;
@@ -168,6 +171,31 @@ static void setup_pv_console(void)
     init_pv_console(cons_ring, cons_evtchn);
 }
 
+static void map_shared_info(void)
+{
+    int rc;
+
+    if ( IS_DEFINED(CONFIG_HVM) )
+    {
+        struct xen_add_to_physmap xatp =
+            {
+                .domid = DOMID_SELF,
+                .space = XENMAPSPACE_shared_info,
+                .idx = 0,
+                .gfn = virt_to_gfn(&shared_info),
+            };
+
+        rc = hypercall_memory_op(XENMEM_add_to_physmap, &xatp);
+    }
+    else /* PV */
+        rc = hypercall_update_va_mapping(
+            &shared_info, start_info->shared_info | PF_SYM(RW, P),
+            UVMF_INVLPG);
+
+    if ( rc )
+        panic("Failed to map shared_info: %d\n", rc);
+}
+
 static void qemu_console_write(const char *buf, size_t len)
 {
     asm volatile("rep; outsb"
@@ -196,6 +224,7 @@ void arch_setup(void)
     init_hypercalls();
 
     setup_pv_console();
+    map_shared_info();
 }
 
 /*
index 5e517ff94509e05bdf2d53667c4e4d482ad678b9..37ed16f04aea993d9c91fccaf3737d0742aef443 100644 (file)
@@ -17,6 +17,24 @@ struct xen_memory_reservation {
     domid_t domid;
 };
 
+#define XENMEM_add_to_physmap       7
+
+struct xen_add_to_physmap {
+    domid_t domid;
+    uint16_t size;
+
+#define XENMAPSPACE_shared_info  0
+#define XENMAPSPACE_grant_table  1
+#define XENMAPSPACE_gmfn         2
+#define XENMAPSPACE_gmfn_range   3
+#define XENMAPSPACE_gmfn_foreign 4
+#define XENMAPSPACE_dev_mmio     5
+    unsigned int space;
+
+    unsigned long idx;
+    unsigned long gfn;
+};
+
 #define XENMEM_exchange             11
 
 struct xen_memory_exchange {