RE: [PATCH v2] KVM: x86: Implement PCID/INVPCID for guests with EPT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: kvm-owner@xxxxxxxxxxxxxxx [mailto:kvm-owner@xxxxxxxxxxxxxxx] On
> Behalf Of Mao, Junjie
> Sent: Thursday, May 17, 2012 9:22 AM
> To: Marcelo Tosatti
> Cc: 'kvm@xxxxxxxxxxxxxxx'
> Subject: RE: [PATCH v2] KVM: x86: Implement PCID/INVPCID for guests with
> EPT
> 
> > -----Original Message-----
> > From: Marcelo Tosatti [mailto:mtosatti@xxxxxxxxxx]
> > Sent: Tuesday, May 15, 2012 10:42 AM
> > To: Mao, Junjie
> > Cc: 'kvm@xxxxxxxxxxxxxxx'
> > Subject: Re: [PATCH v2] KVM: x86: Implement PCID/INVPCID for guests
> > with EPT
> >
> > On Mon, May 14, 2012 at 06:25:40AM +0000, Mao, Junjie wrote:
> > > This patch handles PCID/INVPCID for guests.
> > >
> > > Process-context identifiers (PCIDs) are a facility by which a
> > > logical processor may cache information for multiple linear-address
> > > spaces so that the processor may retain cached information when
> > > software switches to a different linear address space. Refer to
> > > section 4.10.1 in IA32 Intel Software Developer's Manual Volume 3A for
> details.
> > >
> > > For guests with EPT, the PCID feature is enabled and INVPCID behaves
> > > as running natively.
> > > For guests without EPT, the PCID feature is disabled and INVPCID
> > > triggers
> > #UD.
> > >
> > > Changes from v1:
> > > 	Move cr0/cr4 writing checks to x86.c
> > > 	Update comments for the reason why PCID is disabled for non-EPT guests
> > > 	Do not support PCID/INVPCID for nested guests at present
> > > 	Clean up useless symbols
> > >
> > > Signed-off-by: Junjie Mao <junjie.mao@xxxxxxxxx>
> > > +++ b/arch/x86/kvm/vmx.c
> > > @@ -1711,6 +1711,18 @@ static bool vmx_rdtscp_supported(void)
> > >  	return cpu_has_vmx_rdtscp();
> > >  }
> > >
> > > +static bool vmx_pcid_supported(void) {
> > > +	/*
> > > +	 * Enable INVPCID for non-ept guests may cause performance
> regression,
> > > +	 * and without INVPCID, PCID has little benefits. So disable them all
> > > +	 * for non-ept guests.
> > > +	 *
> > > +	 * PCID is not supported for nested guests yet.
> > > +	 */
> > > +	return enable_ept && (boot_cpu_data.x86_capability[4] &
> > > +bit(X86_FEATURE_PCID)) && !cpu_has_hypervisor; }
> >
> > The comment Avi made was regarding running a nested guest, not running
> > _as_ a nested guest (which is what cpu_has_hypervisor is about).
> >
> > You can disable INVPCID exec control (which #UDs), if its in Level-2
> > guest mode (see if_guest_mode()), and restore the Level-1 value when
> > leaving nested mode.
> 
> This "!cpu_has_hypervisor " is brought by my ignorance on nested vmx. Sorry
> for that.
> 

BTW, this 'vmx_pcid_supported' is used for determining whether X86_FEATURE_[PCID|INVPCID] should be exposed for KVM_GET_SUPPORTED_CPUID ioctl. These bits are exposed to qemu in L0 if cpuid of L0 has them, but should now always be hidden from qemu in L1 no matter cpuid of L1 has them or not. I think that, for guest hypervisor, 'do_cpuid_ent' is run in L1 which has this hypervisor bit in its cpuid, giving rise to this '!cpu_has_hypervisor'. Do I understand things in the right way?
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux