ARM adaptations for vhost irqfd setup
v2 cover ARM adaptations for vhost irqfd setup
After the introduction of gicv2m, this series adds missing pieces to run VIRTIO-PCI with vhost back-end on ARM.
It is proposed to use the kvm_gsi_direct_mapping modality that sets the irqfd gsi to the MSI data value. With that trick there is no need to create a KVM MSI routing entry featuring a different gsi.
The only adaptation needed for ARM consists in adding an architecture specific function that converts the MSI data field into the actual gsi index: there is an offset of 32 between the MSI data content (SPI ID) and the SPI index that is passed to KVM_IRQFD ioctl. Once this is done we can set the requested flags to enable vhost:kvm_gsi_direct_mapping, kvm_msi_via_irqfd_allowed.
This was tested on XGene, on top of Christoffer's series, [PATCH 0/3] Add support for for GICv2m and MSIs to arm-virt
(https://lists.gnu.org/archive/html/qemu-devel/2015-04/msg00881.html)
Best Regards
Eric
v1 -> v2:
- abort on i386/mips/s390x since those archs do not support kvm_gsi_direct_mapping
Eric Auger (2):
kvm: introduce kvm_arch_msi_data_to_gsi
arm_gicv2m: set kvm_gsi_direct_mapping and kvm_msi_via_irqfd_allowed
hw/intc/arm_gicv2m.c | 2 ++ include/sysemu/kvm.h | 2 ++ kvm-all.c | 2 +- target-arm/kvm.c | 5 +++++ target-i386/kvm.c | 5 +++++ target-mips/kvm.c | 5 +++++ target-ppc/kvm.c | 5 +++++ target-s390x/kvm.c | 5 +++++ 8 files changed, 30 insertions(+), 1 deletion(-)
Signature · 1 line
1.8.3.2
PATCH v2 1/2 kvm: introduce kvm_arch_msi_data_to_gsi
On ARM the MSI data corresponds to the shared peripheral interrupt (SPI) ID. This latter equals to the SPI index + 32. to retrieve the SPI index, matching the gsi, an architecture specific function is introduced.
---
v1 -> v2:
- abort on i386/mips/s390x since those archs do not support kvm_gsi_direct_mapping
--- include/sysemu/kvm.h | 2 ++ kvm-all.c | 2 +- target-arm/kvm.c | 5 +++++ target-i386/kvm.c | 5 +++++ target-mips/kvm.c | 5 +++++ target-ppc/kvm.c | 5 +++++ target-s390x/kvm.c | 5 +++++ 7 files changed, 28 insertions(+), 1 deletion(-)
include/sysemu/kvm.h +2 -0
@@ -286,6 +286,8 @@ void kvm_arch_init_irq_routing(KVMState *s);int kvm_arch_fixup_msi_route (struct kvm_irq_routing_entry *route,uint64_t address,uint32_t data); +int kvm_arch_msi_data_to_gsi (uint32_t data); +int kvm_set_irq (KVMState *s,int irq,int level);int kvm_irqchip_send_msi (KVMState *s,MSIMessage msg);
kvm-all.c +1 -1
@@ -1228,7 +1228,7 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)int virq;if (kvm_gsi_direct_mapping ()) { -return msg.data &0xffff ; +return kvm_arch_msi_data_to_gsi (msg.data); }if (!kvm_gsi_routing_enabled ()) {
target-arm/kvm.c +5 -0
@@ -598,3 +598,8 @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, {return 0 ; } + +int kvm_arch_msi_data_to_gsi (uint32_t data) +{ +return (data -32 ) &0xffff ; +}
target-i386/kvm.c +5 -0
@@ -2764,3 +2764,8 @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, {return 0 ; } + +int kvm_arch_msi_data_to_gsi (uint32_t data) +{ +abort (); +}
target-mips/kvm.c +5 -0
@@ -694,3 +694,8 @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, {return 0 ; } + +int kvm_arch_msi_data_to_gsi (uint32_t data) +{ +abort (); +}
target-ppc/kvm.c +5 -0
@@ -2408,3 +2408,8 @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, {return 0 ; } + +int kvm_arch_msi_data_to_gsi (uint32_t data) +{ +return data &0xffff ; +}
target-s390x/kvm.c +5 -0
@@ -1940,3 +1940,8 @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, route->u.adapter.adapter_id = pbdev->routes.adapter.adapter_id;return 0 ; } + +int kvm_arch_msi_data_to_gsi (uint32_t data) +{ +abort (); +}
Signature · 1 line
1.8.3.2
Re: [PATCH v2 1/2] kvm: introduce kvm_arch_msi_data_to_gsi
Quoted 6 lines · Eric Auger
On ARM the MSI data corresponds to the shared peripheral interrupt (SPI) ID. This latter equals to the SPI index + 32. to retrieve the SPI index, matching the gsi, an architecture specific function is introduced.
Signed-off-by Eric Auger <[email protected]>
Re: [PATCH v2 1/2] kvm: introduce kvm_arch_msi_data_to_gsi
In reply to Eric AugerQuoted 11 lines · On Fri, 10 Apr 2015 08:48:09 +0100 Eric Auger <[email protected]> wrote:
On ARM the MSI data corresponds to the shared peripheral interrupt (SPI) ID. This latter equals to the SPI index + 32. to retrieve the SPI index, matching the gsi, an architecture specific function is introduced.
Signed-off-by Eric Auger <[email protected]>---
v1 -> v2:
- abort on i386/mips/s390x since those archs do not supportkvm_gsi_direct_mapping
Quoted 9 lines
--- include/sysemu/kvm.h | 2 ++ kvm-all.c | 2 +- target-arm/kvm.c | 5 +++++ target-i386/kvm.c | 5 +++++ target-mips/kvm.c | 5 +++++ target-ppc/kvm.c | 5 +++++ target-s390x/kvm.c | 5 +++++ 7 files changed, 28 insertions(+), 1 deletion(-)
PATCH v2 2/2 arm_gicv2m: set kvm_gsi_direct_mapping and kvm_msi_via_irqfd_allowed
In reply to Eric AugerAfter introduction of kvm_arch_msi_data_to_gsi, kvm_gsi_direct_mapping now can be set on ARM. Also kvm_msi_via_irqfd_allowed can be set, depending on kernel irqfd support, hence enabling VIRTIO-PCI with vhost back-end.
--- hw/intc/arm_gicv2m.c | 2 ++ 1 file changed, 2 insertions(+)
hw/intc/arm_gicv2m.c +2 -0
@@ -138,6 +138,8 @@ static void gicv2m_realize(DeviceState *dev, Error **errp) } msi_supported = true; + kvm_gsi_direct_mapping = true; + kvm_msi_via_irqfd_allowed =kvm_irqfds_enabled (); }static void gicv2m_init (Object *obj)
Signature · 1 line
1.8.3.2
Quoted 18 lines · Eric Auger
After the introduction of gicv2m, this series adds missing pieces to run VIRTIO-PCI with vhost back-end on ARM.
It is proposed to use the
kvm_gsi_direct_mappingmodality that sets the irqfd gsi to the MSI data value. With that trick there is no need to create a KVM MSI routing entry featuring a different gsi.The only adaptation needed for ARM consists in adding an architecture specific function that converts the MSI data field into the actual gsi index: there is an offset of 32 between the MSI data content (SPI ID) and the SPI index that is passed to
KVM_IRQFDioctl. Once this is done we can set the requested flags to enable vhost:kvm_gsi_direct_mapping,kvm_msi_via_irqfd_allowed.This was tested on XGene, on top of Christoffer's series, [PATCH 0/3] Add support for for GICv2m and MSIs to arm-virt
(https://lists.gnu.org/archive/html/qemu-devel/2015-04/msg00881.html)
Quoted 7 lines
Best Regards
Eric
v1 -> v2:
- abort on i386/mips/s390x since those archs do not supportkvm_gsi_direct_mapping
Patch 1 is okay. I guess this series will go through some ARM tree.
Paolo
Quoted 23 lines · Paolo Bonzini
Quoted 20 lines · Eric Auger
After the introduction of gicv2m, this series adds missing pieces to run VIRTIO-PCI with vhost back-end on ARM.
It is proposed to use the
kvm_gsi_direct_mappingmodality that sets the irqfd gsi to the MSI data value. With that trick there is no need to create a KVM MSI routing entry featuring a different gsi.The only adaptation needed for ARM consists in adding an architecture specific function that converts the MSI data field into the actual gsi index: there is an offset of 32 between the MSI data content (SPI ID) and the SPI index that is passed to
KVM_IRQFDioctl. Once this is done we can set the requested flags to enable vhost:kvm_gsi_direct_mapping,kvm_msi_via_irqfd_allowed.This was tested on XGene, on top of Christoffer's series, [PATCH 0/3] Add support for for GICv2m and MSIs to arm-virt
(https://lists.gnu.org/archive/html/qemu-devel/2015-04/msg00881.html)Best Regards
Quoted 7 lines
Quoted 5 lines
Eric
v1 -> v2:
- abort on i386/mips/s390x since those archs do not supportkvm_gsi_direct_mappingPatch 1 is okay. I guess this series will go through some ARM tree.
Now that I've applied the gicv2m patches I've also applied this series to target-arm.next.
thanks
-- PMM