Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vm: fix interp max program counter #179

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion scripts/run_test_vectors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ find dump/test-vectors/txn/fixtures/precompile/secp256k1 -type f -name '*.fix' -
find dump/test-vectors/txn/fixtures/programs -type f -name '*.fix' -exec ./target/release/test_exec_txn {} + > $LOG_PATH/test_exec_txn.log 2>&1
find dump/test-vectors/cpi/fixtures -type f -name '*.fix' -exec ./target/release/test_exec_cpi {} + > $LOG_PATH/test_exec_cpi.log 2>&1
find dump/test-vectors/syscall/fixtures -type f -name '*.fix' -exec ./target/release/test_exec_vm_syscall {} + > $LOG_PATH/test_exec_vm_syscall.log 2>&1
find dump/test-vectors/vm_interp/fixtures -type f -name '*.fix' -exec ./target/release/test_exec_vm_interp {} + > $LOG_PATH/test_exec_vm_interp.log 2>&1
find dump/test-vectors/vm_interp/fixtures/latest -type f -name '*.fix' -exec ./target/release/test_exec_vm_interp {} + > $LOG_PATH/test_exec_vm_interp.log 2>&1
find dump/test-vectors/vm_interp/fixtures/v0 -type f -name '*.fix' -exec ./target/release/test_exec_vm_interp {} + > $LOG_PATH/test_exec_vm_interp.log 2>&1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added explicitly subdirs so we can add /v1, /v2, /v3... until we upgrade rbpf we can't run those. (but we'll use those tests in fd)

find dump/test-vectors/elf_loader/fixtures -type f -name '*.fix' -exec ./target/release/test_exec_elf_loader {} + > $LOG_PATH/test_exec_elf_loader.log 2>&1
find dump/test-vectors/vm_validate/fixtures -type f -name '*.fix' -exec ./target/release/test_exec_vm_validate {} + > $LOG_PATH/test_exec_vm_validate.log 2>&1

Expand Down
15 changes: 10 additions & 5 deletions src/vm_interp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ difference in error checks in CALL_IMM, which we handle in process_result.
[1](https://github.com/firedancer-io/firedancer/blob/93cea434dfe2f728f2ab4746590972644c06b863/src/ballet/sbpf/fd_sbpf_loader.h#L27). */
fn setup_internal_fn_registry(vm_ctx: &VmContext) -> FunctionRegistry<usize> {
let mut fn_reg = FunctionRegistry::default();
let max_pc = vm_ctx.rodata.len() / 8;

// register entry point
let _ = fn_reg.register_function(
Expand All @@ -322,11 +323,15 @@ fn setup_internal_fn_registry(vm_ctx: &VmContext) -> FunctionRegistry<usize> {
for bit_idx in 0..8 {
if (byte & (1 << bit_idx)) != 0 {
let pc = byte_idx * 8 + bit_idx;
let _ = fn_reg.register_function(
ebpf::hash_symbol_name(&u64::to_le_bytes(pc as u64)),
b"fn",
pc,
);
// ignore invalid pc, i.e. assume the test was set up correctly.
// registering fn beyond max_pc segfaults inside the JIT.
if pc < max_pc {
let _ = fn_reg.register_function(
ebpf::hash_symbol_name(&u64::to_le_bytes(pc as u64)),
b"fn",
pc,
);
}
}
}
}
Expand Down
Loading