[PATCH v3 5/6] powerpc/64: Add support for out-of-line static calls

Michael Ellerman mpe at ellerman.id.au
Thu Oct 6 11:39:50 AEDT 2022


Christophe Leroy <christophe.leroy at csgroup.eu> writes:
> Le 05/10/2022 à 07:32, Benjamin Gray a écrit :
>> Implement static call support for 64 bit V2 ABI. This requires making
>> sure the TOC is kept correct across kernel-module boundaries. As a
>> secondary concern, it tries to use the local entry point of a target
>> wherever possible. It does so by checking if both tramp & target are
>> kernel code, and falls back to detecting the common global entry point
>> patterns if modules are involved. Detecting the global entry point is
>> also required for setting the local entry point as the trampoline
>> target: if we cannot detect the local entry point, then we need to
>> convservatively initialise r12 and use the global entry point.
>> 
>> The trampolines are marked with `.localentry NAME, 1` to make the
>> linker save and restore the TOC on each call to the trampoline. This
>> allows the trampoline to safely target functions with different TOC
>> values.
>> 
>> However this directive also implies the TOC is not initialised on entry
>> to the trampoline. The kernel TOC is easily found in the PACA, but not
>> an arbitrary module TOC. Therefore the trampoline implementation depends
>> on whether it's in the kernel or not. If in the kernel, we initialise
>> the TOC using the PACA. If in a module, we have to initialise the TOC
>> with zero context, so it's quite expensive.
>> 
>> Signed-off-by: Benjamin Gray <bgray at linux.ibm.com>
>
> This looks good to me
>
> Reviewed-by: Christophe Leroy <christophe.leroy at csgroup.eu>
>
> However, thinking out loudly, I'm wondering, could we make things any 
> simpler when CONFIG_MODULES is not selected, or is that a too much 
> corner case on PPC64 ?

I'd say it's mostly a corner case.

Obviously no distros ship with modules disabled. 

AFAIK even the stripped down kernels we use in CPU bringup have modules
enabled.

So I think it's probably not worth worrying about, unless there's an
obvious and fairly simple optimisation.

cheers


More information about the Linuxppc-dev mailing list