Skip to content

Commit

Permalink
SailBugfix: pmp_cfg_idx must be multiplied by two
Browse files Browse the repository at this point in the history
The pmpcfg registers have a stride of two, therefore we also need to multiply the pmp_cfg_idx by two.
  • Loading branch information
francois141 authored and CharlyCst committed Jan 31, 2025
1 parent 7f6abd2 commit e67b5d5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions model_checking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,7 @@ pub fn fences() {
#[cfg_attr(kani, kani::proof)]
#[cfg_attr(test, test)]
pub fn read_csr() {
let (mut ctx, mctx, mut sail_ctx) = symbolic::new_symbolic_contexts();

// Infinite number of pmps for the formal verification
ctx.nb_pmp = usize::MAX;
let (ctx, mctx, mut sail_ctx) = symbolic::new_symbolic_contexts();

let csr_register = generate_csr_register();

Expand Down
2 changes: 1 addition & 1 deletion src/virt/csr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl RegisterContextGetter<Csr> for VirtContext {
log::warn!("Invalid pmpcfg {}", pmp_cfg_idx);
return 0;
}
if pmp_cfg_idx >= self.nb_pmp / 8 {
if pmp_cfg_idx >= 2 * self.nb_pmp / 8 {
// This PMP is not emulated
return 0;
}
Expand Down

0 comments on commit e67b5d5

Please sign in to comment.