# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1275372792 -3600
# Node ID 6e77bf0852ecbea205ec96b175461a42a34c47a0
# Parent e9110e15235c422949ca8f255085adef57f3c798
EPT 2M super page detection
Signed-off-by: Xin Li <xin.li@xxxxxxxxx>
---
xen/arch/x86/hvm/svm/svm.c | 2 ++
xen/arch/x86/hvm/vmx/vmcs.c | 12 ++++++++++++
xen/arch/x86/hvm/vmx/vmx.c | 7 +++++++
xen/arch/x86/mm/p2m.c | 4 ++--
xen/include/asm-x86/hvm/hvm.h | 12 ++++++++++++
xen/include/asm-x86/hvm/vmx/vmcs.h | 6 ++++++
xen/include/asm-x86/msr-index.h | 1 +
7 files changed, 42 insertions(+), 2 deletions(-)
diff -r e9110e15235c -r 6e77bf0852ec xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c Wed May 26 08:29:15 2010 +0100
+++ b/xen/arch/x86/hvm/svm/svm.c Tue Jun 01 07:13:12 2010 +0100
@@ -903,6 +903,8 @@ void start_svm(struct cpuinfo_x86 *c)
svm_function_table.hap_supported = cpu_has_svm_npt;
+ svm_function_table.hap_capabilities = HVM_HAP_SUPERPAGE_2MB;
+
hvm_enable(&svm_function_table);
}
diff -r e9110e15235c -r 6e77bf0852ec xen/arch/x86/hvm/vmx/vmcs.c
--- a/xen/arch/x86/hvm/vmx/vmcs.c Wed May 26 08:29:15 2010 +0100
+++ b/xen/arch/x86/hvm/vmx/vmcs.c Tue Jun 01 07:13:12 2010 +0100
@@ -64,6 +64,7 @@ u32 vmx_secondary_exec_control __read_mo
u32 vmx_secondary_exec_control __read_mostly;
u32 vmx_vmexit_control __read_mostly;
u32 vmx_vmentry_control __read_mostly;
+u64 vmx_ept_vpid_cap __read_mostly;
bool_t cpu_has_vmx_ins_outs_instr_info __read_mostly;
static DEFINE_PER_CPU_READ_MOSTLY(struct vmcs_struct *, host_vmcs);
@@ -90,6 +91,9 @@ static void __init vmx_display_features(
if ( !printed )
printk(" - none\n");
+
+ if ( cpu_has_vmx_ept_2mb )
+ printk("EPT supports 2MB super page.\n");
}
static u32 adjust_vmx_controls(u32 ctl_min, u32 ctl_opt, u32 msr)
@@ -113,6 +117,7 @@ static void vmx_init_vmcs_config(void)
u32 _vmx_pin_based_exec_control;
u32 _vmx_cpu_based_exec_control;
u32 _vmx_secondary_exec_control = 0;
+ u64 _vmx_ept_vpid_cap = 0;
u32 _vmx_vmexit_control;
u32 _vmx_vmentry_control;
@@ -185,6 +190,11 @@ static void vmx_init_vmcs_config(void)
SECONDARY_EXEC_UNRESTRICTED_GUEST);
}
+ /* The IA32_VMX_EPT_VPID_CAP MSR exists only when EPT or VPID available */
+ if ( _vmx_secondary_exec_control &
+ (SECONDARY_EXEC_ENABLE_EPT | SECONDARY_EXEC_ENABLE_VPID) )
+ rdmsrl(MSR_IA32_VMX_EPT_VPID_CAP, _vmx_ept_vpid_cap);
+
if ( (_vmx_secondary_exec_control & SECONDARY_EXEC_PAUSE_LOOP_EXITING) &&
ple_gap == 0 )
{
@@ -219,6 +229,7 @@ static void vmx_init_vmcs_config(void)
vmx_pin_based_exec_control = _vmx_pin_based_exec_control;
vmx_cpu_based_exec_control = _vmx_cpu_based_exec_control;
vmx_secondary_exec_control = _vmx_secondary_exec_control;
+ vmx_ept_vpid_cap = _vmx_ept_vpid_cap;
vmx_vmexit_control = _vmx_vmexit_control;
vmx_vmentry_control = _vmx_vmentry_control;
cpu_has_vmx_ins_outs_instr_info = !!(vmx_basic_msr_high & (1U<<22));
@@ -231,6 +242,7 @@ static void vmx_init_vmcs_config(void)
BUG_ON(vmx_pin_based_exec_control != _vmx_pin_based_exec_control);
BUG_ON(vmx_cpu_based_exec_control != _vmx_cpu_based_exec_control);
BUG_ON(vmx_secondary_exec_control != _vmx_secondary_exec_control);
+ BUG_ON(vmx_ept_vpid_cap != _vmx_ept_vpid_cap);
BUG_ON(vmx_vmexit_control != _vmx_vmexit_control);
BUG_ON(vmx_vmentry_control != _vmx_vmentry_control);
BUG_ON(cpu_has_vmx_ins_outs_instr_info !=
diff -r e9110e15235c -r 6e77bf0852ec xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c Wed May 26 08:29:15 2010 +0100
+++ b/xen/arch/x86/hvm/vmx/vmx.c Tue Jun 01 07:13:12 2010 +0100
@@ -1444,7 +1444,14 @@ void start_vmx(void)
}
if ( cpu_has_vmx_ept )
+ {
vmx_function_table.hap_supported = 1;
+
+ vmx_function_table.hap_capabilities = 0;
+
+ if ( cpu_has_vmx_ept_2mb )
+ vmx_function_table.hap_capabilities |= HVM_HAP_SUPERPAGE_2MB;
+ }
setup_vmcs_dump();
diff -r e9110e15235c -r 6e77bf0852ec xen/arch/x86/mm/p2m.c
--- a/xen/arch/x86/mm/p2m.c Wed May 26 08:29:15 2010 +0100
+++ b/xen/arch/x86/mm/p2m.c Tue Jun 01 07:13:12 2010 +0100
@@ -1596,8 +1596,8 @@ int set_p2m_entry(struct domain *d, unsi
while ( todo )
{
if ( is_hvm_domain(d) && d->arch.hvm_domain.hap_enabled )
- order = (((gfn | mfn_x(mfn) | todo) & (SUPERPAGE_PAGES - 1)) == 0)
?
- 9 : 0;
+ order = ((((gfn | mfn_x(mfn) | todo) & (SUPERPAGE_PAGES - 1)) == 0)
+ && hvm_hap_has_2mb(d)) ? 9 : 0;
else
order = 0;
if ( !d->arch.p2m->set_entry(d, gfn, mfn, order, p2mt) )
diff -r e9110e15235c -r 6e77bf0852ec xen/include/asm-x86/hvm/hvm.h
--- a/xen/include/asm-x86/hvm/hvm.h Wed May 26 08:29:15 2010 +0100
+++ b/xen/include/asm-x86/hvm/hvm.h Tue Jun 01 07:13:12 2010 +0100
@@ -59,6 +59,12 @@ enum hvm_intblk {
#define HVM_INTR_SHADOW_NMI 0x00000008
/*
+ * HAP super page capabilities:
+ * bit0: if 2MB super page is allowed?
+ */
+#define HVM_HAP_SUPERPAGE_2MB 0x00000001
+
+/*
* The hardware virtual machine (HVM) interface abstracts away from the
* x86/x86_64 CPU virtualization assist specifics. Currently this interface
* supports Intel's VT-x and AMD's SVM extensions.
@@ -68,6 +74,9 @@ struct hvm_function_table {
/* Support Hardware-Assisted Paging? */
int hap_supported;
+
+ /* Indicate HAP capabilities. */
+ int hap_capabilities;
/*
* Initialise/destroy HVM domain/vcpu resources
@@ -163,6 +172,9 @@ int hvm_girq_dest_2_vcpu_id(struct domai
#define hvm_nx_enabled(v) \
(!!((v)->arch.hvm_vcpu.guest_efer & EFER_NX))
+#define hvm_hap_has_2mb(d) \
+ (hvm_funcs.hap_capabilities & HVM_HAP_SUPERPAGE_2MB)
+
#ifdef __x86_64__
#define hvm_long_mode_enabled(v) \
((v)->arch.hvm_vcpu.guest_efer & EFER_LMA)
diff -r e9110e15235c -r 6e77bf0852ec xen/include/asm-x86/hvm/vmx/vmcs.h
--- a/xen/include/asm-x86/hvm/vmx/vmcs.h Wed May 26 08:29:15 2010 +0100
+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h Tue Jun 01 07:13:12 2010 +0100
@@ -176,6 +176,10 @@ extern u32 vmx_secondary_exec_control;
extern bool_t cpu_has_vmx_ins_outs_instr_info;
+extern u64 vmx_ept_vpid_cap;
+
+#define VMX_EPT_SUPERPAGE_2MB 0x00010000
+
#define cpu_has_wbinvd_exiting \
(vmx_secondary_exec_control & SECONDARY_EXEC_WBINVD_EXITING)
#define cpu_has_vmx_virtualize_apic_accesses \
@@ -190,6 +194,8 @@ extern bool_t cpu_has_vmx_ins_outs_instr
(vmx_cpu_based_exec_control & CPU_BASED_ACTIVATE_SECONDARY_CONTROLS)
#define cpu_has_vmx_ept \
(vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_EPT)
+#define cpu_has_vmx_ept_2mb \
+ (vmx_ept_vpid_cap & VMX_EPT_SUPERPAGE_2MB)
#define cpu_has_vmx_vpid \
(vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_VPID)
#define cpu_has_monitor_trap_flag \
diff -r e9110e15235c -r 6e77bf0852ec xen/include/asm-x86/msr-index.h
--- a/xen/include/asm-x86/msr-index.h Wed May 26 08:29:15 2010 +0100
+++ b/xen/include/asm-x86/msr-index.h Tue Jun 01 07:13:12 2010 +0100
@@ -171,6 +171,7 @@
#define MSR_IA32_VMX_CR4_FIXED0 0x488
#define MSR_IA32_VMX_CR4_FIXED1 0x489
#define MSR_IA32_VMX_PROCBASED_CTLS2 0x48b
+#define MSR_IA32_VMX_EPT_VPID_CAP 0x48c
#define MSR_IA32_VMX_TRUE_PINBASED_CTLS 0x48d
#define MSR_IA32_VMX_TRUE_PROCBASED_CTLS 0x48e
#define MSR_IA32_VMX_TRUE_EXIT_CTLS 0x48f
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|