All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xen-devel] [PATCH v7 00/10] More Hyper-V infrastructures
@ 2020-02-04 15:36 Wei Liu
  2020-02-04 15:36 ` [Xen-devel] [PATCH v7 01/10] x86/hypervisor: make hypervisor_ap_setup return an error code Wei Liu
                   ` (9 more replies)
  0 siblings, 10 replies; 23+ messages in thread
From: Wei Liu @ 2020-02-04 15:36 UTC (permalink / raw)
  To: Xen Development List
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Paul Durrant, Michael Kelley,
	Jan Beulich, Roger Pau Monné

This patch sereis implements several important functionalities to run
Xen on top of Hyper-V. See individual patches for more details.

I've checked the assembly code as well as putting in a test patch to
make sure the hypercall interface is implemented correctly.

Wei.

Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Wei Liu <wl@xen.org>
Cc: Roger Pau Monné <roger.pau@citrix.com>
Cc: Michael Kelley <mikelley@microsoft.com>
Cc: Paul Durrant <pdurrant@amazon.com>

Wei Liu (10):
  x86/hypervisor: make hypervisor_ap_setup return an error code
  x86/smp: don't online cpu if hypervisor_ap_setup fails
  x86: provide executable fixmap facility
  x86/hypervisor: provide hypervisor_fixup_e820
  x86/hyperv: setup hypercall page
  x86/hyperv: provide Hyper-V hypercall functions
  DO NOT APPLY: x86/hyperv: issue an hypercall
  x86/hyperv: provide percpu hypercall input page
  x86/hyperv: retrieve vp_index from Hyper-V
  x86/hyperv: setup VP assist page

 MAINTAINERS                              |   1 +
 xen/arch/x86/boot/x86_64.S               |  15 ++-
 xen/arch/x86/e820.c                      |   4 +-
 xen/arch/x86/guest/hyperv/hyperv.c       | 154 ++++++++++++++++++++++-
 xen/arch/x86/guest/hyperv/private.h      |  31 +++++
 xen/arch/x86/guest/hypervisor.c          |  12 +-
 xen/arch/x86/guest/xen/xen.c             |  65 ++++++----
 xen/arch/x86/livepatch.c                 |   3 +-
 xen/arch/x86/mm.c                        |  14 ++-
 xen/arch/x86/smpboot.c                   |  12 +-
 xen/arch/x86/xen.lds.S                   |   5 +
 xen/include/asm-x86/asm_defns.h          |   5 +
 xen/include/asm-x86/config.h             |   2 +-
 xen/include/asm-x86/fixmap.h             |  24 ++++
 xen/include/asm-x86/guest/hyperv-hcall.h |  97 ++++++++++++++
 xen/include/asm-x86/guest/hyperv-tlfs.h  |   5 +-
 xen/include/asm-x86/guest/hyperv.h       |   3 +
 xen/include/asm-x86/guest/hypervisor.h   |  12 +-
 18 files changed, 419 insertions(+), 45 deletions(-)
 create mode 100644 xen/arch/x86/guest/hyperv/private.h
 create mode 100644 xen/include/asm-x86/guest/hyperv-hcall.h

-- 
2.20.1


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

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Xen-devel] [PATCH v7 01/10] x86/hypervisor: make hypervisor_ap_setup return an error code
  2020-02-04 15:36 [Xen-devel] [PATCH v7 00/10] More Hyper-V infrastructures Wei Liu
@ 2020-02-04 15:36 ` Wei Liu
  2020-02-04 16:48   ` Wei Liu
  2020-02-05 11:12   ` Jan Beulich
  2020-02-04 15:36 ` [Xen-devel] [PATCH v7 02/10] x86/smp: don't online cpu if hypervisor_ap_setup fails Wei Liu
                   ` (8 subsequent siblings)
  9 siblings, 2 replies; 23+ messages in thread
From: Wei Liu @ 2020-02-04 15:36 UTC (permalink / raw)
  To: Xen Development List
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Paul Durrant, Michael Kelley,
	Jan Beulich, Roger Pau Monné

We want to be able to handle AP setup error in the upper layer.

For Xen, remove all panic() and BUG_ON() in init_evtchn and
map_vcpuinfo. Only panic/BUG_ON when Xen can't fail gracefully.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
---
v7:
1. Change init_evtchn

v6:
1. Change map_vcpuinfo as well
2. Make code shorter
---
 xen/arch/x86/guest/hypervisor.c        |  6 ++-
 xen/arch/x86/guest/xen/xen.c           | 58 ++++++++++++++++----------
 xen/include/asm-x86/guest/hypervisor.h |  6 +--
 3 files changed, 42 insertions(+), 28 deletions(-)

diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c
index 4f27b98740..e72c92ffdf 100644
--- a/xen/arch/x86/guest/hypervisor.c
+++ b/xen/arch/x86/guest/hypervisor.c
@@ -52,10 +52,12 @@ void __init hypervisor_setup(void)
         ops->setup();
 }
 
-void hypervisor_ap_setup(void)
+int hypervisor_ap_setup(void)
 {
     if ( ops && ops->ap_setup )
-        ops->ap_setup();
+        return ops->ap_setup();
+
+    return 0;
 }
 
 void hypervisor_resume(void)
diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c
index 6dbc5f953f..1cf09886da 100644
--- a/xen/arch/x86/guest/xen/xen.c
+++ b/xen/arch/x86/guest/xen/xen.c
@@ -113,16 +113,16 @@ static int map_vcpuinfo(void)
     info.mfn = virt_to_mfn(&vcpu_info[vcpu]);
     info.offset = (unsigned long)&vcpu_info[vcpu] & ~PAGE_MASK;
     rc = xen_hypercall_vcpu_op(VCPUOP_register_vcpu_info, vcpu, &info);
-    if ( rc )
-    {
-        BUG_ON(vcpu >= XEN_LEGACY_MAX_VCPUS);
-        this_cpu(vcpu_info) = &XEN_shared_info->vcpu_info[vcpu];
-    }
-    else
+    if ( !rc )
     {
         this_cpu(vcpu_info) = &vcpu_info[vcpu];
         set_bit(vcpu, vcpu_info_mapped);
     }
+    else if ( vcpu < XEN_LEGACY_MAX_VCPUS )
+    {
+        rc = 0;
+        this_cpu(vcpu_info) = &XEN_shared_info->vcpu_info[vcpu];
+    }
 
     return rc;
 }
@@ -202,10 +202,15 @@ static void xen_evtchn_upcall(struct cpu_user_regs *regs)
     ack_APIC_irq();
 }
 
-static void init_evtchn(void)
+static int init_evtchn(void)
 {
     static uint8_t evtchn_upcall_vector;
     int rc;
+    struct xen_hvm_param a = {
+        .domid = DOMID_SELF,
+        .index = HVM_PARAM_CALLBACK_IRQ,
+        .value = 1,
+    };
 
     if ( !evtchn_upcall_vector )
         alloc_direct_apic_vector(&evtchn_upcall_vector, xen_evtchn_upcall);
@@ -215,18 +220,19 @@ static void init_evtchn(void)
     rc = xen_hypercall_set_evtchn_upcall_vector(this_cpu(vcpu_id),
                                                 evtchn_upcall_vector);
     if ( rc )
-        panic("Unable to set evtchn upcall vector: %d\n", rc);
+    {
+        printk("Unable to set evtchn upcall vector: %d\n", rc);
+        goto out;
+    }
 
     /* Trick toolstack to think we are enlightened */
-    {
-        struct xen_hvm_param a = {
-            .domid = DOMID_SELF,
-            .index = HVM_PARAM_CALLBACK_IRQ,
-            .value = 1,
-        };
+    rc = xen_hypercall_hvm_op(HVMOP_set_param, &a);
 
-        BUG_ON(xen_hypercall_hvm_op(HVMOP_set_param, &a));
-    }
+    if ( rc )
+        printk("Unable to set HVM_PARAM_CALLBACK_IRQ\n");
+
+ out:
+    return rc;
 }
 
 static void __init setup(void)
@@ -254,14 +260,20 @@ static void __init setup(void)
                XEN_LEGACY_MAX_VCPUS);
     }
 
-    init_evtchn();
+    BUG_ON(init_evtchn());
 }
 
-static void ap_setup(void)
+static int ap_setup(void)
 {
+    int rc;
+
     set_vcpu_id();
-    map_vcpuinfo();
-    init_evtchn();
+
+    rc = map_vcpuinfo();
+    if ( rc )
+        return rc;
+
+    return init_evtchn();
 }
 
 int xg_alloc_unused_page(mfn_t *mfn)
@@ -283,8 +295,8 @@ int xg_free_unused_page(mfn_t mfn)
 
 static void ap_resume(void *unused)
 {
-    map_vcpuinfo();
-    init_evtchn();
+    BUG_ON(map_vcpuinfo());
+    BUG_ON(init_evtchn());
 }
 
 static void resume(void)
@@ -303,7 +315,7 @@ static void resume(void)
         panic("unable to remap vCPU info and vCPUs > legacy limit\n");
 
     /* Setup event channel upcall vector. */
-    init_evtchn();
+    BUG_ON(init_evtchn());
     smp_call_function(ap_resume, NULL, 1);
 
     if ( pv_console )
diff --git a/xen/include/asm-x86/guest/hypervisor.h b/xen/include/asm-x86/guest/hypervisor.h
index 392f4b90ae..b503854c5b 100644
--- a/xen/include/asm-x86/guest/hypervisor.h
+++ b/xen/include/asm-x86/guest/hypervisor.h
@@ -25,7 +25,7 @@ struct hypervisor_ops {
     /* Main setup routine */
     void (*setup)(void);
     /* AP setup */
-    void (*ap_setup)(void);
+    int (*ap_setup)(void);
     /* Resume from suspension */
     void (*resume)(void);
 };
@@ -34,7 +34,7 @@ struct hypervisor_ops {
 
 const char *hypervisor_probe(void);
 void hypervisor_setup(void);
-void hypervisor_ap_setup(void);
+int hypervisor_ap_setup(void);
 void hypervisor_resume(void);
 
 #else
@@ -44,7 +44,7 @@ void hypervisor_resume(void);
 
 static inline const char *hypervisor_probe(void) { return NULL; }
 static inline void hypervisor_setup(void) { ASSERT_UNREACHABLE(); }
-static inline void hypervisor_ap_setup(void) { ASSERT_UNREACHABLE(); }
+static inline int hypervisor_ap_setup(void) { ASSERT_UNREACHABLE(); return 0; }
 static inline void hypervisor_resume(void) { ASSERT_UNREACHABLE(); }
 
 #endif  /* CONFIG_GUEST */
-- 
2.20.1


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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [Xen-devel] [PATCH v7 02/10] x86/smp: don't online cpu if hypervisor_ap_setup fails
  2020-02-04 15:36 [Xen-devel] [PATCH v7 00/10] More Hyper-V infrastructures Wei Liu
  2020-02-04 15:36 ` [Xen-devel] [PATCH v7 01/10] x86/hypervisor: make hypervisor_ap_setup return an error code Wei Liu
