kvm irqfd: support direct msimessage to irq translation
PATCH v6 1/1 kvm irqfd: support direct msimessage to irq translation
On PPC64 systems MSI Messages are translated to system IRQ in a PCI host bridge. This is already supported for emulated MSI/MSIX but not for irqfd where the current QEMU allocates IRQ numbers from irqchip and maps MSIMessages to IRQ in the host kernel.
This adds a new direct mapping flag which tells
the kvm_irqchip_add_msi_route() function that a new VIRQ should not be allocated, instead the value from MSIMessage::data should be used. It is up to the platform code to make sure that this contains a valid IRQ number as sPAPR does in spapr_pci.c.
---
The patch does not enable this mapping for any platform in this patch as it is going be done for spapr only on a separate patch which is not ready to go as it depends on the in-kernel XICS-KVM patchset which is not in upstream yet.
---
Changes:
v6:
* simplified to a single global flag and putting an IRQ number in MSIMessage::data
2013/08/07 v5:
* pci_bus_map_msi now has default behaviour which is to call kvm_irqchip_add_msi_route
* kvm_irqchip_release_virq fixed not crash when there is no routes
--- include/sysemu/kvm.h | 9 +++++++++ kvm-all.c | 13 +++++++++++++ kvm-stub.c | 1 + 3 files changed, 23 insertions(+)
include/sysemu/kvm.h +9 -0
@@ -46,6 +46,7 @@ extern bool kvm_halt_in_kernel_allowed;extern bool kvm_irqfds_allowed;extern bool kvm_msi_via_irqfd_allowed;extern bool kvm_gsi_routing_allowed; +extern bool kvm_gsi_direct_mapping;extern bool kvm_readonly_mem_allowed;#if definedCONFIG_KVM || !definedNEED_CPU_H
@@ -108,6 +109,13 @@ extern bool kvm_readonly_mem_allowed;#define kvm_gsi_routing_enabled () (kvm_gsi_routing_allowed)/** +* kvm_gsi_direct_mapping: +* +* Returns: true if GSI direct mapping is enabled. +*/ +#define kvm_gsi_direct_mapping () (kvm_gsi_direct_mapping) + +/** * kvm_readonly_mem_enabled: * * Returns: true if KVM readonly memory is enabled (ie the kernel
@@ -123,6 +131,7 @@ extern bool kvm_readonly_mem_allowed;#define kvm_irqfds_enabled () (false)#define kvm_msi_via_irqfd_enabled () (false)#define kvm_gsi_routing_allowed () (false) +#define kvm_gsi_direct_mapping () (false)#define kvm_readonly_mem_enabled () (false)#endif
kvm-all.c +13 -0
@@ -111,6 +111,7 @@ bool kvm_halt_in_kernel_allowed;bool kvm_irqfds_allowed;bool kvm_msi_via_irqfd_allowed;bool kvm_gsi_routing_allowed; +bool kvm_gsi_direct_mapping;bool kvm_allowed;bool kvm_readonly_mem_allowed;
@@ -1069,6 +1070,10 @@ void kvm_irqchip_release_virq(KVMState *s, int virq)struct kvm_irq_routing_entry *e;int i; +if (kvm_gsi_direct_mapping ()) { +return ; + } +for (i =0 ; i < s->irq_routes->nr; i++) { e = &s->irq_routes->entries[i];if (e->gsi == virq) {
@@ -1190,6 +1195,10 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)struct kvm_irq_routing_entry kroute = {};int virq; +if (kvm_gsi_direct_mapping ()) { +return msg.data &0xffff ; + } +if (!kvm_gsi_routing_enabled ()) {return -ENOSYS ; }
@@ -1216,6 +1225,10 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg) {struct kvm_irq_routing_entry kroute = {}; +if (kvm_gsi_direct_mapping ()) { +return 0 ; + } +if (!kvm_irqchip_in_kernel ()) {return -ENOSYS ; }
kvm-stub.c +1 -0
@@ -25,6 +25,7 @@ bool kvm_async_interrupts_allowed;bool kvm_irqfds_allowed;bool kvm_msi_via_irqfd_allowed;bool kvm_gsi_routing_allowed; +bool kvm_gsi_direct_mapping;bool kvm_allowed;bool kvm_readonly_mem_allowed;
Signature · 1 line
1.8.4.rc4
Quoted 5 lines · Alexey Kardashevskiy
On PPC64 systems MSI Messages are translated to system IRQ in a PCI host bridge. This is already supported for emulated MSI/MSIX but not for irqfd where the current QEMU allocates IRQ numbers from irqchip and maps MSIMessages to IRQ in the host kernel.
Quoted 7 lines
This adds a new direct mapping flag which tells
thekvm_irqchip_add_msi_route()function that a new VIRQ should not be allocated, instead the value fromMSIMessage::datashould be used. It is up to the platform code to make sure that this contains a valid IRQ number as sPAPR does inspapr_pci.c.Signed-off-by Alexey Kardashevskiy <[email protected]>
Fine with me
Quoted 116 lines
---
The patch does not enable this mapping for any platform in this patch as it is going be done for spapr only on a separate patch which is not ready to go as it depends on the in-kernel XICS-KVM patchset which is not in upstream yet.
---
Changes:
v6:
* simplified to a single global flag and putting an IRQ number inMSIMessage::data2013/08/07 v5:
*pci_bus_map_msinow has default behaviour which is to callkvm_irqchip_add_msi_route
*kvm_irqchip_release_virqfixed not crash when there is no routes--- include/sysemu/kvm.h | 9 +++++++++ kvm-all.c | 13 +++++++++++++ kvm-stub.c | 1 + 3 files changed, 23 insertions(+)include/sysemu/kvm.h +9
-0@@ -46,6 +46,7 @@ extern bool kvm_halt_in_kernel_allowed;extern bool kvm_irqfds_allowed;extern bool kvm_msi_via_irqfd_allowed;extern bool kvm_gsi_routing_allowed; +extern bool kvm_gsi_direct_mapping;extern bool kvm_readonly_mem_allowed;#if definedCONFIG_KVM || !definedNEED_CPU_H @@ -108,6 +109,13 @@ extern bool kvm_readonly_mem_allowed;#define kvm_gsi_routing_enabled () (kvm_gsi_routing_allowed)/** +* kvm_gsi_direct_mapping: +* +* Returns: true if GSI direct mapping is enabled. +*/ +#define kvm_gsi_direct_mapping () (kvm_gsi_direct_mapping) + +/** * kvm_readonly_mem_enabled: * * Returns: true if KVM readonly memory is enabled (ie the kernel @@ -123,6 +131,7 @@ extern bool kvm_readonly_mem_allowed;#define kvm_irqfds_enabled () (false)#define kvm_msi_via_irqfd_enabled () (false)#define kvm_gsi_routing_allowed () (false) +#define kvm_gsi_direct_mapping () (false)#define kvm_readonly_mem_enabled () (false)#endif kvm-all.c +13
-0@@ -111,6 +111,7 @@ bool kvm_halt_in_kernel_allowed;bool kvm_irqfds_allowed;bool kvm_msi_via_irqfd_allowed;bool kvm_gsi_routing_allowed; +bool kvm_gsi_direct_mapping;bool kvm_allowed;bool kvm_readonly_mem_allowed;@@ -1069,6 +1070,10 @@ void kvm_irqchip_release_virq(KVMState *s, int virq)struct kvm_irq_routing_entry *e;int i; +if (kvm_gsi_direct_mapping ()) { +return ; + } +for (i =0 ; i < s->irq_routes->nr; i++) { e = &s->irq_routes->entries[i];if (e->gsi == virq) {@@ -1190,6 +1195,10 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)struct kvm_irq_routing_entry kroute = {};int virq; +if (kvm_gsi_direct_mapping ()) { +return msg.data &0xffff ; + } +if (!kvm_gsi_routing_enabled ()) {return -ENOSYS ; }@@ -1216,6 +1225,10 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg) {struct kvm_irq_routing_entry kroute = {}; +if (kvm_gsi_direct_mapping ()) { +return 0 ; + } +if (!kvm_irqchip_in_kernel ()) {return -ENOSYS ; }kvm-stub.c +1
-0@@ -25,6 +25,7 @@ bool kvm_async_interrupts_allowed;bool kvm_irqfds_allowed;bool kvm_msi_via_irqfd_allowed;bool kvm_gsi_routing_allowed; +bool kvm_gsi_direct_mapping;bool kvm_allowed;bool kvm_readonly_mem_allowed;Signature · 1 line
1.8.4.rc4
Alexander Graf
AppliedQuoted 12 lines · Michael S. Tsirkin
Quoted 11 lines · Alexey Kardashevskiy
On PPC64 systems MSI Messages are translated to system IRQ in a PCI host bridge. This is already supported for emulated MSI/MSIX but not for irqfd where the current QEMU allocates IRQ numbers from irqchip and maps MSIMessages to IRQ in the host kernel.
This adds a new direct mapping flag which tells
thekvm_irqchip_add_msi_route()function that a new VIRQ should not be allocated, instead the value fromMSIMessage::datashould be used. It is up to the platform code to make sure that this contains a valid IRQ number as sPAPR does inspapr_pci.c.
Quoted 4 lines
Quoted 1 line
Signed-off-by Alexey Kardashevskiy<[email protected]>Fine with me
Thanks, applied to ppc-next.
Alex
Il 03/09/2013 10:17, Michael S. Tsirkin ha scritto:
Quoted 11 lines
Quoted 11 lines
On PPC64 systems MSI Messages are translated to system IRQ in a PCI
Quoted 10 lines
host bridge. This is already supported for emulated MSI/MSIX but not for irqfd where the current QEMU allocates IRQ numbers from irqchip and maps MSIMessages to IRQ in the host kernel.
This adds a new direct mapping flag which tells
thekvm_irqchip_add_msi_route()function that a new VIRQ should not be allocated, instead the value fromMSIMessage::datashould be used. It is up to the platform code to make sure that this contains a valid IRQ number as sPAPR does inspapr_pci.c.
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Signed-off-by Alexey Kardashevskiy <[email protected]>Fine with me
Alex, are you picking this one?
Paolo
Quoted 12 lines · Paolo Bonzini
Il 03/09/2013 10:17, Michael S. Tsirkin ha scritto:
Quoted 11 lines
Quoted 11 lines
On PPC64 systems MSI Messages are translated to system IRQ in a PCI
Quoted 10 lines
host bridge. This is already supported for emulated MSI/MSIX but not for irqfd where the current QEMU allocates IRQ numbers from irqchip and maps MSIMessages to IRQ in the host kernel.
This adds a new direct mapping flag which tells
thekvm_irqchip_add_msi_route()function that a new VIRQ should not be allocated, instead the value fromMSIMessage::datashould be used. It is up to the platform code to make sure that this contains a valid IRQ number as sPAPR does inspapr_pci.c.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Signed-off-by Alexey Kardashevskiy <[email protected]>Fine with me
Alex, are you picking this one?
I wouldn't mind if you pull it in. It mostly touches generic kvm code after all.
Alex
Paolo Bonzini
AppliedIl 03/09/2013 10:08, Alexey Kardashevskiy ha scritto:
Quoted 121 lines
On PPC64 systems MSI Messages are translated to system IRQ in a PCI host bridge. This is already supported for emulated MSI/MSIX but not for irqfd where the current QEMU allocates IRQ numbers from irqchip and maps MSIMessages to IRQ in the host kernel.
This adds a new direct mapping flag which tells
thekvm_irqchip_add_msi_route()function that a new VIRQ should not be allocated, instead the value fromMSIMessage::datashould be used. It is up to the platform code to make sure that this contains a valid IRQ number as sPAPR does inspapr_pci.c.Signed-off-by Alexey Kardashevskiy <[email protected]>---
The patch does not enable this mapping for any platform in this patch as it is going be done for spapr only on a separate patch which is not ready to go as it depends on the in-kernel XICS-KVM patchset which is not in upstream yet.
---
Changes:
v6:
* simplified to a single global flag and putting an IRQ number inMSIMessage::data2013/08/07 v5:
*pci_bus_map_msinow has default behaviour which is to callkvm_irqchip_add_msi_route
*kvm_irqchip_release_virqfixed not crash when there is no routes--- include/sysemu/kvm.h | 9 +++++++++ kvm-all.c | 13 +++++++++++++ kvm-stub.c | 1 + 3 files changed, 23 insertions(+)include/sysemu/kvm.h +9
-0@@ -46,6 +46,7 @@ extern bool kvm_halt_in_kernel_allowed;extern bool kvm_irqfds_allowed;extern bool kvm_msi_via_irqfd_allowed;extern bool kvm_gsi_routing_allowed; +extern bool kvm_gsi_direct_mapping;extern bool kvm_readonly_mem_allowed;#if definedCONFIG_KVM || !definedNEED_CPU_H @@ -108,6 +109,13 @@ extern bool kvm_readonly_mem_allowed;#define kvm_gsi_routing_enabled () (kvm_gsi_routing_allowed)/** +* kvm_gsi_direct_mapping: +* +* Returns: true if GSI direct mapping is enabled. +*/ +#define kvm_gsi_direct_mapping () (kvm_gsi_direct_mapping) + +/** * kvm_readonly_mem_enabled: * * Returns: true if KVM readonly memory is enabled (ie the kernel @@ -123,6 +131,7 @@ extern bool kvm_readonly_mem_allowed;#define kvm_irqfds_enabled () (false)#define kvm_msi_via_irqfd_enabled () (false)#define kvm_gsi_routing_allowed () (false) +#define kvm_gsi_direct_mapping () (false)#define kvm_readonly_mem_enabled () (false)#endif kvm-all.c +13
-0@@ -111,6 +111,7 @@ bool kvm_halt_in_kernel_allowed;bool kvm_irqfds_allowed;bool kvm_msi_via_irqfd_allowed;bool kvm_gsi_routing_allowed; +bool kvm_gsi_direct_mapping;bool kvm_allowed;bool kvm_readonly_mem_allowed;@@ -1069,6 +1070,10 @@ void kvm_irqchip_release_virq(KVMState *s, int virq)struct kvm_irq_routing_entry *e;int i; +if (kvm_gsi_direct_mapping ()) { +return ; + } +for (i =0 ; i < s->irq_routes->nr; i++) { e = &s->irq_routes->entries[i];if (e->gsi == virq) {@@ -1190,6 +1195,10 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)struct kvm_irq_routing_entry kroute = {};int virq; +if (kvm_gsi_direct_mapping ()) { +return msg.data &0xffff ; + } +if (!kvm_gsi_routing_enabled ()) {return -ENOSYS ; }@@ -1216,6 +1225,10 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg) {struct kvm_irq_routing_entry kroute = {}; +if (kvm_gsi_direct_mapping ()) { +return 0 ; + } +if (!kvm_irqchip_in_kernel ()) {return -ENOSYS ; }kvm-stub.c +0
-0
kvm-stub.c bool kvm_async_interrupts_allowed; · line 31
Quoted 7 lines
kvm-stub.c +1
-0@@ -25,6 +25,7 @@ bool kvm_async_interrupts_allowed;bool kvm_irqfds_allowed;bool kvm_msi_via_irqfd_allowed;bool kvm_gsi_routing_allowed; +bool kvm_gsi_direct_mapping;bool kvm_allowed;bool kvm_readonly_mem_allowed;
Applied to uq/master, thanks.
Paolo