@samitouri / QOSamiQemu / commits / 4f7a06ec25

hw/hyperv: Fix SynIC not initialized except on first vCPU

hyperv_is_synic_enabled() is a global flag that returns true after the first CPU initializes SynIC. With -smp N, all subsequent CPUs skip hyperv_x86_synic_add(), leaving them without a synic object. This causes get_synic() to return NULL, making hyperv_sint_route_new() fail and triggering an assertion crash in hyperv_testdev. Fix by introducing hyperv_is_synic_present() which checks per-CPU whether a synic object is already attached instead of using the global flag. Fixes: c4cf32fc63f1 ("kvm/hyperv: add synic feature to CPU only if its not enabled") Reported-by: Xudong Hao <xudong.hao@intel.com> Co-authored-by: Ani Sinha <anisinha@redhat.com> Signed-off-by: Sourav Poddar <souravpoddar93042@gmail.com> Tested-by: Xudong Hao <xudong.hao@intel.com> Message-ID: <20260320154752.204725-1-anisinha@redhat.com> [PMD: Reworded subject] Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Sourav Poddar committed Mar 20, 2026 at 21:17 UTC 4f7a06ec25f84605c706cd1050c90a1cf0e76f44
3 files changed +7 -1
hw/hyperv/hyperv.c
+5
@@ -60,6 +60,11 @@ static SynICState *get_synic(CPUState *cs)
60 return SYNIC(object_resolve_path_component(OBJECT(cs), "synic"));
61 }
62
63 +bool hyperv_is_synic_present(CPUState *cs)
64 +{
65 + return get_synic(cs);
66 +}
67 +
68 static void synic_update(SynICState *synic, bool sctl_enable,
69 hwaddr msg_page_addr, hwaddr event_page_addr)
70 {
include/hw/hyperv/hyperv.h
+1
@@ -81,6 +81,7 @@ void hyperv_synic_reset(CPUState *cs);
81 void hyperv_synic_update(CPUState *cs, bool enable,
82 hwaddr msg_page_addr, hwaddr event_page_addr);
83 bool hyperv_is_synic_enabled(void);
84 +bool hyperv_is_synic_present(CPUState *cs);
85
86 /*
87 * Process HVCALL_RESET_DEBUG_SESSION hypercall.
target/i386/kvm/hyperv.c
+1 -1
@@ -27,7 +27,7 @@ int hyperv_x86_synic_add(X86CPU *cpu)
27 int hyperv_enable_synic(X86CPU *cpu)
28 {
29 int ret = 0;
30 - if (!hyperv_is_synic_enabled()) {
30 + if (!hyperv_is_synic_present(CPU(cpu))) {
31 ret = hyperv_x86_synic_add(cpu);
32 }
33 return ret;