@ 2020-02-04 15:36 ` Wei Liu
  2020-02-04 15:36 ` [Xen-devel] [PATCH v7 03/10] x86: provide executable fixmap facility Wei Liu
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 23+ messages in thread
From: Wei Liu @ 2020-02-04 15:36 UTC (permalink / raw)
  To: Xen Development List
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Paul Durrant, Michael Kelley,
	Jan Beulich, Roger Pau Monné

Push hypervisor_ap_setup down to smp_callin.

Take the chance to replace xen_guest with cpu_has_hypervisor.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/smpboot.c                 | 10 +++++++---
 xen/include/asm-x86/guest/hypervisor.h |  2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
index c9d1ab4423..93b86a09e9 100644
--- a/xen/arch/x86/smpboot.c
+++ b/xen/arch/x86/smpboot.c
@@ -199,6 +199,13 @@ static void smp_callin(void)
         goto halt;
     }
 
+    if ( cpu_has_hypervisor && (rc = hypervisor_ap_setup()) != 0 )
+    {
+        printk("CPU%d: Failed to initialise hypervisor functions. Not coming online.\n", cpu);
+        cpu_error = rc;
+        goto halt;
+    }
+
     if ( (rc = hvm_cpu_up()) != 0 )
     {
         printk("CPU%d: Failed to initialise HVM. Not coming online.\n", cpu);
@@ -371,9 +378,6 @@ void start_secondary(void *unused)
 
     tsx_init(); /* Needs microcode.  May change HLE/RTM feature bits. */
 
-    if ( xen_guest )
-        hypervisor_ap_setup();
-
     smp_callin();
 
     set_cpu_sibling_map(cpu);
diff --git a/xen/include/asm-x86/guest/hypervisor.h b/xen/include/asm-x86/guest/hypervisor.h
index b503854c5b..64383f0c3d 100644
--- a/xen/include/asm-x86/guest/hypervisor.h
+++ b/xen/include/asm-x86/guest/hypervisor.h
@@ -44,7 +44,7 @@ void hypervisor_resume(void);
 
 static inline const char *hypervisor_probe(void) { return NULL; }
 static inline void hypervisor_setup(void) { ASSERT_UNREACHABLE(); }
-static inline int hypervisor_ap_setup(void) { ASSERT_UNREACHABLE(); return 0; }
+static inline int hypervisor_ap_setup(void) { return 0; }
 static inline void hypervisor_resume(void) { ASSERT_UNREACHABLE(); }
 
 #endif  /* CONFIG_GUEST */
-- 
2.20.1


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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [Xen-devel] [PATCH v7 03/10] x86: provide executable fixmap facility
  2020-02-04 15:36 [Xen-devel] [PATCH v7 00/10] More Hyper-V infrastructures Wei Liu
  2020-02-04 15:36 ` [Xen-devel] [PATCH v7 01/10] x86/hypervisor: make hypervisor_ap_setup return an error code Wei Liu
  2020-02-04 15:36 ` [Xen-devel] [PATCH v7 02/10] x86/smp: don't online cpu if hypervisor_ap_setup fails Wei Liu
@ 2020-02-04 15:36 ` Wei Liu
  2020-02-05 11:15   ` Jan Beulich
  2020-02-04 15:36 ` [Xen-devel] [PATCH v7 04/10] x86/hypervisor: provide hypervisor_fixup_e820 Wei Liu
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 23+ messages in thread
From: Wei Liu @ 2020-02-04 15:36 UTC (permalink / raw)
  To: Xen Development List
  Cc: Wei Liu, Wei Liu, Konrad Rzeszutek Wilk, Andrew Cooper,
	Paul Durrant, Michael Kelley, Ross Lagerwall, Jan Beulich,
	Roger Pau Monné

This allows us to set aside some address space for executable mapping.
This fixed map range starts from XEN_VIRT_END so that it is within reach
of the .text section.

Shift the percpu stub range and shrink livepatch range accordingly.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
---
v7:
1. Introduce ASM_CONSTANT

v6:
1. Move symbol generation snippet to arch_init_memory and use %P0

v5:
1. drop __virt_to_fix_x
2. also check FIX*_RESERVED in __set_fixmap*
3. generate global symbol to be used in linker script
4. address other misc comments
---
 xen/arch/x86/boot/x86_64.S      | 15 ++++++++++++---
 xen/arch/x86/livepatch.c        |  3 ++-
 xen/arch/x86/mm.c               | 14 +++++++++++++-
 xen/arch/x86/smpboot.c          |  2 +-
 xen/arch/x86/xen.lds.S          |  1 +
 xen/include/asm-x86/asm_defns.h |  5 +++++
 xen/include/asm-x86/config.h    |  2 +-
 xen/include/asm-x86/fixmap.h    | 24 ++++++++++++++++++++++++
 8 files changed, 59 insertions(+), 7 deletions(-)

diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S
index 1cbf5acdfb..314a32a19f 100644
--- a/xen/arch/x86/boot/x86_64.S
+++ b/xen/arch/x86/boot/x86_64.S
@@ -81,11 +81,20 @@ GLOBAL(l2_directmap)
         .size l2_directmap, . - l2_directmap
 
 /*
- * L2 mapping the Xen text/data/bss region, constructed dynamically.  Uses 1x
- * 4k page.
+ * L2 mapping the Xen text/data/bss region, constructed dynamically.
+ * Executable fixmap is hooked up statically.
+ * Uses 1x 4k page.
  */
 GLOBAL(l2_xenmap)
-        .fill L2_PAGETABLE_ENTRIES, 8, 0
+        idx = 0
+        .rept L2_PAGETABLE_ENTRIES
+        .if idx == l2_table_offset(FIXADDR_X_TOP - 1)
+        .quad sym_offs(l1_fixmap_x) + __PAGE_HYPERVISOR
+        .else
+        .quad 0
+        .endif
+        idx = idx + 1
+        .endr
         .size l2_xenmap, . - l2_xenmap
 
 /* L2 mapping the fixmap.  Uses 1x 4k page. */
diff --git a/xen/arch/x86/livepatch.c b/xen/arch/x86/livepatch.c
index 2749cbc5cf..513b0f3841 100644
--- a/xen/arch/x86/livepatch.c
+++ b/xen/arch/x86/livepatch.c
@@ -12,6 +12,7 @@
 #include <xen/livepatch.h>
 #include <xen/sched.h>
 
+#include <asm/fixmap.h>
 #include <asm/nmi.h>
 #include <asm/livepatch.h>
 
@@ -311,7 +312,7 @@ void __init arch_livepatch_init(void)
     void *start, *end;
 
     start = (void *)xen_virt_end;
-    end = (void *)(XEN_VIRT_END - NR_CPUS * PAGE_SIZE);
+    end = (void *)(XEN_VIRT_END - FIXADDR_X_SIZE - NR_CPUS * PAGE_SIZE);
 
     BUG_ON(end <= start);
 
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index a05a713276..9b33829084 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -158,6 +158,8 @@
 /* Mapping of the fixmap space needed early. */
 l1_pgentry_t __section(".bss.page_aligned") __aligned(PAGE_SIZE)
     l1_fixmap[L1_PAGETABLE_ENTRIES];
+l1_pgentry_t __section(".bss.page_aligned") __aligned(PAGE_SIZE)
+    l1_fixmap_x[L1_PAGETABLE_ENTRIES];
 
 paddr_t __read_mostly mem_hotplug;
 
@@ -373,6 +375,9 @@ void __init arch_init_memory(void)
         }
     }
 #endif
+
+    /* Generate a symbol to be used in linker script */
+    ASM_CONSTANT(FIXADDR_X_SIZE, FIXADDR_X_SIZE);
 }
 
 int page_is_ram_type(unsigned long mfn, unsigned long mem_type)
@@ -5719,10 +5724,17 @@ int destroy_xen_mappings(unsigned long s, unsigned long e)
 void __set_fixmap(
     enum fixed_addresses idx, unsigned long mfn, unsigned long flags)
 {
-    BUG_ON(idx >= __end_of_fixed_addresses);
+    BUG_ON(idx >= __end_of_fixed_addresses || idx <= FIX_RESERVED);
     map_pages_to_xen(__fix_to_virt(idx), _mfn(mfn), 1, flags);
 }
 
+void __set_fixmap_x(
+    enum fixed_addresses_x idx, unsigned long mfn, unsigned long flags)
+{
+    BUG_ON(idx >= __end_of_fixed_addresses_x || idx <= FIX_X_RESERVED);
+    map_pages_to_xen(__fix_x_to_virt(idx), _mfn(mfn), 1, flags);
+}
+
 void *__init arch_vmap_virt_end(void)
 {
     return fix_to_virt(__end_of_fixed_addresses);
diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
index 93b86a09e9..e83e4564a4 100644
--- a/xen/arch/x86/smpboot.c
+++ b/xen/arch/x86/smpboot.c
@@ -644,7 +644,7 @@ unsigned long alloc_stub_page(unsigned int cpu, unsigned long *mfn)
         unmap_domain_page(memset(__map_domain_page(pg), 0xcc, PAGE_SIZE));
     }
 
-    stub_va = XEN_VIRT_END - (cpu + 1) * PAGE_SIZE;
+    stub_va = XEN_VIRT_END - FIXADDR_X_SIZE - (cpu + 1) * PAGE_SIZE;
     if ( map_pages_to_xen(stub_va, page_to_mfn(pg), 1,
                           PAGE_HYPERVISOR_RX | MAP_SMALL_PAGES) )
     {
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index f5730ffe93..44fda616d5 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -352,6 +352,7 @@ SECTIONS
 }
 
 ASSERT(__2M_rwdata_end <= XEN_VIRT_END - XEN_VIRT_START + __XEN_VIRT_START -
+                          FIXADDR_X_SIZE -
                           NR_CPUS * PAGE_SIZE,
        "Xen image overlaps stubs area")
 
diff --git a/xen/include/asm-x86/asm_defns.h b/xen/include/asm-x86/asm_defns.h
index 370f239c50..98cd49a89b 100644
--- a/xen/include/asm-x86/asm_defns.h
+++ b/xen/include/asm-x86/asm_defns.h
@@ -392,4 +392,9 @@ label: .long (val);                         \
     .size label, . - label;                 \
     .type label, @object
 
+
+#define ASM_CONSTANT(name, value)                \
+    asm ( ".equ " #name ", %P0; .global " #name  \
+          :: "i" ((value)) );
+
 #endif /* __X86_ASM_DEFNS_H__ */
diff --git a/xen/include/asm-x86/config.h b/xen/include/asm-x86/config.h
index d0cfbb70a8..a34053c4c0 100644
--- a/xen/include/asm-x86/config.h
+++ b/xen/include/asm-x86/config.h
@@ -218,7 +218,7 @@ extern unsigned char boot_edid_info[128];
 /* Slot 261: high read-only compat machine-to-phys conversion table (1GB). */
 #define HIRO_COMPAT_MPT_VIRT_START RDWR_COMPAT_MPT_VIRT_END
 #define HIRO_COMPAT_MPT_VIRT_END (HIRO_COMPAT_MPT_VIRT_START + GB(1))
-/* Slot 261: xen text, static data and bss (1GB). */
+/* Slot 261: xen text, static data, bss, per-cpu stubs and executable fixmap (1GB). */
 #define XEN_VIRT_START          (HIRO_COMPAT_MPT_VIRT_END)
 #define XEN_VIRT_END            (XEN_VIRT_START + GB(1))
 
diff --git a/xen/include/asm-x86/fixmap.h b/xen/include/asm-x86/fixmap.h
index 9fb2f47946..8330097a74 100644
--- a/xen/include/asm-x86/fixmap.h
+++ b/xen/include/asm-x86/fixmap.h
@@ -15,6 +15,7 @@
 #include <asm/page.h>
 
 #define FIXADDR_TOP (VMAP_VIRT_END - PAGE_SIZE)
+#define FIXADDR_X_TOP (XEN_VIRT_END - PAGE_SIZE)
 
 #ifndef __ASSEMBLY__
 
@@ -89,6 +90,29 @@ static inline unsigned long virt_to_fix(const unsigned long vaddr)
     return __virt_to_fix(vaddr);
 }
 
+enum fixed_addresses_x {
+    /* Index 0 is reserved since fix_x_to_virt(0) == FIXADDR_X_TOP. */
+    FIX_X_RESERVED,
+#ifdef CONFIG_HYPERV_GUEST
+    FIX_X_HYPERV_HCALL,
+#endif
+    __end_of_fixed_addresses_x
+};
+
+#define FIXADDR_X_SIZE  (__end_of_fixed_addresses_x << PAGE_SHIFT)
+#define FIXADDR_X_START (FIXADDR_X_TOP - FIXADDR_X_SIZE)
+
+extern void __set_fixmap_x(
+    enum fixed_addresses_x idx, unsigned long mfn, unsigned long flags);
+
+#define set_fixmap_x(idx, phys) \
+    __set_fixmap_x(idx, (phys)>>PAGE_SHIFT, PAGE_HYPERVISOR_RX | MAP_SMALL_PAGES)
+
+#define clear_fixmap_x(idx) __set_fixmap_x(idx, 0, 0)
+
+#define __fix_x_to_virt(x) (FIXADDR_X_TOP - ((x) << PAGE_SHIFT))
+#define fix_x_to_virt(x)   ((void *)__fix_x_to_virt(x))
+
 #endif /* __ASSEMBLY__ */
 
 #endif
-- 
2.20.1


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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [Xen-devel] [PATCH v7 04/10] x86/hypervisor: provide hypervisor_fixup_e820
  2020-02-04 15:36 [Xen-devel] [PATCH v7 00/10] More Hyper-V infrastructures Wei Liu
                   ` (2 preceding siblings ...)
  2020-02-04 15:36 ` [Xen-devel] [PATCH v7 03/10] x86: provide executable fixmap facility Wei Liu
@ 2020-02-04 15:36 ` Wei Liu
  2020-02-04 15:36 ` [Xen-devel] [PATCH v7 05/10] x86/hyperv: setup hypercall page Wei Liu
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 23+ messages in thread
From: Wei Liu @ 2020-02-04 15:36 UTC (permalink / raw)
  To: Xen Development List
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Paul Durrant, Michael Kelley,
	Jan Beulich, Roger Pau Monné

And implement the hook for Xen guest.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
v7:
1. Drop bogus ASSERT_UNREACHABLE from stub
2. Add Jan's Rb, considering #1 doesn't change the meat of the patch
---
 xen/arch/x86/e820.c                    | 4 ++--
 xen/arch/x86/guest/hypervisor.c        | 6 ++++++
 xen/arch/x86/guest/xen/xen.c           | 7 +++++++
 xen/include/asm-x86/guest/hypervisor.h | 6 ++++++
 4 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/e820.c b/xen/arch/x86/e820.c
index b9f589cac3..160f029edd 100644
--- a/xen/arch/x86/e820.c
+++ b/xen/arch/x86/e820.c
@@ -691,8 +691,8 @@ unsigned long __init init_e820(const char *str, struct e820map *raw)
 
     machine_specific_memory_setup(raw);
 
-    if ( pv_shim )
-        pv_shim_fixup_e820(&e820);
+    if ( cpu_has_hypervisor )
+        hypervisor_e820_fixup(&e820);
 
     printk("%s RAM map:\n", str);
     print_e820_memory_map(e820.map, e820.nr_map);
diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c
index e72c92ffdf..5fd433c8d4 100644
--- a/xen/arch/x86/guest/hypervisor.c
+++ b/xen/arch/x86/guest/hypervisor.c
@@ -66,6 +66,12 @@ void hypervisor_resume(void)
         ops->resume();
 }
 
+void __init hypervisor_e820_fixup(struct e820map *e820)
+{
+    if ( ops && ops->e820_fixup )
+        ops->e820_fixup(e820);
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c
index 1cf09886da..5a7f3cce42 100644
--- a/xen/arch/x86/guest/xen/xen.c
+++ b/xen/arch/x86/guest/xen/xen.c
@@ -322,11 +322,18 @@ static void resume(void)
         pv_console_init();
 }
 
+static void __init e820_fixup(struct e820map *e820)
+{
+    if ( pv_shim )
+        pv_shim_fixup_e820(e820);
+}
+
 static const struct hypervisor_ops ops = {
     .name = "Xen",
     .setup = setup,
     .ap_setup = ap_setup,
     .resume = resume,
+    .e820_fixup = e820_fixup,
 };
 
 const struct hypervisor_ops *__init xg_probe(void)
diff --git a/xen/include/asm-x86/guest/hypervisor.h b/xen/include/asm-x86/guest/hypervisor.h
index 64383f0c3d..ade10e74ea 100644
--- a/xen/include/asm-x86/guest/hypervisor.h
+++ b/xen/include/asm-x86/guest/hypervisor.h
@@ -19,6 +19,8 @@
 #ifndef __X86_HYPERVISOR_H__
 #define __X86_HYPERVISOR_H__
 
+#include <asm/e820.h>
+
 struct hypervisor_ops {
     /* Name of the hypervisor */
     const char *name;
@@ -28,6 +30,8 @@ struct hypervisor_ops {
     int (*ap_setup)(void);
     /* Resume from suspension */
     void (*resume)(void);
+    /* Fix up e820 map */
+    void (*e820_fixup)(struct e820map *e820);
 };
 
 #ifdef CONFIG_GUEST
@@ -36,6 +40,7 @@ const char *hypervisor_probe(void);
 void hypervisor_setup(void);
 int hypervisor_ap_setup(void);
 void hypervisor_resume(void);
+void hypervisor_e820_fixup(struct e820map *e820);
 
 #else
 
@@ -46,6 +51,7 @@ static inline const char *hypervisor_probe(void) { return NULL; }
 static inline void hypervisor_setup(void) { ASSERT_UNREACHABLE(); }
 static inline int hypervisor_ap_setup(void) { return 0; }
 static inline void hypervisor_resume(void) { ASSERT_UNREACHABLE(); }
+static inline void hypervisor_e820_fixup(struct e820map *e820) {}
 
 #endif  /* CONFIG_GUEST */
 
-- 
2.20.1


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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [Xen-devel] [PATCH v7 05/10] x86/hyperv: setup hypercall page
  2020-02-04 15:36 [Xen-devel] [PATCH v7 00/10] More Hyper-V infrastructures Wei Liu
                   ` (3 preceding siblings ...)
  2020-02-04 15:36 ` [Xen-devel] [PATCH v7 04/10] x86/hypervisor: provide hypervisor_fixup_e820 Wei Liu
@ 2020-02-04 15:36 ` Wei Liu
  2020-02-05 14:04   ` Roger Pau Monné
  2020-02-05 15:52   ` Durrant, Paul
  2020-02-04 15:37 ` [Xen-devel] [PATCH v7 06/10] x86/hyperv: provide Hyper-V hypercall functions Wei Liu
                   ` (4 subsequent siblings)
  9 siblings, 2 replies; 23+ messages in thread
From: Wei Liu @ 2020-02-04 15:36 UTC (permalink / raw)
  To: Xen Development List
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Paul Durrant, Michael Kelley,
	Jan Beulich, Roger Pau Monné

Hyper-V uses a technique called overlay page for its hypercall page. It
will insert a backing page to the guest when the hypercall functionality
is enabled. That means we can use a page that is not backed by real
memory for hypercall page.

To avoid shattering L0 superpages and treading on any MMIO areas
residing in low addresses, use the top-most addressable page for that
purpose. Adjust e820 map accordingly.

We also need to register Xen's guest OS ID to Hyper-V. Use 0x3 as the
vendor ID. Fix the comment in hyperv-tlfs.h while at it.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
---
v7:
1. Fix a style issue
2. Initialise ID to 0
3. Update commit message

v6:
1. Use hv_guest_os_id
2. Use new e820_fixup hook
3. Add a BUILD_BUG_ON

v5:
1. use hypervisor_reserve_top_pages
2. add a macro for hypercall page mfn
3. address other misc comments

v4:
1. Use fixmap
2. Follow routines listed in TLFS
---
 xen/arch/x86/guest/hyperv/hyperv.c      | 69 +++++++++++++++++++++++--
 xen/include/asm-x86/guest/hyperv-tlfs.h |  5 +-
 xen/include/asm-x86/guest/hyperv.h      |  3 ++
 3 files changed, 72 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c
index 8d38313d7a..2e20a96f30 100644
--- a/xen/arch/x86/guest/hyperv/hyperv.c
+++ b/xen/arch/x86/guest/hyperv/hyperv.c
@@ -19,15 +19,27 @@
  * Copyright (c) 2019 Microsoft.
  */
 #include <xen/init.h>
+#include <xen/version.h>
 
+#include <asm/fixmap.h>
 #include <asm/guest.h>
 #include <asm/guest/hyperv-tlfs.h>
+#include <asm/processor.h>
 
 struct ms_hyperv_info __read_mostly ms_hyperv;
 
-static const struct hypervisor_ops ops = {
-    .name = "Hyper-V",
-};
+static uint64_t generate_guest_id(void)
+{
+    union hv_guest_os_id id = {};
+
+    id.vendor = HV_XEN_VENDOR_ID;
+    id.major = xen_major_version();
+    id.minor = xen_minor_version();
+
+    return id.raw;
+}
+
+static const struct hypervisor_ops ops;
 
 const struct hypervisor_ops *__init hyperv_probe(void)
 {
@@ -72,6 +84,57 @@ 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;
+    union hv_guest_os_id guest_id;
+    unsigned long mfn;
+
+    BUILD_BUG_ON(HV_HYP_PAGE_SHIFT != PAGE_SHIFT);
+
+    rdmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id.raw);
+    if ( !guest_id.raw )
+    {
+        guest_id.raw = generate_guest_id();
+        wrmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id.raw);
+    }
+
+    rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
+    if ( !hypercall_msr.enable )
+    {
+        mfn = HV_HCALL_MFN;
+        hypercall_msr.enable = 1;
+        hypercall_msr.guest_physical_address = mfn;
+        wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
+    }
+    else
+        mfn = hypercall_msr.guest_physical_address;
+
+    rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
+    BUG_ON(!hypercall_msr.enable);
+
+    set_fixmap_x(FIX_X_HYPERV_HCALL, mfn << PAGE_SHIFT);
+}
+
+static void __init setup(void)
+{
+    setup_hypercall_page();
+}
+
+static void __init e820_fixup(struct e820map *e820)
+{
+    uint64_t s = HV_HCALL_MFN << PAGE_SHIFT;
+
+    if ( !e820_add_range(e820, s, s + PAGE_SIZE, E820_RESERVED) )
+        panic("Unable to reserve Hyper-V hypercall range\n");
+}
+
+static const struct hypervisor_ops ops = {
+    .name = "Hyper-V",
+    .setup = setup,
+    .e820_fixup = e820_fixup,
+};
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/include/asm-x86/guest/hyperv-tlfs.h b/xen/include/asm-x86/guest/hyperv-tlfs.h
index 091e25cdd1..0a0f3398c1 100644
--- a/xen/include/asm-x86/guest/hyperv-tlfs.h
+++ b/xen/include/asm-x86/guest/hyperv-tlfs.h
@@ -318,15 +318,16 @@ struct ms_hyperv_tsc_page {
  *
  * Bit(s)
  * 63 - Indicates if the OS is Open Source or not; 1 is Open Source
- * 62:56 - Os Type; Linux is 0x100
+ * 62:56 - Os Type; Linux 0x1, FreeBSD 0x2, Xen 0x3
  * 55:48 - Distro specific identification
- * 47:16 - Linux kernel version number
+ * 47:16 - Guest OS version number
  * 15:0  - Distro specific identification
  *
  *
  */
 
 #define HV_LINUX_VENDOR_ID              0x8100
+#define HV_XEN_VENDOR_ID                0x8300
 union hv_guest_os_id
 {
     uint64_t raw;
diff --git a/xen/include/asm-x86/guest/hyperv.h b/xen/include/asm-x86/guest/hyperv.h
index c7a7f32bd5..1a1b47831c 100644
--- a/xen/include/asm-x86/guest/hyperv.h
+++ b/xen/include/asm-x86/guest/hyperv.h
@@ -21,6 +21,9 @@
 
 #include <xen/types.h>
 
+/* Use top-most MFN for hypercall page */
+#define HV_HCALL_MFN   (((1ull << paddr_bits) - 1) >> HV_HYP_PAGE_SHIFT)
+
 /*
  * The specification says: "The partition reference time is computed
  * by the following formula:
-- 
2.20.1


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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [Xen-devel] [PATCH v7 06/10] x86/hyperv: provide Hyper-V hypercall functions
  2020-02-04 15:36 [Xen-devel] [PATCH v7 00/10] More Hyper-V infrastructures Wei Liu
                   ` (4 preceding siblings ...)
  2020-02-04 15:36 ` [Xen-devel] [PATCH v7 05/10] x86/hyperv: setup hypercall page Wei Liu
@ 2020-02-04 15:37 ` Wei Liu
  2020-02-05 11:17   ` Jan Beulich
  2020-02-04 15:37 ` [Xen-devel] [PATCH v7 07/10] DO NOT APPLY: x86/hyperv: issue an hypercall Wei Liu
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 23+ messages in thread
From: Wei Liu @ 2020-02-04 15:37 UTC (permalink / raw)
  To: Xen Development List
  Cc: Stefano Stabellini, Wei Liu, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Paul Durrant, Ian Jackson,
	Michael Kelley, Jan Beulich, Julien Grall, Roger Pau Monné

These functions will be used later to make hypercalls to Hyper-V.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
Reviewed-by: Paul Durrant <pdurrant@amazon.com>
---
v7:
1. Use ASM_CONSTANT and put it in hyperv.c

v6:
1. Use asm(...) to generate symbol
2. Add a comment regarding volatile registers

v5:
1. Switch back to direct call
2. Fix some issues pointed out by Jan
---
 MAINTAINERS                              |  1 +
 xen/arch/x86/guest/hyperv/hyperv.c       |  2 +
 xen/arch/x86/xen.lds.S                   |  4 +
 xen/include/asm-x86/guest/hyperv-hcall.h | 97 ++++++++++++++++++++++++
 4 files changed, 104 insertions(+)
 create mode 100644 xen/include/asm-x86/guest/hyperv-hcall.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 04d91482cd..d0a5ed635b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -519,6 +519,7 @@ S:	Supported
 F:	xen/arch/x86/guest/hyperv/
 F:	xen/arch/x86/hvm/viridian/
 F:	xen/include/asm-x86/guest/hyperv.h
+F:	xen/include/asm-x86/guest/hyperv-hcall.h
 F:	xen/include/asm-x86/guest/hyperv-tlfs.h
 F:	xen/include/asm-x86/hvm/viridian.h
 
diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c
index 2e20a96f30..888bda25b0 100644
--- a/xen/arch/x86/guest/hyperv/hyperv.c
+++ b/xen/arch/x86/guest/hyperv/hyperv.c
@@ -118,6 +118,8 @@ static void __init setup_hypercall_page(void)
 
 static void __init setup(void)
 {
+    ASM_CONSTANT(HV_HCALL_PAGE, __fix_x_to_virt(FIX_X_HYPERV_HCALL));
+
     setup_hypercall_page();
 }
 
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index 44fda616d5..7f9459d683 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -326,6 +326,10 @@ SECTIONS
   efi = .;
 #endif
 
+#ifdef CONFIG_HYPERV_GUEST
+  hv_hcall_page = ABSOLUTE(HV_HCALL_PAGE);
+#endif
+
   /* Sections to be discarded */
   /DISCARD/ : {
        *(.exit.text)
diff --git a/xen/include/asm-x86/guest/hyperv-hcall.h b/xen/include/asm-x86/guest/hyperv-hcall.h
new file mode 100644
index 0000000000..4d3b131b3a
--- /dev/null
+++ b/xen/include/asm-x86/guest/hyperv-hcall.h
@@ -0,0 +1,97 @@
+/******************************************************************************
+ * asm-x86/guest/hyperv-hcall.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (c) 2019 Microsoft.
+ */
+
+#ifndef __X86_HYPERV_HCALL_H__
+#define __X86_HYPERV_HCALL_H__
+
+#include <xen/lib.h>
+#include <xen/types.h>
+
+#include <asm/asm_defns.h>
+#include <asm/fixmap.h>
+#include <asm/guest/hyperv-tlfs.h>
+#include <asm/page.h>
+
+static inline uint64_t hv_do_hypercall(uint64_t control, paddr_t input_addr,
+                                       paddr_t output_addr)
+{
+    uint64_t status;
+    register unsigned long r8 asm ( "r8" ) = output_addr;
+
+    /* See TLFS for volatile registers */
+    asm volatile ( "call hv_hcall_page"
+                   : "=a" (status), "+c" (control),
+                     "+d" (input_addr) ASM_CALL_CONSTRAINT
+                   : "r" (r8)
+                   : "memory" );
+
+    return status;
+}
+
+static inline uint64_t hv_do_fast_hypercall(uint16_t code,
+                                            uint64_t input1, uint64_t input2)
+{
+    uint64_t status;
+    uint64_t control = code | HV_HYPERCALL_FAST_BIT;
+    register unsigned long r8 asm ( "r8" ) = input2;
+
+    /* See TLFS for volatile registers */
+    asm volatile ( "call hv_hcall_page"
+                   : "=a" (status), "+c" (control),
+                     "+d" (input1) ASM_CALL_CONSTRAINT
+                   : "r" (r8) );
+
+    return status;
+}
+
+static inline uint64_t hv_do_rep_hypercall(uint16_t code, uint16_t rep_count,
+                                           uint16_t varhead_size,
+                                           paddr_t input, paddr_t output)
+{
+    uint64_t control = code;
+    uint64_t status;
+    uint16_t rep_comp;
+
+    control |= (uint64_t)varhead_size << HV_HYPERCALL_VARHEAD_OFFSET;
+    control |= (uint64_t)rep_count << HV_HYPERCALL_REP_COMP_OFFSET;
+
+    do {
+        status = hv_do_hypercall(control, input, output);
+        if ( (status & HV_HYPERCALL_RESULT_MASK) != HV_STATUS_SUCCESS )
+            break;
+
+        rep_comp = MASK_EXTR(status, HV_HYPERCALL_REP_COMP_MASK);
+
+        control &= ~HV_HYPERCALL_REP_START_MASK;
+        control |= MASK_INSR(rep_comp, HV_HYPERCALL_REP_START_MASK);
+    } while ( rep_comp < rep_count );
+
+    return status;
+}
+
+#endif /* __X86_HYPERV_HCALL_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
2.20.1


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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [Xen-devel] [PATCH v7 07/10] DO NOT APPLY: x86/hyperv: issue an hypercall
  2020-02-04 15:36 [Xen-devel] [PATCH v7 00/10] More Hyper-V infrastructures Wei Liu
                   ` (5 preceding siblings ...)
  2020-02-04 15:37 ` [Xen-devel] [PATCH v7 06/10] x86/hyperv: provide Hyper-V hypercall functions Wei Liu
@ 2020-02-04 15:37 ` Wei Liu
  2020-02-04 15:37 ` [Xen-devel] [PATCH v7 08/10] x86/hyperv: provide percpu hypercall input page Wei Liu
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 23+ messages in thread
From: Wei Liu @ 2020-02-04 15:37 UTC (permalink / raw)
  To: Xen Development List
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Paul Durrant, Michael Kelley,
	Jan Beulich, Roger Pau Monné

Test if the infrastructure works.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
---
 xen/arch/x86/guest/hyperv/hyperv.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c
index 888bda25b0..2a2afcb363 100644
--- a/xen/arch/x86/guest/hyperv/hyperv.c
+++ b/xen/arch/x86/guest/hyperv/hyperv.c
@@ -23,6 +23,7 @@
 
 #include <asm/fixmap.h>
 #include <asm/guest.h>
+#include <asm/guest/hyperv-hcall.h>
 #include <asm/guest/hyperv-tlfs.h>
 #include <asm/processor.h>
 
@@ -114,6 +115,19 @@ static void __init setup_hypercall_page(void)
     BUG_ON(!hypercall_msr.enable);
 
     set_fixmap_x(FIX_X_HYPERV_HCALL, mfn << PAGE_SHIFT);
+
+    /* XXX Wei: Issue an hypercall here to make sure things are set up
+     * correctly.  When there is actual use of the hypercall facility,
+     * this can be removed.
+     */
+    {
+        uint16_t r = hv_do_hypercall(0xffff, 0, 0);
+        BUG_ON(r != HV_STATUS_INVALID_HYPERCALL_CODE);
+        r = hv_do_fast_hypercall(0xffff, 0, 0);
+        BUG_ON(r != HV_STATUS_INVALID_HYPERCALL_CODE);
+
+        printk("Successfully issued Hyper-V hypercalls\n");
+    }
 }
 
 static void __init setup(void)
-- 
2.20.1


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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [Xen-devel] [PATCH v7 08/10] x86/hyperv: provide percpu hypercall input page
  2020-02-04 15:36 [Xen-devel] [PATCH v7 00/10] More Hyper-V infrastructures Wei Liu
                   ` (6 preceding siblings ...)
  2020-02-04 15:37 ` [Xen-devel] [PATCH v7 07/10] DO NOT APPLY: x86/hyperv: issue an hypercall Wei Liu
@ 2020-02-04 15:37 ` Wei Liu
  2020-02-04 15:37 ` [Xen-devel] [PATCH v7 09/10] x86/hyperv: retrieve vp_index from Hyper-V Wei Liu
  2020-02-04 15:37 ` [Xen-devel] [PATCH v7 10/10] x86/hyperv: setup VP assist page Wei Liu
  9 siblings, 0 replies; 23+ messages in thread
From: Wei Liu @ 2020-02-04 15:37 UTC (permalink / raw)
  To: Xen Development List
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Paul Durrant, Michael Kelley,
	Jan Beulich, Roger Pau Monné

Hyper-V's input / output argument must be 8 bytes aligned an not cross
page boundary. One way to satisfy those requirements is to use percpu
page.

For the foreseeable future we only need to provide input for TLB
and APIC hypercalls, so skip setting up an output page.

We will also need to provide an ap_setup hook for secondary cpus to
setup its own input page.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
Reviewed-by: Paul Durrant <pdurrant@amazon.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
v6:
1. Make code shorter
2. Change variable name

v5:
1. Adjust to new ap_setup
2. Change variable name to hv_pcpu_input_page

v4:
1. Change wording in commit message
2. Prevent leak
3. Introduce a private header

v3:
1. Use xenheap page instead
2. Drop page tracking structure
3. Drop Paul's review tag

address comments
---
 xen/arch/x86/guest/hyperv/hyperv.c  | 28 ++++++++++++++++++++++++++++
 xen/arch/x86/guest/hyperv/private.h | 29 +++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)
 create mode 100644 xen/arch/x86/guest/hyperv/private.h

diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c
index 2a2afcb363..6b58065c78 100644
--- a/xen/arch/x86/guest/hyperv/hyperv.c
+++ b/xen/arch/x86/guest/hyperv/hyperv.c
@@ -27,7 +27,10 @@
 #include <asm/guest/hyperv-tlfs.h>
 #include <asm/processor.h>
 
+#include "private.h"
+
 struct ms_hyperv_info __read_mostly ms_hyperv;
+DEFINE_PER_CPU_READ_MOSTLY(void *, hv_input_page);
 
 static uint64_t generate_guest_id(void)
 {
@@ -130,11 +133,35 @@ static void __init setup_hypercall_page(void)
     }
 }
 
+static int setup_hypercall_pcpu_arg(void)
+{
+    if ( this_cpu(hv_input_page) )
+        return 0;
+
+    this_cpu(hv_input_page) = alloc_xenheap_page();
+    if ( !this_cpu(hv_input_page) )
+    {
+        printk("CPU%u: Failed to allocate hypercall input page\n",
+               smp_processor_id());
+        return -ENOMEM;
+    }
+
+    return 0;
+}
+
 static void __init setup(void)
 {
     ASM_CONSTANT(HV_HCALL_PAGE, __fix_x_to_virt(FIX_X_HYPERV_HCALL));
 
     setup_hypercall_page();
+
+    if ( setup_hypercall_pcpu_arg() )
+        panic("Hyper-V hypercall percpu arg setup failed\n");
+}
+
+static int ap_setup(void)
+{
+    return setup_hypercall_pcpu_arg();
 }
 
 static void __init e820_fixup(struct e820map *e820)
@@ -148,6 +175,7 @@ static void __init e820_fixup(struct e820map *e820)
 static const struct hypervisor_ops ops = {
     .name = "Hyper-V",
     .setup = setup,
+    .ap_setup = ap_setup,
     .e820_fixup = e820_fixup,
 };
 
diff --git a/xen/arch/x86/guest/hyperv/private.h b/xen/arch/x86/guest/hyperv/private.h
new file mode 100644
index 0000000000..093985a94b
--- /dev/null
+++ b/xen/arch/x86/guest/hyperv/private.h
@@ -0,0 +1,29 @@
+/******************************************************************************
+ * arch/x86/guest/hyperv/private.h
+ *
+ * Definitions / declarations only useful to Hyper-V code.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (c) 2020 Microsoft.
+ */
+
+#ifndef __XEN_HYPERV_PRIVIATE_H__
+#define __XEN_HYPERV_PRIVIATE_H__
+
+#include <xen/percpu.h>
+
+DECLARE_PER_CPU(void *, hv_input_page);
+
+#endif /* __XEN_HYPERV_PRIVIATE_H__  */
-- 
2.20.1


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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [Xen-devel] [PATCH v7 09/10] x86/hyperv: retrieve vp_index from Hyper-V
  2020-02-04 15:36 [Xen-devel] [PATCH v7 00/10] More Hyper-V infrastructures Wei Liu
                   ` (7 preceding siblings ...)
  2020-02-04 15:37 ` [Xen-devel] [PATCH v7 08/10] x86/hyperv: provide percpu hypercall input page Wei Liu
@ 2020-02-04 15:37 ` Wei Liu
  2020-02-04 15:37 ` [Xen-devel] [PATCH v7 10/10] x86/hyperv: setup VP assist page Wei Liu
  9 siblings, 0 replies; 23+ messages in thread
From: Wei Liu @ 2020-02-04 15:37 UTC (permalink / raw)
  To: Xen Development List
  Cc: Wei Liu, Wei Liu, Paul Durrant, Andrew Cooper, Paul Durrant,
	Michael Kelley, Jan Beulich, Roger Pau Monné

This will be useful when invoking hypercall that targets specific
vcpu(s).

Signed-off-by: Wei Liu <liuwe@microsoft.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
v5:
1. Add Jan's Ack.

v4:
1. Use private.h
2. Add Paul's review tag

v2:
1. Fold into setup_pcpu_arg function
---
 xen/arch/x86/guest/hyperv/hyperv.c  | 6 ++++++
 xen/arch/x86/guest/hyperv/private.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c
index 6b58065c78..e31c4b30b8 100644
--- a/xen/arch/x86/guest/hyperv/hyperv.c
+++ b/xen/arch/x86/guest/hyperv/hyperv.c
@@ -31,6 +31,7 @@
 
 struct ms_hyperv_info __read_mostly ms_hyperv;
 DEFINE_PER_CPU_READ_MOSTLY(void *, hv_input_page);
+DEFINE_PER_CPU_READ_MOSTLY(unsigned int, hv_vp_index);
 
 static uint64_t generate_guest_id(void)
 {
@@ -135,6 +136,8 @@ static void __init setup_hypercall_page(void)
 
 static int setup_hypercall_pcpu_arg(void)
 {
+    uint64_t vp_index_msr;
+
     if ( this_cpu(hv_input_page) )
         return 0;
 
@@ -146,6 +149,9 @@ static int setup_hypercall_pcpu_arg(void)
         return -ENOMEM;
     }
 
+    rdmsrl(HV_X64_MSR_VP_INDEX, vp_index_msr);
+    this_cpu(hv_vp_index) = vp_index_msr;
+
     return 0;
 }
 
diff --git a/xen/arch/x86/guest/hyperv/private.h b/xen/arch/x86/guest/hyperv/private.h
index 093985a94b..d1765d4f23 100644
--- a/xen/arch/x86/guest/hyperv/private.h
+++ b/xen/arch/x86/guest/hyperv/private.h
@@ -25,5 +25,6 @@
 #include <xen/percpu.h>
 
 DECLARE_PER_CPU(void *, hv_input_page);
+DECLARE_PER_CPU(unsigned int, hv_vp_index);
 
 #endif /* __XEN_HYPERV_PRIVIATE_H__  */
-- 
2.20.1


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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [Xen-devel] [PATCH v7 10/10] x86/hyperv: setup VP assist page
  2020-02-04 15:36 [Xen-devel] [PATCH v7 00/10] More Hyper-V infrastructures Wei Liu
                   ` (8 preceding siblings ...)
  2020-02-04 15:37 ` [Xen-devel] [PATCH v7 09/10] x86/hyperv: retrieve vp_index from Hyper-V Wei Liu
@ 2020-02-04 15:37 ` Wei Liu
  9 siblings, 0 replies; 23+ messages in thread
From: Wei Liu @ 2020-02-04 15:37 UTC (permalink / raw)
  To: Xen Development List
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Paul Durrant, Michael Kelley,
	Jan Beulich, Roger Pau Monné

VP assist page is rather important as we need to toggle some bits in it
for efficient nested virtualisation.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
Reviewed-by: Paul Durrant <pdurrant@amazon.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
v6:
1. Use hv_vp_assist_page_msr
2. Make code shorter
3. Preserve rsvdP fields

v5:
1. Deal with error properly instead of always panicking
2. Swap percpu variables declarations' location

v4:
1. Use private.h
2. Prevent leak

v3:
1. Use xenheap page
2. Drop set_vp_assist

v2:
1. Use HV_HYP_PAGE_SHIFT instead
---
 xen/arch/x86/guest/hyperv/hyperv.c  | 37 ++++++++++++++++++++++++++++-
 xen/arch/x86/guest/hyperv/private.h |  1 +
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c
index e31c4b30b8..248f854d6e 100644
--- a/xen/arch/x86/guest/hyperv/hyperv.c
+++ b/xen/arch/x86/guest/hyperv/hyperv.c
@@ -31,6 +31,7 @@
 
 struct ms_hyperv_info __read_mostly ms_hyperv;
 DEFINE_PER_CPU_READ_MOSTLY(void *, hv_input_page);
+DEFINE_PER_CPU_READ_MOSTLY(void *, hv_vp_assist);
 DEFINE_PER_CPU_READ_MOSTLY(unsigned int, hv_vp_index);
 
 static uint64_t generate_guest_id(void)
@@ -155,6 +156,31 @@ static int setup_hypercall_pcpu_arg(void)
     return 0;
 }
 
+static int setup_vp_assist(void)
+{
+    union hv_vp_assist_page_msr msr;
+
+    if ( !this_cpu(hv_vp_assist) )
+    {
+        this_cpu(hv_vp_assist) = alloc_xenheap_page();
+        if ( !this_cpu(hv_vp_assist) )
+        {
+            printk("CPU%u: Failed to allocate vp_assist page\n",
+                   smp_processor_id());
+            return -ENOMEM;
+        }
+
+        clear_page(this_cpu(hv_vp_assist));
+    }
+
+    rdmsrl(HV_X64_MSR_VP_ASSIST_PAGE, msr.raw);
+    msr.pfn = virt_to_mfn(this_cpu(hv_vp_assist));
+    msr.enabled = 1;
+    wrmsrl(HV_X64_MSR_VP_ASSIST_PAGE, msr.raw);
+
+    return 0;
+}
+
 static void __init setup(void)
 {
     ASM_CONSTANT(HV_HCALL_PAGE, __fix_x_to_virt(FIX_X_HYPERV_HCALL));
@@ -163,11 +189,20 @@ static void __init setup(void)
 
     if ( setup_hypercall_pcpu_arg() )
         panic("Hyper-V hypercall percpu arg setup failed\n");
+
+    if ( setup_vp_assist() )
+        panic("VP assist page setup failed\n");
 }
 
 static int ap_setup(void)
 {
-    return setup_hypercall_pcpu_arg();
+    int rc;
+
+    rc = setup_hypercall_pcpu_arg();
+    if ( rc )
+        return rc;
+
+    return setup_vp_assist();
 }
 
 static void __init e820_fixup(struct e820map *e820)
diff --git a/xen/arch/x86/guest/hyperv/private.h b/xen/arch/x86/guest/hyperv/private.h
index d1765d4f23..956eff831f 100644
--- a/xen/arch/x86/guest/hyperv/private.h
+++ b/xen/arch/x86/guest/hyperv/private.h
@@ -25,6 +25,7 @@
 #include <xen/percpu.h>
 
 DECLARE_PER_CPU(void *, hv_input_page);
+DECLARE_PER_CPU(void *, hv_vp_assist);
 DECLARE_PER_CPU(unsigned int, hv_vp_index);
 
 #endif /* __XEN_HYPERV_PRIVIATE_H__  */
-- 
2.20.1


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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [Xen-devel] [PATCH v7 01/10] x86/hypervisor: make hypervisor_ap_setup return an error code
  2020-02-04 15:36 ` [Xen-devel] [PATCH v7 01/10] x86/hypervisor: make hypervisor_ap_setup return an error code Wei Liu
@ 2020-02-04 16:48   ` Wei Liu
  2020-02-04 16:56     ` Roger Pau Monné
  2020-02-05 11:12   ` Jan Beulich
  1 sibling, 1 reply; 23+ messages in thread
From: Wei Liu @ 2020-02-04 16:48 UTC (permalink / raw)
  To: Xen Development List
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Paul Durrant, Michael Kelley,
	Jan Beulich, Roger Pau Monné

On Tue, Feb 04, 2020 at 03:36:55PM +0000, Wei Liu wrote:
> We want to be able to handle AP setup error in the upper layer.
> 
> For Xen, remove all panic() and BUG_ON() in init_evtchn and
> map_vcpuinfo. Only panic/BUG_ON when Xen can't fail gracefully.
> 
> Signed-off-by: Wei Liu <liuwe@microsoft.com>
> ---

BTW I discover an issue: init_evtchn sets HVM_PARAM_CALLBACK_IRQ every
time it is called. That's unnecessary for APs. Perhaps it would be best
to break that function into two, one for setting HVM_PARAM_CALLBACK_IRQ,
the other for allocating and setting callback. BSP needs to call both
while APs only needs to call the latter.

This is out of scope for this series, but it is something to consider in
the future.

Wei.

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

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Xen-devel] [PATCH v7 01/10] x86/hypervisor: make hypervisor_ap_setup return an error code
  2020-02-04 16:48   ` Wei Liu
@ 2020-02-04 16:56     ` Roger Pau Monné
  2020-02-04 17:03       ` Wei Liu
  0 siblings, 1 reply; 23+ messages in thread
From: Roger Pau Monné @ 2020-02-04 16:56 UTC (permalink / raw)
  To: Wei Liu
  Cc: Wei Liu, Andrew Cooper, Paul Durrant, Michael Kelley,
	Jan Beulich, Xen Development List

On Tue, Feb 04, 2020 at 04:48:05PM +0000, Wei Liu wrote:
> On Tue, Feb 04, 2020 at 03:36:55PM +0000, Wei Liu wrote:
> > We want to be able to handle AP setup error in the upper layer.
> > 
> > For Xen, remove all panic() and BUG_ON() in init_evtchn and
> > map_vcpuinfo. Only panic/BUG_ON when Xen can't fail gracefully.
> > 
> > Signed-off-by: Wei Liu <liuwe@microsoft.com>
> > ---
> 
> BTW I discover an issue: init_evtchn sets HVM_PARAM_CALLBACK_IRQ every
> time it is called. That's unnecessary for APs. Perhaps it would be best
> to break that function into two, one for setting HVM_PARAM_CALLBACK_IRQ,
> the other for allocating and setting callback. BSP needs to call both
> while APs only needs to call the latter.

We could gate the call to HVMOP_set_param on !smp_processor_id(), that
way the BSP would be the only one to set HVM_PARAM_CALLBACK_IRQ. I'm
not sure splitting this into a separate function is worth it.

Thanks, Roger.

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

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Xen-devel] [PATCH v7 01/10] x86/hypervisor: make hypervisor_ap_setup return an error code
  2020-02-04 16:56     ` Roger Pau Monné
