Skip to content

Commit

Permalink
Removes add64 r10, imm special handling in execution.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Nov 27, 2024
1 parent 53f7e30 commit 04ee028
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
12 changes: 1 addition & 11 deletions src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//! Interpreter for eBPF programs.
use crate::{
ebpf::{self, FRAME_PTR_REG},
ebpf,
elf::Executable,
error::{EbpfError, ProgramResult},
program::BuiltinFunction,
Expand Down Expand Up @@ -188,16 +188,6 @@ impl<'a, 'b, C: ContextObject> Interpreter<'a, 'b, C> {
}

match insn.opc {
ebpf::ADD64_IMM if dst == FRAME_PTR_REG && self.executable.get_sbpf_version().dynamic_stack_frames() => {
// Let the stack overflow. For legitimate programs, this is a nearly
// impossible condition to hit since programs are metered and we already
// enforce a maximum call depth. For programs that intentionally mess
// around with the stack pointer, MemoryRegion::map will return
// InvalidVirtualAddress(stack_ptr) once an invalid stack address is
// accessed.
self.reg[ebpf::FRAME_PTR_REG] = self.reg[ebpf::FRAME_PTR_REG].overflowing_add(insn.imm as u64).0;
}

ebpf::LD_DW_IMM if !self.executable.get_sbpf_version().disable_lddw() => {
ebpf::augment_lddw_unchecked(self.program, &mut insn);
self.reg[dst] = insn.imm as u64;
Expand Down
4 changes: 0 additions & 4 deletions src/jit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,6 @@ impl<'a, C: ContextObject> JitCompiler<'a, C> {
let target_pc = (self.pc as isize + insn.off as isize + 1) as usize;

match insn.opc {
ebpf::ADD64_IMM if insn.dst == FRAME_PTR_REG as u8 && self.executable.get_sbpf_version().dynamic_stack_frames() => {
self.emit_ins(X86Instruction::alu(OperandSize::S64, 0x81, 0, REGISTER_MAP[FRAME_PTR_REG], insn.imm, None));
}

ebpf::LD_DW_IMM if !self.executable.get_sbpf_version().disable_lddw() => {
self.emit_validate_and_profile_instruction_count(false, Some(self.pc + 2));
self.pc += 1;
Expand Down

0 comments on commit 04ee028

Please sign in to comment.