Skip to content

Commit

Permalink
Enable CBOs (but upgrade inval to flush for safety)
Browse files Browse the repository at this point in the history
  • Loading branch information
aswaterman committed Sep 26, 2024
1 parent 47a2e87 commit 7f3bef0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion machine/minit.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void enter_supervisor_mode(void (*fn)(uintptr_t), uintptr_t arg0, uintptr_t arg1
mstatus = INSERT_FIELD(mstatus, MSTATUS_MPIE, 0);
write_csr(mstatus, mstatus);
write_csr(mscratch, MACHINE_STACK_TOP() - MENTRY_FRAME_SIZE);
write_csr(menvcfg, MENVCFG_SSE);
write_csr(menvcfg, MENVCFG_SSE | MENVCFG_CBCFE | INSERT_FIELD(0, MENVCFG_CBIE, 1));
#ifndef __riscv_flen
uintptr_t *p_fcsr = (uintptr_t*)(MACHINE_STACK_TOP() - MENTRY_FRAME_SIZE); // the x0's save slot
*p_fcsr = 0;
Expand Down
2 changes: 2 additions & 0 deletions pk/pk.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ static void run_loaded_program(size_t argc, char** argv, uintptr_t kstack_top)
write_csr(ssp, shadow_stack_top);
}

set_csr(senvcfg, SENVCFG_CBCFE | INSERT_FIELD(0, SENVCFG_CBIE, 1));

// copy phdrs to user stack
size_t stack_top = current.stack_top - current.phdr_size;
memcpy_to_user((void*)stack_top, (void*)current.phdr, current.phdr_size);
Expand Down

0 comments on commit 7f3bef0

Please sign in to comment.