All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marat Khalili <marat.khalili@huawei.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: Wathsala Vithanage <wathsala.vithanage@arm.com>,
	Konstantin Ananyev <konstantin.ananyev@huawei.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Subject: RE: [PATCH v5 7/9] bpf/arm64: add BPF_ABS/BPF_IND packet load support
Date: Thu, 25 Jun 2026 13:59:52 +0000	[thread overview]
Message-ID: <42ae97d2d2754ea69025a6f6cc6c057d@huawei.com> (raw)
In-Reply-To: <20260624175815.673064-8-stephen@networkplumber.org>

Below is what gdb shows actually generated for instruction 15 of
test_ld_mbuf1_prog (with minimal changes and comments for readability). I
suggest adding this to the comments or (if we don't feel like keeping it
updated) the commit message, it helps analyzing the code a bit.

(Also, stack drawings in the file do not include the buffer we use here.)

     0: 0x92800069      mov     x9, #-4         // mov x9, <imm>
     1: 0x8b150129      add     x9, x9, x21     // add x9, src_reg
     2: 0xd280050a      mov     x10, #40        // mov x9, <&::data_len>
     3: 0x786a6a6a      ldrh    w10, [x19, x10]
     4: 0xcb09014a      sub     x10, x10, x9
     5: 0xd280008b      mov     x11, #4         // mov x11, <sz>
     6: 0xeb0b014f      subs    x15, x10, x11
     7: 0x5400010b      b.lt    +8              // b.lt slow
     8: 0xd280020a      mov     x10, #16        // mov x10, <&::data_off>
     9: 0x786a6a6a      ldrh    w10, [x19, x10]
    10: 0xd2800007      mov     x7, #0          // mov x7, <&::buf_addr>
    11: 0xf8676a67      ldr     x7, [x19, x7]
    12: 0x8b0a00e7      add     x7, x7, x10
    13: 0x8b0900e7      add     x7, x7, x9
    14: 0x1400000c      b       +12             // b load
                        slow:
    15: 0x91000121      add     x1, x9, #0      // mov x1, x9
    16: 0x91000260      add     x0, x19, #0     // mov x0, x19
    17: 0x52800082      mov     w2, #4          // mov w2, <sz>
    18: 0xd1002323      sub     x3, x25, #8     // sub x3, x25, <stack_ofs>
    19: 0xd2a04d49      mov     x9, #0x26a0000  // mov x9,
    20: 0xf29d3409      movk    x9, #0xe9a0     //   __rte_pktmbuf_read
    21: 0xd63f0120      blr     x9
    22: 0x91000007      add     x7, x0, #0      // mov x7, x0
    23: 0xb5000067      cbnz    x7, +3          // cbnz load
    24: 0xd2800007      mov     x7, #0x0
    25: 0x17ffff88      b       -120            // b epilogue
                        load:
    26: 0xb87f68e7      ldr     w7, [x7, xzr]
    27: 0xdac008e7      rev32   x7, x7

Opcode variations:
* Instruction 1 is omitted for BPF_ABS.
* Instruction 26 varies depending on sz.
* Instruction 27 varies or is omitted depending on sz.

Some benign nits:
* Instruction 6 should probably be `subs xzr, x10, x11`, a slight 1-bit error in
  the existing code, though x15 is unused.
* Instructions 5 and 17 use different encoding for the same operation, would be
  nice to keep them consistent, though operand never exceeds INT32_MAX.
* Instruction 10 is redundant.

I see two problems:
* We never check that x9 is non-negative. We could either add one more check,
  or rearrange the code and use unsigned comparison at 7: (currently b.lt).
  (There was some discussion previously regarding the special meaning of
  negative BPF_ABS immediate, but I believe this is out of scope of this patch,
  here we should just fail on negative _effective_ offset regardless of opcode.)
* Second argument of __rte_pktmbuf_read is `uint32_t off`, and we are trying to
  pass 64-bit offset in x1. We need a check that it does not exceed UINT32_MAX.

