From: Tulio A M Mendes Date: Thu, 11 Jun 2026 01:43:33 +0000 (-0300) Subject: virtio-blk: fix V2P usage for kva_alloc addresses (H6 regression) X-Git-Url: https://projects.tadryanom.me/?a=commitdiff_plain;h=6f21a0ae17048c66f1fdcf50333672afa92f7ef4;p=AdrOS.git virtio-blk: fix V2P usage for kva_alloc addresses (H6 regression) 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 --- diff --git a/src/drivers/virtio_blk.c b/src/drivers/virtio_blk.c index 145be421..52bf1aaf 100644 --- a/src/drivers/virtio_blk.c +++ b/src/drivers/virtio_blk.c @@ -201,8 +201,10 @@ int virtio_blk_init(void) { 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 */