@ 2020-02-04 17:03       ` Wei Liu
  0 siblings, 0 replies; 23+ messages in thread
From: Wei Liu @ 2020-02-04 17:03 UTC (permalink / raw)
  To: Roger Pau Monné
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Paul Durrant, Michael Kelley,
	Jan Beulich, Xen Development List

On Tue, Feb 04, 2020 at 05:56:21PM +0100, Roger Pau Monné wrote:
> On Tue, Feb 04, 2020 at 04:48:05PM +0000, Wei Liu wrote:
> > On Tue, Feb 04, 2020 at 03:36:55PM +0000, Wei Liu wrote:
> > > We want to be able to handle AP setup error in the upper layer.
> > > 
> > > For Xen, remove all panic() and BUG_ON() in init_evtchn and
> > > map_vcpuinfo. Only panic/BUG_ON when Xen can't fail gracefully.
> > > 
> > > Signed-off-by: Wei Liu <liuwe@microsoft.com>
> > > ---
> > 
> > BTW I discover an issue: init_evtchn sets HVM_PARAM_CALLBACK_IRQ every
> > time it is called. That's unnecessary for APs. Perhaps it would be best
> > to break that function into two, one for setting HVM_PARAM_CALLBACK_IRQ,
> > the other for allocating and setting callback. BSP needs to call both
> > while APs only needs to call the latter.
> 
> We could gate the call to HVMOP_set_param on !smp_processor_id(), that
> way the BSP would be the only one to set HVM_PARAM_CALLBACK_IRQ. I'm
> not sure splitting this into a separate function is worth it.

This works too. But again, something for another day.

Wei.

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

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Xen-devel] [PATCH v7 01/10] x86/hypervisor: make hypervisor_ap_setup return an error code
  2020-02-04 15:36 ` [Xen-devel] [PATCH v7 01/10] x86/hypervisor: make hypervisor_ap_setup return an error code Wei Liu
  2020-02-04 16:48   ` Wei Liu
@ 2020-02-05 11:12   ` Jan Beulich
  2020-02-05 12:09     ` Wei Liu
  1 sibling, 1 reply; 23+ messages in thread
From: Jan Beulich @ 2020-02-05 11:12 UTC (permalink / raw)
  To: Wei Liu
  Cc: Wei Liu, Andrew Cooper, Paul Durrant, Michael Kelley,
	Xen Development List, Roger Pau Monné

On 04.02.2020 16:36, Wei Liu wrote:
> @@ -215,18 +220,19 @@ static void init_evtchn(void)
>      rc = xen_hypercall_set_evtchn_upcall_vector(this_cpu(vcpu_id),
>                                                  evtchn_upcall_vector);
>      if ( rc )
> -        panic("Unable to set evtchn upcall vector: %d\n", rc);
> +    {
> +        printk("Unable to set evtchn upcall vector: %d\n", rc);
> +        goto out;

There's no need for "goto" here - "return rc" is all you need
instead. As stated elsewhere, when there's complex cleanup or
a fair risk of leaving out an important cleanup step, I can
live with "goto" getting used. But I don't think it should be
used to replace a simple "return".

With this
Reviewed-by: Jan Beulich <jbeulich@suse.com>
with one more (optional!) suggestion and one more remark:

> @@ -254,14 +260,20 @@ static void __init setup(void)
>                 XEN_LEGACY_MAX_VCPUS);
>      }
>  
> -    init_evtchn();
> +    BUG_ON(init_evtchn());
>  }
>  
> -static void ap_setup(void)
> +static int ap_setup(void)
>  {
> +    int rc;
> +
>      set_vcpu_id();
> -    map_vcpuinfo();
> -    init_evtchn();
> +
> +    rc = map_vcpuinfo();
> +    if ( rc )
> +        return rc;
> +
> +    return init_evtchn();
>  }

To avoid a local variable, how about

    return map_vcpuinfo() ?: init_evtchn();

?

> @@ -283,8 +295,8 @@ int xg_free_unused_page(mfn_t mfn)
>  
>  static void ap_resume(void *unused)
>  {
> -    map_vcpuinfo();
> -    init_evtchn();
> +    BUG_ON(map_vcpuinfo());
> +    BUG_ON(init_evtchn());
>  }

Current code structure calls for this, but in principle I don't
think AP failure on resume should be any different from AP
failure during boot. Nothing to be address here and now, of
course.

Jan

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

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Xen-devel] [PATCH v7 03/10] x86: provide executable fixmap facility
  2020-02-04 15:36 ` [Xen-devel] [PATCH v7 03/10] x86: provide executable fixmap facility Wei Liu
