KVM: arm/arm64: gsi routing support
Subsystems (5)
v5 cover KVM: arm/arm64: gsi routing support
With the advent of GICv3 ITS in-kernel emulation, KVM MSI routing becomes mandated for proper VIRTIO-PCI vhost integration.
In QEMU, when the VIRTIO-PCI device is programmed with the MSI message, we previously used direct_mapping trick: this consists in extracting the IRQ ID found in the MSI message and associating an irqfd to that IRQ ID. When vhost worker thread gets a new buffer it signals the irqfd and kvm then injects this IRQ ID on guest. That way although the guest uses MSIs, no MSI emulation is used.
This worked fine with GICv2m but does not work anymore with GICV3 ITS. Indeed this latter implements IRQ translation: what is found in the MSI message no more is the target IRQ ID but is an intermediate event ID used in the translation process.
Hence true MSI routing is needed so that the vhost back channel irqfd is associated to a dummy gsi ID, routed towards the programmed MSI. When KVM injects the MSI through the in-kernel ITS emulation, the MSI is properly translated and eventually the LPI ID associated to the event ID is injected on guest.
MSI routing also mandates to integrate irqchip routing. The initial implementation of irqfd on arm must be upgraded with the integration of kvm irqchip.c code and the implementation of its standard hooks in the architecture specific part.
In case KVM_SET_GSI_ROUTING ioctl is not called, a default routing table with flat irqchip routing entries is built enabling to inject gsi corresponding to the SPI indexes seen by the guest.
As soon as KVM_SET_GSI_ROUTING is called, user-space overwrites this default routing table and is responsible for building the whole routing table.
for arm/arm64 KVM_SET_GSI_ROUTING has a limited support:
- only applies to KVM_IRQFD and not to KVM_IRQ_LINE
- irqchip routing was tested on Calxeda midway (VFIO with irqfd) with and without explicit routing
- MSI routing without GICv3 ITS was tested on AMD Overdrive (qemu VIRTIO-PCI vhost-net without gsi_direct_mapping).
- MSI routing with GICv3 ITS is *NOT* tested.
Code can be found at https:
https://github.com/eauger/linux/tree/v4.7-rc6-its-emul-v7-gsi-routing-v5
The series depends on
[1]: [PATCH v7 00/12] KVM: arm64: GICv3 ITS emulation
http://www.spinics.net/lists/kvm/msg134737.html
hence the RFC.
GSI flat routing setup on QEMU can be found at:
https://lists.nongnu.org/archive/html/qemu-devel/2015-07/msg06262.html
History:
V4 -> v5:
- rebase on Andre's v7 + final new vgic code
- check msi->data is within SPI range in vgic_v2m_inject_msi
- squashed enable irq routing and default irqchip table patches
- handle default irqchip table allocation failure
- some rephrasing in doc & comment according to Christoffer's feedbacks
- lock issue reported by Pavel seems to have disappear after 4.2 (MSI injection fast path)
v3 -> v4:
- rebase on top of NEW-VGIC RFC and ITS emulation series v4. This is not a stable foundation yet. Hence the revert to RFC. This v4 mostly is a reflesh/reminder.
- rewrite the cover letter
v2 -> v3:
- don't use KVM_IRQ_ROUTING_EXTENDED_MSI type at uapi and kernel level anymore; use KVM_MSI_VALID_DEVID flag instead
- propagate user flags downto the kernel to make sure the userspace correctly set devid in GICv3 ITS case (still under discussion)
v1 -> v2:
- user API changed:
x devid id passed in kvm_irq_routing_msi
x kept the new routing entry type: KVM_IRQ_ROUTING_EXTENDED_MSI
- kvm_host.h: adopt Andre's proposal to replace the msi_msg by a struct composed of the msi_msg and devid in kvm_kernel_irq_routing_entry
- Fix bug reported by Pavel: Added KVM_IRQ_ROUTING_EXTENDED_MSI handling in eventfd.c
- added vgic_v2m_inject_msi in vgic-v2-emul.c as suggested by Andre
- fix bug reported by Andre: bad setting of msi.flags and msi.devid in kvm_send_userspace_msi
- avoid injecting reserved IRQ numbers in vgic_irqfd_set_irq
RFC -> PATCH:
- clearly state limited support on arm/arm64:
KVM_IRQ_LINE not impacted by GSI routing
- add default routing table feature (new patch file)
- changed uapi to use padding field area
- reword api.txt
Eric Auger (6):
KVM: api: pass the devid in the msi routing entry
KVM: kvm_host: add devid in kvm_kernel_irq_routing_entry
KVM: irqchip: convey devid to kvm_set_msi
KVM: arm/arm64: enable irqchip routing
KVM: arm/arm64: enable MSI routing
KVM: arm: enable KVM_SIGNAL_MSI and MSI routing
Documentation/virtual/kvm/api.txt | 36 +++++++++++++--- arch/arm/include/asm/kvm_host.h | 2 + arch/arm/kvm/Kconfig | 3 ++ arch/arm/kvm/Makefile | 1 + arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/Kconfig | 2 + arch/arm64/kvm/Makefile | 1 + include/linux/kvm_host.h | 8 +++- include/uapi/linux/kvm.h | 5 ++- virt/kvm/arm/vgic/vgic-init.c | 27 ++++++++++++ virt/kvm/arm/vgic/vgic-irqfd.c | 90 ++++++++++++++++++++++++++++++--------- virt/kvm/arm/vgic/vgic-v2.c | 17 ++++++++ virt/kvm/arm/vgic/vgic.c | 7 --- virt/kvm/arm/vgic/vgic.h | 1 + virt/kvm/irqchip.c | 8 +++- 15 files changed, 173 insertions(+), 36 deletions(-)
Signature · 1 line
1.9.1
RFC v5 1/6 KVM: api: pass the devid in the msi routing entry
On ARM, the MSI msg (address and data) comes along with out-of-band device ID information. The device ID encodes the device that writes the MSI msg. Let's convey the device id in kvm_irq_routing_msi and use KVM_MSI_VALID_DEVID flag value in kvm_irq_routing_entry to indicate the msi devid is populated.
---
v4 -> v5:
- some rephrasing in api.txt according to Christoffer's comments v2 -> v3:
- replace usage of KVM_IRQ_ROUTING_EXTENDED_MSI type by usage of KVM_MSI_VALID_DEVID flag
- add note about KVM_CAP_MSI_DEVID capability
v1 -> v2:
- devid id passed in kvm_irq_routing_msi instead of in kvm_irq_routing_entry
RFC -> PATCH
- remove kvm_irq_routing_extended_msi and use union instead
--- Documentation/virtual/kvm/api.txt | 19 +++++++++++++++++-- include/uapi/linux/kvm.h | 5 ++++- 2 files changed, 21 insertions(+), 3 deletions(-)
Documentation/virtual/kvm/api.txt +17 -2
@@ -1468,7 +1468,11 @@ struct kvm_irq_routing_entry { #define KVM_IRQ_ROUTING_S390_ADAPTER 3 #define KVM_IRQ_ROUTING_HV_SINT 4 -No flags are specified so far, the corresponding field must be set to zero. +flags: +- KVM_MSI_VALID_DEVID: used along with KVM_IRQ_ROUTING_MSI + routing entry type, specifies that the devid field contains + a valid value. +- zero otherwise struct kvm_irq_routing_irqchip { __u32 irqchip;
@@ -1479,9 +1483,20 @@ struct kvm_irq_routing_msi { __u32 address_lo; __u32 address_hi; __u32 data; - __u32 pad; + union { + __u32 pad; + __u32 devid; + }; }; +devid: If KVM_MSI_VALID_DEVID is set, contains a unique device identifier + for the device that wrote the MSI message. + For PCI, this is usually a BFD identifier in the lower 16 bits. + +The per-VM KVM_CAP_MSI_DEVID capability advertises the requirement to +provide the device ID. If this capability is not set, userland cannot +rely on the kernel to allow the KVM_MSI_VALID_DEVID flag being set. + struct kvm_irq_routing_s390_adapter { __u64 ind_addr; __u64 summary_addr;
include/uapi/linux/kvm.h +4 -1
@@ -879,7 +879,10 @@ struct kvm_irq_routing_msi {__u32 address_lo;__u32 address_hi;__u32 data; -__u32 pad; +union { +__u32 pad; +__u32 devid; + }; };struct kvm_irq_routing_s390_adapter {
Signature · 1 line
1.9.1
RFC v5 2/6 KVM: kvm_host: add devid in kvm_kernel_irq_routing_entry
In reply to Eric AugerExtend kvm_kernel_irq_routing_entry to transport the device id field, devid. A new flags field makes possible to indicate the devid is valid. Those additions are used for ARM GICv3 ITS MSI injection.
---
v4 -> v5:
- add Christoffer's R-b
v2 -> v3:
- add flags
v1 -> v2:
- replace msi_msg field by a struct composed of msi_msg and devid
RFC -> PATCH:
- reword the commit message after change in first patch (uapi)
--- include/linux/kvm_host.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
include/linux/kvm_host.h +5 -1
@@ -317,7 +317,11 @@ struct kvm_kernel_irq_routing_entry {unsigned irqchip;unsigned pin; } irqchip; -struct msi_msg msi; +struct { +struct msi_msg msi; +u32 flags; +u32 devid; + };struct kvm_s390_adapter_int adapter;struct kvm_hv_sint hv_sint; };
Signature · 1 line
1.9.1
RFC v5 3/6 KVM: irqchip: convey devid to kvm_set_msi
In reply to Eric Augeron ARM, a devid field is populated in kvm_msi struct in case the flag is set to KVM_MSI_VALID_DEVID. Let's propagate both flags and devid field in kvm_kernel_irq_routing_entry.
---
v4 -> v5:
- Add Christoffer's R-b
v2 -> v3:
- do not set the type to KVM_IRQ_ROUTING_EXTENDED_MSI anymore as suggested by Andre
- correct msi->flags check
- propagate the flags
--- virt/kvm/irqchip.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
virt/kvm/irqchip.c +3 -1
@@ -62,12 +62,14 @@ int kvm_send_userspace_msi(struct kvm *kvm, struct kvm_msi *msi) {struct kvm_kernel_irq_routing_entry route; -if (!irqchip_in_kernel (kvm) || msi->flags !=0 ) +if (!irqchip_in_kernel (kvm) || (msi->flags & ~KVM_MSI_VALID_DEVID ))return -EINVAL ; route.msi.address_lo = msi->address_lo; route.msi.address_hi = msi->address_hi; route.msi.data = msi->data; + route.flags = msi->flags; + route.devid = msi->devid;return kvm_set_msi (&route, kvm,KVM_USERSPACE_IRQ_SOURCE_ID ,1 , false); }
Signature · 1 line
1.9.1
RFC v5 4/6 KVM: arm/arm64: enable irqchip routing
In reply to Eric AugerThis patch adds compilation and link against irqchip.
Main motivation behind using irqchip code is to enable MSI routing code. In the future irqchip routing may also be useful when targeting multiple irqchips.
Routing standard callbacks now are implemented in vgic-irqfd:
- kvm_set_routing_entry
- kvm_set_irq
- kvm_set_msi
They only are supported with new_vgic code.
Both HAVE_KVM_IRQCHIP and HAVE_KVM_IRQ_ROUTING are defined. KVM_CAP_IRQ_ROUTING is advertised and KVM_SET_GSI_ROUTING is allowed.
So from now on IRQCHIP routing is enabled and a routing table entry must exist for irqfd injection to succeed for a given SPI. This patch builds a default flat irqchip routing table (gsi=irqchip.pin) covering all the VGIC SPI indexes. This routing table is overwritten by the first first user-space call to KVM_SET_GSI_ROUTING ioctl.
MSI routing setup is not yet allowed.
---
v4 -> v5:
- vgic_irqfd.c was renamed into vgic-irqfd.c by Andre
- minor comment changes
- remove trace_kvm_set_irq since it is called in irqchip
- remove CONFIG_HAVE_KVM_MSI setting (done in KVM section)
- despite Christoffer's question, in kvm_set_msi, I kept the copy from the input "struct kvm_kernel_irq_routing_entry *e" imposed by the irqchip callback API into the struct kvm_msi * passed to vits_inject_msi. Since vits_inject_msi is directly called by kvm_send_userspace_msi which takes a struct kvm_msi*, makes sense to me to keep the copy.
- squash former [PATCH v4 5/7] KVM: arm/arm64: build a default routing table into that patch
- handle default routing table alloc failure
v3 -> v4:
- provide support only for new-vgic
- code previously in vgic.c now in vgic_irqfd.c
v2 -> v3:
- unconditionally set devid and KVM_MSI_VALID_DEVID flag as suggested by Andre (KVM_IRQ_ROUTING_EXTENDED_MSI type not used anymore)
- vgic_irqfd_set_irq now is static
- propagate flags
- add comments
v1 -> v2:
- fix bug reported by Andre related to msi.flags and msi.devid setting in kvm_send_userspace_msi
- avoid injecting reserved IRQ numbers in vgic_irqfd_set_irq
RFC -> PATCH
- reword api.txt:
x move MSI routing comments in a subsequent patch, x clearly state GSI routing does not apply to KVM_IRQ_LINE
--- Documentation/virtual/kvm/api.txt | 12 ++++-- arch/arm/include/asm/kvm_host.h | 2 + arch/arm/kvm/Kconfig | 2 + arch/arm/kvm/Makefile | 1 + arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/Kconfig | 2 + arch/arm64/kvm/Makefile | 1 + virt/kvm/arm/vgic/vgic-init.c | 27 +++++++++++++ virt/kvm/arm/vgic/vgic-irqfd.c | 82 ++++++++++++++++++++++++++++++--------- virt/kvm/arm/vgic/vgic.c | 7 ---- virt/kvm/irqchip.c | 2 + 11 files changed, 109 insertions(+), 30 deletions(-)
Documentation/virtual/kvm/api.txt +8 -4
@@ -1433,13 +1433,16 @@ KVM_ASSIGN_DEV_IRQ. Partial deassignment of host or guest IRQ is allowed. 4.52 KVM_SET_GSI_ROUTING Capability: KVM_CAP_IRQ_ROUTING -Architectures: x86 s390 +Architectures: x86 s390 arm arm64 Type: vm ioctl Parameters: struct kvm_irq_routing (in) Returns: 0 on success, -1 on error Sets the GSI routing table entries, overwriting any previously set entries. +On arm/arm64, GSI routing has the following limitation: +- GSI routing does not apply to KVM_IRQ_LINE but only to KVM_IRQFD. + struct kvm_irq_routing { __u32 nr; __u32 flags;
@@ -2368,9 +2371,10 @@ Note that closing the resamplefd is not sufficient to disable the irqfd. The KVM_IRQFD_FLAG_RESAMPLE is only necessary on assignment and need not be specified with KVM_IRQFD_FLAG_DEASSIGN. -On ARM/ARM64, the gsi field in the kvm_irqfd struct specifies the Shared -Peripheral Interrupt (SPI) index, such that the GIC interrupt ID is -given by gsi + 32. +On arm/arm64, gsi routing being supported, the following can happen: +- in case no routing entry is associated to this gsi, injection fails +- in case the gsi is associated to an irqchip routing entry, + irqchip.pin + 32 corresponds to the injected SPI ID. 4.76 KVM_PPC_ALLOCATE_HTAB
arch/arm/include/asm/kvm_host.h +2 -0
@@ -37,6 +37,8 @@#define KVM_VCPU_MAX_FEATURES 2 +#define KVM_IRQCHIP_NUM_PINS 988/* 1020 - 32 is the number of SPIs */ +#include <kvm/arm_vgic.h> #define KVM_MAX_VCPUS VGIC_V2_MAX_CPUS
arch/arm/kvm/Kconfig +2 -0
@@ -50,6 +50,8 @@ config KVM_NEW_VGIC bool "New VGIC implementation" depends on KVM default y + select HAVE_KVM_IRQCHIP + select HAVE_KVM_IRQ_ROUTING ---help--- uses the new VGIC implementation
arch/arm/kvm/Makefile +1 -0
@@ -30,6 +30,7 @@ obj-y += $(KVM)/arm/vgic/vgic-v2.o obj-y += $(KVM)/arm/vgic/vgic-mmio.o obj-y += $(KVM)/arm/vgic/vgic-mmio-v2.o obj-y += $(KVM)/arm/vgic/vgic-kvm-device.o +obj-y += $(KVM)//irqchip.o else obj-y += $(KVM)/arm/vgic.o obj-y += $(KVM)/arm/vgic-v2.o
arch/arm64/include/asm/kvm_host.h +1 -0
@@ -34,6 +34,7 @@#define KVM_PRIVATE_MEM_SLOTS 4#define KVM_COALESCED_MMIO_PAGE_OFFSET 1#define KVM_HALT_POLL_NS_DEFAULT 500000 +#define KVM_IRQCHIP_NUM_PINS 988/* 1020 - 32 is the number of SPIs */ #include <kvm/arm_vgic.h> #include <kvm/arm_arch_timer.h>
arch/arm64/kvm/Kconfig +2 -0
@@ -59,6 +59,8 @@ config KVM_NEW_VGIC bool "New VGIC implementation" depends on KVM default y + select HAVE_KVM_IRQCHIP + select HAVE_KVM_IRQ_ROUTING ---help--- uses the new VGIC implementation
arch/arm64/kvm/Makefile +1 -0
@@ -31,6 +31,7 @@ kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/vgic/vgic-mmio-v2.o kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/vgic/vgic-mmio-v3.o kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/vgic/vgic-kvm-device.o kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/vgic/vgic-its.o +kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/irqchip.o else kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/vgic.o kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/vgic-v2.o
virt/kvm/arm/vgic/vgic-init.c +27 -0
@@ -264,6 +264,10 @@ int vgic_init(struct kvm *kvm)kvm_for_each_vcpu (i, vcpu, kvm)kvm_vgic_vcpu_init (vcpu); + ret =kvm_setup_default_irq_routing (kvm); +if (ret) + goto out; + dist->initialized = true; out:return ret;
@@ -457,3 +461,26 @@ out_free_irq: kvm_get_running_vcpus());return ret; } + +int kvm_setup_default_irq_routing (struct kvm *kvm) +{ +struct kvm_irq_routing_entry *entries; +struct vgic_dist *dist = &kvm->arch.vgic; +u32 nr = dist->nr_spis; +int i, ret; + + entries =kcalloc (nr,sizeof (struct kvm_kernel_irq_routing_entry ), +GFP_KERNEL ); +if (!entries) +return -ENOMEM ; + +for (i =0 ; i < nr; i++) { + entries[i].gsi = i; + entries[i].type =KVM_IRQ_ROUTING_IRQCHIP ; + entries[i].u.irqchip.irqchip =0 ; + entries[i].u.irqchip.pin = i; + } + ret =kvm_set_irq_routing (kvm, entries, nr,0 ); +kfree (entries); +return ret; +}
virt/kvm/arm/vgic/vgic-irqfd.c +63 -19
99 lines not on this page · raw message
virt/kvm/arm/vgic/vgic.c +0 -7
@@ -683,10 +683,3 @@ bool kvm_vgic_map_is_active(struct kvm_vcpu *vcpu, unsigned int virt_irq)return map_is_active; } -int kvm_send_userspace_msi (struct kvm *kvm,struct kvm_msi *msi) -{ -if (vgic_has_its (kvm)) -return vits_inject_msi (kvm, msi); -else -return -ENODEV ; -}
virt/kvm/irqchip.c +2 -0
@@ -29,7 +29,9 @@#include <linux/srcu.h> #include <linux/export.h> #include <trace/events/kvm.h> +#if !defined(CONFIG_ARM ) && !defined(CONFIG_ARM64 )#include "irq.h" +#endif int kvm_irq_map_gsi (struct kvm *kvm,struct kvm_kernel_irq_routing_entry *entries,int gsi)
Signature · 1 line
1.9.1
RFC v5 5/6 KVM: arm/arm64: enable MSI routing
In reply to Eric AugerUp to now, only irqchip routing entries could be set. This patch adds the capability to insert MSI routing entries.
For ARM64, let's also increase KVM_MAX_IRQ_ROUTES to 4096: this include SPI irqchip routes plus MSI routes. In the future this might be extended.
---
v2 -> v3:
- remove any reference to KVM_IRQ_ROUTING_EXTENDED_MSI type
- unconditionnaly uapi flags and devid downto the kernel routing entry struct
- handle KVM_MSI_VALID_DEVID flag in kvm_set_irq_routing
- note about KVM_CAP_MSI_DEVID moved in the first patch file of the series
v1 -> v2:
- adapt to new routing entry types
RFC -> PATCH:
- move api MSI routing updates into that patch file
- use new devid field of user api struct
--- Documentation/virtual/kvm/api.txt | 5 +++++ include/linux/kvm_host.h | 2 ++ virt/kvm/arm/vgic/vgic-irqfd.c | 8 ++++++++ virt/kvm/irqchip.c | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-)
Documentation/virtual/kvm/api.txt +5 -0
@@ -2375,6 +2375,11 @@ On arm/arm64, gsi routing being supported, the following can happen: - in case no routing entry is associated to this gsi, injection fails - in case the gsi is associated to an irqchip routing entry, irqchip.pin + 32 corresponds to the injected SPI ID. +- in case the gsi is associated to an MSI routing entry, + * without GICv3 ITS in-kernel emulation, MSI data matches the SPI ID + of the injected SPI + * with GICv3 ITS in-kernel emulation, the MSI message and device ID + are translated into an LPI. 4.76 KVM_PPC_ALLOCATE_HTAB
include/linux/kvm_host.h +2 -0
@@ -1038,6 +1038,8 @@ static inline int mmu_notifier_retry(struct kvm *kvm, unsigned long mmu_seq)#ifdef CONFIG_S390 #define KVM_MAX_IRQ_ROUTES 4096 //FIXME: we can have more than that... +#elif defined(CONFIG_ARM64 ) +#define KVM_MAX_IRQ_ROUTES 4096#else #define KVM_MAX_IRQ_ROUTES 1024#endif
virt/kvm/arm/vgic/vgic-irqfd.c +8 -0
@@ -62,6 +62,14 @@ int kvm_set_routing_entry(struct kvm_kernel_irq_routing_entry *e, (e->irqchip.irqchip >= KVM_NR_IRQCHIPS)) goto out;break ; +case KVM_IRQ_ROUTING_MSI : + e->set = kvm_set_msi; + e->msi.address_lo = ue->u.msi.address_lo; + e->msi.address_hi = ue->u.msi.address_hi; + e->msi.data = ue->u.msi.data; + e->flags = ue->flags; + e->devid = ue->u.msi.devid; +break ;default : goto out; }
virt/kvm/irqchip.c +1 -1
@@ -211,7 +211,7 @@ int kvm_set_irq_routing(struct kvm *kvm, goto out; r = -EINVAL ; -if (ue->flags) { +if (ue->flags & ~KVM_MSI_VALID_DEVID ) {kfree (e); goto out; }
Signature · 1 line
1.9.1
RFC v5 6/6 KVM: arm: enable KVM_SIGNAL_MSI and MSI routing
In reply to Eric AugerIf the ITS modality is not available, let's simply support MSI injection by transforming the MSI.data into an SPI ID.
This becomes possible to use KVM_SIGNAL_MSI ioctl and MSI routing for arm too.
---
v4 -> v5:
- on vgic_v2m_inject_msi check the msi->data is within the SPI range
- move KVM_HAVE_MSI in the KVM section (to be symetrical with ARM64)
v2 -> v3:
- reword the commit message
- add sanity check about devid provision
v1 -> v2:
- introduce vgic_v2m_inject_msi in vgic-v2-emul.c following Andre's advice
--- arch/arm/kvm/Kconfig | 1 + virt/kvm/arm/vgic/vgic-irqfd.c | 2 +- virt/kvm/arm/vgic/vgic-v2.c | 17 +++++++++++++++++ virt/kvm/arm/vgic/vgic.h | 1 + 4 files changed, 20 insertions(+), 1 deletion(-)
arch/arm/kvm/Kconfig +1 -0
@@ -32,6 +32,7 @@ config KVM select KVM_VFIO select HAVE_KVM_EVENTFD select HAVE_KVM_IRQFD + select HAVE_KVM_MSI depends on ARM_VIRT_EXT && ARM_LPAE && ARM_ARCH_TIMER ---help--- Support hosting virtualized guest machines.
virt/kvm/arm/vgic/vgic-irqfd.c +1 -1
@@ -98,7 +98,7 @@ int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e, msi.devid = e->devid;if (!vgic_has_its (kvm)) -return -ENODEV ; +return vgic_v2m_inject_msi (kvm, &msi);return vits_inject_msi (kvm, &msi); }
virt/kvm/arm/vgic/vgic-v2.c +17 -0
@@ -241,6 +241,23 @@ static bool vgic_v2_check_base(gpa_t dist_base, gpa_t cpu_base)return false; } +/** +* vgic_v2m_inject_msi: emulates GICv2M MSI injection by injecting +* the SPI ID matching the msi data +* +* @kvm: pointer to the kvm struct +* @msi: the msi struct handle +*/ +int vgic_v2m_inject_msi (struct kvm *kvm,struct kvm_msi *msi) +{ +if (msi->flags &KVM_MSI_VALID_DEVID ) +return -EINVAL ; +if (!vgic_valid_spi (kvm, msi->data)) +return -EINVAL ; + +return kvm_vgic_inject_irq (kvm,0 , msi->data,1 ); +} +int vgic_v2_map_resources (struct kvm *kvm) {struct vgic_dist *dist = &kvm->arch.vgic;
virt/kvm/arm/vgic/vgic.h +1 -0
@@ -64,6 +64,7 @@ int vgic_v2_probe(const struct gic_kvm_info *info);int vgic_v2_map_resources (struct kvm *kvm);int vgic_register_dist_iodev (struct kvm *kvm,gpa_t dist_base_address,enum vgic_type ); +int vgic_v2m_inject_msi (struct kvm *kvm,struct kvm_msi *msi);#ifdef CONFIG_KVM_ARM_VGIC_V3 void vgic_v3_process_maintenance (struct kvm_vcpu *vcpu);
Signature · 1 line
1.9.1