Skip to content

Commit

Permalink
Renames MM_PROGRAM_START => MM_RODATA_START.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Oct 11, 2024
1 parent c168a87 commit d4800c3
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 108 deletions.
4 changes: 2 additions & 2 deletions src/debugger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ fn get_host_ptr<C: ContextObject>(
interpreter: &mut Interpreter<C>,
mut vm_addr: u64,
) -> Result<*mut u8, EbpfError> {
if vm_addr < ebpf::MM_PROGRAM_START {
vm_addr += ebpf::MM_PROGRAM_START;
if vm_addr < ebpf::MM_RODATA_START {
vm_addr += ebpf::MM_RODATA_START;
}
match interpreter.vm.memory_mapping.map(
AccessType::Load,
Expand Down
14 changes: 9 additions & 5 deletions src/ebpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,18 @@ pub const VIRTUAL_ADDRESS_BITS: usize = 32;
// Memory map regions virtual addresses need to be (1 << VIRTUAL_ADDRESS_BITS) bytes apart.
// Also the region at index 0 should be skipped to catch NULL ptr accesses.

/// Start of the program bits (text and ro segments) in the memory map
pub const MM_PROGRAM_START: u64 = 0x100000000;
/// Size (and alignment) of a memory region
pub const MM_REGION_SIZE: u64 = 0x100000000;
/// Start of the bytecode in the memory map (SBPFv2 only)
pub const MM_BYTECODE_START: u64 = 0;
/// Start of the readonly data in the memory map (contains the bytecode in SBPFv1)
pub const MM_RODATA_START: u64 = MM_REGION_SIZE;
/// Start of the stack in the memory map
pub const MM_STACK_START: u64 = 0x200000000;
pub const MM_STACK_START: u64 = MM_REGION_SIZE * 2;
/// Start of the heap in the memory map
pub const MM_HEAP_START: u64 = 0x300000000;
pub const MM_HEAP_START: u64 = MM_REGION_SIZE * 3;
/// Start of the input buffers in the memory map
pub const MM_INPUT_START: u64 = 0x400000000;
pub const MM_INPUT_START: u64 = MM_REGION_SIZE * 4;

// eBPF op codes.
// See also https://www.kernel.org/doc/Documentation/networking/filter.txt
Expand Down
Loading

0 comments on commit d4800c3

Please sign in to comment.