diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2013-05-30 02:59:32 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2015-01-21 00:58:54 -0500 |
commit | 89461c4a12faa643fd7564037440d626b777b033 (patch) | |
tree | a55669d93922f0e31d9f6ee397b6cdaef11e688e /drivers/virtio | |
parent | 1fcf0512c9c870e78e1c9898ecb9458593403466 (diff) |
virtio_pci: macros for PCI layout offsets
QEMU wants it, so why not? Trust, but verify.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/virtio')
-rw-r--r-- | drivers/virtio/virtio_pci_modern.c | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c index a3d81013e0c2..b2e707ad81cf 100644 --- a/drivers/virtio/virtio_pci_modern.c +++ b/drivers/virtio/virtio_pci_modern.c | |||
@@ -464,9 +464,67 @@ static void virtio_pci_release_dev(struct device *_d) | |||
464 | kfree(vp_dev); | 464 | kfree(vp_dev); |
465 | } | 465 | } |
466 | 466 | ||
467 | /* TODO: validate the ABI statically. */ | 467 | /* This is part of the ABI. Don't screw with it. */ |
468 | static inline void check_offsets(void) | 468 | static inline void check_offsets(void) |
469 | { | 469 | { |
470 | /* Note: disk space was harmed in compilation of this function. */ | ||
471 | BUILD_BUG_ON(VIRTIO_PCI_CAP_VNDR != | ||
472 | offsetof(struct virtio_pci_cap, cap_vndr)); | ||
473 | BUILD_BUG_ON(VIRTIO_PCI_CAP_NEXT != | ||
474 | offsetof(struct virtio_pci_cap, cap_next)); | ||
475 | BUILD_BUG_ON(VIRTIO_PCI_CAP_LEN != | ||
476 | offsetof(struct virtio_pci_cap, cap_len)); | ||
477 | BUILD_BUG_ON(VIRTIO_PCI_CAP_CFG_TYPE != | ||
478 | offsetof(struct virtio_pci_cap, cfg_type)); | ||
479 | BUILD_BUG_ON(VIRTIO_PCI_CAP_BAR != | ||
480 | offsetof(struct virtio_pci_cap, bar)); | ||
481 | BUILD_BUG_ON(VIRTIO_PCI_CAP_OFFSET != | ||
482 | offsetof(struct virtio_pci_cap, offset)); | ||
483 | BUILD_BUG_ON(VIRTIO_PCI_CAP_LENGTH != | ||
484 | offsetof(struct virtio_pci_cap, length)); | ||
485 | BUILD_BUG_ON(VIRTIO_PCI_NOTIFY_CAP_MULT != | ||
486 | offsetof(struct virtio_pci_notify_cap, | ||
487 | notify_off_multiplier)); | ||
488 | BUILD_BUG_ON(VIRTIO_PCI_COMMON_DFSELECT != | ||
489 | offsetof(struct virtio_pci_common_cfg, | ||
490 | device_feature_select)); | ||
491 | BUILD_BUG_ON(VIRTIO_PCI_COMMON_DF != | ||
492 | offsetof(struct virtio_pci_common_cfg, device_feature)); | ||
493 | BUILD_BUG_ON(VIRTIO_PCI_COMMON_GFSELECT != | ||
494 | offsetof(struct virtio_pci_common_cfg, | ||
495 | guest_feature_select)); | ||
496 | BUILD_BUG_ON(VIRTIO_PCI_COMMON_GF != | ||
497 | offsetof(struct virtio_pci_common_cfg, guest_feature)); | ||
498 | BUILD_BUG_ON(VIRTIO_PCI_COMMON_MSIX != | ||
499 | offsetof(struct virtio_pci_common_cfg, msix_config)); | ||
500 | BUILD_BUG_ON(VIRTIO_PCI_COMMON_NUMQ != | ||
501 | offsetof(struct virtio_pci_common_cfg, num_queues)); | ||
502 | BUILD_BUG_ON(VIRTIO_PCI_COMMON_STATUS != | ||
503 | offsetof(struct virtio_pci_common_cfg, device_status)); | ||
504 | BUILD_BUG_ON(VIRTIO_PCI_COMMON_CFGGENERATION != | ||
505 | offsetof(struct virtio_pci_common_cfg, config_generation)); | ||
506 | BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_SELECT != | ||
507 | offsetof(struct virtio_pci_common_cfg, queue_select)); | ||
508 | BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_SIZE != | ||
509 | offsetof(struct virtio_pci_common_cfg, queue_size)); | ||
510 | BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_MSIX != | ||
511 | offsetof(struct virtio_pci_common_cfg, queue_msix_vector)); | ||
512 | BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_ENABLE != | ||
513 | offsetof(struct virtio_pci_common_cfg, queue_enable)); | ||
514 | BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_NOFF != | ||
515 | offsetof(struct virtio_pci_common_cfg, queue_notify_off)); | ||
516 | BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_DESCLO != | ||
517 | offsetof(struct virtio_pci_common_cfg, queue_desc_lo)); | ||
518 | BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_DESCHI != | ||
519 | offsetof(struct virtio_pci_common_cfg, queue_desc_hi)); | ||
520 | BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_AVAILLO != | ||
521 | offsetof(struct virtio_pci_common_cfg, queue_avail_lo)); | ||
522 | BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_AVAILHI != | ||
523 | offsetof(struct virtio_pci_common_cfg, queue_avail_hi)); | ||
524 | BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_USEDLO != | ||
525 | offsetof(struct virtio_pci_common_cfg, queue_used_lo)); | ||
526 | BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_USEDHI != | ||
527 | offsetof(struct virtio_pci_common_cfg, queue_used_hi)); | ||
470 | } | 528 | } |
471 | 529 | ||
472 | /* the PCI probing function */ | 530 | /* the PCI probing function */ |