How to check if Linux kernel is "Retpoline" enabled or not?

If you’re using mainline kernels, or most major distributions’ kernels, the best way to check for full retpoline support (i.e. the kernel was configured with CONFIG_RETPOLINE, and was built with a retpoline-capable compiler) is to look for “Full generic retpoline” in /sys/devices/system/cpu/vulnerabilities/spectre_v2. On my system:

$ cat /sys/devices/system/cpu/vulnerabilities/spectre_v2
Mitigation: Full generic retpoline, IBPB, IBRS_FW

If you want more comprehensive tests, to detect retpolines on kernels without the spectre_v2 systree file, check out how spectre-meltdown-checker goes about things.


Stephen Kitt's answer is more comprehensive in this specific case, because the retpoline support also needs new compiler version.

But in general case, most distributions have the kernel configuration file available in one of the following locations:

  • /boot/config-4.xx.xx-...
  • /proc/config.gz

Then you can simply zgrep CONFIG_RETPOLINE /boot/config* /proc/config.gz