xref: /linux/Documentation/admin-guide/hw-vuln/multihit.rst (revision 4b4193256c8d3bc3a5397b5cd9494c2ad386317d)
17f00cc8dSGomez Iglesias, AntonioiTLB multihit
27f00cc8dSGomez Iglesias, Antonio=============
37f00cc8dSGomez Iglesias, Antonio
47f00cc8dSGomez Iglesias, AntonioiTLB multihit is an erratum where some processors may incur a machine check
57f00cc8dSGomez Iglesias, Antonioerror, possibly resulting in an unrecoverable CPU lockup, when an
67f00cc8dSGomez Iglesias, Antonioinstruction fetch hits multiple entries in the instruction TLB. This can
77f00cc8dSGomez Iglesias, Antoniooccur when the page size is changed along with either the physical address
87f00cc8dSGomez Iglesias, Antonioor cache type. A malicious guest running on a virtualized system can
97f00cc8dSGomez Iglesias, Antonioexploit this erratum to perform a denial of service attack.
107f00cc8dSGomez Iglesias, Antonio
117f00cc8dSGomez Iglesias, Antonio
127f00cc8dSGomez Iglesias, AntonioAffected processors
137f00cc8dSGomez Iglesias, Antonio-------------------
147f00cc8dSGomez Iglesias, Antonio
157f00cc8dSGomez Iglesias, AntonioVariations of this erratum are present on most Intel Core and Xeon processor
167f00cc8dSGomez Iglesias, Antoniomodels. The erratum is not present on:
177f00cc8dSGomez Iglesias, Antonio
187f00cc8dSGomez Iglesias, Antonio   - non-Intel processors
197f00cc8dSGomez Iglesias, Antonio
207f00cc8dSGomez Iglesias, Antonio   - Some Atoms (Airmont, Bonnell, Goldmont, GoldmontPlus, Saltwell, Silvermont)
217f00cc8dSGomez Iglesias, Antonio
227f00cc8dSGomez Iglesias, Antonio   - Intel processors that have the PSCHANGE_MC_NO bit set in the
237f00cc8dSGomez Iglesias, Antonio     IA32_ARCH_CAPABILITIES MSR.
247f00cc8dSGomez Iglesias, Antonio
257f00cc8dSGomez Iglesias, Antonio
267f00cc8dSGomez Iglesias, AntonioRelated CVEs
277f00cc8dSGomez Iglesias, Antonio------------
287f00cc8dSGomez Iglesias, Antonio
297f00cc8dSGomez Iglesias, AntonioThe following CVE entry is related to this issue:
307f00cc8dSGomez Iglesias, Antonio
317f00cc8dSGomez Iglesias, Antonio   ==============  =================================================
327f00cc8dSGomez Iglesias, Antonio   CVE-2018-12207  Machine Check Error Avoidance on Page Size Change
337f00cc8dSGomez Iglesias, Antonio   ==============  =================================================
347f00cc8dSGomez Iglesias, Antonio
357f00cc8dSGomez Iglesias, Antonio
367f00cc8dSGomez Iglesias, AntonioProblem
377f00cc8dSGomez Iglesias, Antonio-------
387f00cc8dSGomez Iglesias, Antonio
397f00cc8dSGomez Iglesias, AntonioPrivileged software, including OS and virtual machine managers (VMM), are in
407f00cc8dSGomez Iglesias, Antoniocharge of memory management. A key component in memory management is the control
417f00cc8dSGomez Iglesias, Antonioof the page tables. Modern processors use virtual memory, a technique that creates
427f00cc8dSGomez Iglesias, Antoniothe illusion of a very large memory for processors. This virtual space is split
437f00cc8dSGomez Iglesias, Antoniointo pages of a given size. Page tables translate virtual addresses to physical
447f00cc8dSGomez Iglesias, Antonioaddresses.
457f00cc8dSGomez Iglesias, Antonio
467f00cc8dSGomez Iglesias, AntonioTo reduce latency when performing a virtual to physical address translation,
477f00cc8dSGomez Iglesias, Antonioprocessors include a structure, called TLB, that caches recent translations.
487f00cc8dSGomez Iglesias, AntonioThere are separate TLBs for instruction (iTLB) and data (dTLB).
497f00cc8dSGomez Iglesias, Antonio
507f00cc8dSGomez Iglesias, AntonioUnder this errata, instructions are fetched from a linear address translated
517f00cc8dSGomez Iglesias, Antoniousing a 4 KB translation cached in the iTLB. Privileged software modifies the
527f00cc8dSGomez Iglesias, Antoniopaging structure so that the same linear address using large page size (2 MB, 4
537f00cc8dSGomez Iglesias, AntonioMB, 1 GB) with a different physical address or memory type.  After the page
547f00cc8dSGomez Iglesias, Antoniostructure modification but before the software invalidates any iTLB entries for
557f00cc8dSGomez Iglesias, Antoniothe linear address, a code fetch that happens on the same linear address may
567f00cc8dSGomez Iglesias, Antoniocause a machine-check error which can result in a system hang or shutdown.
577f00cc8dSGomez Iglesias, Antonio
587f00cc8dSGomez Iglesias, Antonio
597f00cc8dSGomez Iglesias, AntonioAttack scenarios
607f00cc8dSGomez Iglesias, Antonio----------------
617f00cc8dSGomez Iglesias, Antonio
627f00cc8dSGomez Iglesias, AntonioAttacks against the iTLB multihit erratum can be mounted from malicious
637f00cc8dSGomez Iglesias, Antonioguests in a virtualized system.
647f00cc8dSGomez Iglesias, Antonio
657f00cc8dSGomez Iglesias, Antonio
667f00cc8dSGomez Iglesias, AntonioiTLB multihit system information
677f00cc8dSGomez Iglesias, Antonio--------------------------------
687f00cc8dSGomez Iglesias, Antonio
697f00cc8dSGomez Iglesias, AntonioThe Linux kernel provides a sysfs interface to enumerate the current iTLB
707f00cc8dSGomez Iglesias, Antoniomultihit status of the system:whether the system is vulnerable and which
717f00cc8dSGomez Iglesias, Antoniomitigations are active. The relevant sysfs file is:
727f00cc8dSGomez Iglesias, Antonio
737f00cc8dSGomez Iglesias, Antonio/sys/devices/system/cpu/vulnerabilities/itlb_multihit
747f00cc8dSGomez Iglesias, Antonio
757f00cc8dSGomez Iglesias, AntonioThe possible values in this file are:
767f00cc8dSGomez Iglesias, Antonio
777f00cc8dSGomez Iglesias, Antonio.. list-table::
787f00cc8dSGomez Iglesias, Antonio
797f00cc8dSGomez Iglesias, Antonio     * - Not affected
807f00cc8dSGomez Iglesias, Antonio       - The processor is not vulnerable.
817f00cc8dSGomez Iglesias, Antonio     * - KVM: Mitigation: Split huge pages
827f00cc8dSGomez Iglesias, Antonio       - Software changes mitigate this issue.
83*f29dfa53SPawan Gupta     * - KVM: Mitigation: VMX unsupported
84*f29dfa53SPawan Gupta       - KVM is not vulnerable because Virtual Machine Extensions (VMX) is not supported.
85*f29dfa53SPawan Gupta     * - KVM: Mitigation: VMX disabled
86*f29dfa53SPawan Gupta       - KVM is not vulnerable because Virtual Machine Extensions (VMX) is disabled.
877f00cc8dSGomez Iglesias, Antonio     * - KVM: Vulnerable
887f00cc8dSGomez Iglesias, Antonio       - The processor is vulnerable, but no mitigation enabled
897f00cc8dSGomez Iglesias, Antonio
907f00cc8dSGomez Iglesias, Antonio
917f00cc8dSGomez Iglesias, AntonioEnumeration of the erratum
927f00cc8dSGomez Iglesias, Antonio--------------------------------
937f00cc8dSGomez Iglesias, Antonio
947f00cc8dSGomez Iglesias, AntonioA new bit has been allocated in the IA32_ARCH_CAPABILITIES (PSCHANGE_MC_NO) msr
957f00cc8dSGomez Iglesias, Antonioand will be set on CPU's which are mitigated against this issue.
967f00cc8dSGomez Iglesias, Antonio
977f00cc8dSGomez Iglesias, Antonio   =======================================   ===========   ===============================
987f00cc8dSGomez Iglesias, Antonio   IA32_ARCH_CAPABILITIES MSR                Not present   Possibly vulnerable,check model
997f00cc8dSGomez Iglesias, Antonio   IA32_ARCH_CAPABILITIES[PSCHANGE_MC_NO]    '0'           Likely vulnerable,check model
1007f00cc8dSGomez Iglesias, Antonio   IA32_ARCH_CAPABILITIES[PSCHANGE_MC_NO]    '1'           Not vulnerable
1017f00cc8dSGomez Iglesias, Antonio   =======================================   ===========   ===============================
1027f00cc8dSGomez Iglesias, Antonio
1037f00cc8dSGomez Iglesias, Antonio
1047f00cc8dSGomez Iglesias, AntonioMitigation mechanism
1057f00cc8dSGomez Iglesias, Antonio-------------------------
1067f00cc8dSGomez Iglesias, Antonio
1077f00cc8dSGomez Iglesias, AntonioThis erratum can be mitigated by restricting the use of large page sizes to
1087f00cc8dSGomez Iglesias, Antonionon-executable pages.  This forces all iTLB entries to be 4K, and removes
1097f00cc8dSGomez Iglesias, Antoniothe possibility of multiple hits.
1107f00cc8dSGomez Iglesias, Antonio
1117f00cc8dSGomez Iglesias, AntonioIn order to mitigate the vulnerability, KVM initially marks all huge pages
1127f00cc8dSGomez Iglesias, Antonioas non-executable. If the guest attempts to execute in one of those pages,
1137f00cc8dSGomez Iglesias, Antoniothe page is broken down into 4K pages, which are then marked executable.
1147f00cc8dSGomez Iglesias, Antonio
1157f00cc8dSGomez Iglesias, AntonioIf EPT is disabled or not available on the host, KVM is in control of TLB
1167f00cc8dSGomez Iglesias, Antonioflushes and the problematic situation cannot happen.  However, the shadow
1177f00cc8dSGomez Iglesias, AntonioEPT paging mechanism used by nested virtualization is vulnerable, because
1187f00cc8dSGomez Iglesias, Antoniothe nested guest can trigger multiple iTLB hits by modifying its own
1197f00cc8dSGomez Iglesias, Antonio(non-nested) page tables.  For simplicity, KVM will make large pages
1207f00cc8dSGomez Iglesias, Antonionon-executable in all shadow paging modes.
1217f00cc8dSGomez Iglesias, Antonio
1227f00cc8dSGomez Iglesias, AntonioMitigation control on the kernel command line and KVM - module parameter
1237f00cc8dSGomez Iglesias, Antonio------------------------------------------------------------------------
1247f00cc8dSGomez Iglesias, Antonio
1257f00cc8dSGomez Iglesias, AntonioThe KVM hypervisor mitigation mechanism for marking huge pages as
1267f00cc8dSGomez Iglesias, Antonionon-executable can be controlled with a module parameter "nx_huge_pages=".
1277f00cc8dSGomez Iglesias, AntonioThe kernel command line allows to control the iTLB multihit mitigations at
1287f00cc8dSGomez Iglesias, Antonioboot time with the option "kvm.nx_huge_pages=".
1297f00cc8dSGomez Iglesias, Antonio
1307f00cc8dSGomez Iglesias, AntonioThe valid arguments for these options are:
1317f00cc8dSGomez Iglesias, Antonio
1327f00cc8dSGomez Iglesias, Antonio  ==========  ================================================================
1337f00cc8dSGomez Iglesias, Antonio  force       Mitigation is enabled. In this case, the mitigation implements
1347f00cc8dSGomez Iglesias, Antonio              non-executable huge pages in Linux kernel KVM module. All huge
1357f00cc8dSGomez Iglesias, Antonio              pages in the EPT are marked as non-executable.
1367f00cc8dSGomez Iglesias, Antonio              If a guest attempts to execute in one of those pages, the page is
1377f00cc8dSGomez Iglesias, Antonio              broken down into 4K pages, which are then marked executable.
1387f00cc8dSGomez Iglesias, Antonio
1397f00cc8dSGomez Iglesias, Antonio  off	      Mitigation is disabled.
1407f00cc8dSGomez Iglesias, Antonio
1417f00cc8dSGomez Iglesias, Antonio  auto        Enable mitigation only if the platform is affected and the kernel
1427f00cc8dSGomez Iglesias, Antonio              was not booted with the "mitigations=off" command line parameter.
1437f00cc8dSGomez Iglesias, Antonio	      This is the default option.
1447f00cc8dSGomez Iglesias, Antonio  ==========  ================================================================
1457f00cc8dSGomez Iglesias, Antonio
1467f00cc8dSGomez Iglesias, Antonio
1477f00cc8dSGomez Iglesias, AntonioMitigation selection guide
1487f00cc8dSGomez Iglesias, Antonio--------------------------
1497f00cc8dSGomez Iglesias, Antonio
1507f00cc8dSGomez Iglesias, Antonio1. No virtualization in use
1517f00cc8dSGomez Iglesias, Antonio^^^^^^^^^^^^^^^^^^^^^^^^^^^
1527f00cc8dSGomez Iglesias, Antonio
1537f00cc8dSGomez Iglesias, Antonio   The system is protected by the kernel unconditionally and no further
1547f00cc8dSGomez Iglesias, Antonio   action is required.
1557f00cc8dSGomez Iglesias, Antonio
1567f00cc8dSGomez Iglesias, Antonio2. Virtualization with trusted guests
1577f00cc8dSGomez Iglesias, Antonio^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1587f00cc8dSGomez Iglesias, Antonio
1597f00cc8dSGomez Iglesias, Antonio   If the guest comes from a trusted source, you may assume that the guest will
1607f00cc8dSGomez Iglesias, Antonio   not attempt to maliciously exploit these errata and no further action is
1617f00cc8dSGomez Iglesias, Antonio   required.
1627f00cc8dSGomez Iglesias, Antonio
1637f00cc8dSGomez Iglesias, Antonio3. Virtualization with untrusted guests
1647f00cc8dSGomez Iglesias, Antonio^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1657f00cc8dSGomez Iglesias, Antonio   If the guest comes from an untrusted source, the guest host kernel will need
1667f00cc8dSGomez Iglesias, Antonio   to apply iTLB multihit mitigation via the kernel command line or kvm
1677f00cc8dSGomez Iglesias, Antonio   module parameter.
168