As we continue cutting a VGIC-shaped hole in KVM, let's indirect all of the handling of mapped interrupts into the bit irqchip_flow bucket. Signed-off-by: Marc Zyngier <maz@xxxxxxxxxx> --- arch/arm64/include/asm/kvm_irq.h | 17 +++++++++++++++++ arch/arm64/kvm/arch_timer.c | 22 +++++++++++----------- arch/arm64/kvm/vgic/vgic-init.c | 4 ++++ arch/arm64/kvm/vgic/vgic.h | 6 ++++++ include/kvm/arm_vgic.h | 7 ------- 5 files changed, 38 insertions(+), 18 deletions(-) diff --git a/arch/arm64/include/asm/kvm_irq.h b/arch/arm64/include/asm/kvm_irq.h index f816d4814fcf..16556417bd4a 100644 --- a/arch/arm64/include/asm/kvm_irq.h +++ b/arch/arm64/include/asm/kvm_irq.h @@ -33,6 +33,11 @@ struct kvm_irqchip_flow { int (*irqchip_inject_userspace_irq)(struct kvm *, unsigned int type, unsigned int cpu, unsigned int intid, bool); + bool (*irqchip_map_is_active)(struct kvm_vcpu *, unsigned in); + void (*irqchip_reset_mapped_irq)(struct kvm_vcpu *, u32); + int (*irqchip_map_phys_irq)(struct kvm_vcpu *, unsigned int, + u32, bool (*)(int)); + int (*irqchip_unmap_phys_irq)(struct kvm_vcpu *, unsigned int); }; /* @@ -97,4 +102,16 @@ struct kvm_irqchip_flow { #define kvm_irqchip_inject_userspace_irq(k, ...) \ __kvm_irqchip_action_ret((k), inject_userspace_irq, (k), __VA_ARGS__) +#define kvm_irqchip_map_is_active(v, ...) \ + __vcpu_irqchip_action_ret((v), map_is_active, (v), __VA_ARGS__) + +#define kvm_irqchip_reset_mapped_irq(v, ...) \ + __vcpu_irqchip_action((v), reset_mapped_irq, (v), __VA_ARGS__) + +#define kvm_irqchip_map_phys_irq(v, ...) \ + __vcpu_irqchip_action_ret((v), map_phys_irq, (v), __VA_ARGS__) + +#define kvm_irqchip_unmap_phys_irq(v, ...) \ + __vcpu_irqchip_action_ret((v), unmap_phys_irq, (v), __VA_ARGS__) + #endif diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c index 397bd7aea1f5..16999de299a7 100644 --- a/arch/arm64/kvm/arch_timer.c +++ b/arch/arm64/kvm/arch_timer.c @@ -562,7 +562,7 @@ static void kvm_timer_vcpu_load_gic(struct arch_timer_context *ctx) kvm_timer_update_irq(ctx->vcpu, kvm_timer_should_fire(ctx), ctx); if (irqchip_in_kernel(vcpu->kvm)) - phys_active = kvm_vgic_map_is_active(vcpu, ctx->irq.irq); + phys_active = kvm_irqchip_map_is_active(vcpu, ctx->irq.irq); phys_active |= ctx->irq.level; @@ -734,9 +734,9 @@ int kvm_timer_vcpu_reset(struct kvm_vcpu *vcpu) kvm_timer_update_irq(vcpu, false, vcpu_ptimer(vcpu)); if (irqchip_in_kernel(vcpu->kvm)) { - kvm_vgic_reset_mapped_irq(vcpu, map.direct_vtimer->irq.irq); + kvm_irqchip_reset_mapped_irq(vcpu, map.direct_vtimer->irq.irq); if (map.direct_ptimer) - kvm_vgic_reset_mapped_irq(vcpu, map.direct_ptimer->irq.irq); + kvm_irqchip_reset_mapped_irq(vcpu, map.direct_ptimer->irq.irq); } } @@ -1139,18 +1139,18 @@ int kvm_timer_enable(struct kvm_vcpu *vcpu) get_timer_map(vcpu, &map); - ret = kvm_vgic_map_phys_irq(vcpu, - map.direct_vtimer->host_timer_irq, - map.direct_vtimer->irq.irq, - kvm_arch_timer_get_input_level); + ret = kvm_irqchip_map_phys_irq(vcpu, + map.direct_vtimer->host_timer_irq, + map.direct_vtimer->irq.irq, + kvm_arch_timer_get_input_level); if (ret) return ret; if (map.direct_ptimer) { - ret = kvm_vgic_map_phys_irq(vcpu, - map.direct_ptimer->host_timer_irq, - map.direct_ptimer->irq.irq, - kvm_arch_timer_get_input_level); + ret = kvm_irqchip_map_phys_irq(vcpu, + map.direct_ptimer->host_timer_irq, + map.direct_ptimer->irq.irq, + kvm_arch_timer_get_input_level); } if (ret) diff --git a/arch/arm64/kvm/vgic/vgic-init.c b/arch/arm64/kvm/vgic/vgic-init.c index 7a8504a5b634..ed62c0a27b53 100644 --- a/arch/arm64/kvm/vgic/vgic-init.c +++ b/arch/arm64/kvm/vgic/vgic-init.c @@ -29,6 +29,10 @@ static struct kvm_irqchip_flow vgic_irqchip_flow = { .irqchip_vcpu_sync_hwstate = kvm_vgic_sync_hwstate, .irqchip_inject_irq = kvm_vgic_inject_irq, .irqchip_inject_userspace_irq = kvm_vgic_inject_userspace_irq, + .irqchip_map_is_active = kvm_vgic_map_is_active, + .irqchip_reset_mapped_irq = kvm_vgic_reset_mapped_irq, + .irqchip_map_phys_irq = kvm_vgic_map_phys_irq, + .irqchip_unmap_phys_irq = kvm_vgic_unmap_phys_irq, }; /* diff --git a/arch/arm64/kvm/vgic/vgic.h b/arch/arm64/kvm/vgic/vgic.h index cddbd9b951e4..af4a0e5f31c1 100644 --- a/arch/arm64/kvm/vgic/vgic.h +++ b/arch/arm64/kvm/vgic/vgic.h @@ -329,6 +329,12 @@ int vgic_v4_init(struct kvm *kvm); void vgic_v4_teardown(struct kvm *kvm); void vgic_v4_configure_vsgis(struct kvm *kvm); +bool kvm_vgic_map_is_active(struct kvm_vcpu *vcpu, unsigned int vintid); +void kvm_vgic_reset_mapped_irq(struct kvm_vcpu *vcpu, u32 vintid); +int kvm_vgic_map_phys_irq(struct kvm_vcpu *vcpu, unsigned int host_irq, + u32 vintid, bool (*get_input_level)(int)); +int kvm_vgic_unmap_phys_irq(struct kvm_vcpu *vcpu, unsigned int vintid); + int kvm_vgic_vcpu_pending_irq(struct kvm_vcpu *vcpu); void kvm_vgic_load(struct kvm_vcpu *vcpu); diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h index fba68129337d..ff8c49c0ebbd 100644 --- a/include/kvm/arm_vgic.h +++ b/include/kvm/arm_vgic.h @@ -339,17 +339,10 @@ int kvm_vgic_create(struct kvm *kvm, u32 type); int kvm_vgic_hyp_init(void); void kvm_vgic_init_cpu_hardware(void); -int kvm_vgic_map_phys_irq(struct kvm_vcpu *vcpu, unsigned int host_irq, - u32 vintid, bool (*get_input_level)(int vindid)); -int kvm_vgic_unmap_phys_irq(struct kvm_vcpu *vcpu, unsigned int vintid); -bool kvm_vgic_map_is_active(struct kvm_vcpu *vcpu, unsigned int vintid); - #define vgic_initialized(k) ((k)->arch.vgic.initialized) #define vgic_valid_spi(k, i) (((i) >= VGIC_NR_PRIVATE_IRQS) && \ ((i) < (k)->arch.vgic.nr_spis + VGIC_NR_PRIVATE_IRQS)) -void kvm_vgic_reset_mapped_irq(struct kvm_vcpu *vcpu, u32 vintid); - void vgic_v3_dispatch_sgi(struct kvm_vcpu *vcpu, u64 reg, bool allow_group1); /** -- 2.27.0