All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Wei Liu <wl@xen.org>
Cc: Wei Liu <liuwe@microsoft.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Paul Durrant <pdurrant@amazon.com>,
	Michael Kelley <mikelley@microsoft.com>,
	Jan Beulich <jbeulich@suse.com>,
	Xen Development List <xen-devel@lists.xenproject.org>
Subject: Re: [Xen-devel] [PATCH v7 05/10] x86/hyperv: setup hypercall page
Date: Wed, 5 Feb 2020 15:04:16 +0100	[thread overview]
Message-ID: <20200205140416.GT4679@Air-de-Roger> (raw)
In-Reply-To: <20200204153704.15934-6-liuwe@microsoft.com>

On Tue, Feb 04, 2020 at 03:36:59PM +0000, Wei Liu wrote:
> Hyper-V uses a technique called overlay page for its hypercall page. It
> will insert a backing page to the guest when the hypercall functionality
> is enabled. That means we can use a page that is not backed by real
> memory for hypercall page.
> 
> To avoid shattering L0 superpages and treading on any MMIO areas
> residing in low addresses, use the top-most addressable page for that
> purpose. Adjust e820 map accordingly.
> 
> We also need to register Xen's guest OS ID to Hyper-V. Use 0x3 as the
> vendor ID. Fix the comment in hyperv-tlfs.h while at it.
> 
> Signed-off-by: Wei Liu <liuwe@microsoft.com>

Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

> ---
> v7:
> 1. Fix a style issue
> 2. Initialise ID to 0
> 3. Update commit message
> 
> v6:
> 1. Use hv_guest_os_id
> 2. Use new e820_fixup hook
> 3. Add a BUILD_BUG_ON
> 
> v5:
> 1. use hypervisor_reserve_top_pages
> 2. add a macro for hypercall page mfn
> 3. address other misc comments
> 
> v4:
> 1. Use fixmap
> 2. Follow routines listed in TLFS
> ---
>  xen/arch/x86/guest/hyperv/hyperv.c      | 69 +++++++++++++++++++++++--
>  xen/include/asm-x86/guest/hyperv-tlfs.h |  5 +-
>  xen/include/asm-x86/guest/hyperv.h      |  3 ++
>  3 files changed, 72 insertions(+), 5 deletions(-)
> 
> diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c
> index 8d38313d7a..2e20a96f30 100644
> --- a/xen/arch/x86/guest/hyperv/hyperv.c
> +++ b/xen/arch/x86/guest/hyperv/hyperv.c
> @@ -19,15 +19,27 @@
>   * Copyright (c) 2019 Microsoft.
>   */
>  #include <xen/init.h>
> +#include <xen/version.h>
>  
> +#include <asm/fixmap.h>
>  #include <asm/guest.h>
>  #include <asm/guest/hyperv-tlfs.h>
> +#include <asm/processor.h>
>  
>  struct ms_hyperv_info __read_mostly ms_hyperv;
>  
> -static const struct hypervisor_ops ops = {
> -    .name = "Hyper-V",
> -};
> +static uint64_t generate_guest_id(void)
> +{
> +    union hv_guest_os_id id = {};
> +
> +    id.vendor = HV_XEN_VENDOR_ID;
> +    id.major = xen_major_version();
> +    id.minor = xen_minor_version();
> +
> +    return id.raw;
> +}
> +
> +static const struct hypervisor_ops ops;
>  
>  const struct hypervisor_ops *__init hyperv_probe(void)
>  {
> @@ -72,6 +84,57 @@ 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;
> +    union hv_guest_os_id guest_id;
> +    unsigned long mfn;
> +
> +    BUILD_BUG_ON(HV_HYP_PAGE_SHIFT != PAGE_SHIFT);
> +
> +    rdmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id.raw);
> +    if ( !guest_id.raw )
> +    {
> +        guest_id.raw = generate_guest_id();
> +        wrmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id.raw);
> +    }
> +
> +    rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> +    if ( !hypercall_msr.enable )
> +    {
> +        mfn = HV_HCALL_MFN;
> +        hypercall_msr.enable = 1;
> +        hypercall_msr.guest_physical_address = mfn;
> +        wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> +    }
> +    else
> +        mfn = hypercall_msr.guest_physical_address;

Is it expected that the guest ID or the hypercal page is already
setup?

Ie: would virtual firmware setup any of this? (and not clean it up
afterwards)

Thanks, Roger.

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

  reply	other threads:[~2020-02-05 14:04 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-04 15:36 [Xen-devel] [PATCH v7 00/10] More Hyper-V infrastructures Wei Liu
2020-02-04 15:36 ` [Xen-devel] [PATCH v7 01/10] x86/hypervisor: make hypervisor_ap_setup return an error code Wei Liu
2020-02-04 16:48   ` Wei Liu
2020-02-04 16:56     ` Roger Pau Monné
2020-02-04 17:03       ` Wei Liu
2020-02-05 11:12   ` Jan Beulich
2020-02-05 12:09     ` Wei Liu
2020-02-05 12:42       ` Jan Beulich
2020-02-04 15:36 ` [Xen-devel] [PATCH v7 02/10] x86/smp: don't online cpu if hypervisor_ap_setup fails Wei Liu
2020-02-04 15:36 ` [Xen-devel] [PATCH v7 03/10] x86: provide executable fixmap facility Wei Liu
2020-02-05 11:15   ` Jan Beulich
2020-02-04 15:36 ` [Xen-devel] [PATCH v7 04/10] x86/hypervisor: provide hypervisor_fixup_e820 Wei Liu
2020-02-04 15:36 ` [Xen-devel] [PATCH v7 05/10] x86/hyperv: setup hypercall page Wei Liu
2020-02-05 14:04   ` Roger Pau Monné [this message]
2020-02-05 15:00     ` Wei Liu
2020-02-05 15:03       ` Wei Liu
2020-02-05 15:52   ` Durrant, Paul
2020-02-04 15:37 ` [Xen-devel] [PATCH v7 06/10] x86/hyperv: provide Hyper-V hypercall functions Wei Liu
2020-02-05 11:17   ` Jan Beulich
2020-02-04 15:37 ` [Xen-devel] [PATCH v7 07/10] DO NOT APPLY: x86/hyperv: issue an hypercall Wei Liu
2020-02-04 15:37 ` [Xen-devel] [PATCH v7 08/10] x86/hyperv: provide percpu hypercall input page Wei Liu
2020-02-04 15:37 ` [Xen-devel] [PATCH v7 09/10] x86/hyperv: retrieve vp_index from Hyper-V Wei Liu
2020-02-04 15:37 ` [Xen-devel] [PATCH v7 10/10] x86/hyperv: setup VP assist page Wei Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200205140416.GT4679@Air-de-Roger \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=liuwe@microsoft.com \
    --cc=mikelley@microsoft.com \
    --cc=pdurrant@amazon.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.