Tomorrow I am flying to Alberta to attend HotOS, I will be presenting our work on lightweight hypervisor verification.
In a nutshell, we translated the RISC-V spec to Rust (with an in-house Sail-to-Rust transpiler), and used the Kani model checker to verify key parts of Miralis.
ALT A snippet of code to verify the implementation of `mret` emulation in the Miralis virtual firmware monitor.
The function first create two symbolic contexts (i.e. where all registers are symbolic, that is they can be arbitrary values), and execute the `mret` instruction with both the Miralis instruction emulator and the reference Sail RISC-V model. If the resulting symbolic contexts are equal, the Miralis implementation is correct for all possible inputs.
```rust
/// Verify the emulation of the `mret` instruction.
#[cfg_attr(kani, kani::proof)]
pub fn check_mret() {
let (mut ctx, mut mctx, mut sail_ctx) =
symbolic::new_symbolic_contexts();
ctx.emulate_mret(&mut mctx); // Miralis implementation
execute_MRET(&mut sail_ctx); // Sail implementation
assert_eq!(
ctx,
adapters::sail_to_miralis(sail_ctx, &mctx),
"mret instruction emulation is not correct"
);
}
```