On Fri, Mar 20, 2026 at 4:20 PM Sourav Poddar
<[email protected]> wrote:
>
> 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.

You may want to rebase this on top of
fhttps://mail.gnu.org/archive/html/qemu-devel/2026-03/msg05998.html
and then fix hyperv_enable_synic()

>
> Fixes: c4cf32fc63f1 ("kvm/hyperv: add synic feature to CPU only if its not 
> enabled")
> Reported-by: Xudong Hao
> Signed-off-by: Sourav Poddar <[email protected]>
> ---
>  hw/hyperv/hyperv.c         | 5 +++++
>  include/hw/hyperv/hyperv.h | 1 +
>  target/i386/kvm/kvm.c      | 2 +-
>  3 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c
> index 27e323a819..ff53cbc699 100644
> --- a/hw/hyperv/hyperv.c
> +++ b/hw/hyperv/hyperv.c
> @@ -60,6 +60,11 @@ static SynICState *get_synic(CPUState *cs)
>      return SYNIC(object_resolve_path_component(OBJECT(cs), "synic"));
>  }
>
> +bool hyperv_is_synic_present(CPUState *cs)
> +{
> +    return get_synic(cs) != NULL;
> +}
> +
>  static void synic_update(SynICState *synic, bool sctl_enable,
>                           hwaddr msg_page_addr, hwaddr event_page_addr)
>  {
> diff --git a/include/hw/hyperv/hyperv.h b/include/hw/hyperv/hyperv.h
> index 63a8b65278..23091301d0 100644
> --- a/include/hw/hyperv/hyperv.h
> +++ b/include/hw/hyperv/hyperv.h
> @@ -81,6 +81,7 @@ void hyperv_synic_reset(CPUState *cs);
>  void hyperv_synic_update(CPUState *cs, bool enable,
>                           hwaddr msg_page_addr, hwaddr event_page_addr);
>  bool hyperv_is_synic_enabled(void);
> +bool hyperv_is_synic_present(CPUState *cs);
>
>  /*
>   * Process HVCALL_RESET_DEBUG_SESSION hypercall.
> diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
> index a29f757c16..f5faf32606 100644
> --- a/target/i386/kvm/kvm.c
> +++ b/target/i386/kvm/kvm.c
> @@ -1754,7 +1754,7 @@ static int hyperv_init_vcpu(X86CPU *cpu)
>              return ret;
>          }
>
> -        if (!hyperv_is_synic_enabled()) {
> +        if (!hyperv_is_synic_present(CPU(cpu))) {
>              ret = hyperv_x86_synic_add(cpu);
>              if (ret < 0) {
>                  error_report("failed to create HyperV SynIC: %s",
> --
> 2.53.0
>


Reply via email to