This repository was archived by the owner on Jan 22, 2025. It is now read-only.
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
Solana BPF v2 #20323
Closed as not planned
Description
Problem
Solana Bytecode Format is a variation of eBPF. Some of the architectural requirements are different from eBPF and what Solana needs. A new version 2 is needed to move away from BPF and meet the specific needs of Solana
Proposed Solution
- #34258
- BTF ELF-section parsing
- Static type inference
- Instruction stream verification
- Dynamic linking / dynamic dispatch
- Decide about implicit vs explicit sign extension in 32bit ALU operations (Sign Extension in SBPFv2 #32924)
- ISA changes: LLVM changes related to BPFv2 #34250
- Reduce the overhead for the loader at runtime, by letting the linker concatenate sections to become consecutive in virtual address space (elf: avoid copying read only sections rbpf#284 and elf: add support for rodata sections already aligned to MM_PROGRAM_START rbpf#301)
- Restrict the control flow:
- Only symbols registered in the ELF or referenced by
call
are valid destinations forcallx
. (Refactor - Restrictcallx
to registered functions rbpf#397 and Refactor - Unifycall
andcallx
error handlers in JIT rbpf#439) - Functions can not start in the middle of a
lddw
instruction (Fix - Makes functions starting in the middle oflddw
fail verification in SBFv2 rbpf#440) - Jumps have to stay within a function, only
call
/callx
can reach other functions. (Verifier - Stricter control flow rbpf#454) - Forbids the fall-through at the end of a function, which now must be a unconditional-jump back into the function. (Feature - Restricts the final instruction in each function to be diverted rbpf#522)
- Only symbols registered in the ELF or referenced by
- toolchain administration
- New target triple SBFv2
- New or featurized llvm backend
- New tool
cargo-build-sbf
- Tooling changes to specify version (default to v1 for now, eventually to v2), eg.
cargo build-sbf --arch=sbfv2
From a documentation perspective SBFv2 will still be referred to as "SBF" and when calling tools like cargo build-sbf
a default arch will be provided, v1 initially, then a switch over to v2.