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 nvmm-x86-vmx: fix detection of the BIOS lock
details: https://anonhg.NetBSD.org/src/rev/0c801de6a55e
branches: trunk
changeset: 1013167:0c801de6a55e
user: maxv <maxv%NetBSD.org@localhost>
date: Sat Aug 22 11:01:10 2020 +0000
description:
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.
diffstat:
sys/dev/nvmm/x86/nvmm_x86_vmx.c | 23 +++++++++++++++--------
1 files changed, 15 insertions(+), 8 deletions(-)
diffs (51 lines):
diff -r f95bcd1dbf56 -r 0c801de6a55e sys/dev/nvmm/x86/nvmm_x86_vmx.c
--- a/sys/dev/nvmm/x86/nvmm_x86_vmx.c Sat Aug 22 11:00:00 2020 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86_vmx.c Sat Aug 22 11:01:10 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm_x86_vmx.c,v 1.71 2020/08/20 11:09:56 maxv Exp $ */
+/* $NetBSD: nvmm_x86_vmx.c,v 1.72 2020/08/22 11:01:10 maxv Exp $ */
/*
* Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.71 2020/08/20 11:09:56 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.72 2020/08/22 11:01:10 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -3192,11 +3192,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;
}
@@ -3322,7 +3319,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