KVM: VMX: Add instruction rdtscp support for guest
PATCH 1/1 KVM: VMX: Add instruction rdtscp support for guest
Before enabling, execution of "rdtscp" in guest would result in #UD.
--- arch/x86/include/asm/vmx.h | 1 + arch/x86/kvm/vmx.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletions(-)
arch/x86/include/asm/vmx.h +1 -0
@@ -53,6 +53,7 @@*/ #define SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES 0x00000001#define SECONDARY_EXEC_ENABLE_EPT 0x00000002 +#define SECONDARY_EXEC_RDTSCP 0x00000008#define SECONDARY_EXEC_ENABLE_VPID 0x00000020#define SECONDARY_EXEC_WBINVD_EXITING 0x00000040#define SECONDARY_EXEC_UNRESTRICTED_GUEST 0x00000080
arch/x86/kvm/vmx.c +2 -1
@@ -1243,7 +1243,8 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf)SECONDARY_EXEC_ENABLE_VPID |SECONDARY_EXEC_ENABLE_EPT |SECONDARY_EXEC_UNRESTRICTED_GUEST | -SECONDARY_EXEC_PAUSE_LOOP_EXITING ; +SECONDARY_EXEC_PAUSE_LOOP_EXITING | +SECONDARY_EXEC_RDTSCP ;if (adjust_vmx_controls (min2, opt2,MSR_IA32_VMX_PROCBASED_CTLS2 , &_cpu_based_2nd_exec_control) <0 )
Signature · 1 line
1.5.4.5
Quoted 26 lines · Sheng Yang
Before enabling, execution of "rdtscp" in guest would result in #UD.
Signed-off-by Sheng Yang<[email protected]>--- arch/x86/include/asm/vmx.h | 1 + arch/x86/kvm/vmx.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletions(-)arch/x86/include/asm/vmx.h +1
-0@@ -53,6 +53,7 @@*/ #define SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES 0x00000001#define SECONDARY_EXEC_ENABLE_EPT 0x00000002 +#define SECONDARY_EXEC_RDTSCP 0x00000008#define SECONDARY_EXEC_ENABLE_VPID 0x00000020#define SECONDARY_EXEC_WBINVD_EXITING 0x00000040#define SECONDARY_EXEC_UNRESTRICTED_GUEST 0x00000080arch/x86/kvm/vmx.c +0
-0
arch/x86/kvm/vmx.c static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf) · line 1250
Quoted 9 lines
arch/x86/kvm/vmx.c +2
-1@@ -1243,7 +1243,8 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf)SECONDARY_EXEC_ENABLE_VPID |SECONDARY_EXEC_ENABLE_EPT |SECONDARY_EXEC_UNRESTRICTED_GUEST | -SECONDARY_EXEC_PAUSE_LOOP_EXITING ; +SECONDARY_EXEC_PAUSE_LOOP_EXITING | +SECONDARY_EXEC_RDTSCP ;if (adjust_vmx_controls (min2, opt2,MSR_IA32_VMX_PROCBASED_CTLS2 , &_cpu_based_2nd_exec_control)<0 )
Need to save/restore MSR_TSC_AUX (but only if rdtscp in cpuid), support MSR_TSC_AUX in get/save, and expose via GET_SUPPORTED_CPUID (only on processors which support the feature).
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
Quoted 31 lines · On Wednesday 09 December 2009 17:54:46 Avi Kivity wrote:
Quoted 30 lines · Sheng Yang
Before enabling, execution of "rdtscp" in guest would result in #UD.
Signed-off-by Sheng Yang<[email protected]>--- arch/x86/include/asm/vmx.h | 1 + arch/x86/kvm/vmx.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletions(-)arch/x86/include/asm/vmx.h +1
-0@@ -53,6 +53,7 @@*/ #define SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES 0x00000001#define SECONDARY_EXEC_ENABLE_EPT 0x00000002 +#define SECONDARY_EXEC_RDTSCP 0x00000008#define SECONDARY_EXEC_ENABLE_VPID 0x00000020#define SECONDARY_EXEC_WBINVD_EXITING 0x00000040#define SECONDARY_EXEC_UNRESTRICTED_GUEST 0x00000080arch/x86/kvm/vmx.c +0
-0@@ -1243,7 +1243,8 @@ static __init int setup_vmcs_config(struct
vmcs_config*vmcs_conf)SECONDARY_EXEC_ENABLE_VPID|
SECONDARY_EXEC_ENABLE_EPT|SECONDARY_EXEC_UNRESTRICTED_GUEST|arch/x86/kvm/vmx.c +1
-1-SECONDARY_EXEC_PAUSE_LOOP_EXITING ; + SECONDARY_EXEC_PAUSE_LOOP_EXITING |
Quoted 8 lines
arch/x86/kvm/vmx.c static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf)
Quoted 4 lines
arch/x86/kvm/vmx.c +1
-0+SECONDARY_EXEC_RDTSCP ;if (adjust_vmx_controls (min2, opt2,MSR_IA32_VMX_PROCBASED_CTLS2 , &_cpu_based_2nd_exec_control)<0 )Need to save/restore
MSR_TSC_AUX(but only if rdtscp in cpuid), supportMSR_TSC_AUXin get/save, and expose viaGET_SUPPORTED_CPUID(only on processors which support the feature).
Yeah, I realize this later last night... Though it passed my testing program.
Would update it soon.
Signature · 2 lines
regards Yang, Sheng
Quoted 1 line · Sheng Yang
Yeah, I realize this later last night... Though it passed my testing program.
Please post the test program as well... it's now easy to extend kvm/user/test since it runs with qemu -kernel.
Signature · 1 line
error compiling committee.c: too many arguments to function