This also requires to tune up mptable code. Note the srcbusirq need to follow specification convention, so we merge device number and pin into one field inside mptable_set_default_int_src helper. Signed-off-by: Cyrill Gorcunov <gorcunov@xxxxxxxxx> --- tools/kvm/include/kvm/virtio-pci-dev.h | 16 +++++-- tools/kvm/mptable.c | 67 ++++++++++++++++++++++++--------- 2 files changed, 61 insertions(+), 22 deletions(-) Index: linux-2.6.git/tools/kvm/include/kvm/virtio-pci-dev.h ===================================================================== --- linux-2.6.git.orig/tools/kvm/include/kvm/virtio-pci-dev.h +++ linux-2.6.git/tools/kvm/include/kvm/virtio-pci-dev.h @@ -30,11 +30,19 @@ enum { VIRTIO_RNG_PIN = 4, }; +/* + * The IRQ numbers should confirm Linux IRQ numbering + * scheme model, which supposes devices to start IRQs + * from 32 ... 127, but 0x30-0x3f are used for ISA + * interrupts so we choose 0x40 as the origin. + */ +#define VIRTIO_PCI_DEV_FIRST_IRQ 0x40 + enum { - VIRTIO_RNG_IRQ = 11, - VIRTIO_CONSOLE_IRQ = 13, - VIRTIO_NET_IRQ = 14, - VIRTIO_BLK_IRQ = 15, + VIRTIO_RNG_IRQ = VIRTIO_PCI_DEV_FIRST_IRQ + 0, + VIRTIO_CONSOLE_IRQ = VIRTIO_PCI_DEV_FIRST_IRQ + 1, + VIRTIO_NET_IRQ = VIRTIO_PCI_DEV_FIRST_IRQ + 2, + VIRTIO_BLK_IRQ = VIRTIO_PCI_DEV_FIRST_IRQ + 3, }; #endif /* VIRTIO_PCI_DEV_H_ */ Index: linux-2.6.git/tools/kvm/mptable.c ===================================================================== --- linux-2.6.git.orig/tools/kvm/mptable.c +++ linux-2.6.git/tools/kvm/mptable.c @@ -3,6 +3,7 @@ #include "kvm/apic.h" #include "kvm/mptable.h" #include "kvm/util.h" +#include "kvm/virtio-pci-dev.h" #include <linux/kernel.h> #include <string.h> @@ -60,16 +61,17 @@ static unsigned int gen_cpu_flag(unsigne */ #define MPTABLE_MAX_CPUS 255 -static void mptable_add_irq_src(struct mpc_intsrc *mpc_intsrc, - u16 srcbusid, u16 srcbusirq, - u16 dstapic, u16 dstirq) +static void +mptable_set_default_int_src(struct mpc_intsrc *dst, + u8 dev, u8 pin, u16 srcbusid, + u16 dstapic, u16 dstirq) { - *mpc_intsrc = (struct mpc_intsrc) { + *dst = (struct mpc_intsrc) { .type = MP_INTSRC, .irqtype = mp_INT, .irqflag = MP_IRQDIR_DEFAULT, .srcbus = srcbusid, - .srcbusirq = srcbusirq, + .srcbusirq = (dev << 2) | (pin - 1), .dstapic = dstapic, .dstirq = dstirq }; @@ -186,28 +188,57 @@ void mptable_setup(struct kvm *kvm, unsi * * Also note we use PCI irqs here, no for ISA bus yet. */ - mpc_intsrc = last_addr; - /* src irq = virtio console irq pin, dst irq = virtio console irq */ - mptable_add_irq_src(mpc_intsrc, pcibusid, 2, ioapicid, 13); - last_addr = (void *)&mpc_intsrc[1]; + /* + * Virtio console. + */ + mpc_intsrc = last_addr; + mptable_set_default_int_src(mpc_intsrc, + PCI_VIRTIO_CONSOLE_DEVNUM, + VIRTIO_CONSOLE_PIN, + pcibusid, ioapicid, + VIRTIO_CONSOLE_IRQ); + last_addr = (void *)&mpc_intsrc[1]; nentries++; - /* Currently we define 4 possible virtio-blk devices */ + /* + * Virtio block devices. + * + * Currently we define 4 possible virtio-blk devices. + */ for (i = 0; i < 4; i++) { - mpc_intsrc = last_addr; - - /* src irq = virtio blk irq pin, dst irq = virtio blk irq */ - mptable_add_irq_src(mpc_intsrc, pcibusid, 1, ioapicid, 9 + i); - last_addr = (void *)&mpc_intsrc[1]; + mpc_intsrc = last_addr; + mptable_set_default_int_src(mpc_intsrc, + PCI_VIRTIO_BLK_DEVNUM, + VIRTIO_BLK_PIN, + pcibusid, ioapicid, + VIRTIO_BLK_IRQ + i); + last_addr = (void *)&mpc_intsrc[1]; nentries++; } + /* + * Virtio net device. + */ mpc_intsrc = last_addr; + mptable_set_default_int_src(mpc_intsrc, + PCI_VIRTIO_NET_DEVNUM, + VIRTIO_NET_PIN, + pcibusid, ioapicid, + VIRTIO_NET_IRQ); + last_addr = (void *)&mpc_intsrc[1]; + nentries++; - /* src irq = virtio net irq pin, dst irq = virtio net irq */ - mptable_add_irq_src(mpc_intsrc, pcibusid, 3, ioapicid, 14); - last_addr = (void *)&mpc_intsrc[1]; + /* + * Virtio random number generator. + */ + mpc_intsrc = last_addr; + mptable_set_default_int_src(mpc_intsrc, + PCI_VIRTIO_RNG_DEVNUM, + VIRTIO_RNG_PIN, + pcibusid, ioapicid, + VIRTIO_RNG_IRQ); + last_addr = (void *)&mpc_intsrc[1]; nentries++; /* -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html