Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/sys Pull up following revision(s) (requested by maxv in t...
details: https://anonhg.NetBSD.org/src/rev/8dffdfb6a6ad
branches: netbsd-9
changeset: 964110:8dffdfb6a6ad
user: martin <martin%NetBSD.org@localhost>
date: Fri Sep 04 18:53:43 2020 +0000
description:
Pull up following revision(s) (requested by maxv in ticket #1076):
sys/dev/nvmm/x86/nvmm_x86_svm.c: revision 1.75
sys/arch/x86/include/specialreg.h: revision 1.172
sys/dev/nvmm/x86/nvmm_x86_vmx.c: revision 1.72
nvmm-x86-vmx: fix detection of the BIOS lock
If it's locked, ensure it's locked with VMX enabled. If it's not locked,
then lock it ourselves with VMX enabled.
Should fix NetBSD PR/55596.
-
Add a few more CPUID flags.
-
nvmm-x86-svm: check the SVM revision
Only revision 1 exists, but check it, for future-proofness.
diffstat:
sys/arch/x86/include/specialreg.h | 10 +++++++++-
sys/dev/nvmm/x86/nvmm_x86_svm.c | 10 ++++++++--
sys/dev/nvmm/x86/nvmm_x86_vmx.c | 23 +++++++++++++++--------
3 files changed, 32 insertions(+), 11 deletions(-)
diffs (113 lines):
diff -r b9eeb594d7db -r 8dffdfb6a6ad sys/arch/x86/include/specialreg.h
--- a/sys/arch/x86/include/specialreg.h Thu Sep 03 18:38:16 2020 +0000
+++ b/sys/arch/x86/include/specialreg.h Fri Sep 04 18:53:43 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: specialreg.h,v 1.150.2.7 2020/07/13 13:33:29 martin Exp $ */
+/* $NetBSD: specialreg.h,v 1.150.2.8 2020/09/04 18:53:43 martin Exp $ */
/*
* Copyright (c) 2014-2020 The NetBSD Foundation, Inc.
@@ -755,6 +755,11 @@
#define CPUID_CAPEX_VIRT_SSBD __BIT(25) /* Virt Spec Control SSBD */
#define CPUID_CAPEX_SSB_NO __BIT(26) /* SSBD not required */
+/* %ecx */
+#define CPUID_CAPEX_PerfTscSize __BITS(17,16)
+#define CPUID_CAPEX_ApicIdSize __BITS(15,12)
+#define CPUID_CAPEX_NC __BITS(7,0)
+
#define CPUID_CAPEX_FLAGS "\20" \
"\1CLZERO" "\2IRPERF" "\3XSAVEERPTR" \
"\5RDPRU" "\7B6" \
@@ -763,6 +768,9 @@
"\21IBRS_ALWAYSON" "\22STIBP_ALWAYSON" "\23PREFER_IBRS" "\24B19" \
"\31SSBD" "\32VIRT_SSBD" "\33SSB_NO"
+/* AMD Fn8000_000a %eax (SVM Revision) */
+#define CPUID_AMD_SVM_REV __BITS(7,0)
+
/* AMD Fn8000_000a %edx features (SVM features) */
#define CPUID_AMD_SVM_NP 0x00000001
#define CPUID_AMD_SVM_LbrVirt 0x00000002
diff -r b9eeb594d7db -r 8dffdfb6a6ad sys/dev/nvmm/x86/nvmm_x86_svm.c
--- a/sys/dev/nvmm/x86/nvmm_x86_svm.c Thu Sep 03 18:38:16 2020 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86_svm.c Fri Sep 04 18:53:43 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm_x86_svm.c,v 1.46.4.10 2020/08/29 17:00:28 martin Exp $ */
+/* $NetBSD: nvmm_x86_svm.c,v 1.46.4.11 2020/09/04 18:53:43 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.10 2020/08/29 17:00:28 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.46.4.11 2020/09/04 18:53:43 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -2414,6 +2414,12 @@
}
x86_cpuid(0x8000000a, descs);
+ /* Expect revision 1. */
+ if (__SHIFTOUT(descs[0], CPUID_AMD_SVM_REV) != 1) {
+ printf("NVMM: SVM revision not supported\n");
+ return false;
+ }
+
/* Want Nested Paging. */
if (!(descs[3] & CPUID_AMD_SVM_NP)) {
printf("NVMM: SVM-NP not supported\n");
diff -r b9eeb594d7db -r 8dffdfb6a6ad sys/dev/nvmm/x86/nvmm_x86_vmx.c
--- a/sys/dev/nvmm/x86/nvmm_x86_vmx.c Thu Sep 03 18:38:16 2020 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86_vmx.c Fri Sep 04 18:53:43 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm_x86_vmx.c,v 1.36.2.12 2020/08/29 17:00:28 martin Exp $ */
+/* $NetBSD: nvmm_x86_vmx.c,v 1.36.2.13 2020/09/04 18:53:43 martin Exp $ */
/*
* Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.36.2.12 2020/08/29 17:00:28 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.36.2.13 2020/09/04 18:53:43 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -3169,11 +3169,8 @@
}
msr = rdmsr(MSR_IA32_FEATURE_CONTROL);
- if ((msr & IA32_FEATURE_CONTROL_LOCK) == 0) {
- printf("NVMM: VMX disabled in BIOS\n");
- return false;
- }
- if ((msr & IA32_FEATURE_CONTROL_OUT_SMX) == 0) {
+ if ((msr & IA32_FEATURE_CONTROL_LOCK) != 0 &&
+ (msr & IA32_FEATURE_CONTROL_OUT_SMX) == 0) {
printf("NVMM: VMX disabled in BIOS\n");
return false;
}
@@ -3299,7 +3296,17 @@
{
struct cpu_info *ci = curcpu();
bool enable = arg1 != NULL;
- uint64_t cr4;
+ uint64_t msr, cr4;
+
+ if (enable) {
+ msr = rdmsr(MSR_IA32_FEATURE_CONTROL);
+ if ((msr & IA32_FEATURE_CONTROL_LOCK) == 0) {
+ /* Lock now, with VMX-outside-SMX enabled. */
+ wrmsr(MSR_IA32_FEATURE_CONTROL, msr |
+ IA32_FEATURE_CONTROL_LOCK |
+ IA32_FEATURE_CONTROL_OUT_SMX);
+ }
+ }
if (!enable) {
vmx_vmxoff();
Home |
Main Index |
Thread Index |
Old Index