public inbox for qemu-devel@nongnu.org
 help / color / mirror / Atom feed
From: "Hao, Xudong" <xudong.hao@intel.com>
To: Ani Sinha <anisinha@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>
Cc: Sourav Poddar <souravpoddar93042@gmail.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: RE: [PATCH for-11.0 v2] hw/hyperv: fix SynIC not initialized for CPUs after the first
Date: Mon, 23 Mar 2026 13:28:06 +0000	[thread overview]
Message-ID: <DM4PR11MB5278ABAD62281FC367F3E4CD884BA@DM4PR11MB5278.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20260320154752.204725-1-anisinha@redhat.com>


> -----Original Message-----
> From: Ani Sinha <anisinha@redhat.com>
> Sent: Friday, March 20, 2026 11:48 PM
> To: Paolo Bonzini <pbonzini@redhat.com>; Marcelo Tosatti
> <mtosatti@redhat.com>
> Cc: Sourav Poddar <souravpoddar93042@gmail.com>; Hao, Xudong
> <xudong.hao@intel.com>; Ani Sinha <anisinha@redhat.com>; qemu-
> devel@nongnu.org; kvm@vger.kernel.org
> Subject: [PATCH for-11.0 v2] hw/hyperv: fix SynIC not initialized for CPUs after
> the first
> 
> From: Sourav Poddar <souravpoddar93042@gmail.com>
> 
> 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>
> ---
>  hw/hyperv/hyperv.c         | 5 +++++
>  include/hw/hyperv/hyperv.h | 1 +
>  target/i386/kvm/hyperv.c   | 2 +-
>  3 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c
> index 27e323a819..3d6212613e 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);
> +}
> +
>  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/hyperv.c b/target/i386/kvm/hyperv.c
> index bd3c26d02b..420c76b5ff 100644
> --- a/target/i386/kvm/hyperv.c
> +++ b/target/i386/kvm/hyperv.c
> @@ -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;
> --
> 2.52.0

Tested this patch and patch[1] together, KUT hyperv_connections and hyperv_synic test passed on Intel platforms Granite Rapids and Sierra Forest.

[1] i386/hyperv: add stubs for synic enablement https://lists.nongnu.org/archive/html/qemu-devel/2026-03/msg05955.html

Tested-by: Xudong Hao <xudong.hao@intel.com>



      reply	other threads:[~2026-03-23 13:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-20 15:47 [PATCH for-11.0 v2] hw/hyperv: fix SynIC not initialized for CPUs after the first Ani Sinha
2026-03-23 13:28 ` Hao, Xudong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM4PR11MB5278ABAD62281FC367F3E4CD884BA@DM4PR11MB5278.namprd11.prod.outlook.com \
    --to=xudong.hao@intel.com \
    --cc=anisinha@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=souravpoddar93042@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox