# HG changeset patch
# User Eddie Dong <eddie.dong@xxxxxxxxx>
# Date 1307607849 -28800
# Node ID 480cfcea095bddb2e7c495a092632e80d552332d
# Parent 3189a3e6f05ecc7e14bc55e944c48d7e50613a96
n2 MSR handling and capability exposure
Signed-off-by: Qing He <qing.he@xxxxxxxxx>
Signed-off-by: Eddie Dong <eddie.dong@xxxxxxxxx>
diff -r 3189a3e6f05e -r 480cfcea095b xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c Thu Jun 09 16:24:09 2011 +0800
+++ b/xen/arch/x86/hvm/vmx/vmx.c Thu Jun 09 16:24:09 2011 +0800
@@ -1778,8 +1778,11 @@ static int vmx_msr_read_intercept(unsign
*msr_content |= (u64)__vmread(GUEST_IA32_DEBUGCTL_HIGH) << 32;
#endif
break;
- case MSR_IA32_VMX_BASIC...MSR_IA32_VMX_PROCBASED_CTLS2:
- goto gp_fault;
+ case IA32_FEATURE_CONTROL_MSR:
+ case MSR_IA32_VMX_BASIC...MSR_IA32_VMX_TRUE_ENTRY_CTLS:
+ if ( !nvmx_msr_read_intercept(msr, msr_content) )
+ goto gp_fault;
+ break;
case MSR_IA32_MISC_ENABLE:
rdmsrl(MSR_IA32_MISC_ENABLE, *msr_content);
/* Debug Trace Store is not supported. */
@@ -1940,8 +1943,11 @@ static int vmx_msr_write_intercept(unsig
break;
}
- case MSR_IA32_VMX_BASIC...MSR_IA32_VMX_PROCBASED_CTLS2:
- goto gp_fault;
+ case IA32_FEATURE_CONTROL_MSR:
+ case MSR_IA32_VMX_BASIC...MSR_IA32_VMX_TRUE_ENTRY_CTLS:
+ if ( !nvmx_msr_write_intercept(msr, msr_content) )
+ goto gp_fault;
+ break;
default:
if ( vpmu_do_wrmsr(msr, msr_content) )
return X86EMUL_OKAY;
diff -r 3189a3e6f05e -r 480cfcea095b xen/arch/x86/hvm/vmx/vvmx.c
--- a/xen/arch/x86/hvm/vmx/vvmx.c Thu Jun 09 16:24:09 2011 +0800
+++ b/xen/arch/x86/hvm/vmx/vvmx.c Thu Jun 09 16:24:09 2011 +0800
@@ -22,6 +22,7 @@
#include <xen/config.h>
#include <asm/types.h>
+#include <asm/mtrr.h>
#include <asm/p2m.h>
#include <asm/hvm/vmx/vmx.h>
#include <asm/hvm/vmx/vvmx.h>
@@ -1254,6 +1255,100 @@ int nvmx_handle_vmwrite(struct cpu_user_
return X86EMUL_OKAY;
}
+/*
+ * Capability reporting
+ */
+int nvmx_msr_read_intercept(unsigned int msr, u64 *msr_content)
+{
+ u64 data = 0, tmp;
+ int r = 1;
+
+ if ( !nestedhvm_enabled(current->domain) )
+ return 0;
+
+ /*
+ * Remove unsupport features from n1 guest capability MSR
+ */
+ switch (msr) {
+ case MSR_IA32_VMX_BASIC:
+ data = VVMCS_REVISION | (PAGE_SIZE) << 32 |
+ ((u64)MTRR_TYPE_WRBACK) << 50 | (1L << 55);
+ break;
+ case MSR_IA32_VMX_PINBASED_CTLS:
+ /* 1-seetings */
+ data = PIN_BASED_EXT_INTR_MASK | PIN_BASED_NMI_EXITING;
+ data <<= 32;
+ /* 0-settings */
+ data |= 0;
+ break;
+ case MSR_IA32_VMX_PROCBASED_CTLS:
+ /* 1-seetings */
+ data = (CPU_BASED_HLT_EXITING |
+ CPU_BASED_VIRTUAL_INTR_PENDING |
+ CPU_BASED_CR8_LOAD_EXITING |
+ CPU_BASED_CR8_STORE_EXITING |
+ CPU_BASED_INVLPG_EXITING |
+ CPU_BASED_CR3_LOAD_EXITING |
+ CPU_BASED_CR3_STORE_EXITING |
+ CPU_BASED_MONITOR_EXITING |
+ CPU_BASED_MWAIT_EXITING |
+ CPU_BASED_MOV_DR_EXITING |
+ CPU_BASED_ACTIVATE_IO_BITMAP |
+ CPU_BASED_USE_TSC_OFFSETING |
+ CPU_BASED_UNCOND_IO_EXITING |
+ CPU_BASED_RDTSC_EXITING);
+ /* bit 1, 4-6,8,13-16,26 must be 1 (refer G4 of SDM) */
+ tmp = ( (1<<26) | (0xf << 13) | 0x100 | (0x7 << 4) | 0x2);
+ /* 0-settings */
+ data = ((data | tmp) << 32) | (tmp);
+ break;
+ case MSR_IA32_VMX_EXIT_CTLS:
+ /* 1-seetings */
+ /* bit 0-8, 10,11,13,14,16,17 must be 1 (refer G4 of SDM) */
+ tmp = 0x36dff;
+ data = VM_EXIT_ACK_INTR_ON_EXIT;
+#ifdef __x86_64__
+ data |= VM_EXIT_IA32E_MODE;
+#endif
+ /* 0-settings */
+ data = ((data | tmp) << 32) | tmp;
+ break;
+ case MSR_IA32_VMX_ENTRY_CTLS:
+ /* bit 0-8, and 12 must be 1 (refer G5 of SDM) */
+ data = 0x11ff;
+ data |= VM_ENTRY_IA32E_MODE;
+ data = (data << 32) | data;
+ break;
+
+ case IA32_FEATURE_CONTROL_MSR:
+ data = IA32_FEATURE_CONTROL_MSR_LOCK |
+ IA32_FEATURE_CONTROL_MSR_ENABLE_VMXON_OUTSIDE_SMX;
+ break;
+ /* pass through MSRs */
+ case MSR_IA32_VMX_MISC:
+ case MSR_IA32_VMX_CR0_FIXED0:
+ case MSR_IA32_VMX_CR0_FIXED1:
+ case MSR_IA32_VMX_CR4_FIXED0:
+ case MSR_IA32_VMX_CR4_FIXED1:
+ case MSR_IA32_VMX_VMCS_ENUM:
+ gdprintk(XENLOG_WARNING, "VMX MSR %x not fully supported yet.\n", msr);
+ break;
+
+ default:
+ r = 0;
+ break;
+ }
+
+ *msr_content = data;
+ return r;
+}
+
+int nvmx_msr_write_intercept(unsigned int msr, u64 msr_content)
+{
+ /* silently ignore for now */
+ return 1;
+}
+
void nvmx_idtv_handling(void)
{
struct vcpu *v = current;
diff -r 3189a3e6f05e -r 480cfcea095b xen/include/asm-x86/hvm/vmx/vvmx.h
--- a/xen/include/asm-x86/hvm/vmx/vvmx.h Thu Jun 09 16:24:09 2011 +0800
+++ b/xen/include/asm-x86/hvm/vmx/vvmx.h Thu Jun 09 16:24:09 2011 +0800
@@ -163,6 +163,10 @@ int nvmx_handle_vmread(struct cpu_user_r
int nvmx_handle_vmwrite(struct cpu_user_regs *regs);
int nvmx_handle_vmresume(struct cpu_user_regs *regs);
int nvmx_handle_vmlaunch(struct cpu_user_regs *regs);
+int nvmx_msr_read_intercept(unsigned int msr,
+ u64 *msr_content);
+int nvmx_msr_write_intercept(unsigned int msr,
+ u64 msr_content);
void nvmx_update_exec_control(struct vcpu *v, u32 value);
void nvmx_update_secondary_exec_control(struct vcpu *v,
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|