Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/dev/nvmm/x86 Pull up following revision(s) (requested...



details:   https://anonhg.NetBSD.org/src/rev/044d7cd4a8d6
branches:  netbsd-9
changeset: 378188:044d7cd4a8d6
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Jul 25 15:35:35 2023 +0000

description:
Pull up following revision(s) (requested by riastradh in ticket #1666):

        sys/dev/nvmm/x86/nvmm_x86_svm.c: revision 1.85

nvmm: Filter CR4 bits on x86 SVM (AMD).

In particular, prohibit PKE, Protection Key Enable, which requires
some additional management of CPU state by nvmm.

diffstat:

 sys/dev/nvmm/x86/nvmm_x86_svm.c |  32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)

diffs (60 lines):

diff -r 19c64b616c1c -r 044d7cd4a8d6 sys/dev/nvmm/x86/nvmm_x86_svm.c
--- a/sys/dev/nvmm/x86/nvmm_x86_svm.c   Tue Jul 25 11:35:26 2023 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86_svm.c   Tue Jul 25 15:35:35 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nvmm_x86_svm.c,v 1.46.4.13 2020/09/13 11:56:44 martin Exp $    */
+/*     $NetBSD: nvmm_x86_svm.c,v 1.46.4.14 2023/07/25 15:35:35 martin Exp $    */
 
 /*
  * Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.46.4.13 2020/09/13 11:56:44 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.46.4.14 2023/07/25 15:35:35 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -511,6 +511,33 @@ static uint64_t svm_xcr0_mask __read_mos
 #define CR4_TLB_FLUSH \
        (CR4_PSE|CR4_PAE|CR4_PGE|CR4_PCIDE|CR4_SMEP)
 
+#define CR4_VALID \
+       (CR4_VME |                      \
+        CR4_PVI |                      \
+        CR4_TSD |                      \
+        CR4_DE |                       \
+        CR4_PSE |                      \
+        CR4_PAE |                      \
+        CR4_MCE |                      \
+        CR4_PGE |                      \
+        CR4_PCE |                      \
+        CR4_OSFXSR |                   \
+        CR4_OSXMMEXCPT |               \
+        CR4_UMIP |                     \
+        /* CR4_LA57 excluded */        \
+        /* bit 13 reserved on AMD */   \
+        /* bit 14 reserved on AMD */   \
+        /* bit 15 reserved on AMD */   \
+        CR4_FSGSBASE |                 \
+        CR4_PCIDE |                    \
+        CR4_OSXSAVE |                  \
+        /* bit 19 reserved on AMD */   \
+        CR4_SMEP |                     \
+        CR4_SMAP                       \
+        /* CR4_PKE excluded */         \
+        /* CR4_CET excluded */         \
+        /* bits 24:63 reserved on AMD */)
+
 /* -------------------------------------------------------------------------- */
 
 struct svm_machdata {
@@ -1847,6 +1874,7 @@ svm_vcpu_setstate(struct nvmm_cpu *vcpu)
                vmcb->state.cr2 = state->crs[NVMM_X64_CR_CR2];
                vmcb->state.cr3 = state->crs[NVMM_X64_CR_CR3];
                vmcb->state.cr4 = state->crs[NVMM_X64_CR_CR4];
+               vmcb->state.cr4 &= CR4_VALID;
 
                vmcb->ctrl.v &= ~VMCB_CTRL_V_TPR;
                vmcb->ctrl.v |= __SHIFTIN(state->crs[NVMM_X64_CR_CR8],



Home | Main Index | Thread Index | Old Index