[PATCH v2 2/2] bpf/arm64: support packet data load instructions
Christophe Fontaine
cfontain at redhat.com
Wed May 13 22:56:21 CEST 2026
On Thu, Apr 9, 2026 at 7:24 PM Wathsala Vithanage
<wathsala.vithanage at arm.com> wrote:
>
> Hi Christophe,
>
> Thanks for doing this work. I saw that you intend to submit a v3 due to
> failure in Ubuntu. Please, see my comment regarding emit_b below.
>
> >> + /* A64_R(0) = mbuf->buf_addr */
> >> + emit_mov_imm(ctx, 1, tmp1, offsetof(struct rte_mbuf, buf_addr));
> >> + emit_ldr(ctx, EBPF_DW, A64_R(0), r6, tmp1);
> >> + /* tmp2 = * mbuf->data_off */
> >> + emit_mov_imm(ctx, 1, tmp2, offsetof(struct rte_mbuf, data_off));
> >> + emit_ldr(ctx, BPF_H, tmp2, r6, tmp2);
> >> +
> >> + /* A64_R(0) += data_off + off */
> >> + emit_add(ctx, 1, A64_R(0), tmp2);
> >> + emit_add(ctx, 1, A64_R(0), A64_R(1));
> >> +
> >> + /* End of Fast Path, skip slow path */
> >> + emit_b(ctx, 4);
> >> +
> Followed by emit_b() above there is an emit_call(). It invokes
> emit_mov_imm() which could possibly generate different number of movk
> instructions depending on the address of the __rte_pktmbuf_read. So,
> emit_b(ctx, 4), may not necessarily land at the intended location
> because there could be more than 4 instructions emitted by emit_call.
Hi
Very good point, this was probably the cause of the error on Ubuntu.
Sorry for the delay in responding to this patch, but I'm about to send
a new version, fixing (hopefully!) all the previous comments.
I'll add you in CC for the new version as well.
Christophe
> >> + /* slow path, call __rte_pktmbuf_read */
> >> + emit_call(ctx, tmp1, __rte_pktmbuf_read);
> >> + /* check return value of __rte_pktmbuf_read */
> >> + emit_return_zero_if_src_zero(ctx, 1, A64_R(0));
> >> +
> >> + /* A64_R(0) points to the data, load 1/2/4 bytes into r0*/
> >> + emit_ldr(ctx, opsz, r0, A64_R(0), A64_ZR);
> >> + if (sz != sizeof(uint8_t))
> >> + emit_be(ctx, r0, sz * CHAR_BIT);
> >> +}
> >> +
> >>
>
> --wathsala
>
>
More information about the dev
mailing list