linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Matthew Wilcox <willy@infradead.org>
Cc: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>,
	kvm@vger.kernel.org, linux-mm@kvack.org,
	Borislav Petkov <bp@suse.de>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: Re: [4.18.0 rc8 BUG] possible irq lock inversion dependency detected
Date: Sat, 11 Aug 2018 15:56:12 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.21.1808111552010.3202@nanos.tec.linutronix.de> (raw)
In-Reply-To: <alpine.DEB.2.21.1808111511200.3202@nanos.tec.linutronix.de>

On Sat, 11 Aug 2018, Thomas Gleixner wrote:

> On Sat, 11 Aug 2018, Matthew Wilcox wrote:
> 
> > On Sat, Aug 11, 2018 at 12:28:24PM +0500, Mikhail Gavrilov wrote:
> > > Hi guys.
> > > I am catched new bug. It occured when I start virtual machine.
> > > Can anyone look?
> > 
> > I'd suggest that st->lock should be taken with irqsave.  Like this;
> > please test.
> 
> That should fix it, but that's suboptimal because that's an extra
> safe/restore in switch_to(). So we better disable interrupts at the other
> call site. Patch below.

Which is wrong as well. The placement of the speculation update call in the
SVM code should be moved, so just SVM is affected by a slightly larger irq
disabled region and no overhead at all for all others. Revised patch below.

Thanks,

	tglx

8<------------------
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index f059a73f0fd0..9c9b976d1afd 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -5580,8 +5580,6 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
 
 	clgi();
 
-	local_irq_enable();
-
 	/*
 	 * If this vCPU has touched SPEC_CTRL, restore the guest's value if
 	 * it's non-zero. Since vmentry is serialising on affected CPUs, there
@@ -5590,6 +5588,8 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
 	 */
 	x86_spec_ctrl_set_guest(svm->spec_ctrl, svm->virt_spec_ctrl);
 
+	local_irq_enable();
+
 	asm volatile (
 		"push %%" _ASM_BP "; \n\t"
 		"mov %c[rbx](%[svm]), %%" _ASM_BX " \n\t"

  reply	other threads:[~2018-08-11 13:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-11  7:28 Mikhail Gavrilov
2018-08-11 11:30 ` Matthew Wilcox
2018-08-11 13:14   ` Thomas Gleixner
2018-08-11 13:56     ` Thomas Gleixner [this message]
2018-08-11 15:44       ` Mikhail Gavrilov
2018-08-11 18:19         ` Thomas Gleixner
2018-08-11 19:44           ` Mikhail Gavrilov
2018-08-11 20:16             ` Thomas Gleixner

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=alpine.DEB.2.21.1808111552010.3202@nanos.tec.linutronix.de \
    --to=tglx@linutronix.de \
    --cc=bp@suse.de \
    --cc=konrad.wilk@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mikhail.v.gavrilov@gmail.com \
    --cc=willy@infradead.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