Return-path: Received: from aserp2120.oracle.com ([141.146.126.78]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fImEw-0002w8-Ul for speck@linutronix.de; Wed, 16 May 2018 04:32:31 +0200 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w4G2V2BI187226 for ; Wed, 16 May 2018 02:32:23 GMT Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2hx29w2su9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 16 May 2018 02:32:23 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w4G2WMo1023964 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 16 May 2018 02:32:23 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w4G2WMeZ030118 for ; Wed, 16 May 2018 02:32:22 GMT Date: Tue, 15 May 2018 22:32:21 -0400 From: Konrad Rzeszutek Wilk Subject: [MODERATED] Re: [patch 01/15] Hidden 1 Message-ID: <20180516023221.GB18660@char.us.oracle.com> References: <20180513140048.543641807@linutronix.de> <20180513140538.305725936@linutronix.de> MIME-Version: 1.0 In-Reply-To: <20180513140538.305725936@linutronix.de> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: On Sun, May 13, 2018 at 04:00:49PM +0200, speck for Thomas Gleixner wrote: > Subject: [patch 01/15] KVM: SVM: Move spec control call after restore of GS > From: Thomas Gleixner > > svm_vcpu_run() invokes x86_spec_ctrl_restore_host() after VMEXIT, but > before the host GS is restored. x86_spec_ctrl_restore_host() uses 'current' > to determine the host SSBD state of the thread. 'current' is GS based, but > host GS is not yet restored and the access causes a triple fault. > > Move the call after the host GS restore. > > Fixes: 5cf687548705 ("x86/bugs, KVM: Support the combination of guest and host IBRS") But that commit didn't use 'current' at all. It had: void x86_spec_ctrl_restore_host(u64 guest_spec_ctrl) { if (!boot_cpu_has(X86_FEATURE_IBRS)) return; if (x86_spec_ctrl_base != guest_spec_ctrl) wrmsrl(MSR_IA32_SPEC_CTRL, x86_spec_ctrl_base); } EXPORT_SYMBOL_GPL(x86_spec_ctrl_restore_host); I think you meant: 885f82bfbc6f x86/process: Allow runtime control of Speculative Store Bypass with that: Reviewed-by: Konrad Rzeszutek Wilk Thank you! > Signed-off-by: Thomas Gleixner > --- > arch/x86/kvm/svm.c | 24 ++++++++++++------------ > 1 file changed, 12 insertions(+), 12 deletions(-) > > --- a/arch/x86/kvm/svm.c > +++ b/arch/x86/kvm/svm.c > @@ -5651,6 +5651,18 @@ static void svm_vcpu_run(struct kvm_vcpu > #endif > ); > > + /* Eliminate branch target predictions from guest mode */ > + vmexit_fill_RSB(); > + > +#ifdef CONFIG_X86_64 > + wrmsrl(MSR_GS_BASE, svm->host.gs_base); > +#else > + loadsegment(fs, svm->host.fs); > +#ifndef CONFIG_X86_32_LAZY_GS > + loadsegment(gs, svm->host.gs); > +#endif > +#endif > + > /* > * We do not use IBRS in the kernel. If this vCPU has used the > * SPEC_CTRL MSR it may have left it on; save the value and > @@ -5671,18 +5683,6 @@ static void svm_vcpu_run(struct kvm_vcpu > > x86_spec_ctrl_restore_host(svm->spec_ctrl); > > - /* Eliminate branch target predictions from guest mode */ > - vmexit_fill_RSB(); > - > -#ifdef CONFIG_X86_64 > - wrmsrl(MSR_GS_BASE, svm->host.gs_base); > -#else > - loadsegment(fs, svm->host.fs); > -#ifndef CONFIG_X86_32_LAZY_GS > - loadsegment(gs, svm->host.gs); > -#endif > -#endif > - > reload_tss(vcpu); > > local_irq_disable(); >