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

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


  • To: Ariadne Conill <ariadne@ariadne.space>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Alejandro Vallejo <agarciav@xxxxxxx>
  • Date: Tue, 29 Apr 2025 12:23:13 +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=hxngcqNyQFoCyXhRaLSUeeJ3ReN4p9F/M7ziXji+s+8=; b=jLvRRS1XDHZbNeIAgTBv/sQzopiT5FViCWKcGKsMI/+1yKT8SYVMk1r9Q2UlvJGXtVg6rgZQD5F4p70PdetbdFn8gGGuyUbu4TGf2Jtep+TJXoLWLrFMWvH8ptfhxTlmrYCvz+kQKnH5Kcde8Ib6amn0jSPk/fPswZ7z2xmOw0iQb5oJFRQJIdrgcV0tIcy501Iqt283hgO14EI3gV+pTfKU/PT1GkOHEQQIQ6W8vA5BZGpwN5r/1ghdSliCPYHhm5pYZvcSdo+XK+RtQkBoczlLh+MXY4n0GE3TWSJcCTFDPXnmXqC8FbD44EmOrUdv3AXtqUuVZ72UCxKqJ2Yk7A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xy6cQ7xDhyIJGgn2LtsrAu1JdrTSby/UqIAdMsUWiOqBr/9fUgov2YJ1Jki0eIapue8OEKV8xy8oxB7QoM7g8VB0fiVW85Ax3Rj156TJ20EfgePwAPW/2rXO5vkcQ6aQHOWncAsVG5d396tt+OYjxR4cSrzkoq77tIT77hUHY0guvKH+JBvbQrUMmMt6ufjY7LifSRwIKUQrcmpgHz9e1MS1XnK0SpjzgN4BLphIm/91yx3ZBVdKZhrenvv7R77D3rLz2HQXgBjhsbj5VBOlmKb//ti5c0TE/AzdF3bKVLA1tdRj1LeebQMcs0DL+jAHY2ce47j4YOMfsFT447u73w==
  • 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: Tue, 29 Apr 2025 11:23:30 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon Apr 28, 2025 at 8:57 PM 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.
>
> 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>

  Reviewed-by: Alejandro Vallejo <agarciav@xxxxxxx>

I'm happy with the patch as-is, and I'm equally happy...

> diff --git a/xen/arch/x86/guest/hyperv/hyperv.c 
> b/xen/arch/x86/guest/hyperv/hyperv.c
> index 6989af38f1..f69f596441 100644
> --- a/xen/arch/x86/guest/hyperv/hyperv.c
> +++ b/xen/arch/x86/guest/hyperv/hyperv.c
> @@ -98,10 +98,18 @@ 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");

... with Roger's suggestion to probe <4G first with MEMF(32) here.

> +
> +        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);
> +
> +        dprintk(XENLOG_INFO,
> +                "Hyper-V: Allocated hypercall page at MFN %lx\n", mfn);

nit: This is a personal preference thing, but I find %lx is very
unhelpful when the variable is something like 0x123, as 123 might be
misinterpreted to be in decimal. An mfn is not nearly as problematic as
an error code, but %#lx avoids the ambiguity altogether.

Cheers,
Alejandro



 


Rackspace

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