linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu@kernel.org>
To: Michael Kelley <mikelley@microsoft.com>
Cc: Wei Liu <wei.liu@kernel.org>,
	Linux on Hyper-V List <linux-hyperv@vger.kernel.org>,
	"stable@kernel.org" <stable@kernel.org>,
	KY Srinivasan <kys@microsoft.com>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	Stephen Hemminger <sthemmin@microsoft.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
	<x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
	"open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" 
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86/hyperv: check cpu mask after interrupt has been disabled
Date: Wed, 6 Jan 2021 11:04:35 +0000	[thread overview]
Message-ID: <20210106110435.cajpxwbew4t5afye@liuwe-devbox-debian-v2> (raw)
In-Reply-To: <MWHPR21MB15935E00EAEFD70E49A22667D7D19@MWHPR21MB1593.namprd21.prod.outlook.com>

On Tue, Jan 05, 2021 at 06:20:05PM +0000, Michael Kelley wrote:
> From: Wei Liu <wei.liu@kernel.org> Sent: Tuesday, January 5, 2021 9:51 AM
> > 
> > We've observed crashes due to an empty cpu mask in
> > hyperv_flush_tlb_others.  Obviously the cpu mask in question is changed
> > between the cpumask_empty call at the beginning of the function and when
> > it is actually used later.
> > 
> > One theory is that an interrupt comes in between and a code path ends up
> > changing the mask. Move the check after interrupt has been disabled to
> > see if it fixes the issue.
> > 
> > Signed-off-by: Wei Liu <wei.liu@kernel.org>
> > Cc: stable@kernel.org
> > ---
> >  arch/x86/hyperv/mmu.c | 12 +++++++++---
> >  1 file changed, 9 insertions(+), 3 deletions(-)
> > 
> > diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c
> > index 5208ba49c89a..2c87350c1fb0 100644
> > --- a/arch/x86/hyperv/mmu.c
> > +++ b/arch/x86/hyperv/mmu.c
> > @@ -66,11 +66,17 @@ static void hyperv_flush_tlb_others(const struct cpumask *cpus,
> >  	if (!hv_hypercall_pg)
> >  		goto do_native;
> > 
> > -	if (cpumask_empty(cpus))
> > -		return;
> > -
> >  	local_irq_save(flags);
> > 
> > +	/*
> > +	 * Only check the mask _after_ interrupt has been disabled to avoid the
> > +	 * mask changing under our feet.
> > +	 */
> > +	if (cpumask_empty(cpus)) {
> > +		local_irq_restore(flags);
> > +		return;
> > +	}
> > +
> >  	flush_pcpu = (struct hv_tlb_flush **)
> >  		     this_cpu_ptr(hyperv_pcpu_input_arg);
> > 
> > --
> > 2.20.1
> 
> Reviewed-by:  Michael Kelley <mikelley@microsoft.com>
> 

Applied to hyperv-fixes.

Wei.

      reply	other threads:[~2021-01-06 11:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-05 17:50 [PATCH] x86/hyperv: check cpu mask after interrupt has been disabled Wei Liu
2021-01-05 18:20 ` Michael Kelley
2021-01-06 11:04   ` Wei Liu [this message]

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=20210106110435.cajpxwbew4t5afye@liuwe-devbox-debian-v2 \
    --to=wei.liu@kernel.org \
    --cc=bp@alien8.de \
    --cc=haiyangz@microsoft.com \
    --cc=hpa@zytor.com \
    --cc=kys@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikelley@microsoft.com \
    --cc=mingo@redhat.com \
    --cc=stable@kernel.org \
    --cc=sthemmin@microsoft.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).