binutils Newspaper
NOVEMBER 30, 2026
bpf — Proposed

bpf: add the addr_space_cast instruction

Adds the BPF addr_space_cast instruction to gas and includes tests.

This patch adds support for the BPF addr_space_cast instruction in the GNU Assembler (gas). This instruction is used for casting between generic and arena address spaces. The proposer clarifies that the instruction is available across all ISA versions, aligning with clang’s behavior, and has incorporated reviewer feedback by adding big-endian tests.

In the Thread 2 participants
  1. Vineet Gupta <vineet.gupta@linux.com> proposer

    Responds to review feedback, confirms `addr_space_cast` is not tied to a specific ISA version and explains why, and states big-endian tests have been added.

    “As implemented today it is not tied to the ISA version. Verifier accepts addr_space_cast for any program that has arena associated with it. clang behaves the same way. GCC gating it on something would thus be different, unnecessary and painful for no real gains.”
  2. Jose E. Marchesi reviewer

    Reviewed the patch, initially asking for justification for ISA version availability and suggesting big-endian tests, which were later added.

    “I would add at least one test for big-endian, using some of the 0,1 and 1,0 address space combinations.”

Technical Tradeoffs

  • Adds new functionality to the assembler.
  • Requires careful handling of instruction encoding and testing across different architectures (endianness).

In Details

This patch introduces the addr_space_cast instruction to gas for the BPF target, modifying include/opcode/bpf.h and potentially gas/config/tc-bpf.c. The instruction, which is essentially a mov with specific encoding for address space manipulation (generic 0 and arena 1), is being added to support BPF arenas. The discussion clarifies that this instruction is not ISA-version-specific, mirroring clang's behavior.

For Context
BPF
Berkeley Packet Filter, a technology that allows programs to be run in the Linux kernel without altering kernel source code. It's often used for network packet filtering and more general in-kernel computation.
addr_space_cast
A BPF instruction used to cast between different address spaces, specifically generic and arena address spaces.
gas
The GNU Assembler, part of the GNU Binutils project, responsible for converting assembly language code into machine code.
immediate
A value that is explicitly written into an instruction, rather than being fetched from memory or a register.
ISA
Instruction Set Architecture, the set of commands a CPU understands.
Filed Under: BPFassemblerinstruction set