]> xenbits.xensource.com Git - people/iwj/xen.git/commitdiff
x86/guest: map shared_info page
authorRoger Pau Monne <roger.pau@citrix.com>
Tue, 9 Jan 2018 11:19:44 +0000 (11:19 +0000)
committerRoger Pau Monne <roger.pau@citrix.com>
Thu, 11 Jan 2018 17:51:19 +0000 (17:51 +0000)
Use an unpopulated PFN in order to map it.

Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
Changes since v1:
 - Use an unpopulated PFN to map the shared_info page.
 - Mask all event channels.
 - Report XENMEM_add_to_physmap error code in case of failure.

xen/arch/x86/guest/xen.c
xen/include/asm-x86/fixmap.h
xen/include/asm-x86/guest/xen.h

index abf53ebbc67cdf6e284a0bbb090612358284f5a8..f62f93af16f9e462ec62f383c8f6aeba9c1e6458 100644 (file)
@@ -77,6 +77,31 @@ void __init probe_hypervisor(void)
     xen_guest = true;
 }
 
+static void map_shared_info(void)
+{
+    mfn_t mfn;
+    struct xen_add_to_physmap xatp = {
+        .domid = DOMID_SELF,
+        .space = XENMAPSPACE_shared_info,
+    };
+    unsigned int i;
+    unsigned long rc;
+
+    if ( hypervisor_alloc_unused_page(&mfn) )
+        panic("unable to reserve shared info memory page");
+
+    xatp.gpfn = mfn_x(mfn);
+    rc = xen_hypercall_memory_op(XENMEM_add_to_physmap, &xatp);
+    if ( rc )
+        panic("failed to map shared_info page: %ld", rc);
+
+    set_fixmap(FIX_XEN_SHARED_INFO, mfn_x(mfn) << PAGE_SHIFT);
+
+    /* Mask all upcalls */
+    for ( i = 0; i < ARRAY_SIZE(XEN_shared_info->evtchn_mask); i++ )
+        write_atomic(&XEN_shared_info->evtchn_mask[i], ~0ul);
+}
+
 static void __init init_memmap(void)
 {
     unsigned int i;
@@ -109,6 +134,8 @@ static void __init init_memmap(void)
 void __init hypervisor_setup(void)
 {
     init_memmap();
+
+    map_shared_info();
 }
 
 int hypervisor_alloc_unused_page(mfn_t *mfn)
index 51b0e7e94542da22d5a57f014943829de6300923..ded4ddf21bedbf1e44754edb875c9d26db6085e7 100644 (file)
@@ -45,6 +45,9 @@ enum fixed_addresses {
     FIX_COM_BEGIN,
     FIX_COM_END,
     FIX_EHCI_DBGP,
+#ifdef CONFIG_XEN_GUEST
+    FIX_XEN_SHARED_INFO,
+#endif /* CONFIG_XEN_GUEST */
     /* Everything else should go further down. */
     FIX_APIC_BASE,
     FIX_IO_APIC_BASE_0,
index 427837797b1da9e97eb61dd50d0984ececeb2b4e..f25ad4241b57e39ca510c066a36deb0f7f1aa283 100644 (file)
 
 #include <xen/types.h>
 
+#include <asm/e820.h>
+#include <asm/fixmap.h>
+
+#define XEN_shared_info ((struct shared_info *)fix_to_virt(FIX_XEN_SHARED_INFO))
+
 #ifdef CONFIG_XEN_GUEST
 
 extern bool xen_guest;