Skip to content

Commit

Permalink
Adjusts SBPFVersion.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Nov 22, 2024
1 parent b69ff79 commit 785454e
Show file tree
Hide file tree
Showing 22 changed files with 190 additions and 190 deletions.
12 changes: 6 additions & 6 deletions benches/memory_mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ macro_rules! bench_gapped_randomized_access_with_1024_entries {
)];
let config = Config::default();
let memory_mapping =
$mem::new(memory_regions, &config, SBPFVersion::V2).unwrap();
$mem::new(memory_regions, &config, SBPFVersion::V3).unwrap();
let mut prng = new_prng!();
bencher.iter(|| {
assert!(memory_mapping
Expand Down Expand Up @@ -111,7 +111,7 @@ macro_rules! bench_randomized_access_with_0001_entry {
let content = vec![0; 1024 * 2];
let memory_regions = vec![MemoryRegion::new_readonly(&content[..], 0x100000000)];
let config = Config::default();
let memory_mapping = $mem::new(memory_regions, &config, SBPFVersion::V2).unwrap();
let memory_mapping = $mem::new(memory_regions, &config, SBPFVersion::V3).unwrap();
let mut prng = new_prng!();
bencher.iter(|| {
let _ = memory_mapping.map(
Expand Down Expand Up @@ -145,7 +145,7 @@ macro_rules! bench_randomized_access_with_n_entries {
let (memory_regions, end_address) =
generate_memory_regions($n, MemoryState::Readable, Some(&mut prng));
let config = Config::default();
let memory_mapping = $mem::new(memory_regions, &config, SBPFVersion::V2).unwrap();
let memory_mapping = $mem::new(memory_regions, &config, SBPFVersion::V3).unwrap();
bencher.iter(|| {
let _ = memory_mapping.map(
AccessType::Load,
Expand Down Expand Up @@ -194,7 +194,7 @@ macro_rules! bench_randomized_mapping_with_n_entries {
let (memory_regions, _end_address) =
generate_memory_regions($n, MemoryState::Readable, Some(&mut prng));
let config = Config::default();
let memory_mapping = $mem::new(memory_regions, &config, SBPFVersion::V2).unwrap();
let memory_mapping = $mem::new(memory_regions, &config, SBPFVersion::V3).unwrap();
bencher.iter(|| {
let _ = memory_mapping.map(AccessType::Load, 0x100000000, 1);
});
Expand Down Expand Up @@ -243,7 +243,7 @@ macro_rules! bench_mapping_with_n_entries {
let (memory_regions, _end_address) =
generate_memory_regions($n, MemoryState::Readable, None);
let config = Config::default();
let memory_mapping = $mem::new(memory_regions, &config, SBPFVersion::V2).unwrap();
let memory_mapping = $mem::new(memory_regions, &config, SBPFVersion::V3).unwrap();
bencher.iter(|| {
let _ = memory_mapping.map(AccessType::Load, 0x100000000, 1);
});
Expand Down Expand Up @@ -301,7 +301,7 @@ fn do_bench_mapping_operation(bencher: &mut Bencher, op: MemoryOperation, vm_add
MemoryRegion::new_writable(&mut mem2, 0x100000000 + 8),
],
&config,
SBPFVersion::V2,
SBPFVersion::V3,
)
.unwrap();

Expand Down
14 changes: 4 additions & 10 deletions benches/vm_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ fn bench_jit_vs_interpreter_address_translation_stack_fixed(bencher: &mut Benche
bencher,
ADDRESS_TRANSLATION_STACK_CODE,
Config {
enabled_sbpf_versions: SBPFVersion::V1..=SBPFVersion::V1,
enabled_sbpf_versions: SBPFVersion::V0..=SBPFVersion::V0,
..Config::default()
},
524289,
Expand All @@ -185,10 +185,7 @@ fn bench_jit_vs_interpreter_address_translation_stack_dynamic(bencher: &mut Benc
bench_jit_vs_interpreter(
bencher,
ADDRESS_TRANSLATION_STACK_CODE,
Config {
enabled_sbpf_versions: SBPFVersion::V1..=SBPFVersion::V2,
..Config::default()
},
Config::default(),
524289,
&mut [],
);
Expand Down Expand Up @@ -233,7 +230,7 @@ fn bench_jit_vs_interpreter_call_depth_fixed(bencher: &mut Bencher) {
call function_foo
exit",
Config {
enabled_sbpf_versions: SBPFVersion::V1..=SBPFVersion::V1,
enabled_sbpf_versions: SBPFVersion::V0..=SBPFVersion::V0,
..Config::default()
},
137218,
Expand Down Expand Up @@ -263,10 +260,7 @@ fn bench_jit_vs_interpreter_call_depth_dynamic(bencher: &mut Bencher) {
call function_foo
add r11, 4
exit",
Config {
enabled_sbpf_versions: SBPFVersion::V1..=SBPFVersion::V2,
..Config::default()
},
Config::default(),
176130,
&mut [],
);
Expand Down
2 changes: 1 addition & 1 deletion examples/disassemble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn main() {
let executable = Executable::<TestContextObject>::from_text_bytes(
program,
loader,
SBPFVersion::V2,
SBPFVersion::V3,
FunctionRegistry::default(),
)
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/to_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn to_json(program: &[u8]) -> String {
let executable = Executable::<TestContextObject>::from_text_bytes(
program,
Arc::new(BuiltinProgram::new_mock()),
SBPFVersion::V2,
SBPFVersion::V3,
FunctionRegistry::default(),
)
.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions fuzz/fuzz_targets/dumb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fuzz_target!(|data: DumbFuzzData| {
let function_registry = FunctionRegistry::default();
let syscall_registry = FunctionRegistry::<BuiltinFunction<TestContextObject>>::default();

if RequisiteVerifier::verify(&prog, &config, SBPFVersion::V2, &function_registry, &syscall_registry).is_err() {
if RequisiteVerifier::verify(&prog, &config, SBPFVersion::V3, &function_registry, &syscall_registry).is_err() {
// verify please
return;
}
Expand All @@ -42,7 +42,7 @@ fuzz_target!(|data: DumbFuzzData| {
config,
FunctionRegistry::default(),
)),
SBPFVersion::V2,
SBPFVersion::V3,
function_registry,
)
.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions fuzz/fuzz_targets/smart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fuzz_target!(|data: FuzzData| {
if RequisiteVerifier::verify(
prog.into_bytes(),
&config,
SBPFVersion::V2,
SBPFVersion::V3,
&function_registry,
&syscall_registry,
)
Expand All @@ -54,7 +54,7 @@ fuzz_target!(|data: FuzzData| {
config,
FunctionRegistry::default(),
)),
SBPFVersion::V2,
SBPFVersion::V3,
function_registry,
)
.unwrap();
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 @@ -45,7 +45,7 @@ fuzz_target!(|data: FuzzData| {
if RequisiteVerifier::verify(
prog.into_bytes(),
&config,
SBPFVersion::V2,
SBPFVersion::V3,
&function_registry,
&syscall_registry,
)
Expand All @@ -62,7 +62,7 @@ fuzz_target!(|data: FuzzData| {
config,
FunctionRegistry::default(),
)),
SBPFVersion::V2,
SBPFVersion::V3,
function_registry,
)
.unwrap();
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 @@ -35,7 +35,7 @@ fuzz_target!(|data: FuzzData| {
if RequisiteVerifier::verify(
prog.into_bytes(),
&config,
SBPFVersion::V2,
SBPFVersion::V3,
&function_registry,
&syscall_registry,
)
Expand All @@ -52,7 +52,7 @@ fuzz_target!(|data: FuzzData| {
config,
FunctionRegistry::default(),
)),
SBPFVersion::V2,
SBPFVersion::V3,
function_registry,
)
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/verify_semantic_aware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fuzz_target!(|data: FuzzData| {
RequisiteVerifier::verify(
prog.into_bytes(),
&config,
SBPFVersion::V2,
SBPFVersion::V3,
&function_registry,
&syscall_registry,
)
Expand Down
4 changes: 2 additions & 2 deletions src/assembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ fn make_instruction_map(sbpf_version: SBPFVersion) -> HashMap<String, (Instructi
result.insert(name.to_string(), (inst_type, opc))
};

if sbpf_version == SBPFVersion::V1 {
if sbpf_version == SBPFVersion::V0 {
entry("exit", NoOperand, ebpf::EXIT);
entry("return", NoOperand, ebpf::EXIT);
} else {
Expand All @@ -125,7 +125,7 @@ fn make_instruction_map(sbpf_version: SBPFVersion) -> HashMap<String, (Instructi
entry(
"syscall",
Syscall,
if sbpf_version == SBPFVersion::V1 {
if sbpf_version == SBPFVersion::V0 {
ebpf::CALL_IMM
} else {
ebpf::SYSCALL
Expand Down
4 changes: 2 additions & 2 deletions src/ebpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ pub const BPF_JSGT: u8 = 0x60;
pub const BPF_JSGE: u8 = 0x70;
/// BPF JMP operation code: syscall function call.
pub const BPF_CALL: u8 = 0x80;
/// BPF JMP operation code: return from program (V1).
/// BPF JMP operation code: return from program.
pub const BPF_EXIT: u8 = 0x90;
/// BPF JMP operation code: static syscall (V2).
/// BPF JMP operation code: static syscall.
pub const BPF_SYSCALL: u8 = 0x90;
/// BPF JMP operation code: jump if lower than.
pub const BPF_JLT: u8 = 0xa0;
Expand Down
Loading

0 comments on commit 785454e

Please sign in to comment.