@@ -100,6 +100,7 @@ struct kvm_arch {
/* Interrupt controller */
enum kvm_irqchip_type irqchip_type;
+ struct kvm_irqchip_flow irqchip_flow;
struct vgic_dist vgic;
/* Mandated version of PSCI */
@@ -17,4 +17,33 @@ enum kvm_irqchip_type {
#define irqchip_is_gic_v2(k) ((k)->arch.irqchip_type == IRQCHIP_GICv2)
#define irqchip_is_gic_v3(k) ((k)->arch.irqchip_type == IRQCHIP_GICv3)
+struct kvm_irqchip_flow {
+};
+
+/*
+ * Macro galore. At the point this is included, the various types are
+ * not defined yet. Yes, this is terminally ugly.
+ */
+#define __kvm_irqchip_action(k, x, ...) \
+ do { \
+ if (likely((k)->arch.irqchip_flow.irqchip_##x)) \
+ (k)->arch.irqchip_flow.irqchip_##x(__VA_ARGS__); \
+ } while (0)
+
+#define __kvm_irqchip_action_ret(k, x, ...) \
+ ({ \
+ typeof ((k)->arch.irqchip_flow.irqchip_##x(__VA_ARGS__)) ret; \
+ ret = (likely((k)->arch.irqchip_flow.irqchip_##x) ? \
+ (k)->arch.irqchip_flow.irqchip_##x(__VA_ARGS__) : \
+ 0); \
+ \
+ ret; \
+ })
+
+#define __vcpu_irqchip_action(v, ...) \
+ __kvm_irqchip_action((v)->kvm, __VA_ARGS__)
+
+#define __vcpu_irqchip_action_ret(v, ...) \
+ __kvm_irqchip_action_ret((v)->kvm, __VA_ARGS__)
+
#endif
@@ -12,6 +12,9 @@
#include <asm/kvm_mmu.h>
#include "vgic.h"
+static struct kvm_irqchip_flow vgic_irqchip_flow = {
+};
+
/*
* Initialization rules: there are multiple stages to the vgic
* initialization, both for the distributor and the CPU interfaces. The basic
@@ -98,6 +101,8 @@ int kvm_vgic_create(struct kvm *kvm, u32 type)
else
INIT_LIST_HEAD(&kvm->arch.vgic.rd_regions);
+ kvm->arch.irqchip_flow = vgic_irqchip_flow;
+
INIT_LIST_HEAD(&dist->lpi_list_head);
INIT_LIST_HEAD(&dist->lpi_translation_cache);
raw_spin_lock_init(&dist->lpi_list_lock);
As we are about to abstract part of the vgic implementation in order to make it more modular, let's start by adding a data structure that will eventually contain interrupt controller specific callbacks, as well as helpers to call them (or gracefully skip them if they aren't implemented. It is empty so far, so no functional changes are anticipated. Signed-off-by: Marc Zyngier <maz@kernel.org> --- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/include/asm/kvm_irq.h | 29 +++++++++++++++++++++++++++++ arch/arm64/kvm/vgic/vgic-init.c | 5 +++++ 3 files changed, 35 insertions(+)