1
0
Fork 0
alistair23-linux/arch/x86/kernel/cpu/mtrr
Ying-Tsun Huang a9d49da7ed x86/mtrr: Correct the range check before performing MTRR type lookups
commit cb7f4a8b1f upstream.

In mtrr_type_lookup(), if the input memory address region is not in the
MTRR, over 4GB, and not over the top of memory, a write-back attribute
is returned. These condition checks are for ensuring the input memory
address region is actually mapped to the physical memory.

However, if the end address is just aligned with the top of memory,
the condition check treats the address is over the top of memory, and
write-back attribute is not returned.

And this hits in a real use case with NVDIMM: the nd_pmem module tries
to map NVDIMMs as cacheable memories when NVDIMMs are connected. If a
NVDIMM is the last of the DIMMs, the performance of this NVDIMM becomes
very low since it is aligned with the top of memory and its memory type
is uncached-minus.

Move the input end address change to inclusive up into
mtrr_type_lookup(), before checking for the top of memory in either
mtrr_type_lookup_{variable,fixed}() helpers.

 [ bp: Massage commit message. ]

Fixes: 0cc705f56e ("x86/mm/mtrr: Clean up mtrr_type_lookup()")
Signed-off-by: Ying-Tsun Huang <ying-tsun.huang@amd.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20201215070721.4349-1-ying-tsun.huang@amd.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-12 20:16:24 +01:00
..
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
amd.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
centaur.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
cleanup.c x86/mtrr: Remove unused variable 2019-02-08 14:32:33 +01:00
cyrix.c x86: mtrr: cyrix: Mark expected switch fall-through 2019-08-07 15:12:01 +02:00
generic.c x86/mtrr: Correct the range check before performing MTRR type lookups 2021-01-12 20:16:24 +01:00
if.c x86/mtrr: Don't copy uninitialized gentry fields back to userspace 2018-12-19 00:00:16 +01:00
mtrr.c x86/cpu/mtrr: Support TOP_MEM2 and get MTRR number 2018-09-27 18:28:57 +02:00
mtrr.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00