From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: Re: [PATCH v6 2/5] KVM: x86: Add IBPB support Date: Fri, 2 Feb 2018 15:28:57 -0500 Message-ID: <20180202202857.GI28192@char.us.oracle.com> References: <1517522386-18410-1-git-send-email-karahmed@amazon.de> <1517522386-18410-3-git-send-email-karahmed@amazon.de> <20180202174932.GR28192@char.us.oracle.com> <1517594544.31953.62.camel@infradead.org> <20180202195601.GD28192@char.us.oracle.com> <1517602575.31953.74.camel@infradead.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Cc: KarimAllah Ahmed , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, Ashok Raj , Asit Mallick , Dave Hansen , Arjan Van De Ven , Tim Chen , Linus Torvalds , Andrea Arcangeli , Andi Kleen , Thomas Gleixner , Dan Williams , Jun Nakajima , Andy Lutomirski , Greg KH , Paolo Bonzini , Peter Zijlstra To: David Woodhouse Return-path: Content-Disposition: inline In-Reply-To: <1517602575.31953.74.camel@infradead.org> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Fri, Feb 02, 2018 at 08:16:15PM +0000, David Woodhouse wrote: >=20 >=20 > On Fri, 2018-02-02 at 14:56 -0500, Konrad Rzeszutek Wilk wrote: > > On Fri, Feb 02, 2018 at 06:02:24PM +0000, David Woodhouse wrote: > > >=20 > > > On Fri, 2018-02-02 at 12:49 -0500, Konrad Rzeszutek Wilk wrote: > > > >=20 > > > > >=20 > > > > > @@ -625,7 +629,12 @@ static inline int __do_cpuid_ent(struct > > > > > kvm_cpuid_entry2 *entry, u32 function, > > > > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0if (!g_phys_= as) > > > > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0g_phys_as =3D phys_as; > > > > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0entry->eax =3D= g_phys_as | (virt_as << 8); > > > > > -=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0entry->ebx =3D en= try->edx =3D 0; > > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0entry->edx =3D 0; > > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* IBPB isn't nec= essarily present in hardware cpuid>=A0=A0*/ > > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0if (boot_cpu_has(= X86_FEATURE_IBPB)) > > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0entry->ebx |=3D F(IBPB); > > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0entry->ebx &=3D k= vm_cpuid_8000_0008_ebx_x86_features; > > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0cpuid_mask(&entry= ->ebx, CPUID_8000_0008_EBX); > > > > It is with x86/pti nowadays. I think you can remove that comment. > > > In this code we use the actual CPUID instruction, then filter stuff= out > > > of it (with &=3D kvm_cpuid_XXX_x86_features and then cpuid_mask() t= o turn > > > off any bits which were otherwise present in the hardware and *woul= d* > > > have been supported by KVM, but which the kernel has decided to pre= tend > > > are not present. > > >=20 > > > Nothing would *set* the IBPB bit though, since that's a "virtual" b= it > > > on Intel hardware. The comment explains why we have that |=3D F(IBP= B), > > > and if the comment wasn't true, we wouldn't need that code either. > > > > But this seems wrong. That is on Intel CPUs we will advertise on > > AMD leaf that the IBPB feature is available. > >=20 > > Shouldn't we just check to see if the machine is AMD before advertisi= ng > > this bit? >=20 > No. The AMD feature bits give us more fine-grained support for exposing > IBPB or IBRS alone, so we expose those bits on Intel too. But but.. that runs smack against the idea of exposing a platform that is as close to emulating the real hardware as possible. As in I would never expect an Intel CPU to expose the IBPB on the 0x8000_= 0008 leaf. Hence KVM (nor any hypervisor) should not do it either. Unless Intel is doing it? Did I miss a new spec update?