kvm: vmx: Pass through IA32_TSC_AUX for read iff guest has RDTSCP
PATCH v2 1/1 kvm: vmx: Pass through IA32_TSC_AUX for read iff guest has RDTSCP
If the guest supports RDTSCP, it already has read access to the hardware IA32_TSC_AUX MSR via RDTSCP, so we can allow it read access via the RDMSR instruction as well. If the guest doesn't support RDTSCP, intercept all accesses to the IA32_TSC_AUX MSR, so that kvm can synthesize a #GP. (IA32_TSC_AUX exists iff RDTSCP is supported.)
---
v1 -> v2: Rebased across vmx directory creation.
Modified commit message based on Sean's comments.
arch/x86/kvm/vmx/vmx.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/kvm/vmx/vmx.c +4 -0
@@ -4070,6 +4070,10 @@ static void vmx_compute_secondary_exec_control(struct vcpu_vmx *vmx)if (vmx_rdtscp_supported ()) {bool rdtscp_enabled =guest_cpuid_has (vcpu,X86_FEATURE_RDTSCP ); + +vmx_set_intercept_for_msr (vmx->vmcs01.msr_bitmap,MSR_TSC_AUX , +MSR_TYPE_R , !rdtscp_enabled); +if (!rdtscp_enabled) exec_control &= ~SECONDARY_EXEC_RDTSCP ;
Signature · 1 line
2.24.0.393.g34dc348eaf-goog
Quoted 10 lines · Jim Mattson
If the guest supports RDTSCP, it already has read access to the hardware
IA32_TSC_AUXMSR via RDTSCP, so we can allow it read access via the RDMSR instruction as well. If the guest doesn't support RDTSCP, intercept all accesses to theIA32_TSC_AUXMSR, so that kvm can synthesize a #GP. (IA32_TSC_AUXexists iff RDTSCP is supported.)
Quoted 5 lines
Signed-off-by Jim Mattson <[email protected]>Reviewed-by Marc Orr <[email protected]>Reviewed-by Peter Shier <[email protected]>Reviewed-by Krish Sadhukhan <[email protected]>Reviewed-by Sean Christopherson <[email protected]>
-Liran
Quoted 26 lines
---
v1 -> v2: Rebased across vmx directory creation.
Modified commit message based on Sean's comments.
arch/x86/kvm/vmx/vmx.c| 4 ++++1 file changed, 4 insertions(+)arch/x86/kvm/vmx/vmx.c +4
-0@@ -4070,6 +4070,10 @@ static void vmx_compute_secondary_exec_control(struct vcpu_vmx *vmx)if (vmx_rdtscp_supported ()) {bool rdtscp_enabled =guest_cpuid_has (vcpu,X86_FEATURE_RDTSCP ); + +vmx_set_intercept_for_msr (vmx->vmcs01.msr_bitmap,MSR_TSC_AUX , +MSR_TYPE_R , !rdtscp_enabled); +if (!rdtscp_enabled) exec_control &= ~SECONDARY_EXEC_RDTSCP ;Signature · 1 line
2.24.0.393.g34dc348eaf-goog