MIPS: Fix detection of unsupported highmem with cache aliases
The paging_init() function contains code which detects that highmem is
in use but unsupported due to dcache aliasing. However this code was
ineffective because it was being run before the caches are probed,
meaning that cpu_has_dc_aliases would always evaluate to false (unless a
platform overrides it to a compile-time constant) and the detection of
the unsupported case is never triggered. The kernel would then go on to
attempt to use highmem & either hit coherency issues or trigger the
BUG_ON in flush_kernel_dcache_page().
Fix this by running paging_init() later than cpu_cache_init(), such that
the cpu_has_dc_aliases macro will evaluate correctly & the unsupported
highmem case will be detected successfully.
This then leads to a formerly hidden issue in that
mem_init_free_highmem() will attempt to free all highmem pages, even
though we're avoiding use of them & don't have valid page structs for
them. This leads to an invalid pointer dereference & a TLB exception.
Avoid this by skipping the loop in mem_init_free_highmem() if
cpu_has_dc_aliases evaluates true.
Signed-off-by: Paul Burton <email@example.com>
Cc: Rabin Vincent <firstname.lastname@example.org>
Cc: Matt Redfearn <email@example.com>
Cc: Jerome Marchand <firstname.lastname@example.org>
Cc: Alexander Sverdlin <email@example.com>
Cc: Aurelien Jarno <firstname.lastname@example.org>
Cc: Jaedon Shin <email@example.com>
Cc: Toshi Kani <firstname.lastname@example.org>
Cc: James Hogan <email@example.com>
Cc: Sergey Ryazanov <firstname.lastname@example.org>
Cc: Jonas Gorski <email@example.com>
Cc: Kirill A. Shutemov <firstname.lastname@example.org>
Signed-off-by: Ralf Baechle <email@example.com>
2 files changed