diff --git a/accel/mshv/irq.c b/accel/mshv/irq.c index 3c238c33c3..82f2022c7c 100644 --- a/accel/mshv/irq.c +++ b/accel/mshv/irq.c @@ -396,3 +396,13 @@ int mshv_reserve_ioapic_msi_routes(int vm_fd) return 0; } + +void mshv_init_irq_routing(MshvState *s) +{ + int gsi_count = MSHV_MAX_MSI_ROUTES; + + s->irq_routes = g_malloc0(sizeof(*s->irq_routes)); + s->nr_allocated_irq_routes = 0; + s->gsi_count = gsi_count; + s->used_gsi_bitmap = bitmap_new(gsi_count); +} diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index a6263effa4..2ed3ef4b84 100644 --- a/accel/mshv/mshv-all.c +++ b/accel/mshv/mshv-all.c @@ -43,10 +43,6 @@ #include #include -#define TYPE_MSHV_ACCEL ACCEL_CLASS_NAME("mshv") - -DECLARE_INSTANCE_CHECKER(MshvState, MSHV_STATE, TYPE_MSHV_ACCEL) - bool mshv_allowed; MshvState *mshv_state; @@ -536,6 +532,8 @@ static int mshv_init(AccelState *as, MachineState *ms) mshv_state = s; + mshv_init_irq_routing(s); + register_mshv_memory_listener(s, &s->memory_listener, &address_space_memory, 0, "mshv-memory"); memory_listener_register(&mshv_io_listener, &address_space_io); diff --git a/include/system/mshv.h b/include/system/mshv.h index 8dd77a7624..1e9bcc1b0b 100644 --- a/include/system/mshv.h +++ b/include/system/mshv.h @@ -45,7 +45,13 @@ extern bool mshv_allowed; #define mshv_msi_via_irqfd_enabled() mshv_enabled() #endif +#define TYPE_MSHV_ACCEL ACCEL_CLASS_NAME("mshv") + typedef struct MshvState MshvState; + +DECLARE_INSTANCE_CHECKER(MshvState, MSHV_STATE, + TYPE_MSHV_ACCEL) + extern MshvState *mshv_state; /* interrupt */ @@ -60,6 +66,7 @@ void mshv_irqchip_release_virq(int virq); int mshv_irqchip_add_irqfd_notifier_gsi(const EventNotifier *n, const EventNotifier *rn, int virq); int mshv_irqchip_remove_irqfd_notifier_gsi(const EventNotifier *n, int virq); +void mshv_init_irq_routing(MshvState *s); /* cpuid */ uint32_t mshv_get_supported_cpuid(uint32_t func, uint32_t idx, int reg); diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index 1d9902c9bb..a0fa9a50f7 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -48,6 +48,11 @@ struct MshvState { int nr_as; MshvAddressSpace *as; int fd; + /* irqchip routing */ + struct mshv_user_irq_table *irq_routes; + int nr_allocated_irq_routes; + unsigned long *used_gsi_bitmap; + unsigned int gsi_count; }; typedef struct MshvMsiControl {