From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: "Zhang, Yang Z" <yang.z.zhang@intel.com>,
Jan Beulich <JBeulich@suse.com>
Cc: "keir@xen.org" <keir@xen.org>,
"ian.campbell@citrix.com" <ian.campbell@citrix.com>,
"stefano.stabellini@eu.citrix.com"
<stefano.stabellini@eu.citrix.com>,
"andrew.cooper3@citrix.com" <andrew.cooper3@citrix.com>,
"Dong, Eddie" <eddie.dong@intel.com>,
"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>,
"Nakajima, Jun" <jun.nakajima@intel.com>,
"ian.jackson@eu.citrix.com" <ian.jackson@eu.citrix.com>
Subject: Re: [PATCH v7 3/3] x86/hvm: Indicate avaliability of HW support of APIC virtualization to HVM guests
Date: Tue, 01 Apr 2014 11:39:17 -0400 [thread overview]
Message-ID: <533ADDA5.2000909@oracle.com> (raw)
In-Reply-To: <A9667DDFB95DB7438FA9D7D576C3D87E0AA22CA7@SHSMSX104.ccr.corp.intel.com>
On 03/25/2014 09:03 PM, Zhang, Yang Z wrote:
> Boris Ostrovsky wrote on 2014-03-25:
>> On 03/25/2014 05:45 AM, Jan Beulich wrote:
>>>>>> On 25.03.14 at 00:18, <boris.ostrovsky@oracle.com> wrote:
>>>> +void vmx_hypervisor_cpuid_leaf(uint32_t sub_idx,
>>>> + uint32_t *eax, uint32_t *ebx,
>>>> + uint32_t *ecx, uint32_t *edx) {
>>>> + if ( sub_idx != 0 )
>>>> + return;
>>>> +
>>>> + if ( cpu_has_vmx_apic_reg_virt )
>>>> + *eax |= XEN_HVM_CPUID_APIC_ACCESS_VIRT;
>>>> + if ( cpu_has_vmx_virtualize_x2apic_mode )
>>>> + *eax |= XEN_HVM_CPUID_X2APIC_VIRT; }
>>> So did the two of you then settle on (a) needing to expose two bits
>>> rather than just one and (b) these being the two relevant features
>>> to expose?
>> My argument is that we can't know which APIC model a guest uses and so
>> both are needed. For PVHVM we default to APIC (MMIO accesses), I can't
>> remember what unenlightened HVM Linux would do. And then there are
>> other OSs.
>>
>> For (b) having either (or both) of these two seems to be sufficient to
>> bring down the number of VMEXITs when switching from pirqs to APIC.
>> It's more important to agree on (a) since for (b) we can always add another bit.
> In currently Xen, virtualize_x2apic_mode takes effect only when APICv is enabled. Without APICv, virtualize_x2apic_mode is never set.
> Per your request, you only want to drop the pirqs if guest is using x2apic. So, just check it inside guest OS is enough. NB: to use x2apic for guest doesn't require the virtualize_x2apic_mode been set.
Yang and I talked a bit off-list and I don't think there was an
agreement on this.
Here is a simple experiment to demonstrate why exposing
virtualize_x2apic_mode is important (with one correction to what I said
earlier: PVHVM guest will actualy default to x2apic, at least on Intel
CPUs):
With existing code (using pirqs, i.e. no APIC/x2apic accesses), VMEXIT
stats look as follows:
14397 HLT
22420 INJ_VIRQ
8551 INTR
29849 INTR_WINDOW
4 MMIO_READ
2 MMIO_WRITE
628 TRAP
2 unknown
78157 VMENTRY
78157 VMEXIT
29299 VMMCALL
Without pirqs (i.e. guest using x2APIC), and with virtualized x2apic,
virtualized APIC register accesses:
15572 HLT
164 INJ_VIRQ
4218 INTR
184 INTR_WINDOW
624 TRAP
23199 VMENTRY
23198 VMEXIT
2607 VMMCALL
Without pirqs (again, guest uses x2APIC), without virtualized x2apic
support but with virtualized APIC register access (which can be
simulated by having msr_high of MSR_IA32_VMX_PROCBASED_CTLS2 clear bit 4):
53 cpu_change
18674 HLT
226 INJ_VIRQ
11702 INTR
294 INTR_WINDOW
35186 MSR_WRITE
791 TRAP
70441 VMENTRY
70440 VMEXIT
3823 VMMCALL
In other words, if the guest is unaware of the fact that x2apic is not
virtualized, it will disable pirqs for no good reason.
-boris
next prev parent reply other threads:[~2014-04-01 15:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-24 23:18 [PATCH v7 0/3] Expose HW APIC virtualization support to HVM guests Boris Ostrovsky
2014-03-24 23:18 ` [PATCH v7 1/3] xen/libxc: Allow changing max number of hypervisor cpuid leaves Boris Ostrovsky
2014-03-25 9:42 ` Jan Beulich
2014-03-27 13:13 ` Ian Campbell
2014-03-27 14:04 ` Boris Ostrovsky
2014-03-27 14:46 ` Ian Campbell
2014-03-24 23:18 ` [PATCH v7 2/3] x86/hvm: Add HVM-specific hypervisor CPUID leaf Boris Ostrovsky
2014-03-25 9:43 ` Jan Beulich
2014-03-24 23:18 ` [PATCH v7 3/3] x86/hvm: Indicate avaliability of HW support of APIC virtualization to HVM guests Boris Ostrovsky
2014-03-25 9:45 ` Jan Beulich
2014-03-25 13:34 ` Boris Ostrovsky
2014-03-26 1:03 ` Zhang, Yang Z
2014-04-01 15:39 ` Boris Ostrovsky [this message]
2014-04-02 1:24 ` Zhang, Yang Z
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=533ADDA5.2000909@oracle.com \
--to=boris.ostrovsky@oracle.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=eddie.dong@intel.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jun.nakajima@intel.com \
--cc=keir@xen.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
--cc=yang.z.zhang@intel.com \
/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;
as well as URLs for NNTP newsgroup(s).