kvm: Check that VMX and SVM are disabled in guest PCID

PiperOrigin-RevId: 424267563
This commit is contained in:
Andrei Vagin
2022-01-25 23:23:34 -08:00
committed by gVisor bot
parent ee08e56d4c
commit daea5b7674
2 changed files with 18 additions and 0 deletions
+1
View File
@@ -131,6 +131,7 @@ go_test(
],
deps = [
"//pkg/abi/linux",
"//pkg/cpuid",
"//pkg/hostarch",
"//pkg/memutil",
"//pkg/ring0",
+17
View File
@@ -21,6 +21,7 @@ import (
"testing"
"gvisor.dev/gvisor/pkg/abi/linux"
"gvisor.dev/gvisor/pkg/cpuid"
"gvisor.dev/gvisor/pkg/ring0"
"gvisor.dev/gvisor/pkg/ring0/pagetables"
"gvisor.dev/gvisor/pkg/sentry/arch"
@@ -88,3 +89,19 @@ func TestMXCSR(t *testing.T) {
return false
})
}
//go:nosplit
func nestedVirtIsOn(c *vCPU, fs *cpuid.FeatureSet) bool {
bluepill(c)
return fs.HasFeature(cpuid.X86FeatureVMX) || fs.HasFeature(cpuid.X86FeatureSVM)
}
func TestKernelCPUID(t *testing.T) {
bluepillTest(t, func(c *vCPU) {
fs := cpuid.HostFeatureSet()
if nestedVirtIsOn(c, &fs) {
t.Fatalf("Nested virtualization is enabled")
}
})
}