]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
x86/mm: Reinitialize TLB state on hotplug and resume
authorAndy Lutomirski <luto@kernel.org>
Thu, 5 Apr 2018 05:51:00 +0000 (07:51 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Thu, 5 Apr 2018 12:36:26 +0000 (14:36 +0200)
commitc4b5890251dc1dbf5ff42021f3a2272a535f8c42
tree88e359f345d59adbf223e01cc6a49aa3adc8da9f
parent682c73482397c55f0101a8ffcbb1ceb10f70327f
x86/mm: Reinitialize TLB state on hotplug and resume

BugLink: https://bugs.launchpad.net/bugs/1759920
CVE-2017-5715 (Spectre v2 Intel)
CVE-2017-5754

When Linux brings a CPU down and back up, it switches to init_mm and then
loads swapper_pg_dir into CR3.  With PCID enabled, this has the side effect
of masking off the ASID bits in CR3.

This can result in some confusion in the TLB handling code.  If we
bring a CPU down and back up with any ASID other than 0, we end up
with the wrong ASID active on the CPU after resume.  This could
cause our internal state to become corrupt, although major
corruption is unlikely because init_mm doesn't have any user pages.
More obviously, if CONFIG_DEBUG_VM=y, we'll trip over an assertion
in the next context switch.  The result of *that* is a failure to
resume from suspend with probability 1 - 1/6^(cpus-1).

Fix it by reinitializing cpu_tlbstate on resume and CPU bringup.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Reported-by: Jiri Kosina <jikos@kernel.org>
Fixes: 10af6235e0d3 ("x86/mm: Implement PCID based optimization: try to preserve old TLB entries using PCID")
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(backported from commit 72c0098d92cedb11c7e0151e84918840a4e96b31)
[tyhicks: initialize_tlbstate_and_flush() was added in 72be211ba]
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
arch/x86/include/asm/tlbflush.h
arch/x86/kernel/cpu/common.c
arch/x86/power/cpu.c