From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: jbeulich@suse.com, ian.campbell@citrix.com,
ian.jackson@eu.citrix.com, stefano.stabellini@eu.citrix.com,
eddie.dong@intel.com, kevin.tian@intel.com
Cc: yang.z.zhang@intel.com, andrew.cooper3@citrix.com,
boris.ostrovsky@oracle.com, xen-devel@lists.xen.org
Subject: [PATCH v9 3/3] x86/hvm: Indicate avaliability of HW support of APIC virtualization to HVM guests
Date: Tue, 22 Apr 2014 15:17:43 -0400 [thread overview]
Message-ID: <1398194263-21858-4-git-send-email-boris.ostrovsky@oracle.com> (raw)
In-Reply-To: <1398194263-21858-1-git-send-email-boris.ostrovsky@oracle.com>
Set bits in hypervisor CPUID leaf indicating that HW provides (and the
hypervisor enables) HW support for APIC and x2APIC virtualization.
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
xen/arch/x86/hvm/vmx/vmx.c | 21 +++++++++++++++++++++
xen/include/public/arch-x86/cpuid.h | 4 ++++
2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 180cf6c..9fbd2f9 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -57,6 +57,7 @@
#include <asm/apic.h>
#include <asm/hvm/nestedhvm.h>
#include <asm/event.h>
+#include <public/arch-x86/cpuid.h>
enum handler_return { HNDL_done, HNDL_unhandled, HNDL_exception_raised };
@@ -1651,6 +1652,25 @@ static void vmx_handle_eoi(u8 vector)
__vmwrite(GUEST_INTR_STATUS, status);
}
+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;
+printk("cpu_has_vmx_apic_reg_virt=0x%x cpu_has_vmx_virtualize_x2apic_mode=0x%x cpu_has_vmx_apic_reg_virt=0x%x cpu_has_vmx_virtual_intr_delivery=0x%x\n", cpu_has_vmx_apic_reg_virt, cpu_has_vmx_virtualize_x2apic_mode, cpu_has_vmx_apic_reg_virt, cpu_has_vmx_virtual_intr_delivery);
+ if ( cpu_has_vmx_apic_reg_virt )
+ *eax |= XEN_HVM_CPUID_APIC_ACCESS_VIRT;
+ /*
+ * We want to claim that x2APIC is virtualized if APIC MSR accesses are
+ * not intercepted. When all three of these are true both rdmsr and wrmsr
+ * in the guest will run without VMEXITs (see vmx_vlapic_msr_changed()).
+ */
+ if ( cpu_has_vmx_virtualize_x2apic_mode && cpu_has_vmx_apic_reg_virt &&
+ cpu_has_vmx_virtual_intr_delivery)
+ *eax |= XEN_HVM_CPUID_X2APIC_VIRT;
+}
+
static struct hvm_function_table __initdata vmx_function_table = {
.name = "VMX",
.cpu_up_prepare = vmx_cpu_up_prepare,
@@ -1708,6 +1728,7 @@ static struct hvm_function_table __initdata vmx_function_table = {
.sync_pir_to_irr = vmx_sync_pir_to_irr,
.handle_eoi = vmx_handle_eoi,
.nhvm_hap_walk_L1_p2m = nvmx_hap_walk_L1_p2m,
+ .hypervisor_cpuid_leaf= vmx_hypervisor_cpuid_leaf,
};
const struct hvm_function_table * __init start_vmx(void)
diff --git a/xen/include/public/arch-x86/cpuid.h b/xen/include/public/arch-x86/cpuid.h
index fff972a..7135d54 100644
--- a/xen/include/public/arch-x86/cpuid.h
+++ b/xen/include/public/arch-x86/cpuid.h
@@ -70,6 +70,10 @@
* HVM-specific features
*/
+/* EAX Features */
+#define XEN_HVM_CPUID_APIC_ACCESS_VIRT (1u << 0) /* Virtualized APIC registers */
+#define XEN_HVM_CPUID_X2APIC_VIRT (1u << 1) /* Virtualized x2APIC accesses */
+
#define XEN_CPUID_MAX_NUM_LEAVES 4
#endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */
--
1.7.1
next prev parent reply other threads:[~2014-04-22 19:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-22 19:17 [PATCH v9 0/3] Expose HW APIC virtualization support to HVM guests Boris Ostrovsky
2014-04-22 19:17 ` [PATCH v9 1/3] xen/libxc: Allow changing max number of hypervisor cpuid leaves Boris Ostrovsky
2014-04-23 8:42 ` Ian Campbell
2014-04-23 9:46 ` Jan Beulich
2014-04-24 0:36 ` Zhang, Yang Z
2014-05-06 15:23 ` Boris Ostrovsky
2014-05-06 15:35 ` Jan Beulich
2014-04-22 19:17 ` [PATCH v9 2/3] x86/hvm: Add HVM-specific hypervisor CPUID leaf Boris Ostrovsky
2014-04-22 19:17 ` Boris Ostrovsky [this message]
2014-04-23 9:44 ` [PATCH v9 3/3] x86/hvm: Indicate avaliability of HW support of APIC virtualization to HVM guests Jan Beulich
2014-04-23 13:27 ` Boris Ostrovsky
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=1398194263-21858-4-git-send-email-boris.ostrovsky@oracle.com \
--to=boris.ostrovsky@oracle.com \
--cc=andrew.cooper3@citrix.com \
--cc=eddie.dong@intel.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=kevin.tian@intel.com \
--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).