Re: [PATCH bpf-next v1 10/14] bpf, powerpc: JIT arena kfunc argument rebasing
| Newsgroups | org.kernel.vger.bpf |
|---|---|
| Message-ID | <e930052da6b6bc72fdadb4dd18354afb2fed2c2380fe996acddc03568c1e79b2@mail.kernel.org> |
> diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
> index fc9db691e8203..fc235fbfbeb97 100644
> --- a/arch/powerpc/net/bpf_jit_comp64.c
> +++ b/arch/powerpc/net/bpf_jit_comp64.c
> @@ -624,8 +624,24 @@ static int prepare_for_kfunc_call(const struct bpf_prog *fp, u32 *image,
> for (i = 0; i < m->nr_args; i++) {
> /* Note that BPF ABI only allows up to 5 args for kfuncs */
> u32 reg = bpf_to_ppc(BPF_REG_1 + i), size = m->arg_size[i];
> + u8 flags = m->arg_flags[i];
>
> - if (!(m->arg_flags[i] & BTF_FMODEL_SIGNED_ARG)) {
> + if (flags & BTF_FMODEL_ARENA_ARG) {
> + if (WARN_ON_ONCE(!ctx->arena_vm_start))
> + return -1;
> +
> + /* rN = kern_vm_start + (u32)rN */
> + if (zero_extend(image, ctx, reg, reg, 4))
> + return -1;
> + if (flags & BTF_FMODEL_NULLABLE_ARG) {
> + EMIT(PPC_RAW_CMPLDI(reg, 0));
> + PPC_BCC_CONST_SHORT(COND_EQ, 8);
> + }
> + EMIT(PPC_RAW_ADD(reg, reg, bpf_to_ppc(ARENA_VM_START)));
> + continue;
> + }
This isn't a bug, but the comment above prepare_for_kfunc_call lists:
/*
* Handle powerpc ABI expectations from caller:
* - Unsigned arguments are zero-extended.
* - Signed arguments are sign-extended.
*/
After this change the function also rebases __arena arguments onto the
arena kernel base. Would it be worth adding that as a third bullet?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/32538351576