Return-path: Received: from mx3-rdu2.redhat.com ([66.187.233.73] helo=mx1.redhat.com) by Galois.linutronix.de with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fIWHi-0000cD-Uz for speck@linutronix.de; Tue, 15 May 2018 11:30:19 +0200 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 07B60401FF06 for ; Tue, 15 May 2018 09:30:12 +0000 (UTC) Received: from [10.36.117.239] (ovpn-117-239.ams2.redhat.com [10.36.117.239]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7686810F1C0D for ; Tue, 15 May 2018 09:30:11 +0000 (UTC) Subject: [MODERATED] Re: [patch 01/15] Hidden 1 References: <20180513140048.543641807@linutronix.de> <20180513140538.305725936@linutronix.de> From: Paolo Bonzini Message-ID: <524f3ff7-0487-9c8b-6c40-a805d3f64397@redhat.com> Date: Tue, 15 May 2018 11:30:07 +0200 MIME-Version: 1.0 In-Reply-To: <20180513140538.305725936@linutronix.de> Content-Type: multipart/mixed; boundary="otmxKPVIIq73a9rbLY0FQkkJsTkFUnyY6"; protected-headers="v1" To: speck@linutronix.de List-ID: This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156) --otmxKPVIIq73a9rbLY0FQkkJsTkFUnyY6 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 13/05/2018 16:00, speck for Thomas Gleixner wrote: >=20 >=20 > Subject: [patch 01/15] KVM: SVM: Move spec control call after restore o= f GS > From: Thomas Gleixner >=20 > svm_vcpu_run() invokes x86_spec_ctrl_restore_host() after VMEXIT, but > before the host GS is restored. x86_spec_ctrl_restore_host() uses 'curr= ent' > 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. >=20 > Move the call after the host GS restore. >=20 > Fixes: 5cf687548705 ("x86/bugs, KVM: Support the combination of guest a= nd host IBRS") > Signed-off-by: Thomas Gleixner Acked-by: Paolo Bonzini Thanks, Paolo > --- > arch/x86/kvm/svm.c | 24 ++++++++++++------------ > 1 file changed, 12 insertions(+), 12 deletions(-) >=20 > --- 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 > ); > =20 > + /* 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 > =20 > x86_spec_ctrl_restore_host(svm->spec_ctrl); > =20 > - /* 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); > =20 > local_irq_disable(); >=20 --otmxKPVIIq73a9rbLY0FQkkJsTkFUnyY6--