]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commit - arch/x86/include/asm/mmu_context.h
x86/mm/64: Stop using CR3.PCID == 0 in ASID-aware code
authorAndy Lutomirski <luto@kernel.org>
Sun, 17 Sep 2017 16:03:49 +0000 (09:03 -0700)
committerIngo Molnar <mingo@kernel.org>
Sun, 17 Sep 2017 16:59:08 +0000 (18:59 +0200)
commit52a2af400c1075219b3f0ce5c96fc961da44018a
tree0d51c712a3dbb9a18dd2adee5b786704fca48718
parent47061a24e2ee5bd8a40d473d47a5bd823fa0081f
x86/mm/64: Stop using CR3.PCID == 0 in ASID-aware code

Putting the logical ASID into CR3's PCID bits directly means that we
have two cases to consider separately: ASID == 0 and ASID != 0.
This means that bugs that only hit in one of these cases trigger
nondeterministically.

There were some bugs like this in the past, and I think there's
still one in current kernels.  In particular, we have a number of
ASID-unware code paths that save CR3, write some special value, and
then restore CR3.  This includes suspend/resume, hibernate, kexec,
EFI, and maybe other things I've missed.  This is currently
dangerous: if ASID != 0, then this code sequence will leave garbage
in the TLB tagged for ASID 0.  We could potentially see corruption
when switching back to ASID 0.  In principle, an
initialize_tlbstate_and_flush() call after these sequences would
solve the problem, but EFI, at least, does not call this.  (And it
probably shouldn't -- initialize_tlbstate_and_flush() is rather
expensive.)

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bpetkov@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/cdc14bbe5d3c3ef2a562be09a6368ffe9bd947a6.1505663533.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/include/asm/mmu_context.h