diff --git a/README.md b/README.md index a7fb41f..b36e504 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ Package home: https://github.com/klauspost/cpuid * **RDTSCP** (RDTSCP Instruction) * **CX16** (CMPXCHG16B Instruction) * **SGX** (Software Guard Extensions, with activation details) +* **VMX** (Virtual Machine Extensions) ## Performance * **RDTSCP()** Returns current cycle count. Can be used for benchmarking. diff --git a/cpuid.go b/cpuid.go index db95913..5e90f44 100644 --- a/cpuid.go +++ b/cpuid.go @@ -80,6 +80,7 @@ const ( SGX // Software Guard Extensions IBPB // Indirect Branch Restricted Speculation (IBRS) and Indirect Branch Predictor Barrier (IBPB) STIBP // Single Thread Indirect Branch Predictors + VMX // Virtual Machine Extensions // Performance indicators SSE2SLOW // SSE2 is supported, but usually not faster @@ -137,6 +138,7 @@ var flagNames = map[Flags]string{ SGX: "SGX", // Software Guard Extensions IBPB: "IBPB", // Indirect Branch Restricted Speculation and Indirect Branch Predictor Barrier STIBP: "STIBP", // Single Thread Indirect Branch Predictors + VMX: "VMX", // Virtual Machine Extensions // Performance indicators SSE2SLOW: "SSE2SLOW", // SSE2 supported, but usually not faster @@ -223,6 +225,11 @@ func (c CPUInfo) Amd3dnowExt() bool { return c.Features&AMD3DNOWEXT != 0 } +// VMX indicates support of VMX +func (c CPUInfo) VMX() bool { + return c.Features&VMX != 0 +} + // MMX indicates support of MMX instructions func (c CPUInfo) MMX() bool { return c.Features&MMX != 0 @@ -820,6 +827,9 @@ func support() Flags { if (c & 1) != 0 { rval |= SSE3 } + if (c & (1 << 5)) != 0 { + rval |= VMX + } if (c & 0x00000200) != 0 { rval |= SSSE3 } diff --git a/cpuid_test.go b/cpuid_test.go index e584fe3..cf5595e 100644 --- a/cpuid_test.go +++ b/cpuid_test.go @@ -114,6 +114,16 @@ func TestAmd3dnowExt(t *testing.T) { t.Log("AMD3DNOWEXT Support:", got) } +// TestVMX tests VMX() function +func TestVMX(t *testing.T) { + got := CPU.VMX() + expected := CPU.Features&VMX == VMX + if got != expected { + t.Fatalf("VMX: expected %v, got %v", expected, got) + } + t.Log("VMX Support:", got) +} + // TestMMX tests MMX() function func TestMMX(t *testing.T) { got := CPU.MMX()