From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sheng Yang Subject: Re: [PATCH] KVM: VMX: Add instruction rdtscp support for guest Date: Thu, 10 Dec 2009 09:17:30 +0800 Message-ID: <200912100917.30530.sheng@linux.intel.com> References: <1260349884-23512-1-git-send-email-sheng@linux.intel.com> <4B1F73E6.2040607@redhat.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mga05.intel.com ([192.55.52.89]:51099 "EHLO fmsmga101.fm.intel.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758665AbZLJBRb (ORCPT ); Wed, 9 Dec 2009 20:17:31 -0500 In-Reply-To: <4B1F73E6.2040607@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wednesday 09 December 2009 17:54:46 Avi Kivity wrote: > On 12/09/2009 11:11 AM, Sheng Yang wrote: > > Before enabling, execution of "rdtscp" in guest would result in #UD. > > > > Signed-off-by: Sheng Yang > > --- > > arch/x86/include/asm/vmx.h | 1 + > > arch/x86/kvm/vmx.c | 3 ++- > > 2 files changed, 3 insertions(+), 1 deletions(-) > > > > diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h > > index 2b49454..8c39320 100644 > > --- a/arch/x86/include/asm/vmx.h > > +++ b/arch/x86/include/asm/vmx.h > > @@ -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 > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > > index 9a0a2cf..e1a2ed2 100644 > > --- a/arch/x86/kvm/vmx.c > > +++ b/arch/x86/kvm/vmx.c > > @@ -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). Yeah, I realize this later last night... Though it passed my testing program. Would update it soon. -- regards Yang, Sheng