[RFC PATCH 03/34] KVM: irqfd: Allow KVM backends to override IRQ injection via set_irq callback
Karim Manaouil
karim.manaouil at linaro.org
Thu Apr 24 07:13:10 PDT 2025
Some KVM backends, such as Gunyah, require custom mechanisms to inject
interrupts into the guest. For example, Gunyah performs IRQ injection
through a hypercall to the underlying hypervisor.
To support such use case, this patch introduces a new optional callback
field `set_irq` in `struct kvm_kernel_irqfd`. If this callback is set,
irqfd injection will use the provided function instead of calling
kvm_set_irq() directly.
The default behavior is unchanged for existing users that do not override
the `set_irq` field.
Signed-off-by: Karim Manaouil <karim.manaouil at linaro.org>
---
include/linux/kvm_irqfd.h | 1 +
virt/kvm/eventfd.c | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/include/linux/kvm_irqfd.h b/include/linux/kvm_irqfd.h
index e8d21d443c58..7d54bc12c4bf 100644
--- a/include/linux/kvm_irqfd.h
+++ b/include/linux/kvm_irqfd.h
@@ -46,6 +46,7 @@ struct kvm_kernel_irqfd {
/* Used for level IRQ fast-path */
int gsi;
struct work_struct inject;
+ int (*set_irq)(struct kvm_kernel_irqfd *);
/* The resampler used by this irqfd (resampler-only) */
struct kvm_kernel_irqfd_resampler *resampler;
/* Eventfd notified on resample (resampler-only) */
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 5f3776a1b960..d6702225e7f2 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -63,6 +63,11 @@ irqfd_inject(struct work_struct *work)
container_of(work, struct kvm_kernel_irqfd, inject);
struct kvm *kvm = irqfd->kvm;
+ if (irqfd->set_irq) {
+ irqfd->set_irq(irqfd);
+ return;
+ }
+
if (!irqfd->resampler) {
kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, irqfd->gsi, 1,
false);
--
2.39.5
More information about the linux-arm-kernel
mailing list