Bug: virtio_blk_init used V2P() macro to convert vring virtual address
to physical address. After H6, vring_va comes from kva_alloc_pages()
which may not be in the linear mapping region. V2P assumes linear
mapping (VA = PA + 0xC0000000), which is fragile.
Fix: Replace V2P(vring_va) with vmm_virt_to_phys(vring_va) to use
the proper VMM translation function that works for any mapped virtual
address.
This fixes the regression introduced by H6 where virtio-blk relied on
coincidental overlap between kva_alloc range (0xC0500000..0xC0800000)
and the initial 16MB linear mapping (0xC0000000..0xC0100000).
Test: make test-battery PASS (157/157), make analyzer PASS
vblk_used = (struct vring_used*)(vring_va + used_off);
vblk_last_used_idx = 0;
- /* Tell device where the vring lives (page-aligned physical address) */
- uint32_t vring_phys = (uint32_t)V2P(vring_va);
+ /* Tell device where the vring lives (page-aligned physical address)
+ * Use vmm_virt_to_phys instead of V2P because vring_va comes from
+ * kva_alloc_pages() and may not be in the linear mapping region. */
+ uint32_t vring_phys = (uint32_t)vmm_virt_to_phys(vring_va);
outl(vblk_iobase + VIRTIO_PCI_QUEUE_PFN, vring_phys / 4096U);
/* Mark driver ready */