accel/mshv: update s->irq_routes in release_virq
The state's irq_routes field will be updated when an irqchip's gsi is requested to be released. The old remove_msi_routing() fn is redundant and can be removed. Signed-off-by: Magnus Kulke <magnuskulke@linux.microsoft.com> Link: https://lore.kernel.org/r/20260417105618.3621-11-magnuskulke@linux.microsoft.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Magnus Kulke committed
Apr 17, 2026 at 12:55 UTC
fff99298795cfce9799c750ad1427cdc03883f82
4 files changed
+17
-32
accel/accel-irq.c
+1
-1
@@ -67,7 +67,7 @@ void accel_irqchip_release_virq(int virq)
67
{
68
#ifdef CONFIG_MSHV_IS_POSSIBLE
69
if (mshv_msi_via_irqfd_enabled()) {
70
- mshv_irqchip_release_virq(virq);
70
+ mshv_irqchip_release_virq(mshv_state, virq);
71
}
72
#endif
73
if (kvm_enabled()) {
accel/mshv/irq.c
+14
-29
@@ -123,33 +123,6 @@ static int commit_msi_routing_table(int vm_fd)
123
return 0;
124
}
125
126
-static int remove_msi_routing(uint32_t gsi)
127
-{
128
- struct mshv_user_irq_entry *route_entry;
129
- GHashTable *gsi_routes;
130
-
131
- trace_mshv_remove_msi_routing(gsi);
132
-
133
- if (gsi >= MSHV_MAX_MSI_ROUTES) {
134
- error_report("Invalid GSI: %u", gsi);
135
- return -1;
136
- }
137
-
138
- assert(msi_control);
139
-
140
- WITH_QEMU_LOCK_GUARD(&msi_control_mutex) {
141
- gsi_routes = msi_control->gsi_routes;
142
- route_entry = g_hash_table_lookup(gsi_routes, GINT_TO_POINTER(gsi));
143
- if (route_entry) {
144
- g_hash_table_remove(gsi_routes, GINT_TO_POINTER(gsi));
145
- g_free(route_entry);
146
- msi_control->updated = true;
147
- }
148
- }
149
-
150
- return 0;
151
-}
152
-
126
/* Pass an eventfd which is to be used for injecting interrupts from userland */
127
static int irqfd(int vm_fd, int fd, int resample_fd, uint32_t gsi,
128
uint32_t flags)
@@ -319,9 +292,21 @@ int mshv_irqchip_add_msi_route(AccelRouteChange *c, int vector, PCIDevice *dev)
292
return gsi;
293
}
294
322
-void mshv_irqchip_release_virq(int virq)
295
+void mshv_irqchip_release_virq(MshvState *s, int virq)
296
{
324
- remove_msi_routing(virq);
297
+ struct mshv_user_irq_entry *e;
298
+ int i;
299
+
300
+ for (i = 0; i < s->irq_routes->nr; i++) {
301
+ e = &s->irq_routes->entries[i];
302
+ if (e->gsi == virq) {
303
+ s->irq_routes->nr--;
304
+ *e = s->irq_routes->entries[s->irq_routes->nr];
305
+ }
306
+ }
307
+ irqchip_release_gsi(s, virq);
308
+
309
+ trace_mshv_remove_msi_routing(virq);
310
}
311
312
static int update_routing_entry(MshvState *s,
accel/stubs/mshv-stub.c
+1
-1
@@ -19,7 +19,7 @@ int mshv_irqchip_add_msi_route(AccelRouteChange *c, int vector, PCIDevice *dev)
19
return -ENOSYS;
20
}
21
22
-void mshv_irqchip_release_virq(int virq)
22
+void mshv_irqchip_release_virq(MshvState *s, int virq)
23
{
24
}
25
include/system/mshv.h
+1
-1
@@ -63,7 +63,7 @@ int mshv_request_interrupt(MshvState *mshv_state, uint32_t interrupt_type, uint3
63
int mshv_irqchip_add_msi_route(AccelRouteChange *c, int vector, PCIDevice *dev);
64
int mshv_irqchip_update_msi_route(int virq, MSIMessage msg, PCIDevice *dev);
65
void mshv_irqchip_commit_routes(void);
66
-void mshv_irqchip_release_virq(int virq);
66
+void mshv_irqchip_release_virq(MshvState *s, int virq);
67
int mshv_irqchip_add_irqfd_notifier_gsi(const EventNotifier *n,
68
const EventNotifier *rn, int virq);
69
int mshv_irqchip_remove_irqfd_notifier_gsi(const EventNotifier *n, int virq);