@ 2020-02-05 11:15   ` Jan Beulich
  0 siblings, 0 replies; 23+ messages in thread
From: Jan Beulich @ 2020-02-05 11:15 UTC (permalink / raw)
  To: Wei Liu
  Cc: Wei Liu, Konrad Rzeszutek Wilk, Andrew Cooper, Paul Durrant,
	Michael Kelley, Ross Lagerwall, Xen Development List,
	Roger Pau Monné

On 04.02.2020 16:36, Wei Liu wrote:
> This allows us to set aside some address space for executable mapping.
> This fixed map range starts from XEN_VIRT_END so that it is within reach
> of the .text section.
> 
> Shift the percpu stub range and shrink livepatch range accordingly.
> 
> Signed-off-by: Wei Liu <liuwe@microsoft.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>
with ...

> --- a/xen/include/asm-x86/asm_defns.h
> +++ b/xen/include/asm-x86/asm_defns.h
> @@ -392,4 +392,9 @@ label: .long (val);                         \
>      .size label, . - label;                 \
>      .type label, @object
>  
> +
> +#define ASM_CONSTANT(name, value)                \
> +    asm ( ".equ " #name ", %P0; .global " #name  \
> +          :: "i" ((value)) );
> +
>  #endif /* __X86_ASM_DEFNS_H__ */

... no double blank lines introduced here.

Jan


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

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Xen-devel] [PATCH v7 06/10] x86/hyperv: provide Hyper-V hypercall functions
  2020-02-04 15:37 ` [Xen-devel] [PATCH v7 06/10] x86/hyperv: provide Hyper-V hypercall functions Wei Liu
