linux/arch/riscv/mm
Nam Cao 05f263c166 riscv: force PAGE_SIZE linear mapping if debug_pagealloc is enabled
[ Upstream commit c67ddf59ac ]

debug_pagealloc is a debug feature which clears the valid bit in page table
entry for freed pages to detect illegal accesses to freed memory.

For this feature to work, virtual mapping must have PAGE_SIZE resolution.
(No, we cannot map with huge pages and split them only when needed; because
pages can be allocated/freed in atomic context and page splitting cannot be
done in atomic context)

Force linear mapping to use small pages if debug_pagealloc is enabled.

Note that it is not necessary to force the entire linear mapping, but only
those that are given to memory allocator. Some parts of memory can keep
using huge page mapping (for example, kernel's executable code). But these
parts are minority, so keep it simple. This is just a debug feature, some
extra overhead should be acceptable.

Fixes: 5fde3db5eb ("riscv: add ARCH_SUPPORTS_DEBUG_PAGEALLOC support")
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: stable@vger.kernel.org
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/2e391fa6c6f9b3fcf1b41cefbace02ee4ab4bf59.1715750938.git.namcao@linutronix.de
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-06-27 13:49:15 +02:00
..
cache-ops.c riscv: split cache ops out of dma-noncoherent.c 2023-11-28 17:19:49 +00:00
cacheflush.c riscv: implement the new page table range API 2023-08-24 16:20:23 -07:00
context.c riscv: mm: use bitmap_zero() API 2023-08-31 00:18:29 -07:00
dma-noncoherent.c riscv: split cache ops out of dma-noncoherent.c 2023-11-28 17:19:49 +00:00
extable.c riscv: extable: fix err reg writing in dedicated uaccess handler 2022-02-08 17:02:47 -08:00
fault.c riscv: handle VM_FAULT_[HWPOISON|HWPOISON_LARGE] faults instead of panicking 2023-10-06 14:11:38 -07:00
hugetlbpage.c riscv: Fix build error if !CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION 2024-03-06 14:48:37 +00:00
init.c riscv: force PAGE_SIZE linear mapping if debug_pagealloc is enabled 2024-06-27 13:49:15 +02:00
kasan_init.c RISC-V Patches for the 6.6 Merge Window, Part 1 2023-09-01 08:09:48 -07:00
Makefile riscv: split cache ops out of dma-noncoherent.c 2023-11-28 17:19:49 +00:00
pageattr.c riscv: rewrite __kernel_map_pages() to fix sleeping in invalid context 2024-06-21 14:38:42 +02:00
pgtable.c riscv: mm: Implement pmdp_collapse_flush for THP 2023-02-01 20:52:09 -08:00
physaddr.c riscv: Use PUD/P4D/PGD pages for the linear mapping 2023-04-18 20:43:04 -07:00
pmem.c riscv: mm: dma-noncoherent: nonstandard cache operations support 2023-09-01 09:08:57 -07:00
ptdump.c riscv: correct pt_level name via pgtable_l5/4_enabled 2023-11-28 17:20:13 +00:00
tlbflush.c riscv: mm: execute local TLB flush after populating vmemmap 2024-02-16 19:10:52 +01:00