From: Marcelo Tosatti <mtosatti@redhat.com>
To: "Mao, Junjie" <junjie.mao@intel.com>
Cc: "nyh@math.technion.ac.il" <nyh@math.technion.ac.il>,
"'kvm@vger.kernel.org'" <kvm@vger.kernel.org>
Subject: Re: [PATCH v3] KVM: x86: Implement PCID/INVPCID for guests with EPT
Date: Tue, 22 May 2012 22:52:11 -0300 [thread overview]
Message-ID: <20120523015211.GA19924@amt.cnet> (raw)
In-Reply-To: <EF5A1D57CFBD5A4BA5EB3ED985B6DC6E06900B@SHSMSX101.ccr.corp.intel.com>
On Tue, May 22, 2012 at 12:46:54AM +0000, Mao, Junjie wrote:
> > > > @@
> > > > > -1711,6 +1717,22 @@ static bool vmx_rdtscp_supported(void)
> > > > > return cpu_has_vmx_rdtscp();
> > > > > }
> > > > >
> > > > > +static bool vmx_pcid_supported(void) {
> > > > > + /*
> > > > > + * This function is only for determining whether to expose PCID bit
> > > > > + * in KVM_GET_SUPPORTED_CPUID ioctl. The HYPERVISOR bit is
> > used to
> > > > > + * prevent guest hypervisors from exposing it as PCID is currently
> > > > > + * not supported on L2 guests.
> > > > > + */
> > > > > + return (boot_cpu_has(X86_FEATURE_PCID)
> > && !cpu_has_hypervisor);
> > > > > +}
> > > >
> > > > This is not necessary: KVM will not expose
> > > > secondary-exec-enable-invpcid support to the L1 guest, and so L1
> > > > guest will not attempt to expose PCID support to L2 guest.
> > > >
> > >
> > > On a platform with PCID but without INVPCID, PCID will be exposed when
> > both L1 and L2 are running with '-cpu host' if the '!cpu_has_hypervisor' check
> > doesn't exist. Lacking of INVPCID doesn't prevent PCID from being exposed.
> >
> > Is it correct to expose PCID when INVPCID-EXITING is not supported ?
> >
> > That is, if INVPCID-EXITING is not supported by VMX, it should not expose PCID
> > (because INVPCID is not emulated, and as you mentioned emulating it would
> > be slow), no?
>
> Though PCID brings little performance gain without INVPCID, it doesn't prevent PCID from being exposed as these two features are controlled separately now. And there do exist platforms which has PCID but doesn't have INVPCID. It's up to the user to decide whether to use PCID when INVPCID is not present.
OK, so in case INVPCID is not available, all instructions which would
otherwise flush PCID-tagged TLB entries in VMX root operation also flush
them in VMX non root operation. Example: CR3 write.
>
> The previous patch regards PCID and INVPCID as a whole because qemu doesn't support cpuid leaf 7 configuration at present. This is not the case in this version.
> > The problem with cpu_has_hypervisor check is that its Linux specific.
> > Any solution should also take into account other OSes running as L1 guest and
> > virtualizing L2 guest.
>
> Is there any other way, which applies to all host hypervisors, to know if kvm is running as a guest hypervisor?
The point is that other hypervisor might be running as L1 guest.
The problem with enabling PCID for the L2 guest is that it
can share same PCID values with the L1 hypervisor.
However, if the L1 hypervisor enables and configures VPID (given that
the L0 hypervisor emulates and exposes it), there is no problem
in enabling PCID for both L1 and L2 guests because TLB entries
will be differentiated by their VPID values, even if their PCID
values are the same.
So i think that checking whether EPT _and_ VPID are supported
should be a precondition to enable PCID support for guests.
next prev parent reply other threads:[~2012-05-23 1:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-18 6:17 [PATCH v3] KVM: x86: Implement PCID/INVPCID for guests with EPT Mao, Junjie
2012-05-18 21:51 ` Marcelo Tosatti
2012-05-21 0:40 ` Mao, Junjie
2012-05-21 22:38 ` Marcelo Tosatti
2012-05-22 0:46 ` Mao, Junjie
2012-05-23 1:52 ` Marcelo Tosatti [this message]
2012-05-23 5:02 ` Mao, Junjie
2012-05-25 0:59 ` Marcelo Tosatti
2012-05-29 14:19 ` Avi Kivity
2012-06-14 2:02 ` Mao, Junjie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120523015211.GA19924@amt.cnet \
--to=mtosatti@redhat.com \
--cc=junjie.mao@intel.com \
--cc=kvm@vger.kernel.org \
--cc=nyh@math.technion.ac.il \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox