Lab
Virtqueue visualizer Used in chapter 15 , chapter 16 .
Play the driver and the device on one split virtqueue: publish requests, ring the doorbell, walk and serve chains, reclaim them, then misbehave as the driver and watch which check refuses each hostile ring.
Runs in browser
One request through a virtqueue, and a ring the device refuses
Top, the toy: the guest writes 4096 bytes at 0x4410_0000 into its RAM, writes descriptor 0 (addr 0x4410_0000, len 4096) and puts head 0 in the available ring, then stores to the doorbell at 0x0a00_0050, the first VM exit. Our VMM reads avail.idx, the head and the descriptor, copies the 4096 bytes out of guest RAM to disk sector 8, writes used element id 0, len 0, publishes used.idx 1 and raises the interrupt line with no exit. The guest's handler reads InterruptStatus and writes InterruptACK, two more exits: 3 in all, where the PL011 path needed about 11,000. Bottom, the hostile ring: N is 8, descriptor 0 at addr 0x4000_8000, len 8, flags NEXT, next 0 points at itself; avail.idx is 1 and next_avail 0, so 1 request is pending with head 0. The walk takes hop 1 with budget 8 to 7, and so on to hop 8 with budget 1 to 0; hop 9 finds the budget exhausted, the device answers virtqueue: ChainTooLong { budget: 8 }, sets DEVICE_NEEDS_RESET and raises a configuration interrupt.
The toy: one descriptor, one doorbell, one "done"
1 guest writes 4096 bytes at 0x4410_0000
(ordinary RAM: no exit)
2 guest desc 0 = {0x4410_0000, 4096}
avail.idx 0 -> 1 (no exit)
3 guest stores to QueueNotify 0x0a00_0050
exit 1
4 VMM reads avail.idx, head 0, desc 0
5 VMM copies 4096 bytes to disk sector 8
6 VMM used.ring[0] = {id 0, len 0}
used.idx = 1
7 VMM raises the line (no exit)
8 guest InterruptStatus, InterruptACK
exits 2 and 3
3 exits for 4096 bytes.
Through the PL011: about 11,000.
Hostile: descriptor 0's next is itself
N = 8
desc 0: addr 0x4000_8000, len 8,
flags NEXT, next 0
avail.idx 1, next_avail 0: 1 pending
hop 1: desc 0 (budget 8 -> 7)
...
hop 8: desc 0 (budget 1 -> 0)
hop 9: budget exhausted
virtqueue: ChainTooLong { budget: 8 }
-> DEVICE_NEEDS_RESET and a
configuration interrupt;
the VM keeps running
This lab needs JavaScript. Everything else on this page works without it.
All labs