Skip to content
systemcoding.dev
Virtualization

Check Whether Your CPU Supports Virtualization With vmx, svm and kvm-ok

Find out whether your CPU supports hardware virtualization on Linux by reading the vmx and svm flags, running kvm-ok and checking that /dev/kvm exists.

6 min read
Summarize in AI
Flat illustration of guest machines running on a hypervisor over hardware, with the QEMU, Linux and Docker logos.

Before you launch a KVM guest, you need to know three separate things: the CPU has the feature, the firmware has not turned it off, and the Linux kernel has loaded its KVM modules. They fail independently, and each has its own check. This post walks through them in order on Linux 6.12, with the commands, the output you should see and what each failure means. If a later step fails, the earlier ones tell you where to look. The background on what the feature does is in the complete guide to virtualization for systems programmers, and the checks here work on Intel and AMD x86-64 machines.

Step 1: read the CPU flags

Intel calls its extension VMX and AMD calls its extension SVM. The kernel lists CPU features in /proc/cpuinfo under flags, using the names vmx and svm. Count the matching lines with grep:

Shell
grep -E -c '(vmx|svm)' /proc/cpuinfo
Text
8

The number is how many logical CPUs report the flag, so on an eight-thread Intel desktop you see 8. A result of 0 means the flag is not visible, which has three possible causes: the CPU lacks the feature, the firmware hides it, or you are already inside a virtual machine whose host did not pass it through.

To see which vendor you have, print the first match:

Shell
grep -o -m1 -E '(vmx|svm)' /proc/cpuinfo
Text
vmx

The same information is available in structured form from lscpu, which prints a Virtualization line:

Shell
lscpu | grep -i virtualization
Text
Virtualization:                  VT-x

On AMD this line reads AMD-V. Note that lscpu may also print a Hypervisor vendor line when you are inside a guest. If you see it, you are nested and the flag question depends on the outer hypervisor.

Step 2: check that the firmware has not disabled it

A CPU can support virtualization and still have it switched off in the firmware setup. On Intel systems, a lock bit in the IA32_FEATURE_CONTROL register is set at boot, and if firmware locked it with VMX disabled, the kernel cannot enable VMX later. The flag can still show in /proc/cpuinfo, which is the trap: the CPU reports the capability, but the kernel refuses to use it.

The kernel logs the result when it loads the KVM module. Look at the messages:

Shell
sudo dmesg | grep -i -E 'kvm|vmx|svm'
Text
[    3.412345] kvm_intel: VMX disabled by BIOS

That line is the exact failure. Enter the firmware setup and enable the option named Intel Virtualization Technology, VT-x, SVM Mode or AMD-V, depending on the vendor. A cold power cycle is sometimes needed, because the lock persists across a warm reboot on some boards. When virtualization is enabled, you will not see a "disabled" line, and a successful load prints nothing in many kernels.

Step 3: use kvm-ok

On Debian and Ubuntu, the cpu-checker package provides a command that combines the checks:

Shell
sudo apt install cpu-checker
kvm-ok
Text
INFO: /dev/kvm exists
KVM acceleration can be used

When something is wrong it says so. If the CPU supports the feature but /dev/kvm is missing, you see:

Text
INFO: Your CPU supports KVM extensions
INFO: KVM (vmx) is disabled by your BIOS
HINT:   Enter your BIOS setup and enable Virtualization Technology (VT),
        and then hard poweroff/poweroff your system
KVM acceleration can NOT be used

kvm-ok is a Debian-family convenience rather than a kernel tool. On Fedora or Arch the same facts come from the first and fourth steps.

Step 4: check the device and the kernel modules

The decisive test is whether /dev/kvm exists, because only the KVM kernel modules create it. List it and the modules:

Shell
ls -l /dev/kvm
lsmod | grep -E '^kvm'
Text
crw-rw---- 1 root kvm 10, 232 Nov 23 09:14 /dev/kvm
kvm_intel             389120  0
kvm                  1138688  1 kvm_intel

