Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benches/vm_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn bench_jit_vs_interpreter(
executable.verify::<RequisiteVerifier>().unwrap();
executable.jit_compile().unwrap();
let mut context_object = TestContextObject::default();
let mem_region = MemoryRegion::new_writable(mem, ebpf::MM_INPUT_START);
let mem_region = MemoryRegion::new_writable(mem, ebpf::MM_TX_AREA);
create_vm!(
vm,
&executable,
Expand Down
2 changes: 1 addition & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ fn main() {
},
),
MemoryRegion::new_writable(heap.as_slice_mut(), ebpf::MM_HEAP_START),
MemoryRegion::new_writable(&mut mem, ebpf::MM_INPUT_START),
MemoryRegion::new_writable(&mut mem, ebpf::MM_TX_AREA),
];

let memory_mapping = MemoryMapping::new(regions, config, sbpf_version).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/dumb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fuzz_target!(|data: DumbFuzzData| {
function_registry,
)
.unwrap();
let mem_region = MemoryRegion::new_writable(&mut mem, ebpf::MM_INPUT_START);
let mem_region = MemoryRegion::new_writable(&mut mem, ebpf::MM_TX_AREA);
let mut context_object = TestContextObject::new(29);
create_vm!(
interp_vm,
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/smart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fuzz_target!(|data: FuzzData| {
function_registry,
)
.unwrap();
let mem_region = MemoryRegion::new_writable(&mut mem, ebpf::MM_INPUT_START);
let mem_region = MemoryRegion::new_writable(&mut mem, ebpf::MM_TX_AREA);
let mut context_object = TestContextObject::new(1 << 16);
create_vm!(
interp_vm,
Expand Down
4 changes: 2 additions & 2 deletions fuzz/fuzz_targets/smart_jit_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fuzz_target!(|data: FuzzData| {
.unwrap();
let mut interp_mem = data.mem.clone();
let mut interp_context_object = TestContextObject::new(1 << 16);
let interp_mem_region = MemoryRegion::new_writable(&mut interp_mem, ebpf::MM_INPUT_START);
let interp_mem_region = MemoryRegion::new_writable(&mut interp_mem, ebpf::MM_TX_AREA);
create_vm!(
interp_vm,
&executable,
Expand All @@ -83,7 +83,7 @@ fuzz_target!(|data: FuzzData| {
if executable.jit_compile().is_ok() {
let mut jit_mem = data.mem;
let mut jit_context_object = TestContextObject::new(1 << 16);
let jit_mem_region = MemoryRegion::new_writable(&mut jit_mem, ebpf::MM_INPUT_START);
let jit_mem_region = MemoryRegion::new_writable(&mut jit_mem, ebpf::MM_TX_AREA);
create_vm!(
jit_vm,
&executable,
Expand Down
4 changes: 2 additions & 2 deletions fuzz/fuzz_targets/smarter_jit_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fuzz_target!(|data: FuzzData| {
.unwrap();
let mut interp_mem = data.mem.clone();
let mut interp_context_object = TestContextObject::new(1 << 16);
let interp_mem_region = MemoryRegion::new_writable(&mut interp_mem, ebpf::MM_INPUT_START);
let interp_mem_region = MemoryRegion::new_writable(&mut interp_mem, ebpf::MM_TX_AREA);
create_vm!(
interp_vm,
&executable,
Expand All @@ -73,7 +73,7 @@ fuzz_target!(|data: FuzzData| {
if executable.jit_compile().is_ok() {
let mut jit_mem = data.mem;
let mut jit_context_object = TestContextObject::new(1 << 16);
let jit_mem_region = MemoryRegion::new_writable(&mut jit_mem, ebpf::MM_INPUT_START);
let jit_mem_region = MemoryRegion::new_writable(&mut jit_mem, ebpf::MM_TX_AREA);
create_vm!(
jit_vm,
&executable,
Expand Down
10 changes: 9 additions & 1 deletion src/ebpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,15 @@ pub const MM_STACK_START: u64 = MM_REGION_SIZE * 2;
/// Virtual address of the heap region
pub const MM_HEAP_START: u64 = MM_REGION_SIZE * 3;
/// Virtual address of the input region
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't "Input" be renamed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not rename it, because it is still the same. Should it be called MM_TX_INPUT_START?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Input" is kinda a useless name because it does not say from where to where, it is subjective depending on the perspective, like "left" and "right". Maybe MM_TX_AREA, MM_TX_INSTRUCTION_AREA and MM_TX_INSTRUCTION_DATA.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then again, we probably want multiple instructions mapped in at once. So MM_TX_INSTRUCTION_DATA might not cut it either.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then again, we probably want multiple instructions mapped in at once.

Even if we follow that path, the most important instruction for a program is the one being executed, so having that one in a predicted address that can be read without any other dependencies is preferable. The SDK could then access other instructions on demand.

pub const MM_INPUT_START: u64 = MM_REGION_SIZE * 4;
pub const MM_TX_AREA: u64 = MM_REGION_SIZE * 4;
/// Virtual address of the scratch pad area
pub const MM_SCRATCHPAD_AREA: u64 = MM_REGION_SIZE * 5;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just read the SIMD again, and I think I made a mistake calling this "scratchpad". We should stick with the current naming of this being "return-data".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated all names according to the latest version of the SIMD in 8ba1d93

/// Virtual address of the instruction area
pub const MM_TX_INSTRUCTION_AREA: u64 = MM_REGION_SIZE * 6;
/// Virtual address of the instruction input payload
pub const MM_TX_INSTRUCTION_DATA: u64 = MM_REGION_SIZE * 7;
/// Virtual address of the accounts payload area
pub const MM_ACCOUNTS_AREA: u64 = MM_REGION_SIZE * 8;

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