From: Liran Alon Subject: Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest Date: Mon, 8 Jan 2018 15:58:14 -0800 (PST) Message-ID: <751eaab5-1cc1-4913-b3c7-379255140cd1@default> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: , , , , , , To: Return-path: Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org ----- pbonzini@redhat.com wrote: > ----- Original Message ----- > > From: "David Woodhouse" > > To: "Paolo Bonzini" , > linux-kernel@vger.kernel.org, kvm@vger.kernel.org > > Cc: jmattson@google.com, aliguori@amazon.com, "thomas lendacky" > , bp@alien8.de > > Sent: Monday, January 8, 2018 8:41:07 PM > > Subject: Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and > MSR_IA32_PRED_CMD down to the guest > >=20 > > On Mon, 2018-01-08 at 19:08 +0100, Paolo Bonzini wrote: > > >=20 > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (have_spec_ctrl && vmx-= >spec_ctrl !=3D 0) > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0wrmsrl(MSR_IA32_SPEC_CTRL, vmx->spec_ctrl); > > > + > >=20 > > I think this one probably *is* safe even without an 'else lfence', > > which means that the CPU can speculate around it, but it wants a > > comment explaining that someone has properly analysed it and saying > > precisely why. >=20 > This one is okay as long as there are no indirect jumps until > vmresume. But the one on vmexit is only okay because right now > it's *disabling* IBRS. Once IBRS is used by Linux, we'll need an > lfence there. I'll add a comment. >=20 > Paolo That is true but from what I understand, there is an indirect branch from t= his point until vmresume. That indirect branch resides in atomic_switch_perf_msrs() immediately calle= d after this WRMSR: atomic_switch_perf_msrs() -> perf_guest_get_msrs() -> x86_pmu.guest_get_msr= s(). -Liran