Skip to content

Commit 2903c2b

Browse files
two-heartmjain-jump
authored andcommitted
flamenco, program-cache: join syscall map
esp. with util/tmpl we should stick close to the API contracts for maintainability
1 parent 9884872 commit 2903c2b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/flamenco/runtime/program/fd_program_cache.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ fd_program_cache_validate_sbpf_program( fd_exec_slot_ctx_t const * slot_ctx,
251251
fd_program_cache_entry_t * cache_entry /* out */ ) {
252252
ulong prog_align = fd_sbpf_program_align();
253253
ulong prog_footprint = fd_sbpf_program_footprint( elf_info );
254-
fd_sbpf_program_t * prog = fd_sbpf_program_new( fd_spad_alloc( runtime_spad, prog_align, prog_footprint ), elf_info, cache_entry->rodata );
254+
void * prog_mem = fd_spad_alloc_check( runtime_spad, prog_align, prog_footprint );
255+
fd_sbpf_program_t * prog = fd_sbpf_program_new( prog_mem , elf_info, cache_entry->rodata );
255256
if( FD_UNLIKELY( !prog ) ) {
256257
FD_LOG_DEBUG(( "fd_sbpf_program_new() failed" ));
257258
cache_entry->failed_verification = 1;
@@ -260,7 +261,8 @@ fd_program_cache_validate_sbpf_program( fd_exec_slot_ctx_t const * slot_ctx,
260261

261262
/* Allocate syscalls */
262263

263-
fd_sbpf_syscalls_t * syscalls = fd_sbpf_syscalls_new( fd_spad_alloc( runtime_spad, fd_sbpf_syscalls_align(), fd_sbpf_syscalls_footprint() ) );
264+
void * syscalls_mem = fd_spad_alloc_check( runtime_spad, fd_sbpf_syscalls_align(), fd_sbpf_syscalls_footprint() );
265+
fd_sbpf_syscalls_t * syscalls = fd_sbpf_syscalls_join( fd_sbpf_syscalls_new( syscalls_mem ) );
264266
if( FD_UNLIKELY( !syscalls ) ) {
265267
FD_LOG_CRIT(( "Call to fd_sbpf_syscalls_new() failed" ));
266268
}
@@ -275,6 +277,7 @@ fd_program_cache_validate_sbpf_program( fd_exec_slot_ctx_t const * slot_ctx,
275277
if( FD_UNLIKELY( 0!=fd_sbpf_program_load( prog, program_data, program_data_len, syscalls, false ) ) ) {
276278
FD_LOG_DEBUG(( "fd_sbpf_program_load() failed: %s", fd_sbpf_strerror() ));
277279
cache_entry->failed_verification = 1;
280+
fd_sbpf_syscalls_leave( syscalls );
278281
return -1;
279282
}
280283

@@ -316,6 +319,7 @@ fd_program_cache_validate_sbpf_program( fd_exec_slot_ctx_t const * slot_ctx,
316319
}
317320

318321
int res = fd_vm_validate( vm );
322+
fd_sbpf_syscalls_leave( syscalls );
319323
if( FD_UNLIKELY( res ) ) {
320324
FD_LOG_DEBUG(( "fd_vm_validate() failed" ));
321325
cache_entry->failed_verification = 1;

0 commit comments

Comments
 (0)