powerpc: kprobes insn page fixes
Ritesh Harjani (IBM)
reviewerv2 cover powerpc: kprobes insn page fixes
Hi All,
A few fixes that came out of looking at a W+X warning at boot with KPROBES=y and MODULES=n.
- Patch-1 fixes that warning.
- Patch-2 (reported by Sashiko) fixes an oops on book3s/32 when a kprobe has to single step an instruction out of line, the insn page was in an NX segment.
- Patch-3 makes ptdump show "X" for kernel mappings on e500, which was noticed while testing the other two.
Ritesh Harjani (IBM) (3):
powerpc/execmem: Don't leave kprobes insn pages W+X when CONFIG_MODULES=n powerpc/execmem: Allocate kprobes insn pages from the modules area on book3s/32 powerpc/ptdump: Show the exec flag of kernel mappings on e500
arch/powerpc/mm/mem.c | 12 +++++++++--- arch/powerpc/mm/ptdump/shared.c | 6 +++--- 2 files changed, 12 insertions(+), 6 deletions(-)
--
2.39.5
Ritesh Harjani (IBM)
reviewerPATCH v2 1/3 powerpc/execmem: Don't leave kprobes insn pages W+X when CONFIG_MODULES=n
commit 2e83e2ce34ff ("arch, mm: promote DEBUG_WX to CHECK_WX"), made CHECK_WX default STRICT_KERNEL_RWX.
Now on powerpc, when we boot with CONFIG_KPROBES=y and CONFIG_MODULES=n, we can see the following warning splat at boot:
powerpc/mm: Found insecure W+X mapping at address 000000002ea08992/0xc008000000000000
WARNING: arch/powerpc/mm/ptdump/ptdump.c:194 at note_page+0x4dc/0x4fc, CPU#0: swapper/0/1
NIP [c0000000000ac204] note_page+0x4dc/0x4fc
LR [c0000000000ac200] note_page+0x4d8/0x4fc
Call Trace:
note_page+0x4d8/0x4fc (unreliable)
ptdump_pte_entry+0x70/0x94
walk_pte_range_inner+0x15c/0x260
walk_pgd_range+0x6d8/0xd5c
walk_page_range_debug+0xa4/0xf0
ptdump_walk_pgd+0xec/0x304
ptdump_check_wx+0xd8/0x154
kernel_init+0x94/0x26c
ret_from_kernel_user_thread+0x14/0x1c
Checked W+X mappings: FAILED, 1 W+X pages foundThis happens because CHECK_WX noted a writeable + executable mapping.
This happens because execmem_arch_setup(), checks for struct_modules_rwx_enabled(), while kprobes depenency on modules was earlier removed via commit:
7582b7be16d0 ("kprobes: remove dependency on CONFIG_MODULES")
Since the insn slots are only written with patch_instruction(), which does not need this mapping to be writable. This patch fixes it by checking for strict_kernel_rwx_enabled() instead.
--- arch/powerpc/mm/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/mm/mem.c +1 -1
@@ -388,7 +388,7 @@ static void prealloc_execmem_pgtable(void) { }struct execmem_info __init *execmem_arch_setup (void ) { -pgprot_t kprobes_prot =strict_module_rwx_enabled () ?PAGE_KERNEL_ROX :PAGE_KERNEL_EXEC ; +pgprot_t kprobes_prot =strict_kernel_rwx_enabled () ?PAGE_KERNEL_ROX :PAGE_KERNEL_EXEC ;pgprot_t prot =strict_module_rwx_enabled () ?PAGE_KERNEL :PAGE_KERNEL_EXEC ;unsigned long fallback_start =0 , fallback_end =0 ;unsigned long start, end;
Signature · 1 line
2.39.5
Christophe Leroy (CS GROUP)
reviewerRe: [PATCHv2 1/3] powerpc/execmem: Don't leave kprobes insn pages W+X when CONFIG_MODULES=n
Le 13/11/2026 à 13:31, Ritesh Harjani (IBM) a écrit :
Quoted 43 lines
commit
2e83e2ce34ff("arch, mm: promoteDEBUG_WXtoCHECK_WX"), madeCHECK_WXdefaultSTRICT_KERNEL_RWX.Now on powerpc, when we boot with
CONFIG_KPROBES=yandCONFIG_MODULES=n, we can see the following warning splat at boot:powerpc/mm: Found insecure W+X mapping at address 000000002ea08992/0xc008000000000000 WARNING: arch/powerpc/mm/ptdump/ptdump.c:194 at note_page+0x4dc/0x4fc, CPU#0: swapper/0/1 NIP [c0000000000ac204] note_page+0x4dc/0x4fc LR [c0000000000ac200] note_page+0x4d8/0x4fc Call Trace: note_page+0x4d8/0x4fc (unreliable) ptdump_pte_entry+0x70/0x94 walk_pte_range_inner+0x15c/0x260 walk_pgd_range+0x6d8/0xd5c walk_page_range_debug+0xa4/0xf0 ptdump_walk_pgd+0xec/0x304 ptdump_check_wx+0xd8/0x154 kernel_init+0x94/0x26c ret_from_kernel_user_thread+0x14/0x1c Checked W+X mappings: FAILED, 1 W+X pages foundThis happens because
CHECK_WXnoted a writeable + executable mapping.This happens because
execmem_arch_setup(), checks forstruct_modules_rwx_enabled(), while kprobes depenency on modules was earlier removed via commit:
7582b7be16d0("kprobes: remove dependency onCONFIG_MODULES")
Since the insn slots are only written withpatch_instruction(), which does not need this mapping to be writable. This patch fixes it by checking forstrict_kernel_rwx_enabled()instead.Fixes 7582b7be16d0 ("kprobes: remove dependency on CONFIG_MODULES")Signed-off-by Ritesh Harjani (IBM) <[email protected]>--- arch/powerpc/mm/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/powerpc/mm/mem.c +0
-0
arch/powerpc/mm/mem.c static void prealloc_execmem_pgtable(void) { } · line 392
Quoted 6 lines
arch/powerpc/mm/mem.c +1
-1@@ -388,7 +388,7 @@ static void prealloc_execmem_pgtable(void) { }struct execmem_info __init *execmem_arch_setup (void ) { -pgprot_t kprobes_prot =strict_module_rwx_enabled () ?PAGE_KERNEL_ROX :PAGE_KERNEL_EXEC ; +pgprot_t kprobes_prot =strict_kernel_rwx_enabled () ?PAGE_KERNEL_ROX :PAGE_KERNEL_EXEC ;pgprot_t prot =strict_module_rwx_enabled () ?PAGE_KERNEL :PAGE_KERNEL_EXEC ;
Looking at this, I'd use PAGE_KERNEL_X instead of PAGE_KERNEL_EXEC.
Then we could get rid of PAGE_KERNEL_EXEC completely for powerpc.
Quoted 2 lines
arch/powerpc/mm/mem.c +0
-0unsigned long fallback_start =0 , fallback_end =0 ;unsigned long start, end;
Ritesh Harjani (IBM)
reviewerRe: [PATCHv2 1/3] powerpc/execmem: Don't leave kprobes insn pages W+X when CONFIG_MODULES=n
Quoted 53 lines · Christophe Leroy (CS GROUP)
Le 13/11/2026 à 13:31, Ritesh Harjani (IBM) a écrit :
Quoted 43 lines
commit
2e83e2ce34ff("arch, mm: promoteDEBUG_WXtoCHECK_WX"), madeCHECK_WXdefaultSTRICT_KERNEL_RWX.Now on powerpc, when we boot with
CONFIG_KPROBES=yandCONFIG_MODULES=n, we can see the following warning splat at boot:powerpc/mm: Found insecure W+X mapping at address 000000002ea08992/0xc008000000000000 WARNING: arch/powerpc/mm/ptdump/ptdump.c:194 at note_page+0x4dc/0x4fc, CPU#0: swapper/0/1 NIP [c0000000000ac204] note_page+0x4dc/0x4fc LR [c0000000000ac200] note_page+0x4d8/0x4fc Call Trace: note_page+0x4d8/0x4fc (unreliable) ptdump_pte_entry+0x70/0x94 walk_pte_range_inner+0x15c/0x260 walk_pgd_range+0x6d8/0xd5c walk_page_range_debug+0xa4/0xf0 ptdump_walk_pgd+0xec/0x304 ptdump_check_wx+0xd8/0x154 kernel_init+0x94/0x26c ret_from_kernel_user_thread+0x14/0x1c Checked W+X mappings: FAILED, 1 W+X pages foundThis happens because
CHECK_WXnoted a writeable + executable mapping.This happens because
execmem_arch_setup(), checks forstruct_modules_rwx_enabled(), while kprobes depenency on modules was earlier removed via commit:
7582b7be16d0("kprobes: remove dependency onCONFIG_MODULES")
Since the insn slots are only written withpatch_instruction(), which does not need this mapping to be writable. This patch fixes it by checking forstrict_kernel_rwx_enabled()instead.Fixes 7582b7be16d0 ("kprobes: remove dependency on CONFIG_MODULES")Signed-off-by Ritesh Harjani (IBM) <[email protected]>--- arch/powerpc/mm/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/powerpc/mm/mem.c +0
-0arch/powerpc/mm/mem.c static void prealloc_execmem_pgtable(void) { } · line 392
Quoted 6 lines
arch/powerpc/mm/mem.c +1
-1@@ -388,7 +388,7 @@ static void prealloc_execmem_pgtable(void) { }struct execmem_info __init *execmem_arch_setup (void ) { -pgprot_t kprobes_prot =strict_module_rwx_enabled () ?PAGE_KERNEL_ROX :PAGE_KERNEL_EXEC ; +pgprot_t kprobes_prot =strict_kernel_rwx_enabled () ?PAGE_KERNEL_ROX :PAGE_KERNEL_EXEC ;pgprot_t prot =strict_module_rwx_enabled () ?PAGE_KERNEL :PAGE_KERNEL_EXEC ;Looking at this, I'd use
PAGE_KERNEL_Xinstead ofPAGE_KERNEL_EXEC.
Quoted 2 lines
Then we could get rid of
PAGE_KERNEL_EXECcompletely for powerpc.
I think it's best if we keep the definition of PAGE_KERNEL_EXEC on powerpc as PAGE_KERNEL_X, I think the core expects the arch to define this, if not, then it defaults to PAGE_KERNEL e.g. see this:
include/linux/pgtable.h:
#ifndef PAGE_KERNEL_EXEC
# define PAGE_KERNEL_EXEC PAGE_KERNEL #endif
Also mm/execmem references PAGE_KERNEL_EXEC in __execmem_init(). Although it references only when execmem_arch_setup() is not defined by the arch (which is not true for powerpc).
However, even though nothing breaks today, but later if there are other users of PAGE_KERNEL_EXEC, then PAGE_KERNEL does not have X (execute) bit enabled, so it might break in future. Plus looking at above, I believe there is no harm in keeping it - since core expects the platform to define it's own definition - due to all the other references it has.
Thoughts?
However, if you still think we should remove it (?) - then I feel let's do that as a separate cleanup patch. Since this keeps the usage of EXEC same between prot and kprobes_prot variables in patch-1, which we also need to backport.
Thanks for the quick reviews!
-ritesh
Ritesh Harjani (IBM)
reviewerRe: [PATCHv2 1/3] powerpc/execmem: Don't leave kprobes insn pages W+X when CONFIG_MODULES=n
Hi Christophe,
Quoted 78 lines · Ritesh Harjani (IBM)
Quoted 53 lines · Christophe Leroy (CS GROUP)
Le 13/11/2026 à 13:31, Ritesh Harjani (IBM) a écrit :
Quoted 43 lines
commit
2e83e2ce34ff("arch, mm: promoteDEBUG_WXtoCHECK_WX"), madeCHECK_WXdefaultSTRICT_KERNEL_RWX.Now on powerpc, when we boot with
CONFIG_KPROBES=yandCONFIG_MODULES=n, we can see the following warning splat at boot:powerpc/mm: Found insecure W+X mapping at address 000000002ea08992/0xc008000000000000 WARNING: arch/powerpc/mm/ptdump/ptdump.c:194 at note_page+0x4dc/0x4fc, CPU#0: swapper/0/1 NIP [c0000000000ac204] note_page+0x4dc/0x4fc LR [c0000000000ac200] note_page+0x4d8/0x4fc Call Trace: note_page+0x4d8/0x4fc (unreliable) ptdump_pte_entry+0x70/0x94 walk_pte_range_inner+0x15c/0x260 walk_pgd_range+0x6d8/0xd5c walk_page_range_debug+0xa4/0xf0 ptdump_walk_pgd+0xec/0x304 ptdump_check_wx+0xd8/0x154 kernel_init+0x94/0x26c ret_from_kernel_user_thread+0x14/0x1c Checked W+X mappings: FAILED, 1 W+X pages foundThis happens because
CHECK_WXnoted a writeable + executable mapping.This happens because
execmem_arch_setup(), checks forstruct_modules_rwx_enabled(), while kprobes depenency on modules was earlier removed via commit:
7582b7be16d0("kprobes: remove dependency onCONFIG_MODULES")
Since the insn slots are only written withpatch_instruction(), which does not need this mapping to be writable. This patch fixes it by checking forstrict_kernel_rwx_enabled()instead.Fixes 7582b7be16d0 ("kprobes: remove dependency on CONFIG_MODULES")Signed-off-by Ritesh Harjani (IBM) <[email protected]>--- arch/powerpc/mm/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/powerpc/mm/mem.c +0
-0arch/powerpc/mm/mem.c static void prealloc_execmem_pgtable(void) { } · line 392
Quoted 6 lines
arch/powerpc/mm/mem.c +1
-1@@ -388,7 +388,7 @@ static void prealloc_execmem_pgtable(void) { }struct execmem_info __init *execmem_arch_setup (void ) { -pgprot_t kprobes_prot =strict_module_rwx_enabled () ?PAGE_KERNEL_ROX :PAGE_KERNEL_EXEC ; +pgprot_t kprobes_prot =strict_kernel_rwx_enabled () ?PAGE_KERNEL_ROX :PAGE_KERNEL_EXEC ;pgprot_t prot =strict_module_rwx_enabled () ?PAGE_KERNEL :PAGE_KERNEL_EXEC ;Looking at this, I'd use
PAGE_KERNEL_Xinstead ofPAGE_KERNEL_EXEC.Quoted 2 lines
Then we could get rid of
PAGE_KERNEL_EXECcompletely for powerpc.I think it's best if we keep the definition of
PAGE_KERNEL_EXECon powerpc asPAGE_KERNEL_X, I think the core expects the arch to define this, if not, then it defaults toPAGE_KERNELe.g. see this:
include/linux/pgtable.h:
#ifndefPAGE_KERNEL_EXEC# define PAGE_KERNEL_EXEC PAGE_KERNEL #endifAlso mm/execmem references
PAGE_KERNEL_EXECin__execmem_init(). Although it references only whenexecmem_arch_setup()is not defined by the arch (which is not true for powerpc).However, even though nothing breaks today, but later if there are other users of
PAGE_KERNEL_EXEC, thenPAGE_KERNELdoes not have X (execute) bit enabled, so it might break in future. Plus looking at above, I believe there is no harm in keeping it - since core expects the platform to define it's own definition - due to all the other references it has.
Quoted 7 lines
Thoughts?
However, if you still think we should remove it (?) - then I feel let's do that as a separate cleanup patch. Since this keeps the usage of EXEC same between prot and
kprobes_protvariables in patch-1, which we also need to backport.
Gentle ping on above queries!
-ritesh
Christophe Leroy (CS GROUP)
reviewerRe: [PATCHv2 1/3] powerpc/execmem: Don't leave kprobes insn pages W+X when CONFIG_MODULES=n
In reply to Ritesh Harjani (IBM)Hi Ritesh,
Thanks for your patience,
Le 17/11/2026 à 18:15, Ritesh Harjani a écrit :
Quoted 55 lines
Quoted 53 lines · Christophe Leroy (CS GROUP)
Le 13/11/2026 à 13:31, Ritesh Harjani (IBM) a écrit :
Quoted 43 lines
commit
2e83e2ce34ff("arch, mm: promoteDEBUG_WXtoCHECK_WX"), madeCHECK_WXdefaultSTRICT_KERNEL_RWX.Now on powerpc, when we boot with
CONFIG_KPROBES=yandCONFIG_MODULES=n, we can see the following warning splat at boot:powerpc/mm: Found insecure W+X mapping at address 000000002ea08992/0xc008000000000000 WARNING: arch/powerpc/mm/ptdump/ptdump.c:194 at note_page+0x4dc/0x4fc, CPU#0: swapper/0/1 NIP [c0000000000ac204] note_page+0x4dc/0x4fc LR [c0000000000ac200] note_page+0x4d8/0x4fc Call Trace: note_page+0x4d8/0x4fc (unreliable) ptdump_pte_entry+0x70/0x94 walk_pte_range_inner+0x15c/0x260 walk_pgd_range+0x6d8/0xd5c walk_page_range_debug+0xa4/0xf0 ptdump_walk_pgd+0xec/0x304 ptdump_check_wx+0xd8/0x154 kernel_init+0x94/0x26c ret_from_kernel_user_thread+0x14/0x1c Checked W+X mappings: FAILED, 1 W+X pages foundThis happens because
CHECK_WXnoted a writeable + executable mapping.This happens because
execmem_arch_setup(), checks forstruct_modules_rwx_enabled(), while kprobes depenency on modules was earlier removed via commit:
7582b7be16d0("kprobes: remove dependency onCONFIG_MODULES")
Since the insn slots are only written withpatch_instruction(), which does not need this mapping to be writable. This patch fixes it by checking forstrict_kernel_rwx_enabled()instead.Fixes 7582b7be16d0 ("kprobes: remove dependency on CONFIG_MODULES")Signed-off-by Ritesh Harjani (IBM) <[email protected]>--- arch/powerpc/mm/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/powerpc/mm/mem.c +0
-0arch/powerpc/mm/mem.c static void prealloc_execmem_pgtable(void) { } · line 392
Quoted 6 lines
arch/powerpc/mm/mem.c +1
-1@@ -388,7 +388,7 @@ static void prealloc_execmem_pgtable(void) { }struct execmem_info __init *execmem_arch_setup (void ) { -pgprot_t kprobes_prot =strict_module_rwx_enabled () ?PAGE_KERNEL_ROX :PAGE_KERNEL_EXEC ; +pgprot_t kprobes_prot =strict_kernel_rwx_enabled () ?PAGE_KERNEL_ROX :PAGE_KERNEL_EXEC ;pgprot_t prot =strict_module_rwx_enabled () ?PAGE_KERNEL :PAGE_KERNEL_EXEC ;Looking at this, I'd use
PAGE_KERNEL_Xinstead ofPAGE_KERNEL_EXEC.
Quoted 6 lines
Quoted 2 lines
Then we could get rid of
PAGE_KERNEL_EXECcompletely for powerpc.I think it's best if we keep the definition of
PAGE_KERNEL_EXECon powerpc asPAGE_KERNEL_X, I think the core expects the arch to define this, if not, then it defaults toPAGE_KERNELe.g. see this:
Yes, which is consistent with what powerpc does when strict modules rwx is enabled.
And indeed it doesn't matter, because module code does a rw allocation at the begining then convert it to ROX or X later in module_enable_text_rox(). See comment :
/*
* Since some arches are moving towards PAGE_KERNEL module allocations
instead
* of PAGE_KERNEL_EXEC, keep module_enable_x() independent of
* CONFIG_STRICT_MODULE_RWX because they are needed regardless of
whether we
* are strict.
*/
So really PAGE_KERNEL is what is expected nowadays.
Quoted 11 lines
include/linux/pgtable.h:#ifndef PAGE_KERNEL_EXEC # define PAGE_KERNEL_EXEC PAGE_KERNEL #endifAlso mm/execmem references
PAGE_KERNEL_EXECin__execmem_init(). Although it references only whenexecmem_arch_setup()is not defined by the arch (which is not true for powerpc).
Quoted 7 lines
However, even though nothing breaks today, but later if there are other users of
PAGE_KERNEL_EXEC, thenPAGE_KERNELdoes not have X (execute) bit enabled, so it might break in future. Plus looking at above, I believe there is no harm in keeping it - since core expects the platform to define it's own definition - due to all the other references it has.Thoughts?
Yes but PAGE_KERNEL not having X is on purpose, module first allocates non-X mem, sets up everything then converts to X or ROX. I don't think there will be any more users of PAGE_KERNEL_EXEC in the future. It is going in the other direction I think.
Quoted 5 lines
However, if you still think we should remove it (?) - then I feel let's do that as a separate cleanup patch. Since this keeps the usage of EXEC same between prot and
kprobes_protvariables in patch-1, which we also need to backport.
At least we should stop using it in our own arch, it would help with readability. And really I think we shoud drop it completely. But OK to have it as a separate patch not to be back-ported.
By the way I also see CONFIG_ARCH_HAS_EXECMEM_ROX, maybe we should investigate in using it on powerpc.
Christophe
Ritesh Harjani (IBM)
reviewerRe: [PATCHv2 1/3] powerpc/execmem: Don't leave kprobes insn pages W+X when CONFIG_MODULES=n
Quoted 83 lines · Christophe Leroy (CS GROUP)
Hi Ritesh,
Thanks for your patience,
Le 17/11/2026 à 18:15, Ritesh Harjani a écrit :
Quoted 55 lines
Quoted 53 lines · Christophe Leroy (CS GROUP)
Le 13/11/2026 à 13:31, Ritesh Harjani (IBM) a écrit :
Quoted 43 lines
commit
2e83e2ce34ff("arch, mm: promoteDEBUG_WXtoCHECK_WX"), madeCHECK_WXdefaultSTRICT_KERNEL_RWX.Now on powerpc, when we boot with
CONFIG_KPROBES=yandCONFIG_MODULES=n, we can see the following warning splat at boot:powerpc/mm: Found insecure W+X mapping at address 000000002ea08992/0xc008000000000000 WARNING: arch/powerpc/mm/ptdump/ptdump.c:194 at note_page+0x4dc/0x4fc, CPU#0: swapper/0/1 NIP [c0000000000ac204] note_page+0x4dc/0x4fc LR [c0000000000ac200] note_page+0x4d8/0x4fc Call Trace: note_page+0x4d8/0x4fc (unreliable) ptdump_pte_entry+0x70/0x94 walk_pte_range_inner+0x15c/0x260 walk_pgd_range+0x6d8/0xd5c walk_page_range_debug+0xa4/0xf0 ptdump_walk_pgd+0xec/0x304 ptdump_check_wx+0xd8/0x154 kernel_init+0x94/0x26c ret_from_kernel_user_thread+0x14/0x1c Checked W+X mappings: FAILED, 1 W+X pages foundThis happens because
CHECK_WXnoted a writeable + executable mapping.This happens because
execmem_arch_setup(), checks forstruct_modules_rwx_enabled(), while kprobes depenency on modules was earlier removed via commit:
7582b7be16d0("kprobes: remove dependency onCONFIG_MODULES")
Since the insn slots are only written withpatch_instruction(), which does not need this mapping to be writable. This patch fixes it by checking forstrict_kernel_rwx_enabled()instead.Fixes 7582b7be16d0 ("kprobes: remove dependency on CONFIG_MODULES")Signed-off-by Ritesh Harjani (IBM) <[email protected]>--- arch/powerpc/mm/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/powerpc/mm/mem.c +0
-0arch/powerpc/mm/mem.c static void prealloc_execmem_pgtable(void) { } · line 392
Quoted 6 lines
arch/powerpc/mm/mem.c +1
-1@@ -388,7 +388,7 @@ static void prealloc_execmem_pgtable(void) { }struct execmem_info __init *execmem_arch_setup (void ) { -pgprot_t kprobes_prot =strict_module_rwx_enabled () ?PAGE_KERNEL_ROX :PAGE_KERNEL_EXEC ; +pgprot_t kprobes_prot =strict_kernel_rwx_enabled () ?PAGE_KERNEL_ROX :PAGE_KERNEL_EXEC ;pgprot_t prot =strict_module_rwx_enabled () ?PAGE_KERNEL :PAGE_KERNEL_EXEC ;Looking at this, I'd use
PAGE_KERNEL_Xinstead ofPAGE_KERNEL_EXEC.Quoted 6 lines
Quoted 2 lines
Then we could get rid of
PAGE_KERNEL_EXECcompletely for powerpc.I think it's best if we keep the definition of
PAGE_KERNEL_EXECon powerpc asPAGE_KERNEL_X, I think the core expects the arch to define this, if not, then it defaults toPAGE_KERNELe.g. see this:Yes, which is consistent with what powerpc does when strict modules rwx is enabled.
And indeed it doesn't matter, because module code does a rw allocation at the begining then convert it to ROX or X later in
module_enable_text_rox(). See comment :/*
* Since some arches are moving towardsPAGE_KERNELmodule allocations
instead
* ofPAGE_KERNEL_EXEC, keepmodule_enable_x()independent of
*CONFIG_STRICT_MODULE_RWXbecause they are needed regardless of
whether we
* are strict.
*/
Quoted 2 lines
So really
PAGE_KERNELis what is expected nowadays.
Thanks. Yes, I looked at the git history and I agree with you.
Quoted 25 lines
Quoted 11 lines
include/linux/pgtable.h:#ifndef PAGE_KERNEL_EXEC # define PAGE_KERNEL_EXEC PAGE_KERNEL #endifAlso mm/execmem references
PAGE_KERNEL_EXECin__execmem_init(). Although it references only whenexecmem_arch_setup()is not defined by the arch (which is not true for powerpc).Quoted 7 lines
However, even though nothing breaks today, but later if there are other users of
PAGE_KERNEL_EXEC, thenPAGE_KERNELdoes not have X (execute) bit enabled, so it might break in future. Plus looking at above, I believe there is no harm in keeping it - since core expects the platform to define it's own definition - due to all the other references it has.Thoughts?
Yes but
PAGE_KERNELnot having X is on purpose, module first allocates non-X mem, sets up everything then converts to X or ROX. I don't think there will be any more users ofPAGE_KERNEL_EXECin the future. It is going in the other direction I think.Quoted 1 line
Quoted 9 lines
Quoted 4 lines
However, if you still think we should remove it (?) - then I feel let's do that as a separate cleanup patch. Since this keeps the usage of EXEC same between prot and
kprobes_protvariables in patch-1, which we also need to backport.At least we should stop using it in our own arch, it would help with readability. And really I think we shoud drop it completely. But OK to have it as a separate patch not to be back-ported.
Right. Agreed Christophe, thanks for sharing the pointers.
After looking at the history of changes in there, I see that since commit:
4fcc636615b1 ("powerpc/modules: Make module_alloc() Strict Module RWX aware")
module text is allocated with PAGE_KERNEL, when STRICT_MODULE_RWX is enabled and only made executable later, so there is no longer a reason for a separate name there.
So, let me add a separate patch in this series, which will drop PAGE_KERNEL_EXEC definition from powerpc and it's last remaining users will be converted to it's alias PAGE_KERNEL_X.
Quoted 3 lines
By the way I also see
CONFIG_ARCH_HAS_EXECMEM_ROX, maybe we should investigate in using it on powerpc.
Yes, while doing this work I came across it too. Surely, will take a look at it from powerpc perspective.
Quoted 1 line
Christophe
Thanks for the reviews! Will soon spin up the next revision with all comments addressed and add this cleanup patch at the end.
-ritesh
Ritesh Harjani (IBM)
reviewerPATCH v2 2/3 powerpc/execmem: Allocate kprobes insn pages from the modules area on book3s/32
In reply to Ritesh Harjani (IBM)On book3s/32, a kprobe on an instruction that can't be emulated and has to be single stepped out of line, crashes the kernel. For e.g. with the following cmds...
~> echo 9 > /proc/sys/kernel/printk
~> mount -t debugfs debugfs /sys/kernel/debug
~> echo 'p:wx filldir64+0xb8' > /sys/kernel/debug/tracing/kprobe_events ~> echo 1 > /sys/kernel/debug/tracing/events/kprobes/wx/enable ~> echo 1 > /sys/kernel/debug/tracing/events/kprobes/enable
...we can see the following crash:
kernel tried to execute exec-protected page (f101a008) - exploit attempt? (uid: 0)
BUG: Unable to handle kernel instruction fetch
Faulting instruction address: 0xc02b919c
Vector: 400 (Instruction Access) at [f19a9d60]
pc: c02b919c: filldir64+0xb8/0x2dc
lr: c02b9148: filldir64+0x64/0x2dc
sp: f19a9e20
msr: 10029032
current = 0xc112e900
pid = 102, comm = ls
enter ? for help
[f19a9e20] c1a8d420 (unreliable)
[f19a9e50] c02e4074 dcache_readdir+0x208/0x2a8
[f19a9e90] c02b8c5c iterate_dir+0x88/0x1fc
[f19a9ec0] c02b96e0 sys_getdents64+0x88/0x198
[f19a9f10] c0014400 system_call_exception+0xf8/0x20c
[f19a9f30] c00191ac ret_from_syscall+0x0/0x2c
---- Exception: c00 (System Call) at a7596164
SP (af802310) is in userspaceThis happens because on book3s/32 the exec permission is per segment (256MB), not per page. The page tables have no hardware exec bit, only the segment registers have a no-execute (N) bit. mmu_mark_initmem_nx() sets N on all the kernel segments except the ones of the modules area. So nothing in the vmalloc area can be executed, even when the page is mapped with PAGE_KERNEL_ROX or PAGE_KERNEL_EXEC, because _PAGE_EXEC is a software only bit there and the segment's N bit is what the MMU enforces.
Before commit 1b750c2fbf82 ("powerpc: extend execmem_params for kprobes allocations"), the kprobes insn pages came from module_alloc(). That commit moved them to the whole of the vmalloc space, on the grounds that kprobes use a breakpoint and don't need to be near the kernel text. That is fine on platforms where the exec permission is per page, as PAGE_KERNEL_ROX is then enough to make a vmalloc page executable. It is not on book3s/32, where the modules area is not only close to the kernel text but is also the only page-mapped area whose segment is left executable. So the insn pages must keep coming from there.
Hence, use the modules area for EXECMEM_KPROBES on book3s/32.
--- arch/powerpc/mm/mem.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/powerpc/mm/mem.c +8 -2
@@ -391,6 +391,7 @@ struct execmem_info __init *execmem_arch_setup(void)pgprot_t kprobes_prot =strict_kernel_rwx_enabled () ?PAGE_KERNEL_ROX :PAGE_KERNEL_EXEC ;pgprot_t prot =strict_module_rwx_enabled () ?PAGE_KERNEL :PAGE_KERNEL_EXEC ;unsigned long fallback_start =0 , fallback_end =0 ; +unsigned long kprobes_start =VMALLOC_START , kprobes_end =VMALLOC_END ;unsigned long start, end;/*
@@ -410,6 +411,11 @@ struct execmem_info __init *execmem_arch_setup(void) } end =MODULES_END ; + +if (IS_ENABLED (CONFIG_PPC_BOOK3S_32 )) { + kprobes_start =MODULES_VADDR ; + kprobes_end =MODULES_END ; + }#else start =VMALLOC_START ; end =VMALLOC_END ;
@@ -428,8 +434,8 @@ struct execmem_info __init *execmem_arch_setup(void) .fallback_end = fallback_end, }, [EXECMEM_KPROBES] = { - .start = VMALLOC_START, - .end = VMALLOC_END, + .start = kprobes_start, + .end = kprobes_end, .pgprot = kprobes_prot, .alignment = 1, },
--
2.39.5
Re: [PATCHv2 2/3] powerpc/execmem: Allocate kprobes insn pages from the modules area on book3s/32
Quoted 49 lines · Ritesh Harjani (IBM)
On book3s/32, a kprobe on an instruction that can't be emulated and has to be single stepped out of line, crashes the kernel. For e.g. with the following cmds...
~> echo 9 >/proc/sys/kernel/printk
~> mount -t debugfs debugfs/sys/kernel/debug
~> echo 'p:wxfilldir64+0xb8' >/sys/kernel/debug/tracing/kprobe_events~> echo 1 >/sys/kernel/debug/tracing/events/kprobes/wx/enable~> echo 1 >/sys/kernel/debug/tracing/events/kprobes/enable...we can see the following crash:
kernel tried to execute exec-protected page (f101a008) - exploit attempt? (uid: 0) BUG: Unable to handle kernel instruction fetch Faulting instruction address: 0xc02b919c Vector: 400 (Instruction Access) at [f19a9d60] pc: c02b919c: filldir64+0xb8/0x2dc lr: c02b9148: filldir64+0x64/0x2dc sp: f19a9e20 msr: 10029032 current = 0xc112e900 pid = 102, comm = ls enter ? for help [f19a9e20] c1a8d420 (unreliable) [f19a9e50] c02e4074 dcache_readdir+0x208/0x2a8 [f19a9e90] c02b8c5c iterate_dir+0x88/0x1fc [f19a9ec0] c02b96e0 sys_getdents64+0x88/0x198 [f19a9f10] c0014400 system_call_exception+0xf8/0x20c [f19a9f30] c00191ac ret_from_syscall+0x0/0x2c ---- Exception: c00 (System Call) at a7596164 SP (af802310) is in userspaceThis happens because on book3s/32 the exec permission is per segment (256MB), not per page. The page tables have no hardware exec bit, only the segment registers have a no-execute (N) bit.
mmu_mark_initmem_nx()sets N on all the kernel segments except the ones of the modules area. So nothing in the vmalloc area can be executed, even when the page is mapped withPAGE_KERNEL_ROXorPAGE_KERNEL_EXEC, because_PAGE_EXECis a software only bit there and the segment's N bit is what the MMU enforces.Before commit
1b750c2fbf82("powerpc: extendexecmem_paramsfor kprobes allocations"), the kprobes insn pages came frommodule_alloc(). That commit moved them to the whole of the vmalloc space, on the grounds that kprobes use a breakpoint and don't need to be near the kernel text. That is fine on platforms where the exec permission is per page, asPAGE_KERNEL_ROXis then enough to make a vmalloc page executable. It is not on book3s/32, where the modules area is not only close to the kernel text but is also the only page-mapped area whose segment is left executable. So the insn pages must keep coming from there.
Quoted 1 line
Hence, use the modules area for
EXECMEM_KPROBESon book3s/32.
Right, I missed that on book3s/32 does vmalloc is not executable and its protection can't be changed.
Could it be that 8xx also need a special treatment for kprobes?
Quoted 2 lines
Fixes 1b750c2fbf82 ("powerpc: extend execmem_params for kprobes allocations")Signed-off-by Ritesh Harjani (IBM) <[email protected]>
Quoted 43 lines
--- arch/powerpc/mm/mem.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)arch/powerpc/mm/mem.c +8
-3@@ -391,6 +391,7 @@ struct execmem_info __init *execmem_arch_setup(void)pgprot_t kprobes_prot =strict_kernel_rwx_enabled () ?PAGE_KERNEL_ROX :PAGE_KERNEL_EXEC ;pgprot_t prot =strict_module_rwx_enabled () ?PAGE_KERNEL :PAGE_KERNEL_EXEC ;unsigned long fallback_start =0 , fallback_end =0 ; +unsigned long kprobes_start =VMALLOC_START , kprobes_end =VMALLOC_END ;unsigned long start, end;/* @@ -410,6 +411,11 @@ struct execmem_info __init *execmem_arch_setup(void) } end =MODULES_END ; + +if (IS_ENABLED (CONFIG_PPC_BOOK3S_32 )) { + kprobes_start =MODULES_VADDR ; + kprobes_end =MODULES_END ; + }#else start =VMALLOC_START ; end =VMALLOC_END ;@@ -428,8 +434,8 @@ struct execmem_info __init *execmem_arch_setup(void) .fallback_end = fallback_end, }, [EXECMEM_KPROBES] = { - .start = VMALLOC_START, - .end = VMALLOC_END, + .start = kprobes_start, + .end = kprobes_end, .pgprot = kprobes_prot, .alignment = 1, }, --2.39.5
Signature · 2 lines
Sincerely yours, Mike.
Christophe Leroy (CS GROUP)
reviewerRe: [PATCHv2 2/3] powerpc/execmem: Allocate kprobes insn pages from the modules area on book3s/32
Hi Mike,
Le 15/11/2026 à 09:29, Mike Rapoport a écrit :
Quoted 50 lines · Ritesh Harjani (IBM)
Quoted 49 lines
On book3s/32, a kprobe on an instruction that can't be emulated and has to be single stepped out of line, crashes the kernel. For e.g. with the following cmds...
~> echo 9 >/proc/sys/kernel/printk
~> mount -t debugfs debugfs/sys/kernel/debug
~> echo 'p:wxfilldir64+0xb8' >/sys/kernel/debug/tracing/kprobe_events~> echo 1 >/sys/kernel/debug/tracing/events/kprobes/wx/enable~> echo 1 >/sys/kernel/debug/tracing/events/kprobes/enable...we can see the following crash:
kernel tried to execute exec-protected page (f101a008) - exploit attempt? (uid: 0) BUG: Unable to handle kernel instruction fetch Faulting instruction address: 0xc02b919c Vector: 400 (Instruction Access) at [f19a9d60] pc: c02b919c: filldir64+0xb8/0x2dc lr: c02b9148: filldir64+0x64/0x2dc sp: f19a9e20 msr: 10029032 current = 0xc112e900 pid = 102, comm = ls enter ? for help [f19a9e20] c1a8d420 (unreliable) [f19a9e50] c02e4074 dcache_readdir+0x208/0x2a8 [f19a9e90] c02b8c5c iterate_dir+0x88/0x1fc [f19a9ec0] c02b96e0 sys_getdents64+0x88/0x198 [f19a9f10] c0014400 system_call_exception+0xf8/0x20c [f19a9f30] c00191ac ret_from_syscall+0x0/0x2c ---- Exception: c00 (System Call) at a7596164 SP (af802310) is in userspaceThis happens because on book3s/32 the exec permission is per segment (256MB), not per page. The page tables have no hardware exec bit, only the segment registers have a no-execute (N) bit.
mmu_mark_initmem_nx()sets N on all the kernel segments except the ones of the modules area. So nothing in the vmalloc area can be executed, even when the page is mapped withPAGE_KERNEL_ROXorPAGE_KERNEL_EXEC, because_PAGE_EXECis a software only bit there and the segment's N bit is what the MMU enforces.Before commit
1b750c2fbf82("powerpc: extendexecmem_paramsfor kprobes allocations"), the kprobes insn pages came frommodule_alloc(). That commit moved them to the whole of the vmalloc space, on the grounds that kprobes use a breakpoint and don't need to be near the kernel text. That is fine on platforms where the exec permission is per page, asPAGE_KERNEL_ROXis then enough to make a vmalloc page executable. It is not on book3s/32, where the modules area is not only close to the kernel text but is also the only page-mapped area whose segment is left executable. So the insn pages must keep coming from there.
Quoted 6 lines
Quoted 1 line
Hence, use the modules area for
EXECMEM_KPROBESon book3s/32.Right, I missed that on book3s/32 does vmalloc is not executable and its protection can't be changed.
Could it be that 8xx also need a special treatment for kprobes?
Yes indeed, not for the same reasons but because 8xx ITLB-miss handler doesn't expect any instruction TLB miss on kernel addresses other than the ones from the module area:
Commit 4afb0be7ccda ("powerpc/8xx: Avoid testing for kernel space in ITLB Miss.") Commit 16a71c045186 ("powerpc/8xx: Preallocate execmem page tables") Commit 33c527522f39 ("powerpc/8xx: Inconditionally use task PGDIR in ITLB misses")
So at the end as MODULES_VADDR/MODULES_END only exist on book3s/32 and 8xx I think when they exist they should be used as follows:
arch/powerpc/mm/mem.c +5 -0
@@ -428,8 +428,13 @@ struct execmem_info __init *execmem_arch_setup(void) .fallback_end = fallback_end, }, [EXECMEM_KPROBES] = { +#ifdef MODULES_VADDR + .start = MODULES_VADDR, + .end = MODULES_END, +#else .start = VMALLOC_START, .end = VMALLOC_END, +#endif .pgprot = kprobes_prot, .alignment = 1, },
Quoted 50 lines
Quoted 3 lines
Fixes 1b750c2fbf82 ("powerpc: extend execmem_params for kprobes allocations")Signed-off-by Ritesh Harjani (IBM) <[email protected]>Reviewed-by Mike Rapoport (Microsoft) <[email protected]>Quoted 43 lines
--- arch/powerpc/mm/mem.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)arch/powerpc/mm/mem.c +8
-3@@ -391,6 +391,7 @@ struct execmem_info __init *execmem_arch_setup(void)pgprot_t kprobes_prot =strict_kernel_rwx_enabled () ?PAGE_KERNEL_ROX :PAGE_KERNEL_EXEC ;pgprot_t prot =strict_module_rwx_enabled () ?PAGE_KERNEL :PAGE_KERNEL_EXEC ;unsigned long fallback_start =0 , fallback_end =0 ; +unsigned long kprobes_start =VMALLOC_START , kprobes_end =VMALLOC_END ;unsigned long start, end;/* @@ -410,6 +411,11 @@ struct execmem_info __init *execmem_arch_setup(void) } end =MODULES_END ; + +if (IS_ENABLED (CONFIG_PPC_BOOK3S_32 )) { + kprobes_start =MODULES_VADDR ; + kprobes_end =MODULES_END ; + }#else start =VMALLOC_START ; end =VMALLOC_END ;@@ -428,8 +434,8 @@ struct execmem_info __init *execmem_arch_setup(void) .fallback_end = fallback_end, }, [EXECMEM_KPROBES] = { - .start = VMALLOC_START, - .end = VMALLOC_END, + .start = kprobes_start, + .end = kprobes_end, .pgprot = kprobes_prot, .alignment = 1, }, --2.39.5
Re: [PATCHv2 2/3] powerpc/execmem: Allocate kprobes insn pages from the modules area on book3s/32
Quoted 77 lines · Christophe Leroy (CS GROUP)
Hi Mike,
Le 15/11/2026 à 09:29, Mike Rapoport a écrit :
Quoted 50 lines · Ritesh Harjani (IBM)
Quoted 49 lines
On book3s/32, a kprobe on an instruction that can't be emulated and has to be single stepped out of line, crashes the kernel. For e.g. with the following cmds...
~> echo 9 >/proc/sys/kernel/printk
~> mount -t debugfs debugfs/sys/kernel/debug
~> echo 'p:wxfilldir64+0xb8' >/sys/kernel/debug/tracing/kprobe_events~> echo 1 >/sys/kernel/debug/tracing/events/kprobes/wx/enable~> echo 1 >/sys/kernel/debug/tracing/events/kprobes/enable...we can see the following crash:
kernel tried to execute exec-protected page (f101a008) - exploit attempt? (uid: 0) BUG: Unable to handle kernel instruction fetch Faulting instruction address: 0xc02b919c Vector: 400 (Instruction Access) at [f19a9d60] pc: c02b919c: filldir64+0xb8/0x2dc lr: c02b9148: filldir64+0x64/0x2dc sp: f19a9e20 msr: 10029032 current = 0xc112e900 pid = 102, comm = ls enter ? for help [f19a9e20] c1a8d420 (unreliable) [f19a9e50] c02e4074 dcache_readdir+0x208/0x2a8 [f19a9e90] c02b8c5c iterate_dir+0x88/0x1fc [f19a9ec0] c02b96e0 sys_getdents64+0x88/0x198 [f19a9f10] c0014400 system_call_exception+0xf8/0x20c [f19a9f30] c00191ac ret_from_syscall+0x0/0x2c ---- Exception: c00 (System Call) at a7596164 SP (af802310) is in userspaceThis happens because on book3s/32 the exec permission is per segment (256MB), not per page. The page tables have no hardware exec bit, only the segment registers have a no-execute (N) bit.
mmu_mark_initmem_nx()sets N on all the kernel segments except the ones of the modules area. So nothing in the vmalloc area can be executed, even when the page is mapped withPAGE_KERNEL_ROXorPAGE_KERNEL_EXEC, because_PAGE_EXECis a software only bit there and the segment's N bit is what the MMU enforces.Before commit
1b750c2fbf82("powerpc: extendexecmem_paramsfor kprobes allocations"), the kprobes insn pages came frommodule_alloc(). That commit moved them to the whole of the vmalloc space, on the grounds that kprobes use a breakpoint and don't need to be near the kernel text. That is fine on platforms where the exec permission is per page, asPAGE_KERNEL_ROXis then enough to make a vmalloc page executable. It is not on book3s/32, where the modules area is not only close to the kernel text but is also the only page-mapped area whose segment is left executable. So the insn pages must keep coming from there.Quoted 5 lines
Quoted 1 line
Hence, use the modules area for
EXECMEM_KPROBESon book3s/32.Right, I missed that on book3s/32 does vmalloc is not executable and its protection can't be changed.
Could it be that 8xx also need a special treatment for kprobes?
Yes indeed, not for the same reasons but because 8xx ITLB-miss handler doesn't expect any instruction TLB miss on kernel addresses other than the ones from the module area:
Commit
4afb0be7ccda("powerpc/8xx: Avoid testing for kernel space in ITLB Miss.")
Commit16a71c045186("powerpc/8xx: Preallocate execmem page tables") Commit33c527522f39("powerpc/8xx: Inconditionally use task PGDIR in ITLB misses")So at the end as MODULES_VADDR/MODULES_END only exist on book3s/32 and 8xx I think when they exist they should be used as follows:
arch/powerpc/mm/mem.c +0
-0
arch/powerpc/mm/mem.c struct execmem_info __init *execmem_arch_setup(void) · line 437
Quoted 10 lines
arch/powerpc/mm/mem.c +5
-0@@ -428,8 +428,13 @@ struct execmem_info __init *execmem_arch_setup(void) .fallback_end = fallback_end, }, [EXECMEM_KPROBES] = { +#ifdef MODULES_VADDR + .start = MODULES_VADDR, + .end = MODULES_END, +#else .start = VMALLOC_START, .end = VMALLOC_END, +#endif
We already have #ifdef MODULES_VADDR a few lines above, I think the assignment of kprobes_start and kprobes_end could go there instead of if (IS_ENABLED(CONFIG_PPC_BOOK3S_32)).
Quoted 56 lines
arch/powerpc/mm/mem.c +0
-0.pgprot = kprobes_prot, .alignment = 1, },Quoted 52 lines
Quoted 5 lines
Fixes 1b750c2fbf82 ("powerpc: extend execmem_params for kprobes allocations")Signed-off-by Ritesh Harjani (IBM) <[email protected]>Reviewed-by Mike Rapoport (Microsoft) <[email protected]>Quoted 43 lines
--- arch/powerpc/mm/mem.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)arch/powerpc/mm/mem.c +8
-3@@ -391,6 +391,7 @@ struct execmem_info __init *execmem_arch_setup(void)pgprot_t kprobes_prot =strict_kernel_rwx_enabled () ?PAGE_KERNEL_ROX :PAGE_KERNEL_EXEC ;pgprot_t prot =strict_module_rwx_enabled () ?PAGE_KERNEL :PAGE_KERNEL_EXEC ;unsigned long fallback_start =0 , fallback_end =0 ; +unsigned long kprobes_start =VMALLOC_START , kprobes_end =VMALLOC_END ;unsigned long start, end;/* @@ -410,6 +411,11 @@ struct execmem_info __init *execmem_arch_setup(void) } end =MODULES_END ; + +if (IS_ENABLED (CONFIG_PPC_BOOK3S_32 )) { + kprobes_start =MODULES_VADDR ; + kprobes_end =MODULES_END ; + }#else start =VMALLOC_START ; end =VMALLOC_END ;@@ -428,8 +434,8 @@ struct execmem_info __init *execmem_arch_setup(void) .fallback_end = fallback_end, }, [EXECMEM_KPROBES] = { - .start = VMALLOC_START, - .end = VMALLOC_END, + .start = kprobes_start, + .end = kprobes_end, .pgprot = kprobes_prot, .alignment = 1, }, --2.39.5
Signature · 2 lines
Sincerely yours, Mike.
Ritesh Harjani (IBM)
reviewerRe: [PATCHv2 2/3] powerpc/execmem: Allocate kprobes insn pages from the modules area on book3s/32
Quoted 64 lines · Mike Rapoport
Quoted 63 lines · Christophe Leroy (CS GROUP)
Hi Mike,
Le 15/11/2026 à 09:29, Mike Rapoport a écrit :
Quoted 50 lines · Ritesh Harjani (IBM)
Quoted 49 lines
On book3s/32, a kprobe on an instruction that can't be emulated and has to be single stepped out of line, crashes the kernel. For e.g. with the following cmds...
~> echo 9 >/proc/sys/kernel/printk
~> mount -t debugfs debugfs/sys/kernel/debug
~> echo 'p:wxfilldir64+0xb8' >/sys/kernel/debug/tracing/kprobe_events~> echo 1 >/sys/kernel/debug/tracing/events/kprobes/wx/enable~> echo 1 >/sys/kernel/debug/tracing/events/kprobes/enable...we can see the following crash:
kernel tried to execute exec-protected page (f101a008) - exploit attempt? (uid: 0) BUG: Unable to handle kernel instruction fetch Faulting instruction address: 0xc02b919c Vector: 400 (Instruction Access) at [f19a9d60] pc: c02b919c: filldir64+0xb8/0x2dc lr: c02b9148: filldir64+0x64/0x2dc sp: f19a9e20 msr: 10029032 current = 0xc112e900 pid = 102, comm = ls enter ? for help [f19a9e20] c1a8d420 (unreliable) [f19a9e50] c02e4074 dcache_readdir+0x208/0x2a8 [f19a9e90] c02b8c5c iterate_dir+0x88/0x1fc [f19a9ec0] c02b96e0 sys_getdents64+0x88/0x198 [f19a9f10] c0014400 system_call_exception+0xf8/0x20c [f19a9f30] c00191ac ret_from_syscall+0x0/0x2c ---- Exception: c00 (System Call) at a7596164 SP (af802310) is in userspaceThis happens because on book3s/32 the exec permission is per segment (256MB), not per page. The page tables have no hardware exec bit, only the segment registers have a no-execute (N) bit.
mmu_mark_initmem_nx()sets N on all the kernel segments except the ones of the modules area. So nothing in the vmalloc area can be executed, even when the page is mapped withPAGE_KERNEL_ROXorPAGE_KERNEL_EXEC, because_PAGE_EXECis a software only bit there and the segment's N bit is what the MMU enforces.Before commit
1b750c2fbf82("powerpc: extendexecmem_paramsfor kprobes allocations"), the kprobes insn pages came frommodule_alloc(). That commit moved them to the whole of the vmalloc space, on the grounds that kprobes use a breakpoint and don't need to be near the kernel text. That is fine on platforms where the exec permission is per page, asPAGE_KERNEL_ROXis then enough to make a vmalloc page executable. It is not on book3s/32, where the modules area is not only close to the kernel text but is also the only page-mapped area whose segment is left executable. So the insn pages must keep coming from there.Quoted 5 lines
Quoted 1 line
Hence, use the modules area for
EXECMEM_KPROBESon book3s/32.Right, I missed that on book3s/32 does vmalloc is not executable and its protection can't be changed.
Could it be that 8xx also need a special treatment for kprobes?
Yes indeed, not for the same reasons but because 8xx ITLB-miss handler doesn't expect any instruction TLB miss on kernel addresses other than the ones from the module area:
Quoted 6 lines
Quoted 6 lines
Commit
4afb0be7ccda("powerpc/8xx: Avoid testing for kernel space in ITLB Miss.")
Commit16a71c045186("powerpc/8xx: Preallocate execmem page tables") Commit33c527522f39("powerpc/8xx: Inconditionally use task PGDIR in ITLB misses")
Right. I looked at the above series which added all of this support [1]. So looks like 603 might also have this related problem (other than the per segment N bit issue), since it's iTLB miss handler only walks the task's PGDIR, unlike it's dTLB handler which falls back to reloading the missing kernel PGD entry from swapper_pg_dir. So what I meant to say is that, similar to 8xx, a new PGD entry created in the kernel's vmalloc area for an insn page does not get copied over after the task is created (/PGDIR allocated), on 603 as well.
But since MODLUES_VADDR is defined for both BOOK3S/32 and 8xx, so I guess it gets covered by the same change anyways.
[1]: https://lore.kernel.org/linuxppc-dev/[email protected]/
Quoted 14 lines
Quoted 14 lines
So at the end as MODULES_VADDR/MODULES_END only exist on book3s/32 and 8xx I think when they exist they should be used as follows:
arch/powerpc/mm/mem.c +3
-0@@ -428,8 +428,13 @@ struct execmem_info __init *execmem_arch_setup(void) .fallback_end = fallback_end, }, [EXECMEM_KPROBES] = { +#ifdef MODULES_VADDR + .start = MODULES_VADDR, + .end = MODULES_END,
Quoted 9 lines
arch/powerpc/mm/mem.c struct execmem_info __init *execmem_arch_setup(void) · line 437
Quoted 4 lines
arch/powerpc/mm/mem.c +2
-0+#else .start = VMALLOC_START, .end = VMALLOC_END, +#endif We already have #ifdef
MODULES_VADDRa few lines above, I think the assignment ofkprobes_startandkprobes_endcould go there instead of if (IS_ENABLED(CONFIG_PPC_BOOK3S_32)).
Right. So let me use the following diff then?
Please let me know if this diff looks good to you? If yes, then I can send a v3.
Also - it will be good to know if patch-1 and patch-3 looks ok too, before I spin a next revision?
Thanks Christophe & Mike, for reviewing and pointing this out!
arch/powerpc/mm/mem.c +6 -2
@@ -391,6 +391,7 @@ struct execmem_info __init *execmem_arch_setup(void)pgprot_t kprobes_prot =strict_kernel_rwx_enabled () ?PAGE_KERNEL_ROX :PAGE_KERNEL_EXEC ;pgprot_t prot =strict_module_rwx_enabled () ?PAGE_KERNEL :PAGE_KERNEL_EXEC ;unsigned long fallback_start =0 , fallback_end =0 ; +unsigned long kprobes_start =VMALLOC_START , kprobes_end =VMALLOC_END ;unsigned long start, end;/*
@@ -410,6 +411,9 @@ struct execmem_info __init *execmem_arch_setup(void) } end =MODULES_END ; + + kprobes_start =MODULES_VADDR ; + kprobes_end =MODULES_END ;#else start =VMALLOC_START ; end =VMALLOC_END ;
@@ -428,8 +432,8 @@ struct execmem_info __init *execmem_arch_setup(void) .fallback_end = fallback_end, }, [EXECMEM_KPROBES] = { - .start = VMALLOC_START, - .end = VMALLOC_END, + .start = kprobes_start, + .end = kprobes_end, .pgprot = kprobes_prot, .alignment = 1, },
-ritesh
Quoted 60 lines
Quoted 56 lines
arch/powerpc/mm/mem.c +0
-0.pgprot = kprobes_prot, .alignment = 1, },Quoted 52 lines
Quoted 5 lines
Fixes 1b750c2fbf82 ("powerpc: extend execmem_params for kprobes allocations")Signed-off-by Ritesh Harjani (IBM) <[email protected]>Reviewed-by Mike Rapoport (Microsoft) <[email protected]>Quoted 43 lines
--- arch/powerpc/mm/mem.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)arch/powerpc/mm/mem.c +8
-3@@ -391,6 +391,7 @@ struct execmem_info __init *execmem_arch_setup(void)pgprot_t kprobes_prot =strict_kernel_rwx_enabled () ?PAGE_KERNEL_ROX :PAGE_KERNEL_EXEC ;pgprot_t prot =strict_module_rwx_enabled () ?PAGE_KERNEL :PAGE_KERNEL_EXEC ;unsigned long fallback_start =0 , fallback_end =0 ; +unsigned long kprobes_start =VMALLOC_START , kprobes_end =VMALLOC_END ;unsigned long start, end;/* @@ -410,6 +411,11 @@ struct execmem_info __init *execmem_arch_setup(void) } end =MODULES_END ; + +if (IS_ENABLED (CONFIG_PPC_BOOK3S_32 )) { + kprobes_start =MODULES_VADDR ; + kprobes_end =MODULES_END ; + }#else start =VMALLOC_START ; end =VMALLOC_END ;@@ -428,8 +434,8 @@ struct execmem_info __init *execmem_arch_setup(void) .fallback_end = fallback_end, }, [EXECMEM_KPROBES] = { - .start = VMALLOC_START, - .end = VMALLOC_END, + .start = kprobes_start, + .end = kprobes_end, .pgprot = kprobes_prot, .alignment = 1, }, --2.39.5
Signature · 2 lines
Sincerely yours, Mike.
Christophe Leroy (CS GROUP)
reviewerRe: [PATCHv2 2/3] powerpc/execmem: Allocate kprobes insn pages from the modules area on book3s/32
Le 17/11/2026 à 13:33, Ritesh Harjani a écrit :
Quoted 110 lines
Quoted 64 lines · Mike Rapoport
Quoted 63 lines · Christophe Leroy (CS GROUP)
Hi Mike,
Le 15/11/2026 à 09:29, Mike Rapoport a écrit :
Quoted 50 lines · Ritesh Harjani (IBM)
Quoted 49 lines
On book3s/32, a kprobe on an instruction that can't be emulated and has to be single stepped out of line, crashes the kernel. For e.g. with the following cmds...
~> echo 9 >/proc/sys/kernel/printk
~> mount -t debugfs debugfs/sys/kernel/debug
~> echo 'p:wxfilldir64+0xb8' >/sys/kernel/debug/tracing/kprobe_events~> echo 1 >/sys/kernel/debug/tracing/events/kprobes/wx/enable~> echo 1 >/sys/kernel/debug/tracing/events/kprobes/enable...we can see the following crash:
kernel tried to execute exec-protected page (f101a008) - exploit attempt? (uid: 0) BUG: Unable to handle kernel instruction fetch Faulting instruction address: 0xc02b919c Vector: 400 (Instruction Access) at [f19a9d60] pc: c02b919c: filldir64+0xb8/0x2dc lr: c02b9148: filldir64+0x64/0x2dc sp: f19a9e20 msr: 10029032 current = 0xc112e900 pid = 102, comm = ls enter ? for help [f19a9e20] c1a8d420 (unreliable) [f19a9e50] c02e4074 dcache_readdir+0x208/0x2a8 [f19a9e90] c02b8c5c iterate_dir+0x88/0x1fc [f19a9ec0] c02b96e0 sys_getdents64+0x88/0x198 [f19a9f10] c0014400 system_call_exception+0xf8/0x20c [f19a9f30] c00191ac ret_from_syscall+0x0/0x2c ---- Exception: c00 (System Call) at a7596164 SP (af802310) is in userspaceThis happens because on book3s/32 the exec permission is per segment (256MB), not per page. The page tables have no hardware exec bit, only the segment registers have a no-execute (N) bit.
mmu_mark_initmem_nx()sets N on all the kernel segments except the ones of the modules area. So nothing in the vmalloc area can be executed, even when the page is mapped withPAGE_KERNEL_ROXorPAGE_KERNEL_EXEC, because_PAGE_EXECis a software only bit there and the segment's N bit is what the MMU enforces.Before commit
1b750c2fbf82("powerpc: extendexecmem_paramsfor kprobes allocations"), the kprobes insn pages came frommodule_alloc(). That commit moved them to the whole of the vmalloc space, on the grounds that kprobes use a breakpoint and don't need to be near the kernel text. That is fine on platforms where the exec permission is per page, asPAGE_KERNEL_ROXis then enough to make a vmalloc page executable. It is not on book3s/32, where the modules area is not only close to the kernel text but is also the only page-mapped area whose segment is left executable. So the insn pages must keep coming from there.Quoted 5 lines
Quoted 1 line
Hence, use the modules area for
EXECMEM_KPROBESon book3s/32.Right, I missed that on book3s/32 does vmalloc is not executable and its protection can't be changed.
Could it be that 8xx also need a special treatment for kprobes?
Yes indeed, not for the same reasons but because 8xx ITLB-miss handler doesn't expect any instruction TLB miss on kernel addresses other than the ones from the module area:
Quoted 6 lines
Quoted 6 lines
Commit
4afb0be7ccda("powerpc/8xx: Avoid testing for kernel space in ITLB Miss.")
Commit16a71c045186("powerpc/8xx: Preallocate execmem page tables") Commit33c527522f39("powerpc/8xx: Inconditionally use task PGDIR in ITLB misses")Right. I looked at the above series which added all of this support [1]. So looks like 603 might also have this related problem (other than the per segment N bit issue), since it's iTLB miss handler only walks the task's PGDIR, unlike it's dTLB handler which falls back to reloading the missing kernel PGD entry from
swapper_pg_dir. So what I meant to say is that, similar to 8xx, a new PGD entry created in the kernel's vmalloc area for an insn page does not get copied over after the task is created (/PGDIR allocated), on 603 as well.
But sinceMODLUES_VADDRis defined for both BOOK3S/32 and 8xx, so I guess it gets covered by the same change anyways.Quoted 14 lines
Quoted 14 lines
So at the end as MODULES_VADDR/MODULES_END only exist on book3s/32 and 8xx I think when they exist they should be used as follows:
arch/powerpc/mm/mem.c +3
-0@@ -428,8 +428,13 @@ struct execmem_info __init *execmem_arch_setup(void) .fallback_end = fallback_end, }, [EXECMEM_KPROBES] = { +#ifdef MODULES_VADDR + .start = MODULES_VADDR, + .end = MODULES_END,Quoted 9 lines
arch/powerpc/mm/mem.c struct execmem_info __init *execmem_arch_setup(void) · line 437
Quoted 4 lines
arch/powerpc/mm/mem.c +2
-0+#else .start = VMALLOC_START, .end = VMALLOC_END, +#endif We already have #ifdef
MODULES_VADDRa few lines above, I think the assignment ofkprobes_startandkprobes_endcould go there instead of if (IS_ENABLED(CONFIG_PPC_BOOK3S_32)).
Quoted 4 lines
Right. So let me use the following diff then?
Please let me know if this diff looks good to you? If yes, then I can send a v3.
My preference would go to something similar to 'start' and 'end', no init at declaration, kprobes_start and kprobes_end set to VMALLOC_START/VMALLOC_END inside the #else
Christophe
Quoted 106 lines
Also - it will be good to know if patch-1 and patch-3 looks ok too, before I spin a next revision?
Thanks Christophe & Mike, for reviewing and pointing this out!
arch/powerpc/mm/mem.c +6
-3@@ -391,6 +391,7 @@ struct execmem_info __init *execmem_arch_setup(void)pgprot_t kprobes_prot =strict_kernel_rwx_enabled () ?PAGE_KERNEL_ROX :PAGE_KERNEL_EXEC ;pgprot_t prot =strict_module_rwx_enabled () ?PAGE_KERNEL :PAGE_KERNEL_EXEC ;unsigned long fallback_start =0 , fallback_end =0 ; +unsigned long kprobes_start =VMALLOC_START , kprobes_end =VMALLOC_END ;unsigned long start, end;/* @@ -410,6 +411,9 @@ struct execmem_info __init *execmem_arch_setup(void) } end =MODULES_END ; + + kprobes_start =MODULES_VADDR ; + kprobes_end =MODULES_END ;#else start =VMALLOC_START ; end =VMALLOC_END ;@@ -428,8 +432,8 @@ struct execmem_info __init *execmem_arch_setup(void) .fallback_end = fallback_end, }, [EXECMEM_KPROBES] = { - .start = VMALLOC_START, - .end = VMALLOC_END, + .start = kprobes_start, + .end = kprobes_end, .pgprot = kprobes_prot, .alignment = 1, }, -riteshQuoted 62 lines
Quoted 58 lines
arch/powerpc/mm/mem.c +0
-0.pgprot = kprobes_prot, .alignment = 1, },Quoted 52 lines
Quoted 5 lines
Fixes 1b750c2fbf82 ("powerpc: extend execmem_params for kprobes allocations")Signed-off-by Ritesh Harjani (IBM) <[email protected]>Reviewed-by Mike Rapoport (Microsoft) <[email protected]>Quoted 43 lines
--- arch/powerpc/mm/mem.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)arch/powerpc/mm/mem.c +8
-3@@ -391,6 +391,7 @@ struct execmem_info __init *execmem_arch_setup(void)pgprot_t kprobes_prot =strict_kernel_rwx_enabled () ?PAGE_KERNEL_ROX :PAGE_KERNEL_EXEC ;pgprot_t prot =strict_module_rwx_enabled () ?PAGE_KERNEL :PAGE_KERNEL_EXEC ;unsigned long fallback_start =0 , fallback_end =0 ; +unsigned long kprobes_start =VMALLOC_START , kprobes_end =VMALLOC_END ;unsigned long start, end;/* @@ -410,6 +411,11 @@ struct execmem_info __init *execmem_arch_setup(void) } end =MODULES_END ; + +if (IS_ENABLED (CONFIG_PPC_BOOK3S_32 )) { + kprobes_start =MODULES_VADDR ; + kprobes_end =MODULES_END ; + }#else start =VMALLOC_START ; end =VMALLOC_END ;@@ -428,8 +434,8 @@ struct execmem_info __init *execmem_arch_setup(void) .fallback_end = fallback_end, }, [EXECMEM_KPROBES] = { - .start = VMALLOC_START, - .end = VMALLOC_END, + .start = kprobes_start, + .end = kprobes_end, .pgprot = kprobes_prot, .alignment = 1, }, --2.39.5
Signature · 2 lines
Sincerely yours, Mike.
Mike Rapoport
Acked-byRe: [PATCHv2 2/3] powerpc/execmem: Allocate kprobes insn pages from the modules area on book3s/32
Quoted 54 lines · Christophe Leroy (CS GROUP)
Le 17/11/2026 à 13:33, Ritesh Harjani a écrit :
Quoted 53 lines
Quoted 10 lines · Mike Rapoport
Quoted 10 lines
Quoted 5 lines
Quoted 1 line
Hence, use the modules area for
EXECMEM_KPROBESon book3s/32.Right, I missed that on book3s/32 does vmalloc is not executable and its protection can't be changed.
Could it be that 8xx also need a special treatment for kprobes?
Yes indeed, not for the same reasons but because 8xx ITLB-miss handler doesn't expect any instruction TLB miss on kernel addresses other than the ones from the module area:
Quoted 5 lines
Quoted 5 lines
Commit
4afb0be7ccda("powerpc/8xx: Avoid testing for kernel space in ITLB Miss.")
Commit16a71c045186("powerpc/8xx: Preallocate execmem page tables") Commit33c527522f39("powerpc/8xx: Inconditionally use task PGDIR in ITLB misses")Right. I looked at the above series which added all of this support [1]. So looks like 603 might also have this related problem (other than the per segment N bit issue), since it's iTLB miss handler only walks the task's PGDIR, unlike it's dTLB handler which falls back to reloading the missing kernel PGD entry from
swapper_pg_dir. So what I meant to say is that, similar to 8xx, a new PGD entry created in the kernel's vmalloc area for an insn page does not get copied over after the task is created (/PGDIR allocated), on 603 as well.
But sinceMODLUES_VADDRis defined for both BOOK3S/32 and 8xx, so I guess it gets covered by the same change anyways.Quoted 23 lines
Quoted 8 lines
So at the end as MODULES_VADDR/MODULES_END only exist on book3s/32 and 8xx I think when they exist they should be used as follows:
arch/powerpc/mm/mem.c +0
-0arch/powerpc/mm/mem.c struct execmem_info __init *execmem_arch_setup(void) · line 437
Quoted 10 lines
arch/powerpc/mm/mem.c +5
-0@@ -428,8 +428,13 @@ struct execmem_info __init *execmem_arch_setup(void) .fallback_end = fallback_end, }, [EXECMEM_KPROBES] = { +#ifdef MODULES_VADDR + .start = MODULES_VADDR, + .end = MODULES_END, +#else .start = VMALLOC_START, .end = VMALLOC_END, +#endif We already have #ifdef
MODULES_VADDRa few lines above, I think the assignment ofkprobes_startandkprobes_endcould go there instead of if (IS_ENABLED(CONFIG_PPC_BOOK3S_32)).
Quoted 8 lines
Quoted 4 lines
Right. So let me use the following diff then?
Please let me know if this diff looks good to you? If yes, then I can send a v3.
My preference would go to something similar to 'start' and 'end', no init at declaration,
kprobes_startandkprobes_endset to VMALLOC_START/VMALLOC_END inside the #else
I agree, it's more consistent this way.
Quoted 2 lines
Quoted 2 lines
Also - it will be good to know if patch-1 and patch-3 looks ok too, before I spin a next revision?
Both make sense to me, feel free to add my
Signature · 2 lines
Sincerely yours, Mike.
Ritesh Harjani (IBM)
reviewerRe: [PATCHv2 2/3] powerpc/execmem: Allocate kprobes insn pages from the modules area on book3s/32
Quoted 55 lines · Mike Rapoport
Quoted 54 lines · Christophe Leroy (CS GROUP)
Le 17/11/2026 à 13:33, Ritesh Harjani a écrit :
Quoted 53 lines
Quoted 10 lines · Mike Rapoport
Quoted 10 lines
Quoted 5 lines
Quoted 1 line
Hence, use the modules area for
EXECMEM_KPROBESon book3s/32.Right, I missed that on book3s/32 does vmalloc is not executable and its protection can't be changed.
Could it be that 8xx also need a special treatment for kprobes?
Yes indeed, not for the same reasons but because 8xx ITLB-miss handler doesn't expect any instruction TLB miss on kernel addresses other than the ones from the module area:
Quoted 5 lines
Quoted 5 lines
Commit
4afb0be7ccda("powerpc/8xx: Avoid testing for kernel space in ITLB Miss.")
Commit16a71c045186("powerpc/8xx: Preallocate execmem page tables") Commit33c527522f39("powerpc/8xx: Inconditionally use task PGDIR in ITLB misses")Right. I looked at the above series which added all of this support [1]. So looks like 603 might also have this related problem (other than the per segment N bit issue), since it's iTLB miss handler only walks the task's PGDIR, unlike it's dTLB handler which falls back to reloading the missing kernel PGD entry from
swapper_pg_dir. So what I meant to say is that, similar to 8xx, a new PGD entry created in the kernel's vmalloc area for an insn page does not get copied over after the task is created (/PGDIR allocated), on 603 as well.
But sinceMODLUES_VADDRis defined for both BOOK3S/32 and 8xx, so I guess it gets covered by the same change anyways.Quoted 23 lines
Quoted 8 lines
So at the end as MODULES_VADDR/MODULES_END only exist on book3s/32 and 8xx I think when they exist they should be used as follows:
arch/powerpc/mm/mem.c +0
-0arch/powerpc/mm/mem.c struct execmem_info __init *execmem_arch_setup(void) · line 437
Quoted 10 lines
arch/powerpc/mm/mem.c +5
-0@@ -428,8 +428,13 @@ struct execmem_info __init *execmem_arch_setup(void) .fallback_end = fallback_end, }, [EXECMEM_KPROBES] = { +#ifdef MODULES_VADDR + .start = MODULES_VADDR, + .end = MODULES_END, +#else .start = VMALLOC_START, .end = VMALLOC_END, +#endif We already have #ifdef
MODULES_VADDRa few lines above, I think the assignment ofkprobes_startandkprobes_endcould go there instead of if (IS_ENABLED(CONFIG_PPC_BOOK3S_32)).
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Right. So let me use the following diff then?
Please let me know if this diff looks good to you? If yes, then I can send a v3.
My preference would go to something similar to 'start' and 'end', no init at declaration,
kprobes_startandkprobes_endset to VMALLOC_START/VMALLOC_END inside the #else
Sure.
Quoted 3 lines
I agree, it's more consistent this way.
Ok, then will go with the other approach.
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Also - it will be good to know if patch-1 and patch-3 looks ok too, before I spin a next revision?
Both make sense to me, feel free to add my
Thanks Mike and Christophe. Will make the changes in v3 as discussed.
-ritesh
Ritesh Harjani (IBM)
reviewerPATCH v2 3/3 powerpc/ptdump: Show the exec flag of kernel mappings on e500
In reply to Ritesh Harjani (IBM)On e500, _PAGE_EXEC is made of two bits, _PAGE_BAP_SX and _PAGE_BAP_UX, and a kernel mapping only has _PAGE_BAP_SX (supervisor bit). The flag table requires all the bits of the mask to be set to print "X", so kernel_page_tables never shows a kernel mapping as executable:
w/o this patch:
0xf1015000-0xf1015fff 0x00000000 4K PTE r present coherent accessed
Print "X" when any of the bits is set the same way it is done for _PAGE_READ and _PAGE_WRITE:
with this patch:
0xf1015000-0xf1015fff 0x00000000 4K PTE r X present coherent accessed
This only changes what is displayed. ptdump_check_wx() uses pte_exec() which already tests for either of the bits.
--- arch/powerpc/mm/ptdump/shared.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/mm/ptdump/shared.c +3 -3
@@ -22,9 +22,9 @@ static const struct flag_info flag_array[] = { .clear = "w", }, { .mask = _PAGE_EXEC, - .val = _PAGE_EXEC, - .set = " X ", - .clear = " ", + .val = 0, + .set = " ", + .clear = " X ", }, { .mask = _PAGE_PRESENT, .val = _PAGE_PRESENT,
--
2.39.5
Re: [PATCHv2 3/3] powerpc/ptdump: Show the exec flag of kernel mappings on e500
Le 13/11/2026 à 13:31, Ritesh Harjani (IBM) a écrit :
Quoted 11 lines
On e500,
_PAGE_EXECis made of two bits,_PAGE_BAP_SXand_PAGE_BAP_UX, and a kernel mapping only has_PAGE_BAP_SX(supervisor bit). The flag table requires all the bits of the mask to be set to print "X", sokernel_page_tablesnever shows a kernel mapping as executable:w/o this patch:
0xf1015000-0xf1015fff0x000000004K PTE r present coherent accessedPrint "X" when any of the bits is set the same way it is done for
_PAGE_READand_PAGE_WRITE:
Quoted 7 lines
with this patch:
0xf1015000-0xf1015fff0x000000004K PTE r X present coherent accessedThis only changes what is displayed.
ptdump_check_wx()usespte_exec()which already tests for either of the bits.Signed-off-by Ritesh Harjani (IBM) <[email protected]>
Quoted 24 lines
--- arch/powerpc/mm/ptdump/shared.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)arch/powerpc/mm/ptdump/shared.c +3
-4@@ -22,9 +22,9 @@ static const struct flag_info flag_array[] = { .clear = "w", }, { .mask = _PAGE_EXEC, - .val = _PAGE_EXEC, - .set = " X ", - .clear = " ", + .val = 0, + .set = " ", + .clear = " X ", }, { .mask = _PAGE_PRESENT, .val = _PAGE_PRESENT, --2.39.5