Skip to content

Commit 891af0d

Browse files
committed
WIP: kani proofs
Signed-off-by: Babis Chalios <[email protected]>
1 parent da4106d commit 891af0d

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/vmm/src/arch/aarch64/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub fn arch_memory_regions(offset: usize, size: usize) -> Vec<(GuestAddress, usi
8181
let mut regions = vec![];
8282
if let Some((offset, remaining)) = arch_memory_regions_with_gap(
8383
&mut regions,
84-
usize::try_from(layout::DRAM_MEM_START).unwrap() + offset,
84+
u64_to_usize(layout::DRAM_MEM_START) + offset,
8585
dram_size,
8686
u64_to_usize(layout::MMIO64_MEM_START),
8787
u64_to_usize(layout::MMIO64_MEM_SIZE),
@@ -222,14 +222,14 @@ mod verification {
222222
#[kani::proof]
223223
#[kani::unwind(3)]
224224
fn verify_arch_memory_regions() {
225-
let offset: u64 = kani::any::<u64>();
226-
let len: u64 = kani::any::<u64>();
225+
let offset: u64 = kani::any::<usize>();
226+
let len: u64 = kani::any::<usize>();
227227

228228
kani::assume(len > 0);
229229
kani::assume(offset.checked_add(len).is_some());
230-
kani::assume(offset < DRAM_MEM_MAX_SIZE as u64);
230+
kani::assume(offset < DRAM_MEM_MAX_SIZE);
231231

232-
let regions = arch_memory_regions(offset as usize, len as usize);
232+
let regions = arch_memory_regions(offset, len);
233233

234234
for region in &regions {
235235
println!(
@@ -248,10 +248,10 @@ mod verification {
248248
let actual_len = regions.iter().map(|&(_, len)| len).sum::<usize>();
249249
assert!(actual_len <= DRAM_MEM_MAX_SIZE);
250250
// The total length is smaller or equal to the length we asked
251-
assert!((actual_len as u64) <= len);
251+
assert!(actual_len <= len);
252252
// If it's smaller, it's because we asked more than the the maximum possible.
253-
if (actual_len as u64) < len {
254-
assert!(offset + len >= DRAM_MEM_MAX_SIZE as u64);
253+
if (actual_len) < len {
254+
assert!(offset + len >= DRAM_MEM_MAX_SIZE);
255255
}
256256

257257
// No region overlaps the 64-bit MMIO gap

src/vmm/src/arch/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,7 @@ fn arch_memory_regions_with_gap(
144144
}
145145
// case1: region starts before the gap and goes past it
146146
Some(remaining) if offset < gap_start => {
147-
regions.push((
148-
GuestAddress(offset as u64),
149-
u64_to_usize(gap_start as u64) - offset,
150-
));
147+
regions.push((GuestAddress(offset as u64), gap_start - offset));
151148
Some((first_addr_past_gap, remaining))
152149
}
153150
// case2: region starts past the gap

0 commit comments

Comments
 (0)