Otherwise looks good to me.


  reply	other threads:[~2026-06-25 14:00 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-08 20:28 [PATCH 0/4] bpf/arm64: add BPF_ABS/BPF_IND packet load support Stephen Hemminger
2026-06-08 20:28 ` [PATCH 1/4] bpf/arm64: fix zero-return branch in multi-exit programs Stephen Hemminger
2026-06-17 18:03   ` Marat Khalili
2026-06-08 20:28 ` [PATCH 2/4] test: bpf check that JIT was generated Stephen Hemminger
2026-06-17 18:09   ` Marat Khalili
2026-06-08 20:28 ` [PATCH 3/4] test: bpf check that bpf_convert can be JIT'd Stephen Hemminger
2026-06-17 18:14   ` Marat Khalili
2026-06-08 20:28 ` [PATCH 4/4] bpf/arm64: add BPF_ABS/BPF_IND packet load support Stephen Hemminger
2026-06-17 19:35   ` Marat Khalili
2026-06-17 17:37 ` [PATCH 0/4] " Marat Khalili
2026-06-17 21:17   ` Stephen Hemminger
2026-06-18 20:47 ` [PATCH v2 0/6] bpf: JIT related bug fixes Stephen Hemminger
2026-06-18 20:47   ` [PATCH v2 1/6] bpf/x86: fix JIT encoding of BPF_JSET with immediate Stephen Hemminger
2026-06-19  2:09     ` Stephen Hemminger
2026-06-18 20:47   ` [PATCH v2 2/6] test/bpf: add JSET test with small immediate Stephen Hemminger
2026-06-18 20:47   ` [PATCH v2 3/6] bpf/arm64: fix offset type to allow a negative jump Stephen Hemminger
2026-06-18 20:47   ` [PATCH v2 4/6] test/bpf: check that JIT was generated Stephen Hemminger
2026-06-18 20:47   ` [PATCH v2 5/6] bpf/arm64: add BPF_ABS/BPF_IND packet load support Stephen Hemminger
2026-06-18 20:47   ` [PATCH v2 6/6] test/bpf: check that bpf_convert can be JIT'd Stephen Hemminger
2026-06-21 16:23 ` [PATCH v3 0/6] bpf: JIT related bug fixes Stephen Hemminger
2026-06-21 16:23   ` [PATCH v3 1/6] bpf/x86: fix JIT encoding of BPF_JSET with immediate Stephen Hemminger
2026-06-23 10:11     ` Marat Khalili
2026-06-21 16:23   ` [PATCH v3 2/6] test/bpf: add JSET test with small immediate Stephen Hemminger
2026-06-23 10:16     ` Marat Khalili
2026-06-21 16:23   ` [PATCH v3 3/6] bpf/arm64: fix offset type to allow a negative jump Stephen Hemminger
2026-06-22 16:26     ` Marat Khalili
2026-06-21 16:23   ` [PATCH v3 4/6] test/bpf: check that JIT was generated Stephen Hemminger
2026-06-21 16:23   ` [PATCH v3 5/6] bpf/arm64: add BPF_ABS/BPF_IND packet load support Stephen Hemminger
2026-06-21 16:23   ` [PATCH v3 6/6] test/bpf: check that bpf_convert can be JIT'd Stephen Hemminger
2026-06-23 13:57     ` Marat Khalili
2026-06-23 15:51       ` Stephen Hemminger
2026-06-23 20:58       ` Stephen Hemminger
2026-06-23 23:23 ` [PATCH v4 0/7] bpf: JIT related bug fixes Stephen Hemminger
2026-06-23 23:23   ` [PATCH v4 1/7] bpf/x86: fix JIT encoding of fixed-width immediates Stephen Hemminger
2026-06-23 23:23   ` [PATCH v4 2/7] test/bpf: add JSET test with small immediate Stephen Hemminger
2026-06-23 23:23   ` [PATCH v4 3/7] test/bpf: add test for large shift Stephen Hemminger
2026-06-24  7:59     ` Marat Khalili
2026-06-24 13:44       ` Marat Khalili
2026-06-23 23:23   ` [PATCH v4 4/7] bpf/arm64: fix offset type to allow a negative jump Stephen Hemminger
2026-06-24  8:43     ` Marat Khalili
2026-06-23 23:23   ` [PATCH v4 5/7] test/bpf: check that JIT was generated Stephen Hemminger
2026-06-23 23:23   ` [PATCH v4 6/7] bpf/arm64: add BPF_ABS/BPF_IND packet load support Stephen Hemminger
2026-06-23 23:23   ` [PATCH v4 7/7] test/bpf: check that bpf_convert can be JIT'd Stephen Hemminger
2026-06-24  8:39     ` Marat Khalili
2026-06-24 17:54 ` [PATCH v5 0/9] bpf: JIT related bug fixes Stephen Hemminger
2026-06-24 17:55   ` [PATCH v5 1/9] bpf/x86: fix JIT encoding of fixed-width immediates Stephen Hemminger
2026-06-24 17:55   ` [PATCH v5 2/9] test/bpf: add JSET test with small immediate Stephen Hemminger
2026-06-24 17:55   ` [PATCH v5 3/9] bpf: mask shift count in interpreter per RFC 9669 Stephen Hemminger
2026-06-25 15:35     ` Marat Khalili
2026-06-24 17:55   ` [PATCH v5 4/9] bpf/arm64: mask shift count " Stephen Hemminger
2026-06-25 15:40     ` Marat Khalili
2026-06-24 17:55   ` [PATCH v5 5/9] test/bpf: add test for large shift Stephen Hemminger
2026-06-25 15:38     ` Marat Khalili
2026-06-24 17:55   ` [PATCH v5 6/9] bpf/arm64: fix offset type to allow a negative jump Stephen Hemminger
2026-06-24 17:55   ` [PATCH v5 7/9] bpf/arm64: add BPF_ABS/BPF_IND packet load support Stephen Hemminger
2026-06-25 13:59     ` Marat Khalili [this message]
2026-06-24 17:55   ` [PATCH v5 8/9] test/bpf: check that JIT was generated Stephen Hemminger
2026-06-24 17:55   ` [PATCH v5 9/9] test/bpf: check that bpf_convert can be JIT'd Stephen Hemminger
2026-06-25 17:30 ` [PATCH v6 0/9] bpf: JIT related bug fixes Stephen Hemminger
2026-06-25 17:30   ` [PATCH v6 1/9] bpf/x86: fix JIT encoding of fixed-width immediates Stephen Hemminger
2026-06-25 17:30   ` [PATCH v6 2/9] test/bpf: add JSET test with small immediate Stephen Hemminger
2026-06-25 17:30   ` [PATCH v6 3/9] bpf: mask shift count in interpreter per RFC 9669 Stephen Hemminger
2026-06-25 17:30   ` [PATCH v6 4/9] bpf/arm64: mask shift count " Stephen Hemminger
2026-06-25 17:30   ` [PATCH v6 5/9] test/bpf: add test for large shift Stephen Hemminger
2026-06-25 17:30   ` [PATCH v6 6/9] bpf/arm64: fix offset type to allow a negative jump Stephen Hemminger
2026-06-25 17:30   ` [PATCH v6 7/9] bpf/arm64: add BPF_ABS/BPF_IND packet load support Stephen Hemminger
2026-06-26 10:34     ` Marat Khalili
2026-06-25 17:30   ` [PATCH v6 8/9] test/bpf: check that JIT was generated Stephen Hemminger
2026-06-25 17:30   ` [PATCH v6 9/9] test/bpf: check that bpf_convert can be JIT'd Stephen Hemminger
2026-06-25 23:12     ` Stephen Hemminger
2026-06-26 10:35   ` [PATCH v6 0/9] bpf: JIT related bug fixes Marat Khalili
2026-06-26 15:01     ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42ae97d2d2754ea69025a6f6cc6c057d@huawei.com \
    --to=marat.khalili@huawei.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@huawei.com \
    --cc=stephen@networkplumber.org \
    --cc=wathsala.vithanage@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.