]> git.karo-electronics.de Git - karo-tx-linux.git/commit
kvm, pci: fill up virtio device configuration header
authorAsias He <asias.hejun@gmail.com>
Sat, 7 Aug 2010 06:47:25 +0000 (14:47 +0800)
committerPekka Enberg <penberg@cs.helsinki.fi>
Sun, 8 Aug 2010 15:02:51 +0000 (18:02 +0300)
commit40fb6ef556df1efb72f3f53809cf8f921faadbc3
treeab4408a95f59eb751d131d2624615867e4ac7a7d
parentb491b96f9acd7a41d647927163978f22ba027938
kvm, pci: fill up virtio device configuration header

IO     base address register must be aligned at  4 bytes.
Memory base address register must be aligned at 16 bytes.
We should not shift io port or memory address in base address register.
See PCI_System_Architecture_FourthEdition Page 427.

We need more io space for virtio device, qemu-kvm uses 64 byes,
so io space reserved for bios is not enough.

See drivers/virtio/virtio_pci.c
static struct virtio_config_ops virtio_pci_config_ops = {
        .get            = vp_get,
        .set            = vp_set,
        .get_status     = vp_get_status,
        .set_status     = vp_set_status,
        .reset          = vp_reset,
        .find_vqs       = vp_find_vqs,
        .del_vqs        = vp_del_vqs,
        .get_features   = vp_get_features,
        .finalize_features = vp_finalize_features,
};

---------------------------------------------------------------------
guest_using_virtio_blk $ lspci -xxx
00:04.0 SCSI storage controller: Qumranet, Inc. Virtio block device
00: f4 1a 01 10 03 00 10 00 00 00 00 01 00 00 00 00
10: 01 c2 00 00 00 00 03 f2 00 00 00 00 00 00 00 00
20: 00 00 00 00 00 00 00 00 00 00 00 00 f4 1a 02 00
30: 00 00 00 00 40 00 00 00 00 00 00 00 0b 01 00 00
40: 11 00 01 80 01 00 00 00 01 08 00 00 00 00 00 00
50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
---------------------------------------------------------------------
guest_using_virtio_blk $  cat /proc/iomem
f2030000-f2030fff : 0000:00:04.0
  f2030000-f2030fff : virtio-pci
---------------------------------------------------------------------
guest_using_virtio_blk $ cat /proc/ioports
c200-c23f : 0000:00:04.0
  c200-c23f : virtio-pci
---------------------------------------------------------------------

$ ./kvm bzImage #virtio enabled guest kernel
Logs:
[    0.548000] virtio-pci 0000:00:01.0: enabling device (0000 -> 0001)
[    0.549000] asias:drivers/virtio/virtio.c:virtio_dev_probe
[    0.549000] asias:drivers/virtio/virtio_pci.c:vp_get_features
  Info: virtio_io
[    0.549000] asias:drivers/block/virtio_blk.c:virtblk_probe
[    0.549000] virtio_blk: probe of virtio0 failed with error -16

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
tools/kvm/include/kvm/ioport.h
tools/kvm/pci.c