Kernel v6.17-rc4 with STATIC_CALL_SELFTEST=y enabled fails to boot at early stage (PowerMac G4 DP)
Christophe Leroy
christophe.leroy at csgroup.eu
Thu Sep 4 18:15:31 AEST 2025
Hi Again,
Le 04/09/2025 à 09:31, Christophe Leroy a écrit :
> Hi Erhard,
>
> Le 04/09/2025 à 00:44, Erhard Furtner a écrit :
>> Greetings!
>>
>> In a conversation with Andrew about his page table check code for
>> PowerPC he found out there seems to be a general problem of the code
>> patching code on ppc:
>>
>> > I note that STATIC_CALL_SELFTEST seems to fail, which could be but
>> isn't
>> > necessarily related.
>>
>> > Specifically, it looks like code patching fails if the instruction
>> being patched
>> > is in an __init function, and in this case, that occurs due to
>> > page_table_check_pte_clear() being inlined into ptep_clear(), which
>> is in turn
>> > inlined into pte_clear_tests() in debug_vm_pgtable.c which is
>> marked __init.
>> > Very curious!
>>
>> Indeed, when I enable STATIC_CALL_SELFTEST=y on my G4 the kernel fails
>> to boot at an early stage, the OpenFirmware console showing only:
>>
>> done
>> found display : /pci at f0000000/ATY,AlteracParent at 10/ATY,Alterac_B at 1,
>> opening...
>>
>> Without STATIC_CALL_SELFTEST the kernel boots just fine.
>>
>> Kernel .config attached.
>
> With your .config, on QEMU I get the following. I will investigate.
>
> [ 0.000000] Kernel panic - not syncing: arch_static_call_transform:
> patching failed func_a+0x0/0x10 at 0x0
> [ 0.000000] CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.17.0-
> rc4-PMacG4+ #1628 PREEMPTLAZY
> [ 0.000000] Hardware name: PowerMac3,1 7400 0xc0209 PowerMac
> [ 0.000000] Call Trace:
> [ 0.000000] [c0dd7e60] [c0810e54] dump_stack_lvl+0x70/0x8c (unreliable)
> [ 0.000000] [c0dd7e80] [c004b220] vpanic+0x114/0x2e4
> [ 0.000000] [c0dd7eb0] [c004b45c] arch_set_bit+0x0/0x38
> [ 0.000000] [c0dd7f00] [c00155fc] arch_static_call_transform+0xec/0x1e8
> [ 0.000000] [c0dd7f30] [c0176944] __static_call_init+0x110/0x288
> [ 0.000000] [c0dd7f80] [c0c19ab0] static_call_init+0x4c/0x9c
> [ 0.000000] [c0dd7fa0] [c0c02e00] start_kernel+0x7c/0x664
> [ 0.000000] [c0dd7ff0] [000035d0] 0x35d0
> [ 0.000000] Rebooting in 40 seconds..
The problem comes from the following in arch/powerpc/include/asm/pgtable.h :
/*
* Protection used for kernel text. We want the debuggers to be able to
* set breakpoints anywhere, so don't write protect the kernel text
* on platforms where such control is possible.
*/
#if defined(CONFIG_KGDB) || defined(CONFIG_XMON) ||
defined(CONFIG_BDI_SWITCH) || \
defined(CONFIG_KPROBES) || defined(CONFIG_DYNAMIC_FTRACE)
#define PAGE_KERNEL_TEXT PAGE_KERNEL_X
#else
#define PAGE_KERNEL_TEXT PAGE_KERNEL_ROX
#endif
I don't know what the best fix is at the moment. This probably comes
from the old days when we didn't have CONFIG_STRICT_KERNEL_RWX. Would it
nowadays be acceptable to inconditionnally set:
#define PAGE_KERNEL_TEXT PAGE_KERNEL_X
It propably would, taking into account it is used exclusively on powerpc/32:
arch/powerpc/mm/book3s32/mmu.c: setibat(i++, PAGE_OFFSET + base,
base, size, PAGE_KERNEL_TEXT);
arch/powerpc/mm/book3s32/mmu.c: setibat(i++, PAGE_OFFSET + base,
base, size, PAGE_KERNEL_TEXT);
arch/powerpc/mm/pgtable_32.c: map_kernel_page(v, p, ktext ?
PAGE_KERNEL_TEXT : PAGE_KERNEL);
Christophe
More information about the Linuxppc-dev
mailing list