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>
This commit is contained in:
Magnus Kulke
2026-04-17 12:55:51 +02:00
committed by Paolo Bonzini
parent cc2b30223c
commit f81fefdeb8
4 changed files with 24 additions and 4 deletions

View File

@@ -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);
}

View File

@@ -43,10 +43,6 @@
#include <err.h>
#include <sys/ioctl.h>
#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);

View File

@@ -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);

View File

@@ -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 {