37

Can I disable Spectre and Meltdown mitigation features in Ubuntu 18.04LTS?

I want to test how much more performance I gain when I disable these two features in Linux, and if the performance is big, to make it permanently.

2

3 Answers 3

39

A number of kernel boot parameters are available to disable or fine-tune hardware vulnerability mitigations:

  • for Spectre v1 and v2: nospectre_v1 (x86, PowerPC), nospectre_v2 (x86, PowerPC, S/390, ARM64), spectre_v2_user=off (x86)
  • for SSB: spec_store_bypass_disable=off (x86, PowerPC), ssbd=force-off (ARM64)
  • for L1TF: l1tf=off (x86)
  • for MDS: mds=off (x86)
  • for TAA: tsx_async_abort=off
  • for iTLB multihit: nx_huge_pages=off
  • KPTI can be disabled with nopti (x86, PowerPC) or kpti=0 (ARM64)
  • TSX async abort: tsx_async_abort=off (x86)
  • KVM NX huge pages: kvm.nx_huge_pages=off (x86)

A meta-parameter, mitigations, was introduced in 5.2 and back-ported to 5.1.2, 5.0.16, and 4.19.43 (and perhaps others). It can be used to control all mitigations, on all architectures, as follows:

  • mitigations=off will disable all optional CPU mitigations;
  • mitigations=auto (the default setting) will mitigate all known CPU vulnerabilities, but leave SMT enabled (if it is already);
  • mitigations=auto,nosmt will mitigate all known CPU vulnerabilities and disable SMT if appropriate.

Some of these can be toggled at runtime; see the linked documentation for details.

1
21

With a kernel 5.1.13 or newer :

On boot parameter you can use

mitigations=off 

With a kernel older than 5.1.13 :

noibrs noibpb nopti nospectre_v2 nospectre_v1 l1tf=off nospec_store_bypass_disable no_stf_barrier mds=off mitigations=off 

Add either mitigations=off or that long one-liner to your /etc/sysconfig/grub and re-generate grub's configuration file with

grub2-mkconfig

(your distributions procedure will vary).

Debian/Ubuntu derived distributions:

Edit the file /etc/default/grub then run

update-grub
2
  • 11
    In Ubuntu/Debian/Devuan/…, you don't need grub-install /dev/sdX after update-grub! Just reboot. Apr 28, 2020 at 15:47
  • I notice you have mitigations=off in that long one-liner. Is that going to do anything on older kernels?
    – Mike S
    Feb 17 at 21:45
2

The proper steps on Ubuntu: edit /etc/default/grub find the GRUB_CMDLINE_LINUX_DEFAULT line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash mitigations=off"

Add the mitigations=off section (shown above, but missing from other posts) then

sudo update-grub

then

sudo-grub-install /dev/sdX
1
  • 6
    I don't think sudo-grub-install /dev/sdX is necessary? May 24, 2021 at 6:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.