From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: Re: [PATCH] svm: Do not intercept RDTCS(P) when TSC scaling is supported by hardware Date: Fri, 20 Apr 2012 09:15:03 +0100 Message-ID: <4F913727020000780007EC7A@nat28.tlf.novell.com> References: <55bf11ebce87ceb73fb2.1334888477@wotan.osrc.amd.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <55bf11ebce87ceb73fb2.1334888477@wotan.osrc.amd.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Boris Ostrovsky Cc: wei.huang2@amd.com, keir@xen.org, xen-devel List-Id: xen-devel@lists.xenproject.org >>> On 20.04.12 at 04:21, Boris Ostrovsky wrote: > # HG changeset patch > # User Boris Ostrovsky > # Date 1334875170 14400 > # Node ID 55bf11ebce87ceb73fb2c372dcef170ec0bb4a18 > # Parent 7c777cb8f705411b77c551f34ba88bdc09e38ab8 > svm: Do not intercept RDTCS(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. While the patch itself looks fine, I'm having difficulty to connect the mentioning of TSC_MODE_ALWAYS_EMULATE to it - afaics all modes are affected as long as they result in d->arch.vtsc to be set. Jan > Signed-off-by: Boris Ostrovsky > Acked-by: Wei Huang > Tested-by: Wei Huang > > diff -r 7c777cb8f705 -r 55bf11ebce87 xen/arch/x86/hvm/svm/svm.c > --- a/xen/arch/x86/hvm/svm/svm.c Wed Apr 18 16:49:55 2012 +0100 > +++ b/xen/arch/x86/hvm/svm/svm.c Thu Apr 19 18:39:30 2012 -0400 > @@ -724,12 +724,18 @@ static void svm_set_rdtsc_exiting(struct > { > 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)