Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/nvmm/x86 Reorder the detection in vmx_ident(), to fi...



details:   https://anonhg.NetBSD.org/src/rev/e14176aaa997
branches:  trunk
changeset: 997090:e14176aaa997
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu Feb 21 13:25:44 2019 +0000

description:
Reorder the detection in vmx_ident(), to fix panic on old CPUs. We must
read MSR_IA32_VMX_EPT_VPID_CAP _after_ ensuring EPT is there, because if
it's not, the rdmsr faults.

diffstat:

 sys/dev/nvmm/x86/nvmm_x86_vmx.c |  38 +++++++++++++++++++-------------------
 1 files changed, 19 insertions(+), 19 deletions(-)

diffs (66 lines):

diff -r 42303e46c68e -r e14176aaa997 sys/dev/nvmm/x86/nvmm_x86_vmx.c
--- a/sys/dev/nvmm/x86/nvmm_x86_vmx.c   Thu Feb 21 12:17:52 2019 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86_vmx.c   Thu Feb 21 13:25:44 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nvmm_x86_vmx.c,v 1.9 2019/02/21 12:17:52 maxv Exp $    */
+/*     $NetBSD: nvmm_x86_vmx.c,v 1.10 2019/02/21 13:25:44 maxv Exp $   */
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.9 2019/02/21 12:17:52 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.10 2019/02/21 13:25:44 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -2655,23 +2655,6 @@
                return false;
        }
 
-       msr = rdmsr(MSR_IA32_VMX_EPT_VPID_CAP);
-       if ((msr & IA32_VMX_EPT_VPID_WALKLENGTH_4) == 0) {
-               return false;
-       }
-       if ((msr & IA32_VMX_EPT_VPID_INVEPT) == 0) {
-               return false;
-       }
-       if ((msr & IA32_VMX_EPT_VPID_INVVPID) == 0) {
-               return false;
-       }
-       if ((msr & IA32_VMX_EPT_VPID_FLAGS_AD) == 0) {
-               return false;
-       }
-       if (!(msr & IA32_VMX_EPT_VPID_UC) && !(msr & IA32_VMX_EPT_VPID_WB)) {
-               return false;
-       }
-
        /* PG and PE are reported, even if Unrestricted Guests is supported. */
        vmx_cr0_fixed0 = rdmsr(MSR_IA32_VMX_CR0_FIXED0) & ~(CR0_PG|CR0_PE);
        vmx_cr0_fixed1 = rdmsr(MSR_IA32_VMX_CR0_FIXED1) | (CR0_PG|CR0_PE);
@@ -2724,6 +2707,23 @@
                return false;
        }
 
+       msr = rdmsr(MSR_IA32_VMX_EPT_VPID_CAP);
+       if ((msr & IA32_VMX_EPT_VPID_WALKLENGTH_4) == 0) {
+               return false;
+       }
+       if ((msr & IA32_VMX_EPT_VPID_INVEPT) == 0) {
+               return false;
+       }
+       if ((msr & IA32_VMX_EPT_VPID_INVVPID) == 0) {
+               return false;
+       }
+       if ((msr & IA32_VMX_EPT_VPID_FLAGS_AD) == 0) {
+               return false;
+       }
+       if (!(msr & IA32_VMX_EPT_VPID_UC) && !(msr & IA32_VMX_EPT_VPID_WB)) {
+               return false;
+       }
+
        return true;
 }
 



Home | Main Index | Thread Index | Old Index