Skip to content

Commit

Permalink
flamenco: set registers after the init
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony authored and ravyu-jump committed Nov 18, 2024
1 parent de0d5cd commit 4f66f08
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/flamenco/runtime/tests/fd_vm_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,22 +215,6 @@ do{
fd_vm_t * vm = fd_vm_join( fd_vm_new( fd_valloc_malloc( valloc, fd_vm_align(), fd_vm_footprint() ) ) );
FD_TEST( vm );

/* Override some execution state values from the interp fuzzer input
This is so we can test if the interp (or vm setup) mutates any of
these erroneously */
vm->reg[0] = input->vm_ctx.r0;
vm->reg[1] = input->vm_ctx.r1;
vm->reg[2] = input->vm_ctx.r2;
vm->reg[3] = input->vm_ctx.r3;
vm->reg[4] = input->vm_ctx.r4;
vm->reg[5] = input->vm_ctx.r5;
vm->reg[6] = input->vm_ctx.r6;
vm->reg[7] = input->vm_ctx.r7;
vm->reg[8] = input->vm_ctx.r8;
vm->reg[9] = input->vm_ctx.r9;
vm->reg[10] = input->vm_ctx.r10;
vm->reg[11] = input->vm_ctx.r11;

fd_vm_init(
vm,
instr_ctx,
Expand All @@ -254,6 +238,22 @@ do{
FD_FEATURE_ACTIVE( instr_ctx->slot_ctx, bpf_account_data_direct_mapping ) /* direct mapping */
);

/* Override some execution state values from the interp fuzzer input
This is so we can test if the interp (or vm setup) mutates any of
these erroneously */
vm->reg[0] = input->vm_ctx.r0;
// vm->reg[1] = input->vm_ctx.r1; // set in fd_vm_init
vm->reg[2] = input->vm_ctx.r2;
vm->reg[3] = input->vm_ctx.r3;
vm->reg[4] = input->vm_ctx.r4;
vm->reg[5] = input->vm_ctx.r5;
vm->reg[6] = input->vm_ctx.r6;
vm->reg[7] = input->vm_ctx.r7;
vm->reg[8] = input->vm_ctx.r8;
vm->reg[9] = input->vm_ctx.r9;
// vm->reg[10] = input->vm_ctx.r10; // set in fd_vm_init
vm->reg[11] = input->vm_ctx.r11;

// Propagate the acc_regions_meta to the vm
vm->acc_region_metas = fd_valloc_malloc( valloc, alignof(fd_vm_acc_region_meta_t), sizeof(fd_vm_acc_region_meta_t) * input->vm_ctx.input_data_regions_count );
setup_vm_acc_region_metas( vm->acc_region_metas, vm, vm->instr_ctx );
Expand Down

0 comments on commit 4f66f08

Please sign in to comment.