On AMD you see kvm_amd instead of kvm_intel. If the CPU flag is present and the modules are missing, load them by hand:

Shell
sudo modprobe kvm_intel

When the firmware has disabled the feature, modprobe fails with Operation not supported, which points you back to step 2. If the module loads and /dev/kvm appears, hardware virtualization works.

Step 5: confirm access from your account

/dev/kvm is owned by root:kvm with mode 0660, so your account needs to be in the kvm group, or QEMU fails with a permissions error:

Shell
id -nG | tr ' ' '\n' | grep -x kvm
Text
kvm

If nothing prints, add the group with sudo usermod -aG kvm "$USER" and log in again. The workstation setup post covers udev rules and the no-root arrangement in more detail.

A check from C

If you prefer to ask the CPU yourself, read the CPUID bits. This tells you what the processor reports, which is step 1 only and cannot see firmware locks:

cpuid-virt.cc
#include <cpuid.h>
#include <stdio.h>

int main(void)
{
    unsigned int a, b, c, d;

    if (__get_cpuid(1, &a, &b, &c, &d))
        printf("vmx=%u hypervisor=%u\n", (c >> 5) & 1, (c >> 31) & 1);
    if (__get_cpuid(0x80000001, &a, &b, &c, &d))
        printf("svm=%u\n", (c >> 2) & 1);
    return 0;
}
Text
vmx=1 hypervisor=0
svm=0

The output shown is for an Intel machine running directly on hardware. On AMD the second line reads svm=1. The hypervisor bit is 1 inside a guest.

When you are inside a virtual machine

Everything above assumes bare metal. Inside a guest, the checks answer a different question: did the outer hypervisor pass virtualization through? Cloud instances usually do not, and grep -c vmx /proc/cpuinfo prints 0 even though the physical CPU supports it. The hypervisor flag in the same file confirms you are in a guest:

Shell
grep -c -w hypervisor /proc/cpuinfo
Text
4

If that prints a non-zero count and the vmx count is zero, the fix is on the provider side. Some providers offer nested virtualization as an instance option, and bare-metal instance types expose the real CPU. On a local hypervisor you control, such as a KVM host, enable the nested parameter of kvm_intel or kvm_amd, and start the guest with -cpu host so the flag is not masked. The dedicated post on nested virtualization walks through the sequence.

Common mistakes

Three mistakes cause most of the confusion we see with these checks.

The first is trusting /proc/cpuinfo alone. The flag is a statement about the processor, and the firmware lock is a separate fact, so a machine can show vmx and still print VMX disabled by BIOS from the kernel. Always check /dev/kvm.

The second is forgetting the power cycle. Some firmware applies a changed virtualization setting only after a full power off, not a reboot, because the lock bit survives a warm reset. If you enabled the option and dmesg still reports it disabled, shut down completely and start again.

The third is a conflicting hypervisor. On a desktop, another product may hold the hardware feature exclusively, so the KVM modules refuse to load or /dev/kvm cannot be used. Stop the other product, or unload its kernel module, then reload kvm_intel. The error from modprobe is typically Device or resource busy, which is the signal to look for another hypervisor.

Reading the results together

/proc/cpuinfo flag/dev/kvmMeaning
PresentPresentReady to use
PresentMissing, "disabled by BIOS" in dmesgEnable it in firmware setup and power cycle
PresentMissing, no messageLoad kvm_intel or kvm_amd with modprobe
MissingMissingCPU lacks it, or you are in a guest without nesting
Share

Keep reading

Flat illustration of user space above the system call boundary, the kernel and the hardware, with the C, FreeBSD and Linux logos.
Systems Programming

How argc and argv Reach main in a C Program

The kernel copies argc and argv onto the new process's stack on execve, then startup code hands them to main. See the layout and measure it with a program.

6 min read

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.