Patch "riscv: force PAGE_SIZE linear mapping if debug_pagealloc is enabled" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    riscv: force PAGE_SIZE linear mapping if debug_pagealloc is enabled

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     riscv-force-page_size-linear-mapping-if-debug_pageal.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 4ba20a44587da91fc9d0b0e578d81ff2ea21e602
Author: Nam Cao <namcao@xxxxxxxxxxxxx>
Date:   Wed May 15 07:50:39 2024 +0200

    riscv: force PAGE_SIZE linear mapping if debug_pagealloc is enabled
    
    [ Upstream commit c67ddf59ac44adc60649730bf8347e37c516b001 ]
    
    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: 5fde3db5eb02 ("riscv: add ARCH_SUPPORTS_DEBUG_PAGEALLOC support")
    Signed-off-by: Nam Cao <namcao@xxxxxxxxxxxxx>
    Cc: stable@xxxxxxxxxxxxxxx
    Reviewed-by: Alexandre Ghiti <alexghiti@xxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/2e391fa6c6f9b3fcf1b41cefbace02ee4ab4bf59.1715750938.git.namcao@xxxxxxxxxxxxx
    Signed-off-by: Palmer Dabbelt <palmer@xxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 4d62f54698b99..8adcb9419ad50 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -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;




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux