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: c4cf32fc63 ("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>
This commit is contained in:
Sourav Poddar
2026-03-20 21:17:52 +05:30
committed by Philippe Mathieu-Daudé
parent 04249f0f94
commit 4f7a06ec25
3 changed files with 7 additions and 1 deletions

View File

@@ -27,7 +27,7 @@ int hyperv_x86_synic_add(X86CPU *cpu)
int hyperv_enable_synic(X86CPU *cpu)
{
int ret = 0;
if (!hyperv_is_synic_enabled()) {
if (!hyperv_is_synic_present(CPU(cpu))) {
ret = hyperv_x86_synic_add(cpu);
}
return ret;