|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 4/8] x86/hyperv: setup hypercall page
Signed-off-by: Wei Liu <liuwe@xxxxxxxxxxxxx>
---
xen/arch/x86/guest/hyperv/hyperv.c | 41 +++++++++++++++++++++++++++---
1 file changed, 38 insertions(+), 3 deletions(-)
diff --git a/xen/arch/x86/guest/hyperv/hyperv.c
b/xen/arch/x86/guest/hyperv/hyperv.c
index c6a26c5453..438910c8cb 100644
--- a/xen/arch/x86/guest/hyperv/hyperv.c
+++ b/xen/arch/x86/guest/hyperv/hyperv.c
@@ -19,16 +19,17 @@
* Copyright (c) 2019 Microsoft.
*/
#include <xen/init.h>
+#include <xen/domain_page.h>
#include <asm/guest.h>
#include <asm/guest/hyperv-tlfs.h>
struct ms_hyperv_info __read_mostly ms_hyperv;
-static const struct hypervisor_ops ops = {
- .name = "Hyper-V",
-};
+void *hv_hypercall;
+static struct page_info *hv_hypercall_page;
+static const struct hypervisor_ops ops;
const struct hypervisor_ops *__init hyperv_probe(void)
{
uint32_t eax, ebx, ecx, edx;
@@ -71,6 +72,40 @@ const struct hypervisor_ops *__init hyperv_probe(void)
return &ops;
}
+static void __init setup_hypercall_page(void)
+{
+ union hv_x64_msr_hypercall_contents hypercall_msr;
+
+ /* Unfortunately there isn't a really good way to unwind Xen to
+ * not use Hyper-V hooks, so panic if anything goes wrong.
+ *
+ * In practice if page allocation fails this early on it is
+ * unlikely we can get a working system later.
+ */
+ hv_hypercall_page = alloc_domheap_page(NULL, 0);
+ if ( !hv_hypercall_page )
+ panic("Failed to allocate Hyper-V hypercall page\n");
+
+ hv_hypercall = __map_domain_page_global(hv_hypercall_page);
+ if ( !hv_hypercall )
+ panic("Failed to map Hyper-V hypercall page\n");
+
+ rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
+ hypercall_msr.enable = 1;
+ hypercall_msr.guest_physical_address = page_to_maddr(hv_hypercall_page);
+ wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
+}
+
+static void __init setup(void)
+{
+ setup_hypercall_page();
+}
+
+static const struct hypervisor_ops ops = {
+ .name = "Hyper-V",
+ .setup = setup,
+};
+
/*
* Local variables:
* mode: C
--
2.20.1
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |