Skip to contentSkip to conversation

x86/hyperv: use dynamically allocated page for hypercalls

PATCH Superseded Ariadne Conill 5 participants 10 messages Apr 25, 2025 – Apr 29, 2025

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86/hyperv: use dynamically allocated page for hypercalls

Previously Xen placed the hypercall page at the highest possible MFN, but this caused problems on systems where there is more than 36 bits of physical address space.

In general, it also seems unreliable to assume that the highest possible MFN is not already reserved for some other purpose.

Changes from v1:
- Continue to use fixmap infrastructure
- Use panic in Hyper-V setup() function instead of returning -ENOMEM on hypercall page allocation failure

Fixes 620fc734f854 ("x86/hyperv: setup hypercall page")
Cc Alejandro Vallejo <[email protected]>
Cc Alexander M. Merritt <[email protected]>
---
 xen/arch/x86/guest/hyperv/hyperv.c      | 17 +++++++----------
 xen/arch/x86/include/asm/guest/hyperv.h |  3 ---
 2 files changed, 7 insertions(+), 13 deletions(-)
xen/arch/x86/guest/hyperv/hyperv.c +7 -10
index 6989af38f1..0305374a06 100644
@@ -98,7 +98,13 @@ static void __init setup_hypercall_page(void)
     rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
     if ( !hypercall_msr.enable )
     {
-        mfn = HV_HCALL_MFN;
+        void *hcall_page = alloc_xenheap_page();
+        if ( !hcall_page )
+            panic("Hyper-V: Failed to allocate hypercall trampoline page");
+
+        printk("Hyper-V: Allocated hypercall page @ %p.\n", hcall_page);
+
+        mfn = virt_to_mfn(hcall_page);
         hypercall_msr.enable = 1;
         hypercall_msr.guest_physical_address = mfn;
         wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
@@ -187,14 +193,6 @@ static int cf_check ap_setup(void)
     return setup_vp_assist();
 }
 
