From: Boris Ostrovsky Date: Wed, 25 Apr 2012 12:53:14 +0000 (+0100) Subject: svm: Do not intercept RDTSC(P) when TSC scaling is supported by hardware X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~8555 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4aab59a3c58a3d009f26d3198730256f92193698;p=xen.git svm: Do not intercept RDTSC(P) when TSC scaling is supported by hardware When running in TSC_MODE_ALWAYS_EMULATE mode on processors that support TSC scaling we don't need to intercept RDTSC/RDTSCP instructions. Signed-off-by: Boris Ostrovsky Acked-by: Wei Huang Tested-by: Wei Huang Committed-by: Keir Fraser --- diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 5d9db5694d..6b7b653c21 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -724,12 +724,19 @@ static void svm_set_rdtsc_exiting(struct vcpu *v, bool_t enable) { struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb; u32 general1_intercepts = vmcb_get_general1_intercepts(vmcb); + u32 general2_intercepts = vmcb_get_general2_intercepts(vmcb); general1_intercepts &= ~GENERAL1_INTERCEPT_RDTSC; - if ( enable ) + general2_intercepts &= ~GENERAL2_INTERCEPT_RDTSCP; + + if ( enable && !cpu_has_tsc_ratio ) + { general1_intercepts |= GENERAL1_INTERCEPT_RDTSC; + general2_intercepts |= GENERAL2_INTERCEPT_RDTSCP; + } vmcb_set_general1_intercepts(vmcb, general1_intercepts); + vmcb_set_general2_intercepts(vmcb, general2_intercepts); } static unsigned int svm_get_insn_bytes(struct vcpu *v, uint8_t *buf)