@ 2020-02-05 11:17   ` Jan Beulich
  0 siblings, 0 replies; 23+ messages in thread
From: Jan Beulich @ 2020-02-05 11:17 UTC (permalink / raw)
  To: Wei Liu
  Cc: Julien Grall, Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Paul Durrant, Ian Jackson,
	Michael Kelley, Xen Development List, Roger Pau Monné

On 04.02.2020 16:37, Wei Liu wrote:
> These functions will be used later to make hypercalls to Hyper-V.
> 
> Signed-off-by: Wei Liu <liuwe@microsoft.com>
> Reviewed-by: Paul Durrant <pdurrant@amazon.com>

Acked-by: Jan Beulich <jbeulich@suse.com>

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

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Xen-devel] [PATCH v7 01/10] x86/hypervisor: make hypervisor_ap_setup return an error code
  2020-02-05 11:12   ` Jan Beulich
@ 2020-02-05 12:09     ` Wei Liu
  2020-02-05 12:42       ` Jan Beulich
  0 siblings, 1 reply; 23+ messages in thread
From: Wei Liu @ 2020-02-05 12:09 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Paul Durrant, Michael Kelley,
	Xen Development List, Roger Pau Monné

On Wed, Feb 05, 2020 at 12:12:30PM +0100, Jan Beulich wrote:
> On 04.02.2020 16:36, Wei Liu wrote:
> > @@ -215,18 +220,19 @@ static void init_evtchn(void)
> >      rc = xen_hypercall_set_evtchn_upcall_vector(this_cpu(vcpu_id),
> >                                                  evtchn_upcall_vector);
> >      if ( rc )
> > -        panic("Unable to set evtchn upcall vector: %d\n", rc);
> > +    {
> > +        printk("Unable to set evtchn upcall vector: %d\n", rc);
> > +        goto out;
> 
> There's no need for "goto" here - "return rc" is all you need
> instead. As stated elsewhere, when there's complex cleanup or
> a fair risk of leaving out an important cleanup step, I can
> live with "goto" getting used. But I don't think it should be
> used to replace a simple "return".

OK. That can be fixed.

> 
> With this
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> with one more (optional!) suggestion and one more remark:

Thanks.

> 
> > @@ -254,14 +260,20 @@ static void __init setup(void)
> >                 XEN_LEGACY_MAX_VCPUS);
> >      }
> >  
> > -    init_evtchn();
> > +    BUG_ON(init_evtchn());
> >  }
> >  
> > -static void ap_setup(void)
> > +static int ap_setup(void)
> >  {
> > +    int rc;
> > +
> >      set_vcpu_id();
> > -    map_vcpuinfo();
> > -    init_evtchn();
> > +
> > +    rc = map_vcpuinfo();
> > +    if ( rc )
> > +        return rc;
> > +
> > +    return init_evtchn();
> >  }
> 
> To avoid a local variable, how about
> 
>     return map_vcpuinfo() ?: init_evtchn();
> 
> ?

