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

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


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>, "Ariadne Conill" <ariadne@ariadne.space>
  • From: Alejandro Vallejo <agarciav@xxxxxxx>
  • Date: Mon, 28 Apr 2025 11:55:31 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=citrix.com 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=GeVSj8Toeugrd8LwPFHvqKGuQ6AYaqOfbxEjmhlPk9A=; b=V8dt5OeZv1ZAcs/SjPpA9cwtwcaHcCBL8wnX+UkygIgKQGiI4C+qkWNsSj8F3sqSIixCO/rMuq7OiWnEUi2VRvbnFxQ5QI7hTwjewG2e8cU/Te6B4kCG81jA5utbb6jrr7pzkcI12Dja+ri0qYYN0CWBYIfTUai35D9BT5Hn1yT72S7nwq05pn4dy7IbGfRfBwPGcDT+ji0y0T9Hxjap+HQ+7YEcWvYGNXsuBwD1S2HUvF89VwlQS5PiXKRdjBSgB5hZPM4uuA4mW3B2MLTdZHLfBmQsA5kObjbuimxDlBhNtsnRWlpl1quvhVF0+4TUqIWfgwEZtFozC9cFIH1xIA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZeRqPJeYdHXYfj0C73rB1bko4bZcFmo9ZVNa5SjSsmjQE9M7KQGy2umvbKMSwbvcPEBrSCZVdVWgbb7WI6uuQA8Wh7Q1xbgcdlhej+JZ5YvIFo75YCjmZXS8tFCKTud2HFTJuaR4TMhhPnFY5dABprXnPeZDiWcGr5wyBZn2PDpyAS7oNOQioODRudhZo37/PqK27ghVYzf1rr/Y5LB1LHC+xO9F1fapDKxx8RDmQjkH9R62J0NE4yLcCxVfwGeQ0U879dDAdNhZDh4M2ByBmn3YY7bttPvQNRbgFWYaepqt2lzvTO5cPvdQwZod+4KO6CP8LaiKnpiGTQZHO5mGvQ==
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, "Alexander M . Merritt" <alexander@xxxxxxxxx>
  • Delivery-date: Mon, 28 Apr 2025 10:55:48 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon Apr 28, 2025 at 10:41 AM BST, Roger Pau Monné wrote:
> On Fri, Apr 25, 2025 at 04:43:31PM -0700, 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.
>> 
>> 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);
>
> 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?)

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.

>
> Thanks, Roger.

Cheers,
Alejandro



 


Rackspace

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