Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-10]: src/sys/dev/nvmm/x86 Pull up following revision(s) (requeste...
details: https://anonhg.NetBSD.org/src/rev/2060bcf28213
branches: netbsd-10
changeset: 378186:2060bcf28213
user: martin <martin%NetBSD.org@localhost>
date: Tue Jul 25 15:30:27 2023 +0000
description:
Pull up following revision(s) (requested by riastradh in ticket #246):
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 f93376ecb86b -r 2060bcf28213 sys/dev/nvmm/x86/nvmm_x86_svm.c
--- a/sys/dev/nvmm/x86/nvmm_x86_svm.c Tue Jul 25 11:42:57 2023 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86_svm.c Tue Jul 25 15:30:27 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm_x86_svm.c,v 1.84 2022/08/20 23:48:51 riastradh Exp $ */
+/* $NetBSD: nvmm_x86_svm.c,v 1.84.4.1 2023/07/25 15:30:27 martin Exp $ */
/*
* Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.84 2022/08/20 23:48:51 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.84.4.1 2023/07/25 15:30:27 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -523,6 +523,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 {
@@ -1853,6 +1880,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