Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus

* git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus:
lguest: notify on empty
virtio: force callback on empty.
virtio_blk: fix endianess annotations
virtio_config: fix len calculation of config elements
virtio_net: another race with virtio_net and enable_cb
virtio: An entropy device, as suggested by hpa.
virtio_blk: allow read-only disks
lguest: fix ugly <NULL> in /proc/interrupts
virtio: set device index in common code.
virtio: virtio_pci should not set bus_id.
virtio: bus_id for devices should contain 'virtio'
Fix crash in virtio_blk during modprobe ; rmmod ; modprobe
lguest: use ioremap_cache, not ioremap

+225 -53
+10 -2
Documentation/lguest/lguest.c
··· 157 158 /* The routine to call when the Guest pings us. */ 159 void (*handle_output)(int fd, struct virtqueue *me); 160 }; 161 162 /* Remember the arguments to the program so we can "reboot" */ ··· 705 errx(1, "Looped descriptor"); 706 } while ((i = next_desc(vq, i)) != vq->vring.num); 707 708 return head; 709 } 710 ··· 723 /* Make sure buffer is written before we update index. */ 724 wmb(); 725 vq->vring.used->idx++; 726 } 727 728 /* This actually sends the interrupt for this virtqueue */ ··· 731 { 732 unsigned long buf[] = { LHREQ_IRQ, vq->config.irq }; 733 734 - /* If they don't want an interrupt, don't send one. */ 735 - if (vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT) 736 return; 737 738 /* Send the Guest an interrupt tell them we used something up. */ ··· 1113 vq->next = NULL; 1114 vq->last_avail_idx = 0; 1115 vq->dev = dev; 1116 1117 /* Initialize the configuration. */ 1118 vq->config.num = num_descs; ··· 1375 1376 /* Tell Guest what MAC address to use. */ 1377 add_feature(dev, VIRTIO_NET_F_MAC); 1378 set_config(dev, sizeof(conf), &conf); 1379 1380 /* We don't need the socket any more; setup is done. */
··· 157 158 /* The routine to call when the Guest pings us. */ 159 void (*handle_output)(int fd, struct virtqueue *me); 160 + 161 + /* Outstanding buffers */ 162 + unsigned int inflight; 163 }; 164 165 /* Remember the arguments to the program so we can "reboot" */ ··· 702 errx(1, "Looped descriptor"); 703 } while ((i = next_desc(vq, i)) != vq->vring.num); 704 705 + vq->inflight++; 706 return head; 707 } 708 ··· 719 /* Make sure buffer is written before we update index. */ 720 wmb(); 721 vq->vring.used->idx++; 722 + vq->inflight--; 723 } 724 725 /* This actually sends the interrupt for this virtqueue */ ··· 726 { 727 unsigned long buf[] = { LHREQ_IRQ, vq->config.irq }; 728 729 + /* If they don't want an interrupt, don't send one, unless empty. */ 730 + if ((vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT) 731 + && vq->inflight) 732 return; 733 734 /* Send the Guest an interrupt tell them we used something up. */ ··· 1107 vq->next = NULL; 1108 vq->last_avail_idx = 0; 1109 vq->dev = dev; 1110 + vq->inflight = 0; 1111 1112 /* Initialize the configuration. */ 1113 vq->config.num = num_descs; ··· 1368 1369 /* Tell Guest what MAC address to use. */ 1370 add_feature(dev, VIRTIO_NET_F_MAC); 1371 + add_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY); 1372 set_config(dev, sizeof(conf), &conf); 1373 1374 /* We don't need the socket any more; setup is done. */
+3 -2
arch/x86/lguest/boot.c
··· 582 int vector = FIRST_EXTERNAL_VECTOR + i; 583 if (vector != SYSCALL_VECTOR) { 584 set_intr_gate(vector, interrupt[i]); 585 - set_irq_chip_and_handler(i, &lguest_irq_controller, 586 - handle_level_irq); 587 } 588 } 589 /* This call is required to set up for 4k stacks, where we have
··· 582 int vector = FIRST_EXTERNAL_VECTOR + i; 583 if (vector != SYSCALL_VECTOR) { 584 set_intr_gate(vector, interrupt[i]); 585 + set_irq_chip_and_handler_name(i, &lguest_irq_controller, 586 + handle_level_irq, 587 + "level"); 588 } 589 } 590 /* This call is required to set up for 4k stacks, where we have
+6 -1
drivers/block/virtio_blk.c
··· 260 if (virtio_has_feature(vdev, VIRTIO_BLK_F_BARRIER)) 261 blk_queue_ordered(vblk->disk->queue, QUEUE_ORDERED_TAG, NULL); 262 263 /* Host must always specify the capacity. */ 264 vdev->config->get(vdev, offsetof(struct virtio_blk_config, capacity), 265 &cap, sizeof(cap)); ··· 315 /* Stop all the virtqueues. */ 316 vdev->config->reset(vdev); 317 318 blk_cleanup_queue(vblk->disk->queue); 319 put_disk(vblk->disk); 320 mempool_destroy(vblk->pool); ··· 330 331 static unsigned int features[] = { 332 VIRTIO_BLK_F_BARRIER, VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX, 333 - VIRTIO_BLK_F_GEOMETRY, 334 }; 335 336 static struct virtio_driver virtio_blk = {
··· 260 if (virtio_has_feature(vdev, VIRTIO_BLK_F_BARRIER)) 261 blk_queue_ordered(vblk->disk->queue, QUEUE_ORDERED_TAG, NULL); 262 263 + /* If disk is read-only in the host, the guest should obey */ 264 + if (virtio_has_feature(vdev, VIRTIO_BLK_F_RO)) 265 + set_disk_ro(vblk->disk, 1); 266 + 267 /* Host must always specify the capacity. */ 268 vdev->config->get(vdev, offsetof(struct virtio_blk_config, capacity), 269 &cap, sizeof(cap)); ··· 311 /* Stop all the virtqueues. */ 312 vdev->config->reset(vdev); 313 314 + del_gendisk(vblk->disk); 315 blk_cleanup_queue(vblk->disk->queue); 316 put_disk(vblk->disk); 317 mempool_destroy(vblk->pool); ··· 325 326 static unsigned int features[] = { 327 VIRTIO_BLK_F_BARRIER, VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX, 328 + VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_RO, 329 }; 330 331 static struct virtio_driver virtio_blk = {
+9
drivers/char/hw_random/Kconfig
··· 112 113 If unsure, say Y. 114
··· 112 113 If unsure, say Y. 114 115 + config HW_RANDOM_VIRTIO 116 + tristate "VirtIO Random Number Generator support" 117 + depends on HW_RANDOM && VIRTIO 118 + ---help--- 119 + This driver provides kernel-side support for the virtual Random Number 120 + Generator hardware. 121 + 122 + To compile this driver as a module, choose M here: the 123 + module will be called virtio-rng. If unsure, say N.
+1
drivers/char/hw_random/Makefile
··· 11 obj-$(CONFIG_HW_RANDOM_IXP4XX) += ixp4xx-rng.o 12 obj-$(CONFIG_HW_RANDOM_OMAP) += omap-rng.o 13 obj-$(CONFIG_HW_RANDOM_PASEMI) += pasemi-rng.o
··· 11 obj-$(CONFIG_HW_RANDOM_IXP4XX) += ixp4xx-rng.o 12 obj-$(CONFIG_HW_RANDOM_OMAP) += omap-rng.o 13 obj-$(CONFIG_HW_RANDOM_PASEMI) += pasemi-rng.o 14 + obj-$(CONFIG_HW_RANDOM_VIRTIO) += virtio-rng.o
+155
drivers/char/hw_random/virtio-rng.c
···
··· 1 + /* 2 + * Randomness driver for virtio 3 + * Copyright (C) 2007, 2008 Rusty Russell IBM Corporation 4 + * 5 + * This program is free software; you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License as published by 7 + * the Free Software Foundation; either version 2 of the License, or 8 + * (at your option) any later version. 9 + * 10 + * This program is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + * 15 + * You should have received a copy of the GNU General Public License 16 + * along with this program; if not, write to the Free Software 17 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 + */ 19 + #include <linux/err.h> 20 + #include <linux/hw_random.h> 21 + #include <linux/scatterlist.h> 22 + #include <linux/spinlock.h> 23 + #include <linux/virtio.h> 24 + #include <linux/virtio_rng.h> 25 + 26 + /* The host will fill any buffer we give it with sweet, sweet randomness. We 27 + * give it 64 bytes at a time, and the hwrng framework takes it 4 bytes at a 28 + * time. */ 29 + #define RANDOM_DATA_SIZE 64 30 + 31 + static struct virtqueue *vq; 32 + static u32 *random_data; 33 + static unsigned int data_left; 34 + static DECLARE_COMPLETION(have_data); 35 + 36 + static void random_recv_done(struct virtqueue *vq) 37 + { 38 + int len; 39 + 40 + /* We never get spurious callbacks. */ 41 + if (!vq->vq_ops->get_buf(vq, &len)) 42 + BUG(); 43 + 44 + data_left = len / sizeof(random_data[0]); 45 + complete(&have_data); 46 + } 47 + 48 + static void register_buffer(void) 49 + { 50 + struct scatterlist sg; 51 + 52 + sg_init_one(&sg, random_data, RANDOM_DATA_SIZE); 53 + /* There should always be room for one buffer. */ 54 + if (vq->vq_ops->add_buf(vq, &sg, 0, 1, random_data) != 0) 55 + BUG(); 56 + vq->vq_ops->kick(vq); 57 + } 58 + 59 + /* At least we don't udelay() in a loop like some other drivers. */ 60 + static int virtio_data_present(struct hwrng *rng, int wait) 61 + { 62 + if (data_left) 63 + return 1; 64 + 65 + if (!wait) 66 + return 0; 67 + 68 + wait_for_completion(&have_data); 69 + return 1; 70 + } 71 + 72 + /* virtio_data_present() must have succeeded before this is called. */ 73 + static int virtio_data_read(struct hwrng *rng, u32 *data) 74 + { 75 + BUG_ON(!data_left); 76 + 77 + *data = random_data[--data_left]; 78 + 79 + if (!data_left) { 80 + init_completion(&have_data); 81 + register_buffer(); 82 + } 83 + return sizeof(*data); 84 + } 85 + 86 + static struct hwrng virtio_hwrng = { 87 + .name = "virtio", 88 + .data_present = virtio_data_present, 89 + .data_read = virtio_data_read, 90 + }; 91 + 92 + static int virtrng_probe(struct virtio_device *vdev) 93 + { 94 + int err; 95 + 96 + /* We expect a single virtqueue. */ 97 + vq = vdev->config->find_vq(vdev, 0, random_recv_done); 98 + if (IS_ERR(vq)) 99 + return PTR_ERR(vq); 100 + 101 + err = hwrng_register(&virtio_hwrng); 102 + if (err) { 103 + vdev->config->del_vq(vq); 104 + return err; 105 + } 106 + 107 + register_buffer(); 108 + return 0; 109 + } 110 + 111 + static void virtrng_remove(struct virtio_device *vdev) 112 + { 113 + vdev->config->reset(vdev); 114 + hwrng_unregister(&virtio_hwrng); 115 + vdev->config->del_vq(vq); 116 + } 117 + 118 + static struct virtio_device_id id_table[] = { 119 + { VIRTIO_ID_RNG, VIRTIO_DEV_ANY_ID }, 120 + { 0 }, 121 + }; 122 + 123 + static struct virtio_driver virtio_rng = { 124 + .driver.name = KBUILD_MODNAME, 125 + .driver.owner = THIS_MODULE, 126 + .id_table = id_table, 127 + .probe = virtrng_probe, 128 + .remove = __devexit_p(virtrng_remove), 129 + }; 130 + 131 + static int __init init(void) 132 + { 133 + int err; 134 + 135 + random_data = kmalloc(RANDOM_DATA_SIZE, GFP_KERNEL); 136 + if (!random_data) 137 + return -ENOMEM; 138 + 139 + err = register_virtio_driver(&virtio_rng); 140 + if (err) 141 + kfree(random_data); 142 + return err; 143 + } 144 + 145 + static void __exit fini(void) 146 + { 147 + kfree(random_data); 148 + unregister_virtio_driver(&virtio_rng); 149 + } 150 + module_init(init); 151 + module_exit(fini); 152 + 153 + MODULE_DEVICE_TABLE(virtio, id_table); 154 + MODULE_DESCRIPTION("Virtio random number driver"); 155 + MODULE_LICENSE("GPL");
+10 -15
drivers/lguest/lguest_device.c
··· 20 /* The pointer to our (page) of device descriptions. */ 21 static void *lguest_devices; 22 23 - /* Unique numbering for lguest devices. */ 24 - static unsigned int dev_index; 25 - 26 /* For Guests, device memory can be used as normal memory, so we cast away the 27 * __iomem to quieten sparse. */ 28 static inline void *lguest_map(unsigned long phys_addr, unsigned long pages) 29 { 30 - return (__force void *)ioremap(phys_addr, PAGE_SIZE*pages); 31 } 32 33 static inline void lguest_unmap(void *addr) ··· 322 * As Andrew Tridgell says, "Untested code is buggy code". 323 * 324 * It's worth reading this carefully: we start with a pointer to the new device 325 - * descriptor in the "lguest_devices" page. */ 326 - static void add_lguest_device(struct lguest_device_desc *d) 327 { 328 struct lguest_device *ldev; 329 ··· 333 * it. */ 334 ldev = kzalloc(sizeof(*ldev), GFP_KERNEL); 335 if (!ldev) { 336 - printk(KERN_EMERG "Cannot allocate lguest dev %u\n", 337 - dev_index++); 338 return; 339 } 340 341 /* This devices' parent is the lguest/ dir. */ 342 ldev->vdev.dev.parent = &lguest_root; 343 /* We have a unique device index thanks to the dev_index counter. */ 344 - ldev->vdev.index = dev_index++; 345 - /* The device type comes straight from the descriptor. There's also a 346 - * device vendor field in the virtio_device struct, which we leave as 347 - * 0. */ 348 ldev->vdev.id.device = d->type; 349 /* We have a simple set of routines for querying the device's 350 * configuration information and setting its status. */ ··· 352 * virtio_device and calls device_register(). This makes the bus 353 * infrastructure look for a matching driver. */ 354 if (register_virtio_device(&ldev->vdev) != 0) { 355 - printk(KERN_ERR "Failed to register lguest device %u\n", 356 - ldev->vdev.index); 357 kfree(ldev); 358 } 359 } ··· 374 break; 375 376 printk("Device at %i has size %u\n", i, desc_size(d)); 377 - add_lguest_device(d); 378 } 379 } 380
··· 20 /* The pointer to our (page) of device descriptions. */ 21 static void *lguest_devices; 22 23 /* For Guests, device memory can be used as normal memory, so we cast away the 24 * __iomem to quieten sparse. */ 25 static inline void *lguest_map(unsigned long phys_addr, unsigned long pages) 26 { 27 + return (__force void *)ioremap_cache(phys_addr, PAGE_SIZE*pages); 28 } 29 30 static inline void lguest_unmap(void *addr) ··· 325 * As Andrew Tridgell says, "Untested code is buggy code". 326 * 327 * It's worth reading this carefully: we start with a pointer to the new device 328 + * descriptor in the "lguest_devices" page, and the offset into the device 329 + * descriptor page so we can uniquely identify it if things go badly wrong. */ 330 + static void add_lguest_device(struct lguest_device_desc *d, 331 + unsigned int offset) 332 { 333 struct lguest_device *ldev; 334 ··· 334 * it. */ 335 ldev = kzalloc(sizeof(*ldev), GFP_KERNEL); 336 if (!ldev) { 337 + printk(KERN_EMERG "Cannot allocate lguest dev %u type %u\n", 338 + offset, d->type); 339 return; 340 } 341 342 /* This devices' parent is the lguest/ dir. */ 343 ldev->vdev.dev.parent = &lguest_root; 344 /* We have a unique device index thanks to the dev_index counter. */ 345 ldev->vdev.id.device = d->type; 346 /* We have a simple set of routines for querying the device's 347 * configuration information and setting its status. */ ··· 357 * virtio_device and calls device_register(). This makes the bus 358 * infrastructure look for a matching driver. */ 359 if (register_virtio_device(&ldev->vdev) != 0) { 360 + printk(KERN_ERR "Failed to register lguest dev %u type %u\n", 361 + offset, d->type); 362 kfree(ldev); 363 } 364 } ··· 379 break; 380 381 printk("Device at %i has size %u\n", i, desc_size(d)); 382 + add_lguest_device(d, i); 383 } 384 } 385
+6 -12
drivers/s390/kvm/kvm_virtio.c
··· 31 */ 32 static void *kvm_devices; 33 34 - /* 35 - * Unique numbering for kvm devices. 36 - */ 37 - static unsigned int dev_index; 38 - 39 struct kvm_device { 40 struct virtio_device vdev; 41 struct kvm_device_desc *desc; ··· 245 * adds a new device and register it with virtio 246 * appropriate drivers are loaded by the device model 247 */ 248 - static void add_kvm_device(struct kvm_device_desc *d) 249 { 250 struct kvm_device *kdev; 251 252 kdev = kzalloc(sizeof(*kdev), GFP_KERNEL); 253 if (!kdev) { 254 - printk(KERN_EMERG "Cannot allocate kvm dev %u\n", 255 - dev_index++); 256 return; 257 } 258 259 kdev->vdev.dev.parent = &kvm_root; 260 - kdev->vdev.index = dev_index++; 261 kdev->vdev.id.device = d->type; 262 kdev->vdev.config = &kvm_vq_configspace_ops; 263 kdev->desc = d; 264 265 if (register_virtio_device(&kdev->vdev) != 0) { 266 - printk(KERN_ERR "Failed to register kvm device %u\n", 267 - kdev->vdev.index); 268 kfree(kdev); 269 } 270 } ··· 283 if (d->type == 0) 284 break; 285 286 - add_kvm_device(d); 287 } 288 } 289
··· 31 */ 32 static void *kvm_devices; 33 34 struct kvm_device { 35 struct virtio_device vdev; 36 struct kvm_device_desc *desc; ··· 250 * adds a new device and register it with virtio 251 * appropriate drivers are loaded by the device model 252 */ 253 + static void add_kvm_device(struct kvm_device_desc *d, unsigned int offset) 254 { 255 struct kvm_device *kdev; 256 257 kdev = kzalloc(sizeof(*kdev), GFP_KERNEL); 258 if (!kdev) { 259 + printk(KERN_EMERG "Cannot allocate kvm dev %u type %u\n", 260 + offset, d->type); 261 return; 262 } 263 264 kdev->vdev.dev.parent = &kvm_root; 265 kdev->vdev.id.device = d->type; 266 kdev->vdev.config = &kvm_vq_configspace_ops; 267 kdev->desc = d; 268 269 if (register_virtio_device(&kdev->vdev) != 0) { 270 + printk(KERN_ERR "Failed to register kvm device %u type %u\n", 271 + offset, d->type); 272 kfree(kdev); 273 } 274 } ··· 289 if (d->type == 0) 290 break; 291 292 + add_kvm_device(d, i); 293 } 294 } 295
+7 -1
drivers/virtio/virtio.c
··· 2 #include <linux/spinlock.h> 3 #include <linux/virtio_config.h> 4 5 static ssize_t device_show(struct device *_d, 6 struct device_attribute *attr, char *buf) 7 { ··· 169 int err; 170 171 dev->dev.bus = &virtio_bus; 172 - sprintf(dev->dev.bus_id, "%u", dev->index); 173 174 /* We always start by resetting the device, in case a previous 175 * driver messed it up. This also tests that code path a little. */
··· 2 #include <linux/spinlock.h> 3 #include <linux/virtio_config.h> 4 5 + /* Unique numbering for virtio devices. */ 6 + static unsigned int dev_index; 7 + 8 static ssize_t device_show(struct device *_d, 9 struct device_attribute *attr, char *buf) 10 { ··· 166 int err; 167 168 dev->dev.bus = &virtio_bus; 169 + 170 + /* Assign a unique device index and hence name. */ 171 + dev->index = dev_index++; 172 + sprintf(dev->dev.bus_id, "virtio%u", dev->index); 173 174 /* We always start by resetting the device, in case a previous 175 * driver messed it up. This also tests that code path a little. */
-7
drivers/virtio/virtio_pci.c
··· 78 .bus_id = "virtio-pci", 79 }; 80 81 - /* Unique numbering for devices under the kvm root */ 82 - static unsigned int dev_index; 83 - 84 /* Convert a generic virtio device to our structure */ 85 static struct virtio_pci_device *to_vp_device(struct virtio_device *vdev) 86 { ··· 321 vp_dev = kzalloc(sizeof(struct virtio_pci_device), GFP_KERNEL); 322 if (vp_dev == NULL) 323 return -ENOMEM; 324 - 325 - snprintf(vp_dev->vdev.dev.bus_id, BUS_ID_SIZE, "virtio%d", dev_index); 326 - vp_dev->vdev.index = dev_index; 327 - dev_index++; 328 329 vp_dev->vdev.dev.parent = &virtio_pci_root; 330 vp_dev->vdev.config = &virtio_pci_config_ops;
··· 78 .bus_id = "virtio-pci", 79 }; 80 81 /* Convert a generic virtio device to our structure */ 82 static struct virtio_pci_device *to_vp_device(struct virtio_device *vdev) 83 { ··· 324 vp_dev = kzalloc(sizeof(struct virtio_pci_device), GFP_KERNEL); 325 if (vp_dev == NULL) 326 return -ENOMEM; 327 328 vp_dev->vdev.dev.parent = &virtio_pci_root; 329 vp_dev->vdev.config = &virtio_pci_config_ops;
-8
drivers/virtio/virtio_ring.c
··· 227 struct vring_virtqueue *vq = to_vvq(_vq); 228 229 START_USE(vq); 230 - BUG_ON(!(vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT)); 231 232 /* We optimistically turn back on interrupts, then check if there was 233 * more to do. */ ··· 252 253 if (unlikely(vq->broken)) 254 return IRQ_HANDLED; 255 - 256 - /* Other side may have missed us turning off the interrupt, 257 - * but we should preserve disable semantic for virtio users. */ 258 - if (unlikely(vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT)) { 259 - pr_debug("virtqueue interrupt after disable for %p\n", vq); 260 - return IRQ_HANDLED; 261 - } 262 263 pr_debug("virtqueue callback for %p (%p)\n", vq, vq->vq.callback); 264 if (vq->vq.callback)
··· 227 struct vring_virtqueue *vq = to_vvq(_vq); 228 229 START_USE(vq); 230 231 /* We optimistically turn back on interrupts, then check if there was 232 * more to do. */ ··· 253 254 if (unlikely(vq->broken)) 255 return IRQ_HANDLED; 256 257 pr_debug("virtqueue callback for %p (%p)\n", vq, vq->vq.callback); 258 if (vq->vq.callback)
+5 -4
include/linux/virtio_blk.h
··· 10 #define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment size */ 11 #define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */ 12 #define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available */ 13 14 struct virtio_blk_config 15 { 16 /* The capacity (in 512-byte sectors). */ 17 - __le64 capacity; 18 /* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */ 19 - __le32 size_max; 20 /* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */ 21 - __le32 seg_max; 22 /* geometry the device (if VIRTIO_BLK_F_GEOMETRY) */ 23 struct virtio_blk_geometry { 24 - __le16 cylinders; 25 __u8 heads; 26 __u8 sectors; 27 } geometry;
··· 10 #define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment size */ 11 #define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */ 12 #define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available */ 13 + #define VIRTIO_BLK_F_RO 5 /* Disk is read-only */ 14 15 struct virtio_blk_config 16 { 17 /* The capacity (in 512-byte sectors). */ 18 + __u64 capacity; 19 /* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */ 20 + __u32 size_max; 21 /* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */ 22 + __u32 seg_max; 23 /* geometry the device (if VIRTIO_BLK_F_GEOMETRY) */ 24 struct virtio_blk_geometry { 25 + __u16 cylinders; 26 __u8 heads; 27 __u8 sectors; 28 } geometry;
+5 -1
include/linux/virtio_config.h
··· 15 /* We've given up on this device. */ 16 #define VIRTIO_CONFIG_S_FAILED 0x80 17 18 #ifdef __KERNEL__ 19 #include <linux/virtio.h> 20 ··· 103 * The return value is -ENOENT if the feature doesn't exist. Otherwise 104 * the config value is copied into whatever is pointed to by v. */ 105 #define virtio_config_val(vdev, fbit, offset, v) \ 106 - virtio_config_buf((vdev), (fbit), (offset), (v), sizeof(v)) 107 108 static inline int virtio_config_buf(struct virtio_device *vdev, 109 unsigned int fbit,
··· 15 /* We've given up on this device. */ 16 #define VIRTIO_CONFIG_S_FAILED 0x80 17 18 + /* Do we get callbacks when the ring is completely used, even if we've 19 + * suppressed them? */ 20 + #define VIRTIO_F_NOTIFY_ON_EMPTY 24 21 + 22 #ifdef __KERNEL__ 23 #include <linux/virtio.h> 24 ··· 99 * The return value is -ENOENT if the feature doesn't exist. Otherwise 100 * the config value is copied into whatever is pointed to by v. */ 101 #define virtio_config_val(vdev, fbit, offset, v) \ 102 + virtio_config_buf((vdev), (fbit), (offset), (v), sizeof(*v)) 103 104 static inline int virtio_config_buf(struct virtio_device *vdev, 105 unsigned int fbit,
+8
include/linux/virtio_rng.h
···
··· 1 + #ifndef _LINUX_VIRTIO_RNG_H 2 + #define _LINUX_VIRTIO_RNG_H 3 + #include <linux/virtio_config.h> 4 + 5 + /* The ID for virtio_rng */ 6 + #define VIRTIO_ID_RNG 4 7 + 8 + #endif /* _LINUX_VIRTIO_RNG_H */