lkml.org 
[lkml]   [2020]   [Apr]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v5 6/9] riscv: add ARCH_SUPPORTS_DEBUG_PAGEALLOC support
    Date
    ARCH_SUPPORTS_DEBUG_PAGEALLOC provides a hook to map and unmap
    pages for debugging purposes. Implement the __kernel_map_pages
    functions to fill the poison pattern.

    Signed-off-by: Zong Li <zong.li@sifive.com>
    Reviewed-by: Palmer Dabbelt <palmerdabbelt@google.com>
    ---
    arch/riscv/Kconfig | 3 +++
    arch/riscv/mm/pageattr.c | 13 +++++++++++++
    2 files changed, 16 insertions(+)

    diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
    index a94d0f064d9c..1e1efc998baf 100644
    --- a/arch/riscv/Kconfig
    +++ b/arch/riscv/Kconfig
    @@ -132,6 +132,9 @@ config ARCH_SELECT_MEMORY_MODEL
    config ARCH_WANT_GENERAL_HUGETLB
    def_bool y

    +config ARCH_SUPPORTS_DEBUG_PAGEALLOC
    + def_bool y
    +
    config SYS_SUPPORTS_HUGETLBFS
    def_bool y

    diff --git a/arch/riscv/mm/pageattr.c b/arch/riscv/mm/pageattr.c
    index 7be6cd67e2ef..728759eb530a 100644
    --- a/arch/riscv/mm/pageattr.c
    +++ b/arch/riscv/mm/pageattr.c
    @@ -172,3 +172,16 @@ int set_direct_map_default_noflush(struct page *page)

    return walk_page_range(&init_mm, start, end, &pageattr_ops, &masks);
    }
    +
    +void __kernel_map_pages(struct page *page, int numpages, int enable)
    +{
    + if (!debug_pagealloc_enabled())
    + return;
    +
    + if (enable)
    + __set_memory((unsigned long)page_address(page), numpages,
    + __pgprot(_PAGE_PRESENT), __pgprot(0));
    + else
    + __set_memory((unsigned long)page_address(page), numpages,
    + __pgprot(0), __pgprot(_PAGE_PRESENT));
    +}
    --
    2.26.0
    \
     
     \ /
      Last update: 2020-04-08 09:58    [W:2.699 / U:0.176 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site