-static void __init cf_check e820_fixup(void)
-{
-    uint64_t s = HV_HCALL_MFN << PAGE_SHIFT;
-
-    if ( !e820_add_range(s, s + PAGE_SIZE, E820_RESERVED) )
-        panic("Unable to reserve Hyper-V hypercall range\n");
-}
-
 static int cf_check flush_tlb(
     const cpumask_t *mask, const void *va, unsigned int flags)
 {
@@ -211,7 +209,6 @@ static const struct hypervisor_ops __initconst_cf_clobber ops = {
     .name = "Hyper-V",
     .setup = setup,
     .ap_setup = ap_setup,
-    .e820_fixup = e820_fixup,
     .flush_tlb = flush_tlb,
 };
 
xen/arch/x86/include/asm/guest/hyperv.h +0 -3
index c05efdce71..5792e77104 100644
@@ -10,9 +10,6 @@
 
 #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:
Signature · 1 line
2.39.5 (Apple Git-154)
#1 lore raw
Quoted 11 lines · Ariadne Conill

Previously Xen placed the hypercall page at the highest possible MFN, but this caused problems on systems where there is more than 36 bits of physical address space.

In general, it also seems unreliable to assume that the highest possible MFN is not already reserved for some other purpose.

Changes from v1:
- Continue to use fixmap infrastructure
- Use panic in Hyper-V setup() function instead of returning -ENOMEM on hypercall page allocation failure

Nit: This part wants to go ...

Quoted 5 lines
Fixes 620fc734f854 ("x86/hyperv: setup hypercall page")
Cc Alejandro Vallejo <[email protected]>
Cc Alexander M. Merritt <[email protected]>

---

... somewhere below such a separator.

xen/arch/x86/guest/hyperv/hyperv.c static void __init setup_hypercall_page(void) · line 102

Quoted 9 lines
xen/arch/x86/guest/hyperv/hyperv.c +2 -1
@@ -98,7 +98,13 @@ static void __init setup_hypercall_page(void)
     rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
     if ( !hypercall_msr.enable )
     {
-        mfn = HV_HCALL_MFN;
+        void *hcall_page = alloc_xenheap_page();
+        if ( !hcall_page )

Nit (style): Blank line please between declaration(s) and statement(s). (Both can probably be taken care of upon committing if no other need for a v3 arises.)

Jan

#2 lore raw
In reply to Ariadne Conill
Quoted 26 lines · Ariadne Conill

Previously Xen placed the hypercall page at the highest possible MFN, but this caused problems on systems where there is more than 36 bits of physical address space.

In general, it also seems unreliable to assume that the highest possible MFN is not already reserved for some other purpose.

Changes from v1:
- Continue to use fixmap infrastructure
- Use panic in Hyper-V setup() function instead of returning -ENOMEM on hypercall page allocation failure

Fixes 620fc734f854 ("x86/hyperv: setup hypercall page")
Cc Alejandro Vallejo <[email protected]>
Cc Alexander M. Merritt <[email protected]>
---
 xen/arch/x86/guest/hyperv/hyperv.c      | 17 +++++++----------
 xen/arch/x86/include/asm/guest/hyperv.h |  3 ---
 2 files changed, 7 insertions(+), 13 deletions(-)
xen/arch/x86/guest/hyperv/hyperv.c +0 -0
index 6989af38f1..0305374a06 100644

xen/arch/x86/guest/hyperv/hyperv.c static void __init setup_hypercall_page(void) · line 105

Quoted 9 lines
xen/arch/x86/guest/hyperv/hyperv.c +5 -1
@@ -98,7 +98,13 @@ static void __init setup_hypercall_page(void)
     rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
     if ( !hypercall_msr.enable )
     {
-        mfn = HV_HCALL_MFN;
+        void *hcall_page = alloc_xenheap_page();
+        if ( !hcall_page )
+            panic("Hyper-V: Failed to allocate hypercall trampoline page");
+
+        printk("Hyper-V: Allocated hypercall page @ %p.\n", hcall_page);

This likely wants to be a dprintk, and possibly also print the physical address of the used page? And no period at the end of the sentence IMO.

I think Xen might have used the last page in the physical address range to prevent HyperV from possibly shattering a superpage in the second stage translation page-tables if normal RAM was used?

However I don't know whether HyperV will shatter super-pages if a sub-page of it is used to contain the hypercall page (I don't think it should?)

Thanks, Roger.

#3 lore raw
Quoted 41 lines · Roger Pau Monné
Quoted 26 lines · Ariadne Conill

Previously Xen placed the hypercall page at the highest possible MFN, but this caused problems on systems where there is more than 36 bits of physical address space.

In general, it also seems unreliable to assume that the highest possible MFN is not already reserved for some other purpose.

Changes from v1:
- Continue to use fixmap infrastructure
- Use panic in Hyper-V setup() function instead of returning -ENOMEM on hypercall page allocation failure

Fixes 620fc734f854 ("x86/hyperv: setup hypercall page")
Cc Alejandro Vallejo <[email protected]>
Cc Alexander M. Merritt <[email protected]>
---
 xen/arch/x86/guest/hyperv/hyperv.c      | 17 +++++++----------
 xen/arch/x86/include/asm/guest/hyperv.h |  3 ---
 2 files changed, 7 insertions(+), 13 deletions(-)
xen/arch/x86/guest/hyperv/hyperv.c +0 -0
index 6989af38f1..0305374a06 100644

xen/arch/x86/guest/hyperv/hyperv.c static void __init setup_hypercall_page(void) · line 105

Quoted 9 lines
xen/arch/x86/guest/hyperv/hyperv.c +5 -1
@@ -98,7 +98,13 @@ static void __init setup_hypercall_page(void)
     rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
     if ( !hypercall_msr.enable )
     {
-        mfn = HV_HCALL_MFN;
+        void *hcall_page = alloc_xenheap_page();
+        if ( !hcall_page )
+            panic("Hyper-V: Failed to allocate hypercall trampoline page");
+
+        printk("Hyper-V: Allocated hypercall page @ %p.\n", hcall_page);

This likely wants to be a dprintk, and possibly also print the physical address of the used page? And no period at the end of the sentence IMO.

Quoted 7 lines

I think Xen might have used the last page in the physical address range to prevent HyperV from possibly shattering a superpage in the second stage translation page-tables if normal RAM was used?

However I don't know whether HyperV will shatter super-pages if a sub-page of it is used to contain the hypercall page (I don't think it should?)

I think it's quite unlikely. Seeing how Linux simply vmalloc()s and Microsoft seems to genuinely care about Linux in this day and age. It seems fair to assume Hyper-V might just copy the old memory out and rewrite it with the trampoline contents when enabling the MSR, thereby keeping superpages together in their p2m.

Quoted 2 lines

Thanks, Roger.

Cheers,
Alejandro

#4 lore raw
Quoted 41 lines · Alejandro Vallejo
Quoted 40 lines · Roger Pau Monné
Quoted 26 lines · Ariadne Conill

Previously Xen placed the hypercall page at the highest possible MFN, but this caused problems on systems where there is more than 36 bits of physical address space.

In general, it also seems unreliable to assume that the highest possible MFN is not already reserved for some other purpose.

Changes from v1:
- Continue to use fixmap infrastructure
- Use panic in Hyper-V setup() function instead of returning -ENOMEM on hypercall page allocation failure

Fixes 620fc734f854 ("x86/hyperv: setup hypercall page")
Cc Alejandro Vallejo <[email protected]>
Cc Alexander M. Merritt <[email protected]>
---
 xen/arch/x86/guest/hyperv/hyperv.c      | 17 +++++++----------
 xen/arch/x86/include/asm/guest/hyperv.h |  3 ---
 2 files changed, 7 insertions(+), 13 deletions(-)
xen/arch/x86/guest/hyperv/hyperv.c +0 -0
index 6989af38f1..0305374a06 100644

xen/arch/x86/guest/hyperv/hyperv.c static void __init setup_hypercall_page(void) · line 105

Quoted 9 lines
xen/arch/x86/guest/hyperv/hyperv.c +5 -1
@@ -98,7 +98,13 @@ static void __init setup_hypercall_page(void)
     rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
     if ( !hypercall_msr.enable )
     {
-        mfn = HV_HCALL_MFN;
+        void *hcall_page = alloc_xenheap_page();
+        if ( !hcall_page )
+            panic("Hyper-V: Failed to allocate hypercall trampoline page");
+
+        printk("Hyper-V: Allocated hypercall page @ %p.\n", hcall_page);

This likely wants to be a dprintk, and possibly also print the physical address of the used page? And no period at the end of the sentence IMO.

Quoted 8 lines
Quoted 7 lines

I think Xen might have used the last page in the physical address range to prevent HyperV from possibly shattering a superpage in the second stage translation page-tables if normal RAM was used?

However I don't know whether HyperV will shatter super-pages if a sub-page of it is used to contain the hypercall page (I don't think it should?)

I think it's quite unlikely.

It will shatter superpages.

The overlay is not part of guest memory, and will hide whatever is behind it while it is mapped, which will force a 4k PTE in EPT/NPT.

Thinking about it, a better position would be adjacent to the APIC MMIO window, so at 0xfee01000.  The APIC MMIO window is forced to be a 4k mapping too, and the rest of the 2M window is normally empty.

~Andrew

#5 lore raw
Quoted 49 lines · Andrew Cooper
Quoted 48 lines · Alejandro Vallejo
Quoted 47 lines · Roger Pau Monné
Quoted 26 lines · Ariadne Conill

Previously Xen placed the hypercall page at the highest possible MFN, but this caused problems on systems where there is more than 36 bits of physical address space.

In general, it also seems unreliable to assume that the highest possible MFN is not already reserved for some other purpose.

Changes from v1:
- Continue to use fixmap infrastructure
- Use panic in Hyper-V setup() function instead of returning -ENOMEM on hypercall page allocation failure

Fixes 620fc734f854 ("x86/hyperv: setup hypercall page")
Cc Alejandro Vallejo <[email protected]>
Cc Alexander M. Merritt <[email protected]>
---
 xen/arch/x86/guest/hyperv/hyperv.c      | 17 +++++++----------
 xen/arch/x86/include/asm/guest/hyperv.h |  3 ---
 2 files changed, 7 insertions(+), 13 deletions(-)
xen/arch/x86/guest/hyperv/hyperv.c +0 -0
index 6989af38f1..0305374a06 100644

xen/arch/x86/guest/hyperv/hyperv.c static void __init setup_hypercall_page(void) · line 105

Quoted 9 lines
xen/arch/x86/guest/hyperv/hyperv.c +5 -1
@@ -98,7 +98,13 @@ static void __init setup_hypercall_page(void)
     rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
     if ( !hypercall_msr.enable )
     {
-        mfn = HV_HCALL_MFN;
+        void *hcall_page = alloc_xenheap_page();
+        if ( !hcall_page )
+            panic("Hyper-V: Failed to allocate hypercall trampoline page");
+
+        printk("Hyper-V: Allocated hypercall page @ %p.\n", hcall_page);

This likely wants to be a dprintk, and possibly also print the physical address of the used page? And no period at the end of the sentence IMO.

I think Xen might have used the last page in the physical address range to prevent HyperV from possibly shattering a superpage in the second stage translation page-tables if normal RAM was used?

However I don't know whether HyperV will shatter super-pages if a sub-page of it is used to contain the hypercall page (I don't think it should?)

Quoted 6 lines
Quoted 1 line

I think it's quite unlikely.

It will shatter superpages.

The overlay is not part of guest memory, and will hide whatever is behind it while it is mapped, which will force a 4k PTE in EPT/NPT.

That's an implementation detail. They can very well copy the trampoline to guest memory when there is such (and save the previous contents elsewhere) and restore them when disabling the trampoline. It's a trivial optimisation that would prevent shattering while being fully compliant with the TLFS.

The actual physical location of the trampoline is fully undefined. It is defined to be an overlay; but that's a specification, not an implementation.

Quoted 5 lines

Thinking about it, a better position would be adjacent to the APIC MMIO window, so at 0xfee01000.  The APIC MMIO window is forced to be a 4k mapping too, and the rest of the 2M window is normally empty.

Sounds like an assumption waiting to be broken. Just like the last page of guest-physical was.

Cheers,
Alejandro

#6 lore raw
Quoted 54 lines · Alejandro Vallejo
Quoted 53 lines · Andrew Cooper
Quoted 41 lines · Alejandro Vallejo
Quoted 40 lines · Roger Pau Monné
Quoted 26 lines · Ariadne Conill

Previously Xen placed the hypercall page at the highest possible MFN, but this caused problems on systems where there is more than 36 bits of physical address space.

In general, it also seems unreliable to assume that the highest possible MFN is not already reserved for some other purpose.

Changes from v1:
- Continue to use fixmap infrastructure
- Use panic in Hyper-V setup() function instead of returning -ENOMEM on hypercall page allocation failure

Fixes 620fc734f854 ("x86/hyperv: setup hypercall page")
Cc Alejandro Vallejo <[email protected]>
Cc Alexander M. Merritt <[email protected]>
---
 xen/arch/x86/guest/hyperv/hyperv.c      | 17 +++++++----------
 xen/arch/x86/include/asm/guest/hyperv.h |  3 ---
 2 files changed, 7 insertions(+), 13 deletions(-)
xen/arch/x86/guest/hyperv/hyperv.c +0 -0
index 6989af38f1..0305374a06 100644

xen/arch/x86/guest/hyperv/hyperv.c static void __init setup_hypercall_page(void) · line 105

Quoted 9 lines
xen/arch/x86/guest/hyperv/hyperv.c +5 -1
@@ -98,7 +98,13 @@ static void __init setup_hypercall_page(void)
     rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
     if ( !hypercall_msr.enable )
     {
-        mfn = HV_HCALL_MFN;
+        void *hcall_page = alloc_xenheap_page();
+        if ( !hcall_page )
+            panic("Hyper-V: Failed to allocate hypercall trampoline page");
+
+        printk("Hyper-V: Allocated hypercall page @ %p.\n", hcall_page);

This likely wants to be a dprintk, and possibly also print the physical address of the used page? And no period at the end of the sentence IMO.

Quoted 8 lines
Quoted 7 lines

I think Xen might have used the last page in the physical address range to prevent HyperV from possibly shattering a superpage in the second stage translation page-tables if normal RAM was used?

However I don't know whether HyperV will shatter super-pages if a sub-page of it is used to contain the hypercall page (I don't think it should?)

I think it's quite unlikely.

It will shatter superpages.

Quoted 8 lines
Quoted 2 lines

The overlay is not part of guest memory, and will hide whatever is behind it while it is mapped, which will force a 4k PTE in EPT/NPT.

That's an implementation detail. They can very well copy the trampoline to guest memory when there is such (and save the previous contents elsewhere) and restore them when disabling the trampoline. It's a trivial optimisation that would prevent shattering while being fully compliant with the TLFS.

It's an implementation detail relevant from a guest perspective, as it impacts guest performance. IOW: we care about the specific (current) implementation, as it's meaningful to how the guest-side should be implemented.

Quoted 5 lines

The actual physical location of the trampoline is fully undefined. It is defined to be an overlay; but that's a specification, not an implementation.

Quoted 1 line
Quoted 7 lines
Quoted 4 lines

Thinking about it, a better position would be adjacent to the APIC MMIO window, so at 0xfee01000.  The APIC MMIO window is forced to be a 4k mapping too, and the rest of the 2M window is normally empty.

Sounds like an assumption waiting to be broken. Just like the last page of guest-physical was.

As a compromise - could we try to allocate from < 4GB first, and resort to high memory if that doesn't work? That would at least limit shattering (if done) to the low 4GB, which is quite likely fragmented already:

hcall_page = alloc_xenheap_pages(0, MEMF_bits(32)); if ( !hcall_page )

    hcall_page = alloc_xenheap_page();
if ( !hcall_page )
    panic(...);

That will need a comment to describe what's going on.

Thanks, Roger.

#7 lore raw
Quoted 64 lines · Roger Pau Monné
Quoted 54 lines · Alejandro Vallejo
Quoted 53 lines · Andrew Cooper
Quoted 41 lines · Alejandro Vallejo
Quoted 40 lines · Roger Pau Monné
Quoted 26 lines · Ariadne Conill

Previously Xen placed the hypercall page at the highest possible MFN, but this caused problems on systems where there is more than 36 bits of physical address space.

In general, it also seems unreliable to assume that the highest possible MFN is not already reserved for some other purpose.

Changes from v1:
- Continue to use fixmap infrastructure
- Use panic in Hyper-V setup() function instead of returning -ENOMEM on hypercall page allocation failure

Fixes 620fc734f854 ("x86/hyperv: setup hypercall page")
Cc Alejandro Vallejo <[email protected]>
Cc Alexander M. Merritt <[email protected]>
---
 xen/arch/x86/guest/hyperv/hyperv.c      | 17 +++++++----------
 xen/arch/x86/include/asm/guest/hyperv.h |  3 ---
 2 files changed, 7 insertions(+), 13 deletions(-)
xen/arch/x86/guest/hyperv/hyperv.c +0 -0
index 6989af38f1..0305374a06 100644

xen/arch/x86/guest/hyperv/hyperv.c static void __init setup_hypercall_page(void) · line 105

Quoted 9 lines
xen/arch/x86/guest/hyperv/hyperv.c +5 -1
@@ -98,7 +98,13 @@ static void __init setup_hypercall_page(void)
     rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
     if ( !hypercall_msr.enable )
     {
-        mfn = HV_HCALL_MFN;
+        void *hcall_page = alloc_xenheap_page();
+        if ( !hcall_page )
+            panic("Hyper-V: Failed to allocate hypercall trampoline page");
+
+        printk("Hyper-V: Allocated hypercall page @ %p.\n", hcall_page);

This likely wants to be a dprintk, and possibly also print the physical address of the used page? And no period at the end of the sentence IMO.

Quoted 8 lines
Quoted 7 lines

I think Xen might have used the last page in the physical address range to prevent HyperV from possibly shattering a superpage in the second stage translation page-tables if normal RAM was used?

However I don't know whether HyperV will shatter super-pages if a sub-page of it is used to contain the hypercall page (I don't think it should?)

I think it's quite unlikely.

It will shatter superpages.

Quoted 8 lines
Quoted 2 lines

The overlay is not part of guest memory, and will hide whatever is behind it while it is mapped, which will force a 4k PTE in EPT/NPT.

That's an implementation detail. They can very well copy the trampoline to guest memory when there is such (and save the previous contents elsewhere) and restore them when disabling the trampoline. It's a trivial optimisation that would prevent shattering while being fully compliant with the TLFS.

Quoted 4 lines

It's an implementation detail relevant from a guest perspective, as it impacts guest performance. IOW: we care about the specific (current) implementation, as it's meaningful to how the guest-side should be implemented.

Indeed, I didn't mean otherwise.

My reply had more to do with the assertiveness of "it will shatter". The reality is that we can't know, short of microbenching a read into the trampoline after a TLB flush. And even then it may very well be version-dependent (where old did, and newer doesn't, for instance).

Quoted 19 lines
Quoted 6 lines

The actual physical location of the trampoline is fully undefined. It is defined to be an overlay; but that's a specification, not an implementation.

Quoted 1 line
Quoted 7 lines
Quoted 4 lines

Thinking about it, a better position would be adjacent to the APIC MMIO window, so at 0xfee01000.  The APIC MMIO window is forced to be a 4k mapping too, and the rest of the 2M window is normally empty.

Sounds like an assumption waiting to be broken. Just like the last page of guest-physical was.

As a compromise - could we try to allocate from < 4GB first, and resort to high memory if that doesn't work? That would at least limit shattering (if done) to the low 4GB, which is quite likely fragmented already:

Quoted 7 lines

hcall_page = alloc_xenheap_pages(0, MEMF_bits(32)); if ( !hcall_page )

    hcall_page = alloc_xenheap_page();
if ( !hcall_page )
    panic(...);

That will need a comment to describe what's going on.

Sounds far more resilient to me. I could get behind that, sure.

Ariadne, thoughts?

Cheers,
Alejandro

Reviewed-by on v2 1/1
#8 lore raw
In reply to Ariadne Conill
Quoted 6 lines · Ariadne Conill

Previously Xen placed the hypercall page at the highest possible MFN, but this caused problems on systems where there is more than 36 bits of physical address space.

In general, it also seems unreliable to assume that the highest possible MFN is not already reserved for some other purpose.

Thanks for sending this!

Just one more thing on top of what Jan mentioned.

Quoted 20 lines

Changes from v1:
- Continue to use fixmap infrastructure
- Use panic in Hyper-V setup() function instead of returning -ENOMEM on hypercall page allocation failure

Fixes 620fc734f854 ("x86/hyperv: setup hypercall page")
Cc Alejandro Vallejo <[email protected]>
Cc Alexander M. Merritt <[email protected]>
---
 xen/arch/x86/guest/hyperv/hyperv.c      | 17 +++++++----------
 xen/arch/x86/include/asm/guest/hyperv.h |  3 ---
 2 files changed, 7 insertions(+), 13 deletions(-)
xen/arch/x86/guest/hyperv/hyperv.c +0 -0
index 6989af38f1..0305374a06 100644

xen/arch/x86/guest/hyperv/hyperv.c static void __init setup_hypercall_page(void) · line 105

Quoted 9 lines
xen/arch/x86/guest/hyperv/hyperv.c +5 -1
@@ -98,7 +98,13 @@ static void __init setup_hypercall_page(void)
     rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
     if ( !hypercall_msr.enable )
     {
-        mfn = HV_HCALL_MFN;
+        void *hcall_page = alloc_xenheap_page();
+        if ( !hcall_page )
+            panic("Hyper-V: Failed to allocate hypercall trampoline page");
+
+        printk("Hyper-V: Allocated hypercall page @ %p.\n", hcall_page);

We should be printing the mfn (or maddr) rather than the virtual address out of the allocator, IMO. Especially since we need to remap it anyway.

With that:

Cheers,
Alejandro

#9 lore raw
In reply to Ariadne Conill

xen/arch/x86/guest/hyperv/hyperv.c static void __init setup_hypercall_page(void) · line 103

Quoted 12 lines · Ariadne Conill
xen/arch/x86/guest/hyperv/hyperv.c +3 -1
index 6989af38f1..0305374a06 100644
@@ -98,7 +98,13 @@ static void __init setup_hypercall_page(void)
     rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
     if ( !hypercall_msr.enable )
     {
-        mfn = HV_HCALL_MFN;
+        void *hcall_page = alloc_xenheap_page();
+        if ( !hcall_page )
+            panic("Hyper-V: Failed to allocate hypercall trampoline page");

\n

~Andrew