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>, Paul Durrant <paul@xen.org>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Michael Kelley <mikelley@microsoft.com>,
	Jan Beulich <jbeulich@suse.com>,
	Xen Development List <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH] x86/hyperv: stash and use the configured max VP index
Date: Thu, 30 Apr 2020 12:15:58 +0200	[thread overview]
Message-ID: <20200430101558.GA28601@Air-de-Roger> (raw)
In-Reply-To: <20200429114718.zclpy6r6sbxuo6ph@liuwe-devbox-debian-v2.j3c5onc20sse1dnehy4noqpfcg.zx.internal.cloudapp.net>

On Wed, Apr 29, 2020 at 11:47:18AM +0000, Wei Liu wrote:
> On Wed, Apr 29, 2020 at 11:41:44AM +0100, Wei Liu wrote:
> > The value returned from CPUID is the maximum number for virtual
> > processors supported by Hyper-V. It could be larger than the maximum
> > number of virtual processors configured.
> > 
> > Stash the configured number into a variable and use it in calculations.
> > 
> > Signed-off-by: Wei Liu <liuwe@microsoft.com>
> > ---
> >  xen/arch/x86/guest/hyperv/hyperv.c  | 4 ++++
> >  xen/arch/x86/guest/hyperv/private.h | 1 +
> >  xen/arch/x86/guest/hyperv/tlb.c     | 2 +-
> >  xen/arch/x86/guest/hyperv/util.c    | 2 +-
> >  4 files changed, 7 insertions(+), 2 deletions(-)
> > 
> > diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c
> > index 91a6782cd986..84221b751453 100644
> > --- a/xen/arch/x86/guest/hyperv/hyperv.c
> > +++ b/xen/arch/x86/guest/hyperv/hyperv.c
> > @@ -33,6 +33,7 @@ DEFINE_PER_CPU_READ_MOSTLY(void *, hv_input_page);
> >  DEFINE_PER_CPU_READ_MOSTLY(void *, hv_vp_assist);
> >  DEFINE_PER_CPU_READ_MOSTLY(unsigned int, hv_vp_index);
> >  
> > +unsigned int __read_mostly hv_max_vp_index;
> >  static bool __read_mostly hcall_page_ready;
> >  
> >  static uint64_t generate_guest_id(void)
> > @@ -143,6 +144,9 @@ static int setup_hypercall_pcpu_arg(void)
> >      rdmsrl(HV_X64_MSR_VP_INDEX, vp_index_msr);
> >      this_cpu(hv_vp_index) = vp_index_msr;
> >  
> > +    if ( vp_index_msr > hv_max_vp_index )
> > +        hv_max_vp_index = vp_index_msr;
> > +
> >      return 0;
> >  }
> >  
> > diff --git a/xen/arch/x86/guest/hyperv/private.h b/xen/arch/x86/guest/hyperv/private.h
> > index 354fc7f685a7..fea3e291e944 100644
> > --- a/xen/arch/x86/guest/hyperv/private.h
> > +++ b/xen/arch/x86/guest/hyperv/private.h
> > @@ -28,6 +28,7 @@
> >  DECLARE_PER_CPU(void *, hv_input_page);
> >  DECLARE_PER_CPU(void *, hv_vp_assist);
> >  DECLARE_PER_CPU(unsigned int, hv_vp_index);
> > +extern unsigned int hv_max_vp_index;
> >  
> >  static inline unsigned int hv_vp_index(unsigned int cpu)
> >  {
> > diff --git a/xen/arch/x86/guest/hyperv/tlb.c b/xen/arch/x86/guest/hyperv/tlb.c
> > index 1d723d6ee679..0a44071481bd 100644
> > --- a/xen/arch/x86/guest/hyperv/tlb.c
> > +++ b/xen/arch/x86/guest/hyperv/tlb.c
> > @@ -166,7 +166,7 @@ int hyperv_flush_tlb(const cpumask_t *mask, const void *va,
> >          {
> >              unsigned int vpid = hv_vp_index(cpu);
> >  
> > -            if ( vpid >= ms_hyperv.max_vp_index )
> > +            if ( vpid >= hv_max_vp_index )
> 
> I think the >= should be changed to > here.

I agree. With this fixed:

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

Thanks!


  reply	other threads:[~2020-04-30 10:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-29 10:41 [PATCH] x86/hyperv: stash and use the configured max VP index Wei Liu
2020-04-29 11:47 ` Wei Liu
2020-04-30 10:15   ` Roger Pau Monné [this message]
2020-04-30 10:21     ` Roger Pau Monné
2020-05-06  9:37       ` 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=20200430101558.GA28601@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=paul@xen.org \
    --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.