[v3,4/4] kvm: vmx: Skip all SYSCALL MSRs in setup_msrs() when !EFER.SCE
diff mbox series

Message ID 20181112204816.1524-1-jmattson@google.com
State New
Headers show
Series
  • [v3,1/4] kvm: vmx: Set IA32_TSC_AUX for legacy mode guests
Related show

Commit Message

Jim Mattson Nov. 12, 2018, 8:48 p.m. UTC
Like IA32_STAR, IA32_LSTAR and IA32_FMASK only need to contain guest
values on VM-entry when the guest is in long mode and EFER.SCE is set.

Signed-off-by: Jim Mattson <jmattson@google.com>
Reviewed-by: Peter Shier <pshier@google.com>
Reviewed-by: Marc Orr <marcorr@google.com>
---
 arch/x86/kvm/vmx.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Jim Mattson Nov. 30, 2018, 5:37 p.m. UTC | #1
Ping.
On Mon, Nov 12, 2018 at 12:48 PM Jim Mattson <jmattson@google.com> wrote:
>
> Like IA32_STAR, IA32_LSTAR and IA32_FMASK only need to contain guest
> values on VM-entry when the guest is in long mode and EFER.SCE is set.
>
> Signed-off-by: Jim Mattson <jmattson@google.com>
> Reviewed-by: Peter Shier <pshier@google.com>
> Reviewed-by: Marc Orr <marcorr@google.com>
> ---
>  arch/x86/kvm/vmx.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index df468980a8c1..efcaaf167e6b 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -3408,19 +3408,19 @@ static void setup_msrs(struct vcpu_vmx *vmx)
>
>         save_nmsrs = 0;
>  #ifdef CONFIG_X86_64
> -       if (is_long_mode(&vmx->vcpu)) {
> -               index = __find_msr_index(vmx, MSR_SYSCALL_MASK);
> +       /*
> +        * The SYSCALL MSRs are only needed on long mode guests, and only
> +        * when EFER.SCE is set.
> +        */
> +       if (is_long_mode(&vmx->vcpu) && (vmx->vcpu.arch.efer & EFER_SCE)) {
> +               index = __find_msr_index(vmx, MSR_STAR);
>                 if (index >= 0)
>                         move_msr_up(vmx, index, save_nmsrs++);
>                 index = __find_msr_index(vmx, MSR_LSTAR);
>                 if (index >= 0)
>                         move_msr_up(vmx, index, save_nmsrs++);
> -               /*
> -                * MSR_STAR is only needed on long mode guests, and only
> -                * if efer.sce is enabled.
> -                */
> -               index = __find_msr_index(vmx, MSR_STAR);
> -               if ((index >= 0) && (vmx->vcpu.arch.efer & EFER_SCE))
> +               index = __find_msr_index(vmx, MSR_SYSCALL_MASK);
> +               if (index >= 0)
>                         move_msr_up(vmx, index, save_nmsrs++);
>         }
>  #endif
> --
> 2.19.1.930.g4563a0d9d0-goog
>

Patch
diff mbox series

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index df468980a8c1..efcaaf167e6b 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3408,19 +3408,19 @@  static void setup_msrs(struct vcpu_vmx *vmx)
 
 	save_nmsrs = 0;
 #ifdef CONFIG_X86_64
-	if (is_long_mode(&vmx->vcpu)) {
-		index = __find_msr_index(vmx, MSR_SYSCALL_MASK);
+	/*
+	 * The SYSCALL MSRs are only needed on long mode guests, and only
+	 * when EFER.SCE is set.
+	 */
+	if (is_long_mode(&vmx->vcpu) && (vmx->vcpu.arch.efer & EFER_SCE)) {
+		index = __find_msr_index(vmx, MSR_STAR);
 		if (index >= 0)
 			move_msr_up(vmx, index, save_nmsrs++);
 		index = __find_msr_index(vmx, MSR_LSTAR);
 		if (index >= 0)
 			move_msr_up(vmx, index, save_nmsrs++);
-		/*
-		 * MSR_STAR is only needed on long mode guests, and only
-		 * if efer.sce is enabled.
-		 */
-		index = __find_msr_index(vmx, MSR_STAR);
-		if ((index >= 0) && (vmx->vcpu.arch.efer & EFER_SCE))
+		index = __find_msr_index(vmx, MSR_SYSCALL_MASK);
+		if (index >= 0)
 			move_msr_up(vmx, index, save_nmsrs++);
 	}
 #endif