kernel-hacking-2024-linux-s.../arch/x86/mm
Suresh Siddha a1e46212a4 x86: fix page attribute corruption with cpa()
Impact: fix sporadic slowdowns and warning messages

This patch fixes a performance issue reported by Linus on his
Nehalem system. While Linus reverted the PAT patch (commit
58dab916df) which exposed the issue,
existing cpa() code can potentially still cause wrong(page attribute
corruption) behavior.

This patch also fixes the "WARNING: at arch/x86/mm/pageattr.c:560" that
various people reported.

In 64bit kernel, kernel identity mapping might have holes depending
on the available memory and how e820 reports the address range
covering the RAM, ACPI, PCI reserved regions. If there is a 2MB/1GB hole
in the address range that is not listed by e820 entries, kernel identity
mapping will have a corresponding hole in its 1-1 identity mapping.

If cpa() happens on the kernel identity mapping which falls into these holes,
existing code fails like this:

	__change_page_attr_set_clr()
		__change_page_attr()
			returns 0 because of if (!kpte). But doesn't
			set cpa->numpages and cpa->pfn.
		cpa_process_alias()
			uses uninitialized cpa->pfn (random value)
			which can potentially lead to changing the page
			attribute of kernel text/data, kernel identity
			mapping of RAM pages etc. oops!

This bug was easily exposed by another PAT patch which was doing
cpa() more often on kernel identity mapping holes (physical range between
max_low_pfn_mapped and 4GB), where in here it was setting the
cache disable attribute(PCD) for kernel identity mappings aswell.

Fix cpa() to handle the kernel identity mapping holes. Retain
the WARN() for cpa() calls to other not present address ranges
(kernel-text/data, ioremap() addresses)

Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Cc: <stable@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-01-21 12:24:54 +01:00
..
dump_pagetables.c
extable.c
fault.c x86: avoid theoretical vmalloc fault loop 2009-01-12 19:24:21 +01:00
gup.c x86: two trivial sparse annotations 2008-10-29 08:02:28 +01:00
highmem_32.c Export kmap_atomic_pfn for DRM-GEM. 2008-10-18 07:10:12 +10:00
hugetlbpage.c
init_32.c x86: fix assumed to be contiguous leaf page tables for kmap_atomic region (take 2) 2009-01-16 13:47:04 +01:00
init_64.c x86: remove kernel_physical_mapping_init() from init section 2009-01-20 00:31:43 +01:00
iomap_32.c x86: add iomap_atomic*()/iounmap_atomic() on 32-bit using fixmaps 2008-10-31 10:12:38 +01:00
ioremap.c x86: fix assumed to be contiguous leaf page tables for kmap_atomic region (take 2) 2009-01-16 13:47:04 +01:00
k8topology_64.c x86: k8 numa register active regions later 2009-01-06 13:21:21 +01:00
kmmio.c
Makefile Merge branches 'tracing/ftrace', 'tracing/fastboot', 'tracing/nmisafe' and 'tracing/urgent' into tracing/core 2008-11-08 09:34:35 +01:00
memtest.c x86: memtest fix use of reserve_early() 2008-10-22 17:08:06 +02:00
mmap.c
mmio-mod.c mmiotrace: remove left-over marker cruft 2008-10-14 10:37:17 +02:00
numa_32.c trivial: replace last usages of __FUNCTION__ in kernel 2009-01-07 15:48:54 -08:00
numa_64.c x86: prepare for cpumask iterators to only go to nr_cpu_ids 2008-12-16 17:40:58 -08:00
pageattr-test.c
pageattr.c x86: fix page attribute corruption with cpa() 2009-01-21 12:24:54 +01:00
pat.c x86, pat: fix reserve_memtype() for legacy 1MB range 2009-01-14 20:14:45 +01:00
pf_in.c x86: fix mmiotrace 8-bit register decoding 2008-10-14 10:33:50 +02:00
pf_in.h
pgtable.c
pgtable_32.c
srat_32.c
srat_64.c x86: prepare for cpumask iterators to only go to nr_cpu_ids 2008-12-16 17:40:58 -08:00
testmmiotrace.c x86 mmiotrace: implement mmiotrace_printk() 2008-10-14 10:37:11 +02:00