]> git.baikalelectronics.ru Git - kernel.git/commit
x86/speculation/l1tf: Fix off-by-one error when warning that system has too much RAM
authorVlastimil Babka <vbabka@suse.cz>
Thu, 23 Aug 2018 13:44:18 +0000 (15:44 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 24 Aug 2018 07:51:14 +0000 (09:51 +0200)
commit7418552651f5aef086b7dc6ff0dc75625d99e5a3
treea709f2500ca27f95af9946c752a0ef91cef0b1f0
parentbc135f12d07e93434b4cc890cbc285fa9ff74c42
x86/speculation/l1tf: Fix off-by-one error when warning that system has too much RAM

Two users have reported [1] that they have an "extremely unlikely" system
with more than MAX_PA/2 memory and L1TF mitigation is not effective. In
fact it's a CPU with 36bits phys limit (64GB) and 32GB memory, but due to
holes in the e820 map, the main region is almost 500MB over the 32GB limit:

[    0.000000] BIOS-e820: [mem 0x0000000100000000-0x000000081effffff] usable

Suggestions to use 'mem=32G' to enable the L1TF mitigation while losing the
500MB revealed, that there's an off-by-one error in the check in
l1tf_select_mitigation().

l1tf_pfn_limit() returns the last usable pfn (inclusive) and the range
check in the mitigation path does not take this into account.

Instead of amending the range check, make l1tf_pfn_limit() return the first
PFN which is over the limit which is less error prone. Adjust the other
users accordingly.

[1] https://bugzilla.suse.com/show_bug.cgi?id=1105536

Fixes: f67c155455c5 ("x86/speculation/l1tf: Add sysfs reporting for l1tf")
Reported-by: George Anchev <studio@anchev.net>
Reported-by: Christopher Snowhill <kode54@gmail.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: "H . Peter Anvin" <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20180823134418.17008-1-vbabka@suse.cz
arch/x86/include/asm/processor.h
arch/x86/mm/init.c
arch/x86/mm/mmap.c