MSI / MSIX injection for Xen HVM
PATCH 1/1 MSI / MSIX injection for Xen HVM
Hi all
This patch adds MSI / MSIX injection for Xen HVM guest. This is not new, six months ago we had a discussion in
http://marc.info/?l=qemu-devel&m=130639451725966&w=2
Wei.
-------8<-----
MSI / MSIX injection for Xen.
This is supposed to be used in conjunction with Xen's hypercall interface for emualted MSI / MSIX injection.
--- hw/msi.c | 7 ++++++- hw/msix.c | 8 +++++++- hw/xen.h | 1 + xen-all.c | 5 +++++ xen-stub.c | 4 ++++ 5 files changed, 23 insertions(+), 2 deletions(-)
hw/msi.c +6 -1
@@ -20,6 +20,7 @@#include "msi.h" #include "range.h" +#include "xen.h" /* Eventually those constants should go to Linux pci_regs.h */ #define PCI_MSI_PENDING_32 0x10
@@ -257,7 +258,11 @@ void msi_notify(PCIDevice *dev, unsigned int vector)"notify vector 0x%x" " address: 0x%" PRIx64" data: 0x%" PRIx32"\n" , vector, address, data); -stl_le_phys (address, data); +if (xen_enabled ()) { +xen_hvm_inject_msi (address, data); + }else { +stl_le_phys (address, data); + } }/* call this function after updating configs by pci_default_write_config(). */
hw/msix.c +7 -1
@@ -19,6 +19,7 @@#include "msix.h" #include "pci.h" #include "range.h" +#include "xen.h" #define MSIX_CAP_LENGTH 12
@@ -365,7 +366,12 @@ void msix_notify(PCIDevice *dev, unsigned vector) address =pci_get_quad (table_entry +PCI_MSIX_ENTRY_LOWER_ADDR ); data =pci_get_long (table_entry +PCI_MSIX_ENTRY_DATA ); -stl_le_phys (address, data); + +if (xen_enabled ()) { +xen_hvm_inject_msi (address, data); + }else { +stl_le_phys (address, data); + } }void msix_reset (PCIDevice *dev)
hw/xen.h +1 -0
@@ -34,6 +34,7 @@ static inline int xen_enabled(void)int xen_pci_slot_get_pirq (PCIDevice *pci_dev,int irq_num);void xen_piix3_set_irq (void *opaque,int irq_num,int level);void xen_piix_pci_write_config_client (uint32_t address,uint32_t val,int len); +void xen_hvm_inject_msi (uint64_t addr,uint32_t data);void xen_cmos_set_s3_resume (void *opaque,int irq,int level);qemu_irq *xen_interrupt_controller_init (void );
xen-all.c +5 -0
@@ -122,6 +122,11 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len) } } +void xen_hvm_inject_msi (uint64_t addr,uint32_t data) +{ +xc_hvm_inject_msi (xen_xc, xen_domid, addr, data); +} +static void xen_suspend_notifier (Notifier *notifier,void *data) {xc_set_hvm_param (xen_xc, xen_domid,HVM_PARAM_ACPI_S_STATE ,3 );
xen-stub.c +4 -0
@@ -29,6 +29,10 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len) { } +void xen_hvm_inject_msi (uint64_t addr,uint32_t data) +{ +} +void xen_cmos_set_s3_resume (void *opaque,int irq,int level) { }
Signature · 1 line
1.7.2.5
Quoted 5 lines · Wei Liu
Hi all
This patch adds MSI / MSIX injection for Xen HVM guest. This is not new, six months ago we had a discussion in
http://marc.info/?l=qemu-devel&m=130639451725966&w=2
There are some coding style issues, please use checkpatch.pl.
Back then I voted against "if (xen_enabled())" as I was planning for a msi injection hook that also Xen could use. That may change again, the final MSI layer design is not settled yet. Therefore, no concerns from that POV, this work takes longer. We can refactor the Xen hooks during that run again.
However, you know that you miss those (uncommon) messages that are injected via DMA? They end up directly in apic_deliver_msi (where KVM will once pick them up as well).
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 9 lines · Jan Kiszka
Quoted 5 lines · Wei Liu
Hi all
This patch adds MSI / MSIX injection for Xen HVM guest. This is not new, six months ago we had a discussion in
http://marc.info/?l=qemu-devel&m=130639451725966&w=2There are some coding style issues, please use checkpatch.pl.
Ah, looks like my Emacs messed it up...
Quoted 6 lines
Back then I voted against "if (
xen_enabled())" as I was planning for a msi injection hook that also Xen could use. That may change again, the final MSI layer design is not settled yet. Therefore, no concerns from that POV, this work takes longer. We can refactor the Xen hooks during that run again.
Right, Xen hook is relatively simple.
Quoted 4 lines
However, you know that you miss those (uncommon) messages that are injected via DMA? They end up directly in
apic_deliver_msi(where KVM will once pick them up as well).
Thanks for pointing this out. However I cannot find apic_deliver_msi in qemu-kvm or upstream qemu tree. I can only find apic_send_msi and apic_deliver_irq, none of which seems to be KVM-specific. Can you please give me some pointer on this?
Wei.
Quoted 9 lines · Wei Liu
Quoted 4 lines
However, you know that you miss those (uncommon) messages that are injected via DMA? They end up directly in
apic_deliver_msi(where KVM will once pick them up as well).Thanks for pointing this out. However I cannot find
apic_deliver_msiin qemu-kvm or upstream qemu tree. I can only findapic_send_msiandapic_deliver_irq, none of which seems to be KVM-specific. Can you please give me some pointer on this?
Yes, apic_send_msi. I was accidentally looking at my msi refactoring tree.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 6 lines · Jan Kiszka
Quoted 5 lines · Wei Liu
Quoted 4 lines
However, you know that you miss those (uncommon) messages that are injected via DMA? They end up directly in
apic_deliver_msi(where KVM will once pick them up as well).
Quoted 9 lines
Quoted 4 lines
Thanks for pointing this out. However I cannot find
apic_deliver_msiin qemu-kvm or upstream qemu tree. I can only findapic_send_msiandapic_deliver_irq, none of which seems to be KVM-specific. Can you please give me some pointer on this?Yes,
apic_send_msi. I was accidentally looking at my msi refactoring tree.Jan
New version of this patch.
------8<------
Quoted 1 line
From
d20edc78c71827da9f8be3308c0d473fec03b705Mon Sep 17 00:00:00 2001
From: Wei Liu <[email protected]>
Date: Wed, 29 Feb 2012 16:46:41 +0000
Subject: [PATCH] MSI / MSIX injection for Xen.
This is supposed to be used in conjunction with Xen's hypercall interface for emualted MSI / MSIX injection.
--- hw/apic.c | 10 ++++++++-- hw/msi.c | 7 ++++++- hw/msix.c | 8 +++++++- hw/xen.h | 1 + xen-all.c | 5 +++++ xen-stub.c | 4 ++++ 6 files changed, 31 insertions(+), 4 deletions(-)
hw/apic.c +8 -2
@@ -22,6 +22,7 @@#include "host-utils.h" #include "trace.h" #include "pc.h" +#include "xen.h" #define MAX_APIC_WORDS 8
@@ -641,8 +642,13 @@ static void apic_send_msi(target_phys_addr_t addr, uint32_t data)uint8_t dest_mode = (addr >>MSI_ADDR_DEST_MODE_SHIFT ) &0x1 ;uint8_t trigger_mode = (data >>MSI_DATA_TRIGGER_SHIFT ) &0x1 ;uint8_t delivery = (data >>MSI_DATA_DELIVERY_MODE_SHIFT ) &0x7 ; -/* XXX: Ignore redirection hint. */ -apic_deliver_irq (dest, dest_mode, delivery, vector, trigger_mode); + +if (xen_enabled ()) { +xen_hvm_inject_msi (addr, data); + }else { +/* XXX: Ignore redirection hint. */ +apic_deliver_irq (dest, dest_mode, delivery, vector, trigger_mode); + } }static void apic_mem_writel (void *opaque,target_phys_addr_t addr,uint32_t val)
hw/msi.c +6 -1
@@ -20,6 +20,7 @@#include "msi.h" #include "range.h" +#include "xen.h" /* Eventually those constants should go to Linux pci_regs.h */ #define PCI_MSI_PENDING_32 0x10
@@ -257,7 +258,11 @@ void msi_notify(PCIDevice *dev, unsigned int vector)"notify vector 0x%x" " address: 0x%" PRIx64" data: 0x%" PRIx32"\n" , vector, address, data); -stl_le_phys (address, data); +if (xen_enabled ()) { +xen_hvm_inject_msi (address, data); + }else { +stl_le_phys (address, data); + } }/* call this function after updating configs by pci_default_write_config(). */
hw/msix.c +7 -1
@@ -19,6 +19,7 @@#include "msix.h" #include "pci.h" #include "range.h" +#include "xen.h" #define MSIX_CAP_LENGTH 12
@@ -365,7 +366,12 @@ void msix_notify(PCIDevice *dev, unsigned vector) address =pci_get_quad (table_entry +PCI_MSIX_ENTRY_LOWER_ADDR ); data =pci_get_long (table_entry +PCI_MSIX_ENTRY_DATA ); -stl_le_phys (address, data); + +if (xen_enabled ()) { +xen_hvm_inject_msi (address, data); + }else { +stl_le_phys (address, data); + } }void msix_reset (PCIDevice *dev)
hw/xen.h +1 -0
@@ -34,6 +34,7 @@ static inline int xen_enabled(void)int xen_pci_slot_get_pirq (PCIDevice *pci_dev,int irq_num);void xen_piix3_set_irq (void *opaque,int irq_num,int level);void xen_piix_pci_write_config_client (uint32_t address,uint32_t val,int len); +void xen_hvm_inject_msi (uint64_t addr,uint32_t data);void xen_cmos_set_s3_resume (void *opaque,int irq,int level);qemu_irq *xen_interrupt_controller_init (void );
xen-all.c +5 -0
@@ -122,6 +122,11 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len) } } +void xen_hvm_inject_msi (uint64_t addr,uint32_t data) +{ +xc_hvm_inject_msi (xen_xc, xen_domid, addr, data); +} +static void xen_suspend_notifier (Notifier *notifier,void *data) {xc_set_hvm_param (xen_xc, xen_domid,HVM_PARAM_ACPI_S_STATE ,3 );
xen-stub.c +4 -0
@@ -29,6 +29,10 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len) { } +void xen_hvm_inject_msi (uint64_t addr,uint32_t data) +{ +} +void xen_cmos_set_s3_resume (void *opaque,int irq,int level) { }
Signature · 1 line
1.7.2.5
Il 01/03/2012 12:51, Wei Liu ha scritto:
Quoted 150 lines · Jan Kiszka
Quoted 6 lines · Wei Liu
Quoted 5 lines
Quoted 4 lines
However, you know that you miss those (uncommon) messages that are injected via DMA? They end up directly in
apic_deliver_msi(where KVM will once pick them up as well).Quoted 9 lines
Quoted 4 lines
Thanks for pointing this out. However I cannot find
apic_deliver_msiin qemu-kvm or upstream qemu tree. I can only findapic_send_msiandapic_deliver_irq, none of which seems to be KVM-specific. Can you please give me some pointer on this?Yes,
apic_send_msi. I was accidentally looking at my msi refactoring tree.Jan
New version of this patch.
------8<------
Fromd20edc78c71827da9f8be3308c0d473fec03b705Mon Sep 17 00:00:00 2001
From: Wei Liu <[email protected]>
Date: Wed, 29 Feb 2012 16:46:41 +0000
Subject: [PATCH] MSI / MSIX injection for Xen.This is supposed to be used in conjunction with Xen's hypercall interface for emualted MSI / MSIX injection.
Signed-off-by Wei Liu <[email protected]>--- hw/apic.c | 10 ++++++++-- hw/msi.c | 7 ++++++- hw/msix.c | 8 +++++++- hw/xen.h | 1 + xen-all.c | 5 +++++ xen-stub.c | 4 ++++ 6 files changed, 31 insertions(+), 4 deletions(-)hw/apic.c +8
-2@@ -22,6 +22,7 @@#include "host-utils.h" #include "trace.h" #include "pc.h" +#include "xen.h" #define MAX_APIC_WORDS 8@@ -641,8 +642,13 @@ static void apic_send_msi(target_phys_addr_t addr, uint32_t data)uint8_t dest_mode = (addr >>MSI_ADDR_DEST_MODE_SHIFT ) &0x1 ;uint8_t trigger_mode = (data >>MSI_DATA_TRIGGER_SHIFT ) &0x1 ;uint8_t delivery = (data >>MSI_DATA_DELIVERY_MODE_SHIFT ) &0x7 ; -/* XXX: Ignore redirection hint. */ -apic_deliver_irq (dest, dest_mode, delivery, vector, trigger_mode); + +if (xen_enabled ()) { +xen_hvm_inject_msi (addr, data); + }else { +/* XXX: Ignore redirection hint. */ +apic_deliver_irq (dest, dest_mode, delivery, vector, trigger_mode); + } }static void apic_mem_writel (void *opaque,target_phys_addr_t addr,uint32_t val)hw/msi.c +6
-1@@ -20,6 +20,7 @@#include "msi.h" #include "range.h" +#include "xen.h" /* Eventually those constants should go to Linux pci_regs.h */ #define PCI_MSI_PENDING_32 0x10@@ -257,7 +258,11 @@ void msi_notify(PCIDevice *dev, unsigned int vector)"notify vector 0x%x" " address: 0x%" PRIx64" data: 0x%" PRIx32"\n" , vector, address, data); -stl_le_phys (address, data); +if (xen_enabled ()) { +xen_hvm_inject_msi (address, data); + }else { +stl_le_phys (address, data); + } }/* call this function after updating configs by pci_default_write_config(). */ hw/msix.c +7
-1@@ -19,6 +19,7 @@#include "msix.h" #include "pci.h" #include "range.h" +#include "xen.h" #define MSIX_CAP_LENGTH 12@@ -365,7 +366,12 @@ void msix_notify(PCIDevice *dev, unsigned vector) address =pci_get_quad (table_entry +PCI_MSIX_ENTRY_LOWER_ADDR ); data =pci_get_long (table_entry +PCI_MSIX_ENTRY_DATA ); -stl_le_phys (address, data); + +if (xen_enabled ()) { +xen_hvm_inject_msi (address, data); + }else { +stl_le_phys (address, data); + } }void msix_reset (PCIDevice *dev)hw/xen.h +1
-0@@ -34,6 +34,7 @@ static inline int xen_enabled(void)int xen_pci_slot_get_pirq (PCIDevice *pci_dev,int irq_num);void xen_piix3_set_irq (void *opaque,int irq_num,int level);void xen_piix_pci_write_config_client (uint32_t address,uint32_t val,int len); +void xen_hvm_inject_msi (uint64_t addr,uint32_t data);void xen_cmos_set_s3_resume (void *opaque,int irq,int level);qemu_irq *xen_interrupt_controller_init (void );xen-all.c +5
-0@@ -122,6 +122,11 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len) } } +void xen_hvm_inject_msi (uint64_t addr,uint32_t data) +{ +xc_hvm_inject_msi (xen_xc, xen_domid, addr, data); +} +static void xen_suspend_notifier (Notifier *notifier,void *data) {xc_set_hvm_param (xen_xc, xen_domid,HVM_PARAM_ACPI_S_STATE ,3 );xen-stub.c +0
-0
xen-stub.c void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len) · line 38
Quoted 10 lines
xen-stub.c +4
-0@@ -29,6 +29,10 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len) { } +void xen_hvm_inject_msi (uint64_t addr,uint32_t data) +{ +} +void xen_cmos_set_s3_resume (void *opaque,int irq,int level) { }
This is not a NACK, but I can't help asking. Perhaps the fake Xen interrupt controller is a bit too simplistic? You can add a memory region corresponding to the APICs and trap writes in that region. Writes coming from QEMU are MSIs and can be injected to the hypervisor, writes coming from the VM will be trapped by Xen before going out to QEMU.
Paolo
Quoted 154 lines · Paolo Bonzini
Il 01/03/2012 12:51, Wei Liu ha scritto:
Quoted 153 lines · Jan Kiszka
Quoted 6 lines · Wei Liu
Quoted 5 lines
Quoted 4 lines
However, you know that you miss those (uncommon) messages that are injected via DMA? They end up directly in
apic_deliver_msi(where KVM will once pick them up as well).Quoted 9 lines
Quoted 4 lines
Thanks for pointing this out. However I cannot find
apic_deliver_msiin qemu-kvm or upstream qemu tree. I can only findapic_send_msiandapic_deliver_irq, none of which seems to be KVM-specific. Can you please give me some pointer on this?Yes,
apic_send_msi. I was accidentally looking at my msi refactoring tree.Jan
New version of this patch.
------8<------
Fromd20edc78c71827da9f8be3308c0d473fec03b705Mon Sep 17 00:00:00 2001
From: Wei Liu <[email protected]>
Date: Wed, 29 Feb 2012 16:46:41 +0000
Subject: [PATCH] MSI / MSIX injection for Xen.This is supposed to be used in conjunction with Xen's hypercall interface for emualted MSI / MSIX injection.
Signed-off-by Wei Liu <[email protected]>--- hw/apic.c | 10 ++++++++-- hw/msi.c | 7 ++++++- hw/msix.c | 8 +++++++- hw/xen.h | 1 + xen-all.c | 5 +++++ xen-stub.c | 4 ++++ 6 files changed, 31 insertions(+), 4 deletions(-)hw/apic.c +8
-2@@ -22,6 +22,7 @@#include "host-utils.h" #include "trace.h" #include "pc.h" +#include "xen.h" #define MAX_APIC_WORDS 8@@ -641,8 +642,13 @@ static void apic_send_msi(target_phys_addr_t addr, uint32_t data)uint8_t dest_mode = (addr >>MSI_ADDR_DEST_MODE_SHIFT ) &0x1 ;uint8_t trigger_mode = (data >>MSI_DATA_TRIGGER_SHIFT ) &0x1 ;uint8_t delivery = (data >>MSI_DATA_DELIVERY_MODE_SHIFT ) &0x7 ; -/* XXX: Ignore redirection hint. */ -apic_deliver_irq (dest, dest_mode, delivery, vector, trigger_mode); + +if (xen_enabled ()) { +xen_hvm_inject_msi (addr, data); + }else { +/* XXX: Ignore redirection hint. */ +apic_deliver_irq (dest, dest_mode, delivery, vector, trigger_mode); + } }static void apic_mem_writel (void *opaque,target_phys_addr_t addr,uint32_t val)hw/msi.c +6
-1@@ -20,6 +20,7 @@#include "msi.h" #include "range.h" +#include "xen.h" /* Eventually those constants should go to Linux pci_regs.h */ #define PCI_MSI_PENDING_32 0x10@@ -257,7 +258,11 @@ void msi_notify(PCIDevice *dev, unsigned int vector)"notify vector 0x%x" " address: 0x%" PRIx64" data: 0x%" PRIx32"\n" , vector, address, data); -stl_le_phys (address, data); +if (xen_enabled ()) { +xen_hvm_inject_msi (address, data); + }else { +stl_le_phys (address, data); + } }/* call this function after updating configs by pci_default_write_config(). */ hw/msix.c +7
-1@@ -19,6 +19,7 @@#include "msix.h" #include "pci.h" #include "range.h" +#include "xen.h" #define MSIX_CAP_LENGTH 12@@ -365,7 +366,12 @@ void msix_notify(PCIDevice *dev, unsigned vector) address =pci_get_quad (table_entry +PCI_MSIX_ENTRY_LOWER_ADDR ); data =pci_get_long (table_entry +PCI_MSIX_ENTRY_DATA ); -stl_le_phys (address, data); + +if (xen_enabled ()) { +xen_hvm_inject_msi (address, data); + }else { +stl_le_phys (address, data); + } }void msix_reset (PCIDevice *dev)hw/xen.h +1
-0@@ -34,6 +34,7 @@ static inline int xen_enabled(void)int xen_pci_slot_get_pirq (PCIDevice *pci_dev,int irq_num);void xen_piix3_set_irq (void *opaque,int irq_num,int level);void xen_piix_pci_write_config_client (uint32_t address,uint32_t val,int len); +void xen_hvm_inject_msi (uint64_t addr,uint32_t data);void xen_cmos_set_s3_resume (void *opaque,int irq,int level);qemu_irq *xen_interrupt_controller_init (void );xen-all.c +5
-0@@ -122,6 +122,11 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len) } } +void xen_hvm_inject_msi (uint64_t addr,uint32_t data) +{ +xc_hvm_inject_msi (xen_xc, xen_domid, addr, data); +} +static void xen_suspend_notifier (Notifier *notifier,void *data) {xc_set_hvm_param (xen_xc, xen_domid,HVM_PARAM_ACPI_S_STATE ,3 );xen-stub.c +0
-0@@ -29,6 +29,10 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len) { }
Quoted 13 lines
xen-stub.c void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len) · line 38
Quoted 7 lines
xen-stub.c +4
-0+void xen_hvm_inject_msi (uint64_t addr,uint32_t data) +{ +} +void xen_cmos_set_s3_resume (void *opaque,int irq,int level) { }This is not a NACK, but I can't help asking. Perhaps the fake Xen interrupt controller is a bit too simplistic? You can add a memory region corresponding to the APICs and trap writes in that region. Writes coming from QEMU are MSIs and can be injected to the hypervisor, writes coming from the VM will be trapped by Xen before going out to QEMU.
That is a good point actually: we already have lapic emulation in Xen, it makes sense to have apic-msi in Xen too.
We would still need the changes to msi_notify and msix_notify though.
Il 01/03/2012 15:06, Stefano Stabellini ha scritto:
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
This is not a NACK, but I can't help asking. Perhaps the fake Xen interrupt controller is a bit too simplistic? You can add a memory region corresponding to the APICs and trap writes in that region. Writes coming from QEMU are MSIs and can be injected to the hypervisor, writes coming from the VM will be trapped by Xen before going out to QEMU.
That is a good point actually: we already have lapic emulation in Xen, it makes sense to have apic-msi in Xen too.
We would still need the changes tomsi_notifyandmsix_notifythough.
Why? The stores would just go to the Xen interrupt controller MMIO area which then does the xc_hvm_inject_msi.
Paolo
Quoted 7 lines · Paolo Bonzini
Il 01/03/2012 15:06, Stefano Stabellini ha scritto:
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
This is not a NACK, but I can't help asking. Perhaps the fake Xen interrupt controller is a bit too simplistic? You can add a memory region corresponding to the APICs and trap writes in that region. Writes coming from QEMU are MSIs and can be injected to the hypervisor, writes coming from the VM will be trapped by Xen before going out to QEMU.
Quoted 6 lines
Quoted 3 lines
That is a good point actually: we already have lapic emulation in Xen, it makes sense to have apic-msi in Xen too.
We would still need the changes tomsi_notifyandmsix_notifythough.Why? The stores would just go to the Xen interrupt controller MMIO area which then does the
xc_hvm_inject_msi.
Because msi(x)_notify is called by QEMU's emulated devices: it is not possible from QEMU to cause an emulation trap in Xen on behalf of the guest.
Il 01/03/2012 15:50, Stefano Stabellini ha scritto:
Quoted 10 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
That is a good point actually: we already have lapic emulation in Xen, it makes sense to have apic-msi in Xen too.
We would still need the changes tomsi_notifyandmsix_notifythough.Why? The stores would just go to the Xen interrupt controller MMIO area which then does the
xc_hvm_inject_msi.Because msi(x)_notify is called by QEMU's emulated devices: it is not possible from QEMU to cause an emulation trap in Xen on behalf of the guest.
msi{x,}_notify doesn't have to go to Xen MMIO emulation, so in Wei's patch you don't need anymore the msi{,x}_notify parts, only apic_send_msi.
But you could take it further and create a separate subclass of apic-common that does absolutely nothing except register an MMIO memory region and use it to trap MSI writes. Basically an even more stripped down version than hw/kvm/apic.c, but using memory_region_init_io rather than memory_region_init_reservation. You would also get support for the monitor command inject-nmi (there is another hypercall for that in Xen IIRC).
Paolo
Quoted 15 lines · Paolo Bonzini
Il 01/03/2012 15:50, Stefano Stabellini ha scritto:
Quoted 10 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
That is a good point actually: we already have lapic emulation in Xen, it makes sense to have apic-msi in Xen too.
We would still need the changes tomsi_notifyandmsix_notifythough.Why? The stores would just go to the Xen interrupt controller MMIO area which then does the
xc_hvm_inject_msi.Because msi(x)_notify is called by QEMU's emulated devices: it is not possible from QEMU to cause an emulation trap in Xen on behalf of the guest.
msi{x,}_notify doesn't have to go to Xen MMIO emulation, so in Wei's patch you don't need anymore the msi{,x}_notify parts, only
apic_send_msi.
Quoted 7 lines
But you could take it further and create a separate subclass of apic-common that does absolutely nothing except register an MMIO memory region and use it to trap MSI writes. Basically an even more stripped down version than
hw/kvm/apic.c, but usingmemory_region_init_iorather thanmemory_region_init_reservation. You would also get support for the monitor command inject-nmi (there is another hypercall for that in Xen IIRC).
Yes, that could work and should result in a good and clean patch.
Quoted 12 lines · Paolo Bonzini
Il 01/03/2012 15:50, Stefano Stabellini ha scritto:
Quoted 10 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
That is a good point actually: we already have lapic emulation in Xen, it makes sense to have apic-msi in Xen too.
We would still need the changes tomsi_notifyandmsix_notifythough.Why? The stores would just go to the Xen interrupt controller MMIO area which then does the
xc_hvm_inject_msi.Because msi(x)_notify is called by QEMU's emulated devices: it is not possible from QEMU to cause an emulation trap in Xen on behalf of the guest.
I'm not a QEMU expert, so following question may be dumb. However I do care about a cleaner implementation. So please be patient with me. :-)
Quoted 3 lines
msi{x,}_notify doesn't have to go to Xen MMIO emulation, so in Wei's patch you don't need anymore the msi{,x}_notify parts, only
apic_send_msi.
I don't quite understand "you don't need anymore the msi{,x}_notify parts". Virtio PCI invokes msi_notify directly. If I don't hook up msi{,x}_notify, how can I deal with devices like Virtio PCI?
Wei.
Quoted 9 lines
But you could take it further and create a separate subclass of apic-common that does absolutely nothing except register an MMIO memory region and use it to trap MSI writes. Basically an even more stripped down version than
hw/kvm/apic.c, but usingmemory_region_init_iorather thanmemory_region_init_reservation. You would also get support for the monitor command inject-nmi (there is another hypercall for that in Xen IIRC).Paolo
Quoted 17 lines · Wei Liu
Quoted 12 lines · Paolo Bonzini
Il 01/03/2012 15:50, Stefano Stabellini ha scritto:
Quoted 10 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
That is a good point actually: we already have lapic emulation in Xen, it makes sense to have apic-msi in Xen too.
We would still need the changes tomsi_notifyandmsix_notifythough.Why? The stores would just go to the Xen interrupt controller MMIO area which then does the
xc_hvm_inject_msi.Because msi(x)_notify is called by QEMU's emulated devices: it is not possible from QEMU to cause an emulation trap in Xen on behalf of the guest.
I'm not a QEMU expert, so following question may be dumb. However I do care about a cleaner implementation. So please be patient with me. :-)
Quoted 7 lines
Quoted 3 lines
msi{x,}_notify doesn't have to go to Xen MMIO emulation, so in Wei's patch you don't need anymore the msi{,x}_notify parts, only
apic_send_msi.I don't quite understand "you don't need anymore the msi{,x}_notify parts". Virtio PCI invokes
msi_notifydirectly. If I don't hook up msi{,x}_notify, how can I deal with devices like Virtio PCI?
See how KVM will solve this in [1].
Jan
[1] http://permalink.gmane.org/gmane.comp.emulators.kvm.devel/89121
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 17 lines · Wei Liu (Intern)
Quoted 12 lines · Paolo Bonzini
Il 01/03/2012 15:50, Stefano Stabellini ha scritto:
Quoted 10 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
That is a good point actually: we already have lapic emulation in Xen, it makes sense to have apic-msi in Xen too.
We would still need the changes tomsi_notifyandmsix_notifythough.Why? The stores would just go to the Xen interrupt controller MMIO area which then does the
xc_hvm_inject_msi.Because msi(x)_notify is called by QEMU's emulated devices: it is not possible from QEMU to cause an emulation trap in Xen on behalf of the guest.
I'm not a QEMU expert, so following question may be dumb. However I do care about a cleaner implementation. So please be patient with me. :-)
Quoted 7 lines
Quoted 3 lines
msi{x,}_notify doesn't have to go to Xen MMIO emulation, so in Wei's patch you don't need anymore the msi{,x}_notify parts, only
apic_send_msi.I don't quite understand "you don't need anymore the msi{,x}_notify parts". Virtio PCI invokes
msi_notifydirectly. If I don't hook up msi{,x}_notify, how can I deal with devices like Virtio PCI?
msi_notify calls stl_le_phys that is internal to QEMU and goes to the emulated local apic in QEMU. So you can just hook into the emulated local apic like KVM, rather than adding a new hook in msi{,x}_notify.
The fact that the real emulated local apic is in Xen is very confusing for the sake of this discussion. The emulated local apic in Xen is not involved in Paolo's suggestion.