diff mbox series

[v3,1/4] kvm: vmx: Set IA32_TSC_AUX for legacy mode guests

Message ID 20181112204401.261404-1-jmattson@google.com (mailing list archive)
State New, archived
Headers show
Series [v3,1/4] kvm: vmx: Set IA32_TSC_AUX for legacy mode guests | expand

Commit Message

Jim Mattson Nov. 12, 2018, 8:44 p.m. UTC
RDTSCP is supported in legacy mode as well as long mode. The
IA32_TSC_AUX MSR should be set to the correct guest value before
entering any guest that supports RDTSCP.

Fixes: 4e47c7a6d714 ("KVM: VMX: Add instruction rdtscp support for guest")
Signed-off-by: Jim Mattson <jmattson@google.com>
Reviewed-by: Peter Shier <pshier@google.com>
Reviewed-by: Marc Orr <marcorr@google.com>
Reviewed-by: Liran Alon <liran.alon@oracle.com>
---
 arch/x86/kvm/vmx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Jim Mattson Nov. 30, 2018, 5:36 p.m. UTC | #1
Ping.
On Mon, Nov 12, 2018 at 12:44 PM Jim Mattson <jmattson@google.com> wrote:
>
> RDTSCP is supported in legacy mode as well as long mode. The
> IA32_TSC_AUX MSR should be set to the correct guest value before
> entering any guest that supports RDTSCP.
>
> Fixes: 4e47c7a6d714 ("KVM: VMX: Add instruction rdtscp support for guest")
> Signed-off-by: Jim Mattson <jmattson@google.com>
> Reviewed-by: Peter Shier <pshier@google.com>
> Reviewed-by: Marc Orr <marcorr@google.com>
> Reviewed-by: Liran Alon <liran.alon@oracle.com>
> ---
>  arch/x86/kvm/vmx.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index ccc6a01eb4f4..120fc97a63fc 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -3415,9 +3415,6 @@ static void setup_msrs(struct vcpu_vmx *vmx)
>                 index = __find_msr_index(vmx, MSR_CSTAR);
>                 if (index >= 0)
>                         move_msr_up(vmx, index, save_nmsrs++);
> -               index = __find_msr_index(vmx, MSR_TSC_AUX);
> -               if (index >= 0 && guest_cpuid_has(&vmx->vcpu, X86_FEATURE_RDTSCP))
> -                       move_msr_up(vmx, index, save_nmsrs++);
>                 /*
>                  * MSR_STAR is only needed on long mode guests, and only
>                  * if efer.sce is enabled.
> @@ -3430,6 +3427,9 @@ static void setup_msrs(struct vcpu_vmx *vmx)
>         index = __find_msr_index(vmx, MSR_EFER);
>         if (index >= 0 && update_transition_efer(vmx, index))
>                 move_msr_up(vmx, index, save_nmsrs++);
> +       index = __find_msr_index(vmx, MSR_TSC_AUX);
> +       if (index >= 0 && guest_cpuid_has(&vmx->vcpu, X86_FEATURE_RDTSCP))
> +               move_msr_up(vmx, index, save_nmsrs++);
>
>         vmx->save_nmsrs = save_nmsrs;
>
> --
> 2.19.1.930.g4563a0d9d0-goog
>
diff mbox series

Patch

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index ccc6a01eb4f4..120fc97a63fc 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3415,9 +3415,6 @@  static void setup_msrs(struct vcpu_vmx *vmx)
 		index = __find_msr_index(vmx, MSR_CSTAR);
 		if (index >= 0)
 			move_msr_up(vmx, index, save_nmsrs++);
-		index = __find_msr_index(vmx, MSR_TSC_AUX);
-		if (index >= 0 && guest_cpuid_has(&vmx->vcpu, X86_FEATURE_RDTSCP))
-			move_msr_up(vmx, index, save_nmsrs++);
 		/*
 		 * MSR_STAR is only needed on long mode guests, and only
 		 * if efer.sce is enabled.
@@ -3430,6 +3427,9 @@  static void setup_msrs(struct vcpu_vmx *vmx)
 	index = __find_msr_index(vmx, MSR_EFER);
 	if (index >= 0 && update_transition_efer(vmx, index))
 		move_msr_up(vmx, index, save_nmsrs++);
+	index = __find_msr_index(vmx, MSR_TSC_AUX);
+	if (index >= 0 && guest_cpuid_has(&vmx->vcpu, X86_FEATURE_RDTSCP))
+		move_msr_up(vmx, index, save_nmsrs++);
 
 	vmx->save_nmsrs = save_nmsrs;