[SeaBIOS] [PATCH] fix two issues with virtio-blk

Gleb Natapov gleb at redhat.com
Tue May 11 14:21:09 CEST 2010


1. Check if blk_size is valid in virtio_blk config.
2. Disable interrupt otherwise interrupt may stuck
   with some guests.

Signed-off-by: Gleb Natapov <gleb at redhat.com>
diff --git a/src/virtio-blk.c b/src/virtio-blk.c
index 6c3f8a5..96334b1 100644
--- a/src/virtio-blk.c
+++ b/src/virtio-blk.c
@@ -138,7 +138,9 @@ virtio_blk_setup(void)
         struct virtio_blk_config cfg;
         vp_get(ioaddr, 0, &cfg, sizeof(cfg));
 
-        vdrive_g->drive.blksize = cfg.blk_size;
+        u32 f = vp_get_features(ioaddr);
+        vdrive_g->drive.blksize = (f & (1 << VIRTIO_BLK_F_BLK_SIZE)) ?
+            cfg.blk_size : DISK_SECTOR_SIZE;
         vdrive_g->drive.sectors = cfg.capacity;
         dprintf(3, "virtio-blk %x:%x blksize=%d sectors=%u\n",
                 pci_bdf_to_bus (bdf), pci_bdf_to_dev(bdf),
diff --git a/src/virtio-blk.h b/src/virtio-blk.h
index 8095d5b..7243704 100644
--- a/src/virtio-blk.h
+++ b/src/virtio-blk.h
@@ -16,6 +16,8 @@ struct virtio_blk_config
     u32 opt_io_size;
 } __attribute__((packed));
 
+#define VIRTIO_BLK_F_BLK_SIZE 6
+
 /* These two define direction. */
 #define VIRTIO_BLK_T_IN		0
 #define VIRTIO_BLK_T_OUT	1
diff --git a/src/virtio-ring.h b/src/virtio-ring.h
index 95ae85b..f2f2460 100644
--- a/src/virtio-ring.h
+++ b/src/virtio-ring.h
@@ -105,6 +105,8 @@ static inline void vring_init(struct vring *vr,
    vr->desc = phys_to_virt(pa);
 
    vr->avail = (struct vring_avail *)&vr->desc[num];
+   /* disable interrupts */
+   vr->avail->flags |= VRING_AVAIL_F_NO_INTERRUPT;
 
    /* physical address of used must be page aligned */
 
--
			Gleb.



More information about the SeaBIOS mailing list