From fde4aed1435c5342eca4a70a97a95c4072c02be3 Mon Sep 17 00:00:00 2001 From: xiangzixuan Date: Thu, 18 Dec 2025 15:53:52 +0800 Subject: [PATCH] ub: check kvm state when set kvm interrupt check if it is kvm state before set kvm interrupt Signed-off-by: xiangzixuan --- hw/ub/ub_ummu.c | 4 +++- hw/vfio/ub.c | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/ub/ub_ummu.c b/hw/ub/ub_ummu.c index 5eff0c1f6ed..23f2c6c7985 100644 --- a/hw/ub/ub_ummu.c +++ b/hw/ub/ub_ummu.c @@ -918,7 +918,9 @@ static void ummu_glb_int_enable(UMMUState *u, UMMUUSIVectorType type) KVMRouteChange route_change; USIMessage msg; uint32_t interrupt_id = UMMU_INTERRUPT_ID; - + if (!kvm_state) { + return; + } if (type == UMMU_USI_VECTOR_EVETQ) { msg = ummu_get_eventq_usi_message(u); } else { diff --git a/hw/vfio/ub.c b/hw/vfio/ub.c index 1f0d511bc0d..ab2beea4929 100644 --- a/hw/vfio/ub.c +++ b/hw/vfio/ub.c @@ -536,7 +536,7 @@ static int vfio_usi_vector_do_use(UBDevice *udev, uint16_t nr, USIMessage *msg, vfio_update_kvm_usi_virq(vector, *msg, udev); } } else { - if (msg) { + if (msg && kvm_state) { vfio_route_change = kvm_irqchip_begin_route_changes(kvm_state); vfio_add_kvm_usi_virq(vdev, vector, nr); kvm_irqchip_commit_route_changes(&vfio_route_change); @@ -1283,4 +1283,4 @@ static void register_vfio_ub_dev_types(void) type_register_static(&vfio_ub_dev_info); } -type_init(register_vfio_ub_dev_types) \ No newline at end of file +type_init(register_vfio_ub_dev_types) -- Gitee