[PATCH 11/13] powerpc64/bpf elfv2: Setup kernel TOC in r2 on entry
Christophe Leroy
christophe.leroy at csgroup.eu
Wed Jan 12 01:43:37 AEDT 2022
Le 11/01/2022 à 15:35, Christophe Leroy a écrit :
>
>
> Le 11/01/2022 à 11:31, Naveen N. Rao a écrit :
>> Christophe Leroy wrote:
>>>
>>>
>>> Le 06/01/2022 à 12:45, Naveen N. Rao a écrit :
>>>> In preparation for using kernel TOC, load the same in r2 on entry. With
>>>> elfv1, the kernel TOC is already setup by our caller so we just emit a
>>>> nop. We adjust the number of instructions to skip on a tail call
>>>> accordingly.
>>>>
>>>> Signed-off-by: Naveen N. Rao <naveen.n.rao at linux.vnet.ibm.com>
>>>> ---
>>>> arch/powerpc/net/bpf_jit_comp64.c | 8 +++++++-
>>>> 1 file changed, 7 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/arch/powerpc/net/bpf_jit_comp64.c
>>>> b/arch/powerpc/net/bpf_jit_comp64.c
>>>> index ce4fc59bbd6a92..e05b577d95bf11 100644
>>>> --- a/arch/powerpc/net/bpf_jit_comp64.c
>>>> +++ b/arch/powerpc/net/bpf_jit_comp64.c
>>>> @@ -73,6 +73,12 @@ void bpf_jit_build_prologue(u32 *image, struct
>>>> codegen_context *ctx)
>>>> {
>>>> int i;
>>>> +#ifdef PPC64_ELF_ABI_v2
>>>> + PPC_BPF_LL(_R2, _R13, offsetof(struct paca_struct, kernel_toc));
>>>> +#else
>>>> + EMIT(PPC_RAW_NOP());
>>>> +#endif
>>>
>>> Can we avoid the #ifdef, using
>>>
>>> if (__is_defined(PPC64_ELF_ABI_v2))
>>> PPC_BPF_LL(_R2, _R13, offsetof(struct paca_struct, kernel_toc));
>>> else
>>> EMIT(PPC_RAW_NOP());
>>
>> Hmm... that doesn't work for me. Is __is_defined() expected to work with
>> macros other than CONFIG options?
>
> Yes, __is_defined() should work with any item.
>
> It is IS_ENABLED() which is supposed to work only with CONFIG options.
>
> See commit 5c189c523e78 ("powerpc/time: Fix mftb()/get_tb() for use with
> the compat VDSO")
>
> Or commit ca5999fde0a1 ("mm: introduce include/linux/pgtable.h")
Ah ... wait.
It seems it expects a macro set to 1.
So it would require arch/powerpc/include/asm/types.h to be modified to
define PPC64_ELF_ABI_v2 or PPC64_ELF_ABI_v1 as 1
Christophe
More information about the Linuxppc-dev
mailing list