ISTR this is a GNU extension, but seeing that there is already quite a
lot of it in hypercisor code, I will make the change.

Wei.

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

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Xen-devel] [PATCH v7 01/10] x86/hypervisor: make hypervisor_ap_setup return an error code
  2020-02-05 12:09     ` Wei Liu
@ 2020-02-05 12:42       ` Jan Beulich
  0 siblings, 0 replies; 23+ messages in thread
From: Jan Beulich @ 2020-02-05 12:42 UTC (permalink / raw)
  To: Wei Liu
  Cc: Wei Liu, Andrew Cooper, Paul Durrant, Michael Kelley,
	Xen Development List, Roger Pau Monné

On 05.02.2020 13:09, Wei Liu wrote:
> On Wed, Feb 05, 2020 at 12:12:30PM +0100, Jan Beulich wrote:
>> On 04.02.2020 16:36, Wei Liu wrote:
>>> @@ -254,14 +260,20 @@ static void __init setup(void)
>>>                 XEN_LEGACY_MAX_VCPUS);
>>>      }
>>>  
>>> -    init_evtchn();
>>> +    BUG_ON(init_evtchn());
>>>  }
>>>  
>>> -static void ap_setup(void)
>>> +static int ap_setup(void)
>>>  {
>>> +    int rc;
>>> +
>>>      set_vcpu_id();
>>> -    map_vcpuinfo();
>>> -    init_evtchn();
>>> +
>>> +    rc = map_vcpuinfo();
>>> +    if ( rc )
>>> +        return rc;
>>> +
>>> +    return init_evtchn();
>>>  }
>>
>> To avoid a local variable, how about
>>
>>     return map_vcpuinfo() ?: init_evtchn();
>>
>> ?
> 
> ISTR this is a GNU extension, but seeing that there is already quite a
> lot of it in hypercisor code, I will make the change.

