summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Pau Monne <roger.pau@citrix.com>2018-01-09 11:19:44 +0000
committerRoger Pau Monne <roger.pau@citrix.com>2018-01-11 17:51:19 +0000
commitefa15c993b600e9636cd091c626ee0c989afc62f (patch)
tree67c22d8f296f0d3072f2b0ab9331ae5453fcbb1d
parent83186a8e6988b8f218fce57db3a62e35d39b529a (diff)
downloadxen-efa15c993b600e9636cd091c626ee0c989afc62f.tar.gz
x86/guest: map shared_info page
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.
-rw-r--r--xen/arch/x86/guest/xen.c27
-rw-r--r--xen/include/asm-x86/fixmap.h3
-rw-r--r--xen/include/asm-x86/guest/xen.h5
3 files changed, 35 insertions, 0 deletions
diff --git a/xen/arch/x86/guest/xen.c b/xen/arch/x86/guest/xen.c
index abf53ebbc6..f62f93af16 100644
--- a/xen/arch/x86/guest/xen.c
+++ b/xen/arch/x86/guest/xen.c
@@ -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)
diff --git a/xen/include/asm-x86/fixmap.h b/xen/include/asm-x86/fixmap.h
index 51b0e7e945..ded4ddf21b 100644
--- a/xen/include/asm-x86/fixmap.h
+++ b/xen/include/asm-x86/fixmap.h
@@ -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,
diff --git a/xen/include/asm-x86/guest/xen.h b/xen/include/asm-x86/guest/xen.h
index 427837797b..f25ad4241b 100644
--- a/xen/include/asm-x86/guest/xen.h
+++ b/xen/include/asm-x86/guest/xen.h
@@ -21,6 +21,11 @@
#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;