[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] x86/hyperv: use dynamically allocated page for hypercalls


  • To: Ariadne Conill <ariadne@ariadne.space>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Alejandro Vallejo <agarciav@xxxxxxx>
  • Date: Mon, 28 Apr 2025 11:41:09 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=ariadne.space smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=O3kAo3AB5BRNQwYpw3S9KJQOTJGWIFugK5OLFFCeLtY=; b=j7AujUsnShZTd5EItxs0ASsTB+JwP1wYUbx/6/dqwKhtafkOVj4nbKP7bSS6bk/EpDX659OI5NViexbpuE4dPeeLJwa3jWDrIQWTWBMEgvbbmqOUnFY7ZNz/9iZ6c9VleenP7+Lz12Ve9OwU8kDPd+8N2fSdzKqzKCbsVv5zZxK60ZAWCSwSvuBO9ORiNBAjNMW60TuJjjLQ72kaE4MdCjcyqmHw5jzDmjpiIDyFVBjMKF/1eDUYxPrs7ikeYFgLpvi/5HQRAqiqkCsRE5OX+rKUFLQnWHFSSqxsKdgMq9uNVjOXI0eG9g2Cu2Ler2m6V2xgdzSI2dFwhr5WX5vvDw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J7Z06qoHn0T/of+I5DVqQrwC+j1AV/8QAK4Lymscf40Xnpr+te9APShmYZ8X+AHNBhEAW9SSsTN0VlIlNSNga1/Z9p4H1fKQnLtkj2ow6eMEFBQrS6OeqVpSZRC84XFWHetTlP5Tb72LKKbMI61cH3yZpCFXVUuZtEZPDvYH22gwj0MzS9VPvbGkrwHHrZK+4tC1iWYO3Zdnrq5f7ohDI4Ii1+Xz8Ranc0dil+I5s51F2NBv8XqW8+worqC/XzX+LvZTRPNNn0TNTPkNnfY96FplN5wi2JHxFwYyRCh4oTFq+iF9uYuhRawyL7yRULzhqv7TY2rjJ6r7H/iph2Zteg==
  • Cc: Paul Durrant <paul@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "Alexander M . Merritt" <alexander@xxxxxxxxx>
  • Delivery-date: Mon, 28 Apr 2025 10:41:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Sat Apr 26, 2025 at 12:43 AM BST, Ariadne Conill wrote:
> 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.

>
> 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 <agarciav@xxxxxxx>
> Cc: Alexander M. Merritt <alexander@xxxxxxxxx>
> Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
> ---
>  xen/arch/x86/guest/hyperv/hyperv.c      | 17 +++++++----------
>  xen/arch/x86/include/asm/guest/hyperv.h |  3 ---
>  2 files changed, 7 insertions(+), 13 deletions(-)
>
> diff --git a/xen/arch/x86/guest/hyperv/hyperv.c 
> b/xen/arch/x86/guest/hyperv/hyperv.c
> index 6989af38f1..0305374a06 100644
> --- a/xen/arch/x86/guest/hyperv/hyperv.c
> +++ b/xen/arch/x86/guest/hyperv/hyperv.c
> @@ -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:

  Reviewed-by: Alejandro Vallejo <agarciav@xxxxxxx>

Cheers,
Alejandro



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.