In our own code using extensions is generally fine (as far as
they're sufficiently backwards compatible). It's the public
headers where we want to be more careful.

Jan

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

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Xen-devel] [PATCH v7 05/10] x86/hyperv: setup hypercall page
  2020-02-04 15:36 ` [Xen-devel] [PATCH v7 05/10] x86/hyperv: setup hypercall page Wei Liu
@ 2020-02-05 14:04   ` Roger Pau Monné
  2020-02-05 15:00     ` Wei Liu
  2020-02-05 15:52   ` Durrant, Paul
  1 sibling, 1 reply; 23+ messages in thread
From: Roger Pau Monné @ 2020-02-05 14:04 UTC (permalink / raw)
  To: Wei Liu
  Cc: Wei Liu, Andrew Cooper, Paul Durrant, Michael Kelley,
	Jan Beulich, Xen Development List

On Tue, Feb 04, 2020 at 03:36:59PM +0000, Wei Liu wrote:
> Hyper-V uses a technique called overlay page for its hypercall page. It
> will insert a backing page to the guest when the hypercall functionality
> is enabled. That means we can use a page that is not backed by real
> memory for hypercall page.
> 
> To avoid shattering L0 superpages and treading on any MMIO areas
> residing in low addresses, use the top-most addressable page for that
> purpose. Adjust e820 map accordingly.
> 
> We also need to register Xen's guest OS ID to Hyper-V. Use 0x3 as the
> vendor ID. Fix the comment in hyperv-tlfs.h while at it.
> 
> Signed-off-by: Wei Liu <liuwe@microsoft.com>

Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

> ---
> v7:
> 1. Fix a style issue
> 2. Initialise ID to 0
> 3. Update commit message
> 
> v6:
> 1. Use hv_guest_os_id
> 2. Use new e820_fixup hook
> 3. Add a BUILD_BUG_ON
> 
> v5:
> 1. use hypervisor_reserve_top_pages
> 2. add a macro for hypercall page mfn
> 3. address other misc comments
> 
> v4:
> 1. Use fixmap
> 2. Follow routines listed in TLFS
> ---
>  xen/arch/x86/guest/hyperv/hyperv.c      | 69 +++++++++++++++++++++++--
>  xen/include/asm-x86/guest/hyperv-tlfs.h |  5 +-
>  xen/include/asm-x86/guest/hyperv.h      |  3 ++
>  3 files changed, 72 insertions(+), 5 deletions(-)
> 
> diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c
> index 8d38313d7a..2e20a96f30 100644
> --- a/xen/arch/x86/guest/hyperv/hyperv.c
> +++ b/xen/arch/x86/guest/hyperv/hyperv.c
> @@ -19,15 +19,27 @@
>   * Copyright (c) 2019 Microsoft.
>   */
>  #include <xen/init.h>
> +#include <xen/version.h>
>  
> +#include <asm/fixmap.h>
>  #include <asm/guest.h>
>  #include <asm/guest/hyperv-tlfs.h>
> +#include <asm/processor.h>
>  
>  struct ms_hyperv_info __read_mostly ms_hyperv;
>  
> -static const struct hypervisor_ops ops = {
> -    .name = "Hyper-V",
> -};
> +static uint64_t generate_guest_id(void)
> +{
> +    union hv_guest_os_id id = {};
> +
> +    id.vendor = HV_XEN_VENDOR_ID;
> +    id.major = xen_major_version();
> +    id.minor = xen_minor_version();
> +
> +    return id.raw;
> +}
> +
> +static const struct hypervisor_ops ops;
>  
>  const struct hypervisor_ops *__init hyperv_probe(void)
>  {
> @@ -72,6 +84,57 @@ 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;
> +    union hv_guest_os_id guest_id;
> +    unsigned long mfn;
> +
> +    BUILD_BUG_ON(HV_HYP_PAGE_SHIFT != PAGE_SHIFT);
> +
> +    rdmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id.raw);
> +    if ( !guest_id.raw )
> +    {
> +        guest_id.raw = generate_guest_id();
> +        wrmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id.raw);
> +    }
> +
> +    rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> +    if ( !hypercall_msr.enable )
> +    {
> +        mfn = HV_HCALL_MFN;
> +        hypercall_msr.enable = 1;
> +        hypercall_msr.guest_physical_address = mfn;
> +        wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> +    }
> +    else
> +        mfn = hypercall_msr.guest_physical_address;

Is it expected that the guest ID or the hypercal page is already
setup?

Ie: would virtual firmware setup any of this? (and not clean it up
afterwards)

Thanks, Roger.

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

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Xen-devel] [PATCH v7 05/10] x86/hyperv: setup hypercall page
  2020-02-05 14:04   ` Roger Pau Monné
@ 2020-02-05 15:00     ` Wei Liu
  2020-02-05 15:03       ` Wei Liu
  0 siblings, 1 reply; 23+ messages in thread
From: Wei Liu @ 2020-02-05 15:00 UTC (permalink / raw)
  To: Roger Pau Monné
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Paul Durrant, Michael Kelley,
	Jan Beulich, Xen Development List

On Wed, Feb 05, 2020 at 03:04:16PM +0100, Roger Pau Monné wrote:
[...]
> > +static void __init setup_hypercall_page(void)
> > +{
> > +    union hv_x64_msr_hypercall_contents hypercall_msr;
> > +    union hv_guest_os_id guest_id;
> > +    unsigned long mfn;
> > +
> > +    BUILD_BUG_ON(HV_HYP_PAGE_SHIFT != PAGE_SHIFT);
> > +
> > +    rdmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id.raw);
> > +    if ( !guest_id.raw )
> > +    {
> > +        guest_id.raw = generate_guest_id();
> > +        wrmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id.raw);
> > +    }
> > +
> > +    rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> > +    if ( !hypercall_msr.enable )
> > +    {
> > +        mfn = HV_HCALL_MFN;
> > +        hypercall_msr.enable = 1;
> > +        hypercall_msr.guest_physical_address = mfn;
> > +        wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> > +    }
> > +    else
> > +        mfn = hypercall_msr.guest_physical_address;
> 
> Is it expected that the guest ID or the hypercal page is already
> setup?
> 
> Ie: would virtual firmware setup any of this? (and not clean it up
> afterwards)

There is no definitive answer to why/when this happens in TLFS, but it
does require guest to respect that is already in the MSR.

Wei.

> 
> Thanks, Roger.

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

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Xen-devel] [PATCH v7 05/10] x86/hyperv: setup hypercall page
  2020-02-05 15:00     ` Wei Liu
