]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
powerpc64/modules: replace stub allocation sentinel with an explicit counter
authorJoe Lawrence <joe.lawrence@redhat.com>
Fri, 12 Sep 2025 14:27:40 +0000 (10:27 -0400)
committerMadhavan Srinivasan <maddy@linux.ibm.com>
Mon, 15 Sep 2025 11:10:52 +0000 (16:40 +0530)
commitb137312fbf2dd1edc39acf7e8e6e8ac0a6ad72c0
tree0a5bffc5ea46c74be7bfd5a1f99866430f88fd27
parentf6b4df37ebfeb47e50e27780500d2d06b4d211bd
powerpc64/modules: replace stub allocation sentinel with an explicit counter

The logic for allocating ppc64_stub_entry trampolines in the .stubs
section relies on an inline sentinel, where a NULL .funcdata member
indicates an available slot.

While preceding commits fixed the initialization bugs that led to ftrace
stub corruption, the sentinel-based approach remains fragile: it depends
on an implicit convention between subsystems modifying different
struct types in the same memory area.

Replace the sentinel with an explicit counter, module->arch.num_stubs.
Instead of iterating through memory to find a NULL marker, the module
loader uses this counter as the boundary for the next free slot.

This simplifies the allocation code, hardens it against future changes
to stub structures, and removes the need for an extra relocation slot
previously reserved to terminate the sentinel search.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Acked-by: Naveen N Rao (AMD) <naveen@kernel.org>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20250912142740.3581368-4-joe.lawrence@redhat.com
arch/powerpc/include/asm/module.h
arch/powerpc/kernel/module_64.c