summaryrefslogtreecommitdiff
path: root/mm/highmem.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2020-11-18 22:48:40 +0300
committerThomas Gleixner <tglx@linutronix.de>2020-11-24 16:42:08 +0300
commit0e91a0c6984c837a7c6760e3f28e8e1c532abf87 (patch)
treeca90a3abad7717fa27186c38c2ed0c02f93ab7de /mm/highmem.c
parent6e799cb69a70eedbb41561b750f7180c12cff280 (diff)
downloadlinux-0e91a0c6984c837a7c6760e3f28e8e1c532abf87.tar.xz
mm/highmem: Provide CONFIG_DEBUG_KMAP_LOCAL_FORCE_MAP
CONFIG_DEBUG_KMAP_LOCAL, which is selected by CONFIG_DEBUG_HIGHMEM is only providing guard pages, but does not provide a mechanism to enforce the usage of the kmap_local() infrastructure. Provide CONFIG_DEBUG_KMAP_LOCAL_FORCE_MAP which forces the temporary mapping even for lowmem pages. This needs to be a seperate config switch because this only works on architectures which do not have cache aliasing problems. Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20201118204007.028261233@linutronix.de
Diffstat (limited to 'mm/highmem.c')
-rw-r--r--mm/highmem.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/mm/highmem.c b/mm/highmem.c
index fab128de97de..39aaca1a1ece 100644
--- a/mm/highmem.c
+++ b/mm/highmem.c
@@ -474,7 +474,12 @@ void *__kmap_local_page_prot(struct page *page, pgprot_t prot)
{
void *kmap;
- if (!PageHighMem(page))
+ /*
+ * To broaden the usage of the actual kmap_local() machinery always map
+ * pages when debugging is enabled and the architecture has no problems
+ * with alias mappings.
+ */
+ if (!IS_ENABLED(CONFIG_DEBUG_KMAP_LOCAL_FORCE_MAP) && !PageHighMem(page))
return page_address(page);
/* Try kmap_high_get() if architecture has it enabled */
@@ -494,6 +499,11 @@ void kunmap_local_indexed(void *vaddr)
if (addr < __fix_to_virt(FIX_KMAP_END) ||
addr > __fix_to_virt(FIX_KMAP_BEGIN)) {
+ if (IS_ENABLED(CONFIG_DEBUG_KMAP_LOCAL_FORCE_MAP)) {
+ /* This _should_ never happen! See above. */
+ WARN_ON_ONCE(1);
+ return;
+ }
/*
* Handle mappings which were obtained by kmap_high_get()
* first as the virtual address of such mappings is below