Skip to content

Commit d28ef60

Browse files
committed
fix: clarify comments in kani module
QUEUE_END is the address of the first byte past the end of our queue indeed, but the queue doesnt start at 0 (it starts at QUEUE_BASE_ADDRESS, which is 512), and thus GUEST_MEMORY_SIZE was 512 byte too large, because it assumed QUEUE_END was also the size of the queue. Closes #4997 Reported-by: Matias Ezequiel Vara Larsen <[email protected]> Signed-off-by: Patrick Roy <[email protected]>
1 parent aeb1754 commit d28ef60

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/vmm/src/devices/virtio/queue.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -803,10 +803,11 @@ mod verification {
803803
const GUEST_MEMORY_BASE: u64 = 512;
804804

805805
// We size our guest memory to fit a properly aligned queue, plus some wiggles bytes
806-
// to make sure we not only test queues where all segments are consecutively aligned.
806+
// to make sure we not only test queues where all segments are consecutively aligned (at least
807+
// for those proofs that use a completely arbitrary queue structure).
807808
// We need to give at least 16 bytes of buffer space for the descriptor table to be
808809
// able to change its address, as it is 16-byte aligned.
809-
const GUEST_MEMORY_SIZE: usize = QUEUE_END as usize + 30;
810+
const GUEST_MEMORY_SIZE: usize = (QUEUE_END - QUEUE_BASE_ADDRESS) as usize + 30;
810811

811812
fn guest_memory(memory: *mut u8) -> ProofGuestMemory {
812813
// Ideally, we'd want to do
@@ -876,8 +877,7 @@ mod verification {
876877
const USED_RING_BASE_ADDRESS: u64 =
877878
AVAIL_RING_BASE_ADDRESS + 6 + 2 * FIRECRACKER_MAX_QUEUE_SIZE as u64 + 2;
878879

879-
/// The address of the first byte after the queue. Since our queue starts at guest physical
880-
/// address 0, this is also the size of the memory area occupied by the queue.
880+
/// The address of the first byte after the queue (which starts at QUEUE_BASE_ADDRESS).
881881
/// Note that the used ring structure has size 6 + 8 * FIRECRACKER_MAX_QUEUE_SIZE
882882
const QUEUE_END: u64 = USED_RING_BASE_ADDRESS + 6 + 8 * FIRECRACKER_MAX_QUEUE_SIZE as u64;
883883

0 commit comments

Comments
 (0)