FAILED: patch "[PATCH] riscv: force PAGE_SIZE linear mapping if debug_pagealloc is" failed to apply to 5.15-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x c67ddf59ac44adc60649730bf8347e37c516b001
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2024061951-green-cycle-3ffb@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..
Possible dependencies:
c67ddf59ac44 ("riscv: force PAGE_SIZE linear mapping if debug_pagealloc is enabled") 629db01c64ff ("riscv: Don't use PGD entries for the linear mapping") 49a0a3731596 ("riscv: Check the virtual alignment before choosing a map size") 25abe0db9243 ("riscv: Fix kfence now that the linear mapping can be backed by PUD/P4D/PGD") 310c33dc7a12 ("Merge patch series "Introduce 64b relocatable kernel"")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From c67ddf59ac44adc60649730bf8347e37c516b001 Mon Sep 17 00:00:00 2001
From: Nam Cao <[email protected]>
Date: Wed, 15 May 2024 07:50:39 +0200
Subject: [PATCH] riscv: force PAGE_SIZE linear mapping if debug_pagealloc is
enabled
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.
arch/riscv/mm/init.c +3 -0
@@ -668,6 +668,9 @@ void __init create_pgd_mapping(pgd_t *pgdp,static uintptr_t __init best_map_size (phys_addr_t pa,uintptr_t va,phys_addr_t size) { +if (debug_pagealloc_enabled ()) +return PAGE_SIZE ; +if (pgtable_l5_enabled && !(pa & (P4D_SIZE -1 )) && !(va & (P4D_SIZE -1 )) && size >=P4D_SIZE )return P4D_SIZE ;