Re: [PATCHv2 2/3] powerpc/execmem: Allocate kprobes insn pages from the modules area on book3s/32

From: IBM

Date: Tue Nov 17 2026 - 12:37:20 EST


Mike Rapoport <rppt@xxxxxxxxxx> writes:

> On Tue, Nov 17, 2026 at 03:04:49PM +0100, Christophe Leroy (CS GROUP) wrote:
>> Le 17/11/2026 à 13:33, Ritesh Harjani a écrit :
>> > Mike Rapoport <rppt@xxxxxxxxxx> writes:
>> >
>> > > > > > Hence, use the modules area for EXECMEM_KPROBES on 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")
>> >
>> > 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.
>> >
>> > > > 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:
>> > > >
>> > > > diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
>> > > > index b617b69452cd..856f4609c488 100644
>> > > > --- a/arch/powerpc/mm/mem.c
>> > > > +++ b/arch/powerpc/mm/mem.c
>> > > > @@ -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)).
>> > >
>> >
>> > 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

Sure.

>
> I agree, it's more consistent this way.
>

Ok, then will go with the other approach.

>> > 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
>
> Acked-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
>

Thanks Mike and Christophe. Will make the changes in v3 as discussed.

-ritesh