Skip to content

Commit b422d28

Browse files
zongboxtorvalds
authored andcommitted
riscv: support DEBUG_WX
Support DEBUG_WX to check whether there are mapping with write and execute permission at the same time. [[email protected]: replace macros with C] Signed-off-by: Zong Li <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Will Deacon <[email protected]> Link: http://lkml.kernel.org/r/282e266311bced080bc6f7c255b92f87c1eb65d6.1587455584.git.zong.li@sifive.com Signed-off-by: Linus Torvalds <[email protected]>
1 parent 375d315 commit b422d28

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

arch/riscv/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ config RISCV
1616
select OF_EARLY_FLATTREE
1717
select OF_IRQ
1818
select ARCH_HAS_BINFMT_FLAT
19+
select ARCH_HAS_DEBUG_WX
1920
select ARCH_WANT_FRAME_POINTERS
2021
select CLONE_BACKWARDS
2122
select COMMON_CLK

arch/riscv/include/asm/ptdump.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,15 @@
88

99
void ptdump_check_wx(void);
1010

11+
#ifdef CONFIG_DEBUG_WX
12+
static inline void debug_checkwx(void)
13+
{
14+
ptdump_check_wx();
15+
}
16+
#else
17+
static inline void debug_checkwx(void)
18+
{
19+
}
20+
#endif
21+
1122
#endif /* _ASM_RISCV_PTDUMP_H */

arch/riscv/mm/init.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <asm/sections.h>
2020
#include <asm/pgtable.h>
2121
#include <asm/io.h>
22+
#include <asm/ptdump.h>
2223

2324
#include "../kernel/head.h"
2425

@@ -514,6 +515,8 @@ void mark_rodata_ro(void)
514515
set_memory_ro(rodata_start, (data_start - rodata_start) >> PAGE_SHIFT);
515516
set_memory_nx(rodata_start, (data_start - rodata_start) >> PAGE_SHIFT);
516517
set_memory_nx(data_start, (max_low - data_start) >> PAGE_SHIFT);
518+
519+
debug_checkwx();
517520
}
518521
#endif
519522

0 commit comments

Comments
 (0)