accel/mshv: add irq_routes to state
This change adds fields related to irq routing to the MSHV state, following similar fields in the KVM implementation. So far the fields are only initialized, they will be used in subsequent commits for bookkeeping purposes and storing uncommitted interrupt routes. The TYPE_MSHV_ACCEL defines have been moved to the header. Signed-off-by: Magnus Kulke <magnuskulke@linux.microsoft.com> Link: https://lore.kernel.org/r/20260417105618.3621-8-magnuskulke@linux.microsoft.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Magnus Kulke committed
Apr 17, 2026 at 12:55 UTC
f81fefdeb8ef071c4f70b5ec85272334f7b1f0b2
4 files changed
+24
-4
accel/mshv/irq.c
+10
@@ -396,3 +396,13 @@ int mshv_reserve_ioapic_msi_routes(int vm_fd)
396
397
return 0;
398
}
399
+
400
+void mshv_init_irq_routing(MshvState *s)
401
+{
402
+ int gsi_count = MSHV_MAX_MSI_ROUTES;
403
+
404
+ s->irq_routes = g_malloc0(sizeof(*s->irq_routes));
405
+ s->nr_allocated_irq_routes = 0;
406
+ s->gsi_count = gsi_count;
407
+ s->used_gsi_bitmap = bitmap_new(gsi_count);
408
+}
accel/mshv/mshv-all.c
+2
-4
@@ -43,10 +43,6 @@
43
#include <err.h>
44
#include <sys/ioctl.h>
45
46
-#define TYPE_MSHV_ACCEL ACCEL_CLASS_NAME("mshv")
47
-
48
-DECLARE_INSTANCE_CHECKER(MshvState, MSHV_STATE, TYPE_MSHV_ACCEL)
49
-
46
bool mshv_allowed;
47
48
MshvState *mshv_state;
@@ -536,6 +532,8 @@ static int mshv_init(AccelState *as, MachineState *ms)
532
533
mshv_state = s;
534
535
+ mshv_init_irq_routing(s);
536
+
537
register_mshv_memory_listener(s, &s->memory_listener, &address_space_memory,
538
0, "mshv-memory");
539
memory_listener_register(&mshv_io_listener, &address_space_io);
include/system/mshv.h
+7
@@ -45,7 +45,13 @@ extern bool mshv_allowed;
45
#define mshv_msi_via_irqfd_enabled() mshv_enabled()
46
#endif
47
48
+#define TYPE_MSHV_ACCEL ACCEL_CLASS_NAME("mshv")
49
+
50
typedef struct MshvState MshvState;
51
+
52
+DECLARE_INSTANCE_CHECKER(MshvState, MSHV_STATE,
53
+ TYPE_MSHV_ACCEL)
54
+
55
extern MshvState *mshv_state;
56
57
/* interrupt */
@@ -60,6 +66,7 @@ void mshv_irqchip_release_virq(int virq);
66
int mshv_irqchip_add_irqfd_notifier_gsi(const EventNotifier *n,
67
const EventNotifier *rn, int virq);
68
int mshv_irqchip_remove_irqfd_notifier_gsi(const EventNotifier *n, int virq);
69
+void mshv_init_irq_routing(MshvState *s);
70
71
/* cpuid */
72
uint32_t mshv_get_supported_cpuid(uint32_t func, uint32_t idx, int reg);
include/system/mshv_int.h
+5
@@ -48,6 +48,11 @@ struct MshvState {
48
int nr_as;
49
MshvAddressSpace *as;
50
int fd;
51
+ /* irqchip routing */
52
+ struct mshv_user_irq_table *irq_routes;
53
+ int nr_allocated_irq_routes;
54
+ unsigned long *used_gsi_bitmap;
55
+ unsigned int gsi_count;
56
};
57
58
typedef struct MshvMsiControl {