From 8f3e61b0dd475fe20eb2ff72cbd851a93b701e8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Mei=C3=9Fner?= Date: Tue, 26 Nov 2024 16:41:20 +0100 Subject: [PATCH] Groups the SBPFVersion feature flags by their SIMDs. --- src/program.rs | 69 +++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/src/program.rs b/src/program.rs index 5f86caef..3ca19d38 100644 --- a/src/program.rs +++ b/src/program.rs @@ -20,64 +20,67 @@ 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-0174: SBPF arithmetics improvements + pub fn enable_pqr(self) -> bool { self != SBPFVersion::V1 } - - /// Enable the negation instruction - pub fn disable_neg(self) -> bool { + /// ... SIMD-0174 + pub fn explicit_sign_extension_of_results(self) -> bool { self != SBPFVersion::V1 } - - /// Swaps the reg and imm operands of the subtraction instruction + /// ... SIMD-0174 pub fn swap_sub_reg_imm_operands(self) -> bool { self != SBPFVersion::V1 } + /// ... SIMD-0174 + pub fn disable_neg(self) -> bool { + self != SBPFVersion::V1 + } - /// Enable the only two slots long instruction: LD_DW_IMM + /// Enable SIMD-0173: SBPF instruction encoding improvements + pub fn callx_uses_src_reg(self) -> bool { + self != SBPFVersion::V1 + } + /// ... SIMD-0173 pub fn disable_lddw(self) -> bool { self != SBPFVersion::V1 } - - /// Enable the BPF_PQR instruction class - pub fn enable_pqr(self) -> bool { + /// ... SIMD-0173 + pub fn disable_le(self) -> bool { self != SBPFVersion::V1 } - - /// Use src reg instead of imm in callx - pub fn callx_uses_src_reg(self) -> bool { + /// ... SIMD-0173 + pub fn move_memory_instruction_classes(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 { + /// Enable SIMD-0178: SBPF Static Syscalls + /// Enable SIMD-0179: SBPF stricter verification constraints + pub fn static_syscalls(self) -> bool { self != SBPFVersion::V1 } - - /// Allow sh_addr != sh_offset in elf sections. - pub fn enable_elf_vaddr(self) -> bool { + /// Enable SIMD-0189: SBPF stricter ELF headers + pub fn enable_stricter_elf_headers(self) -> bool { self != SBPFVersion::V1 } - - /// Separates the bytecode from the read only data in virtual address space + /// ... 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 } @@ -90,16 +93,6 @@ impl SBPFVersion { imm as u32 } } - - /// 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