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

Re: [Xen-devel] [PATCH 4/8] x86/hyperv: setup hypercall page


  • To: Wei Liu <wl@xxxxxxx>, Xen Development List <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michael Kelley <mikelley@xxxxxxxxxxxxx>
  • Date: Sun, 29 Dec 2019 19:54:30 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jE/WCB/5ba5ntTSW2G/bljC8UanMLzyvqc5H3GC/e8M=; b=RvYlWMHFn56SBCiWgmslq8U33uLNEAB0lLBfMT7P1+zeAtK1UTXN0CGAqduUUiF6rG4mNZ6ncmH+St7PgdLlyGOq9z3OSGne6M/XtADeYadm4lxfFgsxpBgFca6yIMugcWV7i8y+BDWk0ySk0P7tNxqztNOJtBGINuW1taJFg87A8GN62Ea+kwYoqQ1einvyhxmj3kC+eN+b6S78h4mtpeMyMKSnYj5XB83eRmFEnoQOPc+4LPlnvfXJXZrDbo5XkGoxb4aP618TPqCTaf9X4Qh+DWOY4iy2Yiadn5HV+tUhQJ5ubTCjp5y9m/m/8Lu2Sry8AYkKBgPnAnZ2YKgrDw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eU3aBIBQkcGjvRLO4FcKP5f5myoMlm7dS9awwIVOuXrY6wBQ0kAh4vXY/oJ/gekBusxLMvy5KhnB1Bj+MFx9t3ReINnksa6/zUWrNZVQ+0JyOyRGW5Zj+cA3d1dDtrCO2i7Vti1PkMZW/bsZDVLF10I0I2JX9bfT03nVic+YdIDxs3e1sGJ+y3AIwkt3ZBxmLpABo3z7mvd55lzLMpK9yZ/itceBrSsjnDPUW7388f3Gy9XGnQiGxyiDrmaBjYgwpCbwF+99QiFMoBHJ9+0k3iMbQVI4Z+K/feTexrtuiaLOH0+b+X28NJJdiAP1IDt4kD5YD6ca3pxfzw1VH9DvCQ==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=mikelley@xxxxxxxxxxxxx;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <liuwe@xxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Paul Durrant <paul@xxxxxxx>
  • Delivery-date: Sun, 29 Dec 2019 19:54:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=mikelley@xxxxxxxxxxxxxxxxxxx; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2019-12-29T19:54:28.5145316Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=ece3ddca-bcb2-44f4-a594-673ddb3ebbf5; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic
  • Thread-index: AQHVvnaJNVGyhEF7Vkuv2bDhxlZ7UafRhTGA
  • Thread-topic: [PATCH 4/8] x86/hyperv: setup hypercall page

From: Wei Liu <wei.liu.xen@xxxxxxxxx> On Behalf Of Wei Liu  Sent: Sunday, 
December 29, 2019 10:34 AM
> 
> Signed-off-by: Wei Liu <liuwe@xxxxxxxxxxxxx>
> ---
>  xen/arch/x86/guest/hyperv/hyperv.c | 41 +++++++++++++++++++++++++++---
>  1 file changed, 38 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/arch/x86/guest/hyperv/hyperv.c 
> b/xen/arch/x86/guest/hyperv/hyperv.c
> index c6a26c5453..438910c8cb 100644
> --- a/xen/arch/x86/guest/hyperv/hyperv.c
> +++ b/xen/arch/x86/guest/hyperv/hyperv.c
> @@ -19,16 +19,17 @@
>   * Copyright (c) 2019 Microsoft.
>   */
>  #include <xen/init.h>
> +#include <xen/domain_page.h>
> 
>  #include <asm/guest.h>
>  #include <asm/guest/hyperv-tlfs.h>
> 
>  struct ms_hyperv_info __read_mostly ms_hyperv;
> 
> -static const struct hypervisor_ops ops = {
> -    .name = "Hyper-V",
> -};
> +void *hv_hypercall;
> +static struct page_info *hv_hypercall_page;
> 
> +static const struct hypervisor_ops ops;
>  const struct hypervisor_ops *__init hyperv_probe(void)
>  {
>      uint32_t eax, ebx, ecx, edx;
> @@ -71,6 +72,40 @@ 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;
> +
> +    /* Unfortunately there isn't a really good way to unwind Xen to
> +     * not use Hyper-V hooks, so panic if anything goes wrong.
> +     *
> +     * In practice if page allocation fails this early on it is
> +     * unlikely we can get a working system later.
> +     */
> +    hv_hypercall_page = alloc_domheap_page(NULL, 0);
> +    if ( !hv_hypercall_page )
> +        panic("Failed to allocate Hyper-V hypercall page\n");
> +
> +    hv_hypercall = __map_domain_page_global(hv_hypercall_page);
> +    if ( !hv_hypercall )
> +        panic("Failed to map Hyper-V hypercall page\n");
> +
> +    rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> +    hypercall_msr.enable = 1;
> +    hypercall_msr.guest_physical_address = page_to_maddr(hv_hypercall_page);

The "guest_physical_address" field is actually the guest physical page number.
So the physical address needs to be right shifted 12 bits before being stored
here.  I'd recommend using HV_HYP_PAGE_SHIFT from hyperv-tlfs.h as
the shift value; it was introduced to deal with the possibility that the page
size used and expected by the Hyper-V interface is different from the page
size used by the guest VM (which can happen on ARM64, though not on x86).

Michael

> +    wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> +}
> +
> +static void __init setup(void)
> +{
> +    setup_hypercall_page();
> +}
> +
> +static const struct hypervisor_ops ops = {
> +    .name = "Hyper-V",
> +    .setup = setup,
> +};
> +
>  /*
>   * Local variables:
>   * mode: C
> --
> 2.20.1


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

 


Rackspace

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