Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

virtio: Don't use PAGE_SIZE for vring alignment in virtio_pci.

That doesn't work for non-4k guests which are now appearing.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

+6 -2
+2 -2
drivers/virtio/virtio_pci.c
··· 237 237 info->queue_index = index; 238 238 info->num = num; 239 239 240 - size = PAGE_ALIGN(vring_size(num, PAGE_SIZE)); 240 + size = PAGE_ALIGN(vring_size(num, VIRTIO_PCI_VRING_ALIGN)); 241 241 info->queue = alloc_pages_exact(size, GFP_KERNEL|__GFP_ZERO); 242 242 if (info->queue == NULL) { 243 243 err = -ENOMEM; ··· 290 290 iowrite16(info->queue_index, vp_dev->ioaddr + VIRTIO_PCI_QUEUE_SEL); 291 291 iowrite32(0, vp_dev->ioaddr + VIRTIO_PCI_QUEUE_PFN); 292 292 293 - size = PAGE_ALIGN(vring_size(info->num, PAGE_SIZE)); 293 + size = PAGE_ALIGN(vring_size(info->num, VIRTIO_PCI_VRING_ALIGN)); 294 294 free_pages_exact(info->queue, size); 295 295 kfree(info); 296 296 }
+4
include/linux/virtio_pci.h
··· 57 57 /* How many bits to shift physical queue address written to QUEUE_PFN. 58 58 * 12 is historical, and due to x86 page size. */ 59 59 #define VIRTIO_PCI_QUEUE_ADDR_SHIFT 12 60 + 61 + /* The alignment to use between consumer and producer parts of vring. 62 + * x86 pagesize again. */ 63 + #define VIRTIO_PCI_VRING_ALIGN 4096 60 64 #endif