All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: VMX: Add instruction rdtscp support for guest
@ 2009-12-09  9:11 Sheng Yang
  2009-12-09  9:54 ` Avi Kivity
  0 siblings, 1 reply; 4+ messages in thread
From: Sheng Yang @ 2009-12-09  9:11 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: kvm, Sheng Yang

Before enabling, execution of "rdtscp" in guest would result in #UD.

Signed-off-by: Sheng Yang <sheng@linux.intel.com>
---
 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)
-- 
1.5.4.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: VMX: Add instruction rdtscp support for guest
  2009-12-09  9:11 [PATCH] KVM: VMX: Add instruction rdtscp support for guest Sheng Yang
@ 2009-12-09  9:54 ` Avi Kivity
  2009-12-10  1:17   ` Sheng Yang
  0 siblings, 1 reply; 4+ messages in thread
From: Avi Kivity @ 2009-12-09  9:54 UTC (permalink / raw)
  To: Sheng Yang; +Cc: Marcelo Tosatti, kvm

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<sheng@linux.intel.com>
> ---
>   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).

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: VMX: Add instruction rdtscp support for guest
  2009-12-09  9:54 ` Avi Kivity
@ 2009-12-10  1:17   ` Sheng Yang
  2009-12-10  9:28     ` Avi Kivity
  0 siblings, 1 reply; 4+ messages in thread
From: Sheng Yang @ 2009-12-10  1:17 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Marcelo Tosatti, kvm

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<sheng@linux.intel.com>
> > ---
> >   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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: VMX: Add instruction rdtscp support for guest
  2009-12-10  1:17   ` Sheng Yang
@ 2009-12-10  9:28     ` Avi Kivity
  0 siblings, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2009-12-10  9:28 UTC (permalink / raw)
  To: Sheng Yang; +Cc: Marcelo Tosatti, kvm

On 12/10/2009 03:17 AM, Sheng Yang wrote:
> 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.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-12-10  9:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-09  9:11 [PATCH] KVM: VMX: Add instruction rdtscp support for guest Sheng Yang
2009-12-09  9:54 ` Avi Kivity
2009-12-10  1:17   ` Sheng Yang
2009-12-10  9:28     ` Avi Kivity

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.