binutils Newspaper
OCTOBER 6, 2026
bpf — Proposed — Sentiment 7 / 10

bpf: add the addr_space_cast instruction

Adds the addr_space_cast BPF instruction to gas for supporting BPF arenas.

This patch introduces the addr_space_cast BPF instruction to the GNU Assembler (gas). This instruction is necessary for supporting BPF arenas, as it allows for distinct address spaces (generic and arena) to be encoded within an immediate value. To simplify implementation, the two combinations are spelled out as literal template text, preceding the ‘mov’ instruction to avoid opcode conflicts.

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

    Adds the addr_space_cast instruction to gas, which is required for BPF arena support.

    “gas doesn't support bpf arenas as it is missing addr_space_cast BPF instruction. It is essentially a `mov' with a distinguised offset and the two address spaces supported (0: generic, 1: arena) ecoded in the immediate.”
  2. Jose E. Marchesi <jemarch@gnu.org> reviewer

    Acknowledges the patch and its purpose, indicating it has been received for review.

    “Hi Vineet, thanks for the patch.”

Technical Tradeoffs

  • Spelling out instruction variants to avoid opcode conflicts simplifies implementation but might be less DRY than a more generalized approach.
  • The patch prioritizes simplicity by directly implementing the two required combinations.

In Details

Adds the addr_space_cast instruction to gas for BPF. This instruction is analogous to a mov but encodes the address space (0 for generic, 1 for arena) in its immediate field. The patch implements this by spelling out the two specific combinations to avoid conflicts with the mov opcode's mask.

Filed Under: bpfgasinstruction-set