@ 2020-02-05 15:03       ` Wei Liu
  0 siblings, 0 replies; 23+ messages in thread
From: Wei Liu @ 2020-02-05 15:03 UTC (permalink / raw)
  To: Roger Pau Monné
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Paul Durrant, Michael Kelley,
	Jan Beulich, Xen Development List

On Wed, Feb 05, 2020 at 03:00:24PM +0000, Wei Liu wrote:
> On Wed, Feb 05, 2020 at 03:04:16PM +0100, Roger Pau Monné wrote:
> [...]
> > > +static void __init setup_hypercall_page(void)
> > > +{
> > > +    union hv_x64_msr_hypercall_contents hypercall_msr;
> > > +    union hv_guest_os_id guest_id;
> > > +    unsigned long mfn;
> > > +
> > > +    BUILD_BUG_ON(HV_HYP_PAGE_SHIFT != PAGE_SHIFT);
> > > +
> > > +    rdmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id.raw);
> > > +    if ( !guest_id.raw )
> > > +    {
> > > +        guest_id.raw = generate_guest_id();
> > > +        wrmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id.raw);
> > > +    }
> > > +
> > > +    rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> > > +    if ( !hypercall_msr.enable )
> > > +    {
> > > +        mfn = HV_HCALL_MFN;
> > > +        hypercall_msr.enable = 1;
> > > +        hypercall_msr.guest_physical_address = mfn;
> > > +        wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> > > +    }
> > > +    else
> > > +        mfn = hypercall_msr.guest_physical_address;
> > 
> > Is it expected that the guest ID or the hypercal page is already
> > setup?
> > 
> > Ie: would virtual firmware setup any of this? (and not clean it up
> > afterwards)
> 
> There is no definitive answer to why/when this happens in TLFS, but it
> does require guest to respect that is already in the MSR.

My guess would be after migration Hyper-V sets up the same MSR/page
FWIW.

Wei.

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

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Xen-devel] [PATCH v7 05/10] x86/hyperv: setup hypercall page
  2020-02-04 15:36 ` [Xen-devel] [PATCH v7 05/10] x86/hyperv: setup hypercall page Wei Liu
  2020-02-05 14:04   ` Roger Pau Monné
@ 2020-02-05 15:52   ` Durrant, Paul
  1 sibling, 0 replies; 23+ messages in thread
From: Durrant, Paul @ 2020-02-05 15:52 UTC (permalink / raw)
  To: Wei Liu, Xen Development List
  Cc: Andrew Cooper, Roger Pau Monné,
	Wei Liu, Jan Beulich, Michael Kelley

> -----Original Message-----
> From: Wei Liu <wei.liu.xen@gmail.com> On Behalf Of Wei Liu
> Sent: 04 February 2020 15:37
> To: Xen Development List <xen-devel@lists.xenproject.org>
> Cc: Durrant, Paul <pdurrant@amazon.co.uk>; Michael Kelley
> <mikelley@microsoft.com>; Wei Liu <liuwe@microsoft.com>; Wei Liu
> <wl@xen.org>; Jan Beulich <jbeulich@suse.com>; Andrew Cooper
> <andrew.cooper3@citrix.com>; Roger Pau Monné <roger.pau@citrix.com>
> Subject: [PATCH v7 05/10] x86/hyperv: setup hypercall page
> 
> Hyper-V uses a technique called overlay page for its hypercall page. It
> will insert a backing page to the guest when the hypercall functionality
> is enabled. That means we can use a page that is not backed by real
> memory for hypercall page.
> 
> To avoid shattering L0 superpages and treading on any MMIO areas
> residing in low addresses, use the top-most addressable page for that
> purpose. Adjust e820 map accordingly.
> 
> We also need to register Xen's guest OS ID to Hyper-V. Use 0x3 as the
> vendor ID. Fix the comment in hyperv-tlfs.h while at it.
> 
> Signed-off-by: Wei Liu <liuwe@microsoft.com>

Acked-by: Paul Durrant <pdurrant@amazon.com>

> ---
> v7:
> 1. Fix a style issue
> 2. Initialise ID to 0
> 3. Update commit message
> 
> v6:
> 1. Use hv_guest_os_id
> 2. Use new e820_fixup hook
> 3. Add a BUILD_BUG_ON
> 
> v5:
> 1. use hypervisor_reserve_top_pages
> 2. add a macro for hypercall page mfn
> 3. address other misc comments
> 
> v4:
> 1. Use fixmap
> 2. Follow routines listed in TLFS
> ---
>  xen/arch/x86/guest/hyperv/hyperv.c      | 69 +++++++++++++++++++++++--
>  xen/include/asm-x86/guest/hyperv-tlfs.h |  5 +-
>  xen/include/asm-x86/guest/hyperv.h      |  3 ++
>  3 files changed, 72 insertions(+), 5 deletions(-)
> 
> diff --git a/xen/arch/x86/guest/hyperv/hyperv.c
> b/xen/arch/x86/guest/hyperv/hyperv.c
> index 8d38313d7a..2e20a96f30 100644
> --- a/xen/arch/x86/guest/hyperv/hyperv.c
> +++ b/xen/arch/x86/guest/hyperv/hyperv.c
> @@ -19,15 +19,27 @@
>   * Copyright (c) 2019 Microsoft.
>   */
>  #include <xen/init.h>
> +#include <xen/version.h>
> 
> +#include <asm/fixmap.h>
>  #include <asm/guest.h>
>  #include <asm/guest/hyperv-tlfs.h>
> +#include <asm/processor.h>
> 
>  struct ms_hyperv_info __read_mostly ms_hyperv;
> 
> -static const struct hypervisor_ops ops = {
> -    .name = "Hyper-V",
> -};
> +static uint64_t generate_guest_id(void)
> +{
> +    union hv_guest_os_id id = {};
> +
> +    id.vendor = HV_XEN_VENDOR_ID;
> +    id.major = xen_major_version();
> +    id.minor = xen_minor_version();
> +
> +    return id.raw;
> +}
> +
> +static const struct hypervisor_ops ops;
> 
>  const struct hypervisor_ops *__init hyperv_probe(void)
>  {
> @@ -72,6 +84,57 @@ 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;
> +    union hv_guest_os_id guest_id;
> +    unsigned long mfn;
> +
> +    BUILD_BUG_ON(HV_HYP_PAGE_SHIFT != PAGE_SHIFT);
> +
> +    rdmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id.raw);
> +    if ( !guest_id.raw )
> +    {
> +        guest_id.raw = generate_guest_id();
> +        wrmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id.raw);
> +    }
> +
> +    rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> +    if ( !hypercall_msr.enable )
> +    {
> +        mfn = HV_HCALL_MFN;
> +        hypercall_msr.enable = 1;
> +        hypercall_msr.guest_physical_address = mfn;
> +        wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> +    }
> +    else
> +        mfn = hypercall_msr.guest_physical_address;
> +
> +    rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> +    BUG_ON(!hypercall_msr.enable);
> +
> +    set_fixmap_x(FIX_X_HYPERV_HCALL, mfn << PAGE_SHIFT);
> +}
> +
> +static void __init setup(void)
> +{
> +    setup_hypercall_page();
> +}
> +
> +static void __init e820_fixup(struct e820map *e820)
> +{
> +    uint64_t s = HV_HCALL_MFN << PAGE_SHIFT;
> +
> +    if ( !e820_add_range(e820, s, s + PAGE_SIZE, E820_RESERVED) )
> +        panic("Unable to reserve Hyper-V hypercall range\n");
> +}
> +
> +static const struct hypervisor_ops ops = {
> +    .name = "Hyper-V",
> +    .setup = setup,
> +    .e820_fixup = e820_fixup,
> +};
> +
>  /*
>   * Local variables:
>   * mode: C
> diff --git a/xen/include/asm-x86/guest/hyperv-tlfs.h b/xen/include/asm-
> x86/guest/hyperv-tlfs.h
> index 091e25cdd1..0a0f3398c1 100644
> --- a/xen/include/asm-x86/guest/hyperv-tlfs.h
> +++ b/xen/include/asm-x86/guest/hyperv-tlfs.h
> @@ -318,15 +318,16 @@ struct ms_hyperv_tsc_page {
>   *
>   * Bit(s)
>   * 63 - Indicates if the OS is Open Source or not; 1 is Open Source
> - * 62:56 - Os Type; Linux is 0x100
> + * 62:56 - Os Type; Linux 0x1, FreeBSD 0x2, Xen 0x3
>   * 55:48 - Distro specific identification
> - * 47:16 - Linux kernel version number
> + * 47:16 - Guest OS version number
>   * 15:0  - Distro specific identification
>   *
>   *
>   */
> 
>  #define HV_LINUX_VENDOR_ID              0x8100
> +#define HV_XEN_VENDOR_ID                0x8300
>  union hv_guest_os_id
>  {
>      uint64_t raw;
> diff --git a/xen/include/asm-x86/guest/hyperv.h b/xen/include/asm-
> x86/guest/hyperv.h
> index c7a7f32bd5..1a1b47831c 100644
> --- a/xen/include/asm-x86/guest/hyperv.h
> +++ b/xen/include/asm-x86/guest/hyperv.h
> @@ -21,6 +21,9 @@
> 
>  #include <xen/types.h>
> 
> +/* Use top-most MFN for hypercall page */
> +#define HV_HCALL_MFN   (((1ull << paddr_bits) - 1) >> HV_HYP_PAGE_SHIFT)
> +
>  /*
>   * The specification says: "The partition reference time is computed
>   * by the following formula:
> --
> 2.20.1


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

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2020-02-05 15:53 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-04 15:36 [Xen-devel] [PATCH v7 00/10] More Hyper-V infrastructures Wei Liu
2020-02-04 15:36 ` [Xen-devel] [PATCH v7 01/10] x86/hypervisor: make hypervisor_ap_setup return an error code Wei Liu
2020-02-04 16:48   ` Wei Liu
2020-02-04 16:56     ` Roger Pau Monné
2020-02-04 17:03       ` Wei Liu
2020-02-05 11:12   ` Jan Beulich
2020-02-05 12:09     ` Wei Liu
2020-02-05 12:42       ` Jan Beulich
2020-02-04 15:36 ` [Xen-devel] [PATCH v7 02/10] x86/smp: don't online cpu if hypervisor_ap_setup fails Wei Liu
2020-02-04 15:36 ` [Xen-devel] [PATCH v7 03/10] x86: provide executable fixmap facility Wei Liu
2020-02-05 11:15   ` Jan Beulich
2020-02-04 15:36 ` [Xen-devel] [PATCH v7 04/10] x86/hypervisor: provide hypervisor_fixup_e820 Wei Liu
2020-02-04 15:36 ` [Xen-devel] [PATCH v7 05/10] x86/hyperv: setup hypercall page Wei Liu
2020-02-05 14:04   ` Roger Pau Monné
2020-02-05 15:00     ` Wei Liu
2020-02-05 15:03       ` Wei Liu
2020-02-05 15:52   ` Durrant, Paul
2020-02-04 15:37 ` [Xen-devel] [PATCH v7 06/10] x86/hyperv: provide Hyper-V hypercall functions Wei Liu
2020-02-05 11:17   ` Jan Beulich
2020-02-04 15:37 ` [Xen-devel] [PATCH v7 07/10] DO NOT APPLY: x86/hyperv: issue an hypercall Wei Liu
2020-02-04 15:37 ` [Xen-devel] [PATCH v7 08/10] x86/hyperv: provide percpu hypercall input page Wei Liu
2020-02-04 15:37 ` [Xen-devel] [PATCH v7 09/10] x86/hyperv: retrieve vp_index from Hyper-V Wei Liu
2020-02-04 15:37 ` [Xen-devel] [PATCH v7 10/10] x86/hyperv: setup VP assist page Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.