Skip to content

Commit 2412405

Browse files
eaugerchazy
authored andcommitted
KVM: arm/arm64: register irq bypass consumer on ARM/ARM64
This patch selects IRQ_BYPASS_MANAGER and HAVE_KVM_IRQ_BYPASS configs for ARM/ARM64. kvm_arch_has_irq_bypass() now is implemented and returns true. As a consequence the irq bypass consumer will be registered for ARM/ARM64 with the forwarding callbacks: - stop/start: halt/resume guest execution - add/del_producer: set/unset forwarding at vgic/irqchip level We don't have any actual support yet, so nothing gets actually forwarded. Acked-by: Christoffer Dall <[email protected]> Signed-off-by: Eric Auger <[email protected]> [maz: dropped the DEOI stuff for the time being in order to reduce the dependency chain, amended commit message] Signed-off-by: Marc Zyngier <[email protected]> Signed-off-by: Christoffer Dall <[email protected]>
1 parent 80f77e5 commit 2412405

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

arch/arm/kvm/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44

55
source "virt/kvm/Kconfig"
6+
source "virt/lib/Kconfig"
67

78
menuconfig VIRTUALIZATION
89
bool "Virtualization"
@@ -35,6 +36,8 @@ config KVM
3536
select HAVE_KVM_IRQCHIP
3637
select HAVE_KVM_IRQ_ROUTING
3738
select HAVE_KVM_MSI
39+
select IRQ_BYPASS_MANAGER
40+
select HAVE_KVM_IRQ_BYPASS
3841
depends on ARM_VIRT_EXT && ARM_LPAE && ARM_ARCH_TIMER
3942
---help---
4043
Support hosting virtualized guest machines.

arch/arm64/kvm/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44

55
source "virt/kvm/Kconfig"
6+
source "virt/lib/Kconfig"
67

78
menuconfig VIRTUALIZATION
89
bool "Virtualization"
@@ -35,6 +36,8 @@ config KVM
3536
select HAVE_KVM_MSI
3637
select HAVE_KVM_IRQCHIP
3738
select HAVE_KVM_IRQ_ROUTING
39+
select IRQ_BYPASS_MANAGER
40+
select HAVE_KVM_IRQ_BYPASS
3841
---help---
3942
Support hosting virtualized guest machines.
4043
We don't support KVM with 16K page tables yet, due to the multiple

virt/kvm/arm/arm.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <linux/mman.h>
2828
#include <linux/sched.h>
2929
#include <linux/kvm.h>
30+
#include <linux/kvm_irqfd.h>
31+
#include <linux/irqbypass.h>
3032
#include <trace/events/kvm.h>
3133
#include <kvm/arm_pmu.h>
3234

@@ -1458,6 +1460,44 @@ struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr)
14581460
return NULL;
14591461
}
14601462

1463+
bool kvm_arch_has_irq_bypass(void)
1464+
{
1465+
return true;
1466+
}
1467+
1468+
int kvm_arch_irq_bypass_add_producer(struct irq_bypass_consumer *cons,
1469+
struct irq_bypass_producer *prod)
1470+
{
1471+
struct kvm_kernel_irqfd *irqfd =
1472+
container_of(cons, struct kvm_kernel_irqfd, consumer);
1473+
1474+
return 0;
1475+
}
1476+
void kvm_arch_irq_bypass_del_producer(struct irq_bypass_consumer *cons,
1477+
struct irq_bypass_producer *prod)
1478+
{
1479+
struct kvm_kernel_irqfd *irqfd =
1480+
container_of(cons, struct kvm_kernel_irqfd, consumer);
1481+
1482+
return;
1483+
}
1484+
1485+
void kvm_arch_irq_bypass_stop(struct irq_bypass_consumer *cons)
1486+
{
1487+
struct kvm_kernel_irqfd *irqfd =
1488+
container_of(cons, struct kvm_kernel_irqfd, consumer);
1489+
1490+
kvm_arm_halt_guest(irqfd->kvm);
1491+
}
1492+
1493+
void kvm_arch_irq_bypass_start(struct irq_bypass_consumer *cons)
1494+
{
1495+
struct kvm_kernel_irqfd *irqfd =
1496+
container_of(cons, struct kvm_kernel_irqfd, consumer);
1497+
1498+
kvm_arm_resume_guest(irqfd->kvm);
1499+
}
1500+
14611501
/**
14621502
* Initialize Hyp-mode and memory mappings on all CPUs.
14631503
*/

0 commit comments

Comments
 (0)