Skip to content

Commit

Permalink
Groups the SBPFVersion feature flags by their SIMDs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Nov 21, 2024
1 parent c1062a2 commit 8f80363
Showing 1 changed file with 35 additions and 44 deletions.
79 changes: 35 additions & 44 deletions src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,64 +20,70 @@ pub enum SBPFVersion {
}

impl SBPFVersion {
/// Explicitly perform sign extension of results
pub fn explicit_sign_extension_of_results(self) -> bool {
/// Enable SIMD-0166: SBPF dynamic stack frames
pub fn dynamic_stack_frames(self) -> bool {
self != SBPFVersion::V1
}

/// Enable the little-endian byte swap instructions
pub fn disable_le(self) -> bool {
/// Enable SIMD-0173: SBPF instruction encoding improvements
pub fn callx_uses_src_reg(self) -> bool {
self != SBPFVersion::V1
}

/// Enable the negation instruction
pub fn disable_neg(self) -> bool {
/// ... SIMD-0173
pub fn disable_lddw(self) -> bool {
self != SBPFVersion::V1
}

/// Swaps the reg and imm operands of the subtraction instruction
pub fn swap_sub_reg_imm_operands(self) -> bool {
/// ... SIMD-0173
pub fn disable_le(self) -> bool {
self != SBPFVersion::V1
}

/// Enable the only two slots long instruction: LD_DW_IMM
pub fn disable_lddw(self) -> bool {
/// ... SIMD-0173
pub fn move_memory_instruction_classes(self) -> bool {
self != SBPFVersion::V1
}

/// Enable the BPF_PQR instruction class
/// Enable SIMD-0174: SBPF arithmetics improvements
pub fn enable_pqr(self) -> bool {
self != SBPFVersion::V1
}

/// Use src reg instead of imm in callx
pub fn callx_uses_src_reg(self) -> bool {
/// ... SIMD-0174
pub fn explicit_sign_extension_of_results(self) -> bool {
self != SBPFVersion::V1
}

/// Ensure that rodata sections don't exceed their maximum allowed size and
/// overlap with the stack
pub fn reject_rodata_stack_overlap(self) -> bool {
/// ... SIMD-0174
pub fn swap_sub_reg_imm_operands(self) -> bool {
self != SBPFVersion::V1
}

/// Allow sh_addr != sh_offset in elf sections.
pub fn enable_elf_vaddr(self) -> bool {
/// ... SIMD-0174
pub fn disable_neg(self) -> bool {
self != SBPFVersion::V1
}

/// Separates the bytecode from the read only data in virtual address space
/// Enable SIMD-0179: SBPF stricter verification constraints
pub fn stricter_controlflow(self) -> bool {
self != SBPFVersion::V1
}
/// Enable SIMD-0178: SBPF Static Syscalls
pub fn static_syscalls(self) -> bool {
self != SBPFVersion::V1
}
/// Enable SIMD-0189: SBPF stricter ELF headers
pub fn enable_stricter_elf_headers(self) -> bool {
self != SBPFVersion::V1
}
/// ... SIMD-0189
pub fn enable_lower_bytecode_vaddr(self) -> bool {
self != SBPFVersion::V1
}

/// Use dynamic stack frame sizes
pub fn dynamic_stack_frames(self) -> bool {
/// Ensure that rodata sections don't exceed their maximum allowed size and
/// overlap with the stack
pub fn reject_rodata_stack_overlap(self) -> bool {
self != SBPFVersion::V1
}

/// Support syscalls via pseudo calls (insn.src = 0)
pub fn static_syscalls(self) -> bool {
/// Allow sh_addr != sh_offset in elf sections.
pub fn enable_elf_vaddr(self) -> bool {
self != SBPFVersion::V1
}

Expand All @@ -90,21 +96,6 @@ impl SBPFVersion {
imm as u32
}
}

/// Restricts jump and call targets to function boundaries
pub fn stricter_controlflow(&self) -> bool {
self != &SBPFVersion::V1
}

/// Move opcodes of memory instructions into ALU instruction classes
pub fn move_memory_instruction_classes(self) -> bool {
self != SBPFVersion::V1
}

/// Constrain ELF format to ignore section headers and relocations
pub fn enable_stricter_elf_headers(self) -> bool {
self != SBPFVersion::V1
}
}

/// Holds the function symbols of an Executable
Expand Down

0 comments on commit 8f80363

Please sign in to comment.