[PATCH v2 0/3] bpf: enable indirect calls (callx) for CPU v1 and above

Vineet Gupta vineet.gupta@linux.dev
Fri Oct 9 07:43:33 GMT 2026


Linux kernel recently gained support for callx instruction [1] and BPF-GCC
CI broke immediately.

This series addresses the deficiencies in BPF-GCC.

Patch 1 fixes the pseudo-C asm template.  Also fixes documentation.

Patch 2 adds -mcallx/-mno-callx, enabled for CPU v1 and above like the
other ISA features, along with __BPF_FEATURE_CALLX.  Being on by
default, no flag is needed to adopt it, while -mno-callx keeps indirect
calls out of programs meant for kernels older than [1].  Clang does not
define that macro, as callx is unconditional there, so the expected
usage is `#if defined(__clang__) || defined(__BPF_FEATURE_CALLX)'.

Patch 3 fixes the location and duplication of the "indirect call"
diagnostic, now only emitted with -mno-callx.

Tested on a bpf-unknown-none cross compiler: make check-gcc
RUNTESTFLAGS="bpf.exp" gives 600 pass / 6 xfail / 0 fail, against
587 / 6 / 0 before, the 13 new passes being the added tests.

Not addressed yet, as discussed in v1: diagnosing the indirect calls
the verifier rejects, i.e. to global subprogs, helpers and kfuncs, and
tail calls in the callees of an indirect call.

[1] https://lore.kernel.org/bpf/20260924031042.1690890-1-alexei.starovoitov@gmail.com/

Changes in v2:
- Gate indirect calls on a new -mcallx ISA feature, enabled for CPU v1
  and above, instead of on -mxbpf (new patch 2).  (David Faust)
- Patch 3: diagnose with -mno-callx rather than without -mxbpf, and
  name -mno-callx in the error instead of claiming eBPF does not
  support indirect calls.
- Link to v1: https://inbox.sourceware.org/bpf/20260925183837.481857-1-vineet.gupta@linux.dev/

Vineet Gupta (3):
  bpf: spell xBPF indirect calls `callx' in the pseudo-C dialect
  bpf: add -mcallx, enabled for CPU v1 and above
  bpf: report indirect calls at the call, not at the end of the function

 gcc/config/bpf/bpf-c.cc                       |  2 +
 gcc/config/bpf/bpf-protos.h                   |  1 +
 gcc/config/bpf/bpf.cc                         | 42 ++++++++++++++++---
 gcc/config/bpf/bpf.md                         | 19 ++++++---
 gcc/config/bpf/bpf.opt                        |  4 ++
 gcc/doc/invoke.texi                           | 27 ++++++++----
 .../gcc.target/bpf/diag-indcalls-2.c          | 13 ++++++
 gcc/testsuite/gcc.target/bpf/diag-indcalls.c  |  6 +--
 .../gcc.target/bpf/feature-macro-1.c          |  6 ++-
 .../gcc.target/bpf/feature-macro-3.c          |  6 +++
 .../gcc.target/bpf/feature-macro-4.c          |  6 +++
 .../gcc.target/bpf/indirect-call-1.c          | 21 ++++++++++
 .../gcc.target/bpf/indirect-call-2.c          | 22 ++++++++++
 .../gcc.target/bpf/xbpf-indirect-call-2.c     | 23 ++++++++++
 14 files changed, 174 insertions(+), 24 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/bpf/diag-indcalls-2.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/feature-macro-3.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/feature-macro-4.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/indirect-call-1.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/indirect-call-2.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/xbpf-indirect-call-2.c

-- 
2.53.0-Meta



More information about the Gcc-patches mailing list