public inbox for qemu-devel@nongnu.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PULL 15/27] hw/hyperv: Fix SynIC not initialized except on first vCPU
Date: Mon, 23 Mar 2026 17:52:06 +0100	[thread overview]
Message-ID: <20260323165218.96607-16-philmd@linaro.org> (raw)
In-Reply-To: <20260323165218.96607-1-philmd@linaro.org>

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>
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>
---
 include/hw/hyperv/hyperv.h | 1 +
 hw/hyperv/hyperv.c         | 5 +++++
 target/i386/kvm/hyperv.c   | 2 +-
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/hw/hyperv/hyperv.h b/include/hw/hyperv/hyperv.h
index 63a8b65278f..23091301d06 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/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c
index aa278b179e6..a42c2850e35 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/target/i386/kvm/hyperv.c b/target/i386/kvm/hyperv.c
index bd3c26d02b5..420c76b5ff5 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.53.0



  parent reply	other threads:[~2026-03-23 16:54 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-23 16:51 [PULL 00/27] Misc HW patches for 2026-03-23 Philippe Mathieu-Daudé
2026-03-23 16:51 ` [PULL 01/27] hw/riscv: Mark RISC-V specific peripherals as little-endian Philippe Mathieu-Daudé
2026-03-23 16:51 ` [PULL 02/27] hw/cxl: Use HPA in cxl_cfmws_find_device() rather than offset in window Philippe Mathieu-Daudé
2026-03-23 16:51 ` [PULL 03/27] hw/char/virtio-console: clear dangling GLib event source tag Philippe Mathieu-Daudé
2026-03-23 16:51 ` [PULL 04/27] hw/i3c/dw-i3c: Fix uninitialized data use in short transfer Philippe Mathieu-Daudé
2026-03-23 16:51 ` [PULL 05/27] hw/core/loader: fix error handling for load_image_targphys callers Philippe Mathieu-Daudé
2026-03-23 16:51 ` [PULL 06/27] hw/core/loader: fix error handling for get_image_size callers Philippe Mathieu-Daudé
2026-03-23 16:51 ` [PULL 07/27] util/event_notifier: fix error handling for event_notifier_init callers Philippe Mathieu-Daudé
2026-03-23 16:51 ` [PULL 08/27] hw/pci/msix: fix error handling for msix_init callers Philippe Mathieu-Daudé
2026-03-23 16:52 ` [PULL 09/27] hw/i386/pc_sysfw: stub out x86_firmware_configure Philippe Mathieu-Daudé
2026-03-23 16:52 ` [PULL 10/27] hw/i386/hyperv: add stubs for synic enablement Philippe Mathieu-Daudé
2026-03-23 16:52 ` [PULL 11/27] hw/cxl: Respect Media Operation max ops discovery semantics Philippe Mathieu-Daudé
2026-03-23 16:52 ` [PULL 12/27] hw/cxl: Exclude Discovery from Media Operation Discovery output Philippe Mathieu-Daudé
2026-03-23 16:52 ` [PULL 13/27] backends/iommufd: report error when /dev/iommu is not available Philippe Mathieu-Daudé
2026-03-23 16:52 ` [PULL 14/27] hw/vfio/iommufd: report hint to user when vfio-dev/vfio*/dev is missing Philippe Mathieu-Daudé
2026-03-23 16:52 ` Philippe Mathieu-Daudé [this message]
2026-03-23 16:52 ` [PULL 16/27] hw/usb/hcd-ohci: check for MPS=0 to avoid infinite loop Philippe Mathieu-Daudé
2026-03-23 16:52 ` [PULL 17/27] ati-vga: Fix colors when frame buffer endianness does not match host Philippe Mathieu-Daudé
2026-03-24 19:06   ` Peter Maydell
2026-03-24 20:21     ` BALATON Zoltan
2026-03-23 16:52 ` [PULL 18/27] ati-vga: Also switch mode on HW cursor enable bit change Philippe Mathieu-Daudé
2026-03-23 16:52 ` [PULL 19/27] ati-vga: Do not add crtc offset to src and dst data address Philippe Mathieu-Daudé
2026-03-23 16:52 ` [PULL 20/27] ati-vga: Avoid warnings about sign extension Philippe Mathieu-Daudé
2026-03-23 16:52 ` [PULL 21/27] ati-vga: Fix display updates in non-32 bit modes Philippe Mathieu-Daudé
2026-03-23 16:52 ` [PULL 22/27] ati-vga: Add work around for fuloong2e Philippe Mathieu-Daudé
2026-03-23 16:52 ` [PULL 23/27] ati-vga: Simplify pointer image handling Philippe Mathieu-Daudé
2026-03-23 16:52 ` [PULL 24/27] ati-vga: Make sure hardware cursor data is within vram Philippe Mathieu-Daudé
2026-03-23 16:52 ` [PULL 25/27] hw/net/ftgmac100: Improve DMA error handling Philippe Mathieu-Daudé
2026-03-24  8:03   ` Cédric Le Goater
2026-03-24 19:21     ` Philippe Mathieu-Daudé
2026-03-24 21:59       ` Cédric Le Goater
2026-03-23 16:52 ` [PULL 26/27] monitor: Correctly display virtual addresses while dumping memory Philippe Mathieu-Daudé
2026-03-23 16:52 ` [PULL 27/27] hw/hyperv: add QEMU_PACKED to uapi structs Philippe Mathieu-Daudé
2026-03-24 10:08 ` [PULL 00/27] Misc HW patches for 2026-03-23 Peter Maydell

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=20260323165218.96607-16-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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