Skip to contentSkip to conversation

Misc HW patches for 2025-11-25

GIT PULL Applied Philippe Mathieu-Daudé 2 participants 11 messages Nov 25, 2025 Arm/Aspeed machine support

lore
Share & tools
lore
#0 lore raw

The following changes since commit a8d023be622cab21e90bca8d9618068f0e49b74b:

Merge tag 'for-upstream' of https://repo.or.cz/qemu/kevin into staging (2025-11-25 10:25:16 -0800)

are available in the Git repository at:

https://github.com/philmd/qemu.git tags/hw-misc-20251125

for you to fetch changes up to 57756aa01fe52c50d655929c43d9a80f8214cf1a:

hw/aspeed/{xdma, rtc, sdhci}: Fix endianness to DEVICE_LITTLE_ENDIAN (2025-11-25 22:45:30 +0100)

----------------------------------------------------------------
Misc HW patches

Few fixes in hw/; also including qtest and replay fixes.
----------------------------------------------------------------

Cédric Le Goater (1):
hw/aspeed/{xdma, rtc, sdhci}: Fix endianness to DEVICE_LITTLE_ENDIAN

Markus Armbruster (3):
hw/usb: Convert to qemu_create() for a better error message hw/scsi: Use error_setg_file_open() for a better error message hw/virtio: Use error_setg_file_open() for a better error message

Peter Maydell (3):
qtest: Allow and ignore blank lines in input hw/pci: Make msix_init take a uint32_t for nentries
replay: Improve assert in replay_char_read_all_load()

Peter Xu (1):
hw/core/machine: Provide a description for aux-ram-share property

Zhao Liu (1):
docs/deprecated: Remove undeprecated SMP description

 docs/about/deprecated.rst | 14 --------------
 include/hw/pci/msix.h     |  4 ++--
 hw/core/machine.c         |  2 ++
 hw/misc/aspeed_xdma.c     |  2 +-
 hw/pci/msix.c             | 10 ++++++++--
 hw/rtc/aspeed_rtc.c       |  2 +-
 hw/scsi/vhost-scsi.c      |  3 +--
 hw/sd/aspeed_sdhci.c      |  2 +-
 hw/usb/bus.c              |  5 ++---
 hw/virtio/vhost-vsock.c   |  3 +--
 replay/replay-char.c      |  2 +-
 system/qtest.c            |  9 ++++++++-
 12 files changed, 28 insertions(+), 30 deletions(-)
Signature · 1 line
2.51.0
#1 lore raw

[PULL 2/9] hw/pci: Make msix_init take a uint32_t for nentries

From: Peter Maydell <[email protected]>

msix_init() and msix_init_exclusive_bar() take an "unsigned short" argument for the number of MSI-X vectors to try to use. This is big enough for the maximum permitted number of vectors, which is 2048. Unfortunately, we have several devices (most notably virtio) which allow the user to specify the desired number of vectors, and which use uint32_t properties for this. If the user sets the property to a value that is too big for a uint16_t, the value will be truncated when it is passed to msix_init(), and msix_init() may then return success if the truncated value is a valid one.

The resulting mismatch between the number of vectors the msix code thinks the device has and the number of vectors the device itself thinks it has can cause assertions, such as the one in issue 2631, where "-device virtio-mouse-pci,vectors=19923041" is interpreted by msix as "97 vectors" and by the virtio-pci layer as "19923041 vectors"; a guest attempt to access vector 97 thus passes the virtio-pci bounds checking and hits an essertion in msix_vector_use().

Avoid this by making msix_init() and its wrapper function msix_init_exclusive_bar() take the number of vectors as a uint32_t. The erroneous command line will now produce the warning

qemu-system-i386: -device virtio-mouse-pci,vectors=19923041:
warning: unable to init msix vectors to 19923041

and proceed without crashing. (The virtio device warns and falls back to not using MSIX, rather than complaining that the option is not a valid value this is the same as the existing behaviour for values that are beyond the MSI-X maximum possible value but fit into a 16-bit integer, like 2049.)

To ensure this doesn't result in potential overflows in calculation of the BAR size in msix_init_exclusive_bar(), we duplicate the nentries error-check from msix_init() at the top of msix_init_exclusive_bar(), so we know nentries is sane before we start using it.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2631

Message-ID: <[email protected]>

---
 include/hw/pci/msix.h |  4 ++--
 hw/pci/msix.c         | 10 ++++++++--
 2 files changed, 10 insertions(+), 4 deletions(-)
include/hw/pci/msix.h +2 -2
index 11ef9454c13..551a2bcfe73 100644
@@ -7,12 +7,12 @@
 
 void msix_set_message(PCIDevice *dev, int vector, MSIMessage msg);
 MSIMessage msix_get_message(PCIDevice *dev, unsigned int vector);
-int msix_init(PCIDevice *dev, unsigned short nentries,
+int msix_init(PCIDevice *dev, uint32_t nentries,
               MemoryRegion *table_bar, uint8_t table_bar_nr,
               unsigned table_offset, MemoryRegion *pba_bar,
               uint8_t pba_bar_nr, unsigned pba_offset, uint8_t cap_pos,
               Error **errp);
-int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
+int msix_init_exclusive_bar(PCIDevice *dev, uint32_t nentries,
                             uint8_t bar_nr, Error **errp);
 
 void msix_write_config(PCIDevice *dev, uint32_t address, uint32_t val, int len);
hw/pci/msix.c +8 -2
index 8c7f6709e2a..b35476d0577 100644
@@ -318,7 +318,7 @@ static void msix_mask_all(struct PCIDevice *dev, unsigned nentries)
  * also means a programming error, except device assignment, which can check
  * if a real HW is broken.
  */
-int msix_init(struct PCIDevice *dev, unsigned short nentries,
+int msix_init(struct PCIDevice *dev, uint32_t nentries,
               MemoryRegion *table_bar, uint8_t table_bar_nr,
               unsigned table_offset, MemoryRegion *pba_bar,
               uint8_t pba_bar_nr, unsigned pba_offset, uint8_t cap_pos,
@@ -392,7 +392,7 @@ int msix_init(struct PCIDevice *dev, unsigned short nentries,
     return 0;
 }
 
-int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
+int msix_init_exclusive_bar(PCIDevice *dev, uint32_t nentries,
                             uint8_t bar_nr, Error **errp)
 {
     int ret;
@@ -401,6 +401,12 @@ int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
     uint32_t bar_pba_offset = bar_size / 2;
     uint32_t bar_pba_size = QEMU_ALIGN_UP(nentries, 64) / 8;
 
+    /* Sanity-check nentries before we use it in BAR size calculations */
+    if (nentries < 1 || nentries > PCI_MSIX_FLAGS_QSIZE + 1) {
+        error_setg(errp, "The number of MSI-X vectors is invalid");
+        return -EINVAL;
+    }
+
     /*
      * Migration compatibility dictates that this remains a 4k
      * BAR with the vector table in the lower half and PBA in
Signature · 1 line
2.51.0
#2 lore raw

[PULL 5/9] hw/scsi: Use error_setg_file_open() for a better error message

In reply to Philippe Mathieu-Daudé

From: Markus Armbruster <[email protected]>

The error message changes from

vhost-scsi: open vhost char device failed: REASON

to

Could not open '/dev/vhost-scsi': REASON

I think the exact file name is more useful to know than the file's purpose.

We could put back the "vhost-scsi: " prefix with error_prepend(). Not worth the bother.

Message-ID: <[email protected]>

---
 hw/scsi/vhost-scsi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/scsi/vhost-scsi.c +1 -2
index cdf405b0f86..239138c9316 100644
@@ -245,8 +245,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
     } else {
         vhostfd = open("/dev/vhost-scsi", O_RDWR);
         if (vhostfd < 0) {
-            error_setg(errp, "vhost-scsi: open vhost char device failed: %s",
-                       strerror(errno));
+            error_setg_file_open(errp, errno, "/dev/vhost-scsi");
             return;
         }
     }
Signature · 1 line
2.51.0
#3 lore raw

[PULL 3/9] docs/deprecated: Remove undeprecated SMP description

In reply to Philippe Mathieu-Daudé

From: Zhao Liu <[email protected]>

"Unsupported 'parameter=1' SMP configuration" was proposed to be deprecated in the commit 54c4ea8f3ae6 ("hw/core/machine-smp: Deprecate unsupported "parameter=1" SMP configurations").

But the related code was reverted later in the commit 9d7950edb0cd ("hw/core: allow parameter=1 for SMP topology on any machine").

Thus, this SMP behavior is still valid and is not actually deprecated.

Remove outdated document descriptions.

Message-ID: <[email protected]>

---
 docs/about/deprecated.rst | 14 --------------
 1 file changed, 14 deletions(-)
docs/about/deprecated.rst +0 -14
index 30ab72b2a4c..9386cffba26 100644
@@ -54,20 +54,6 @@ as short-form boolean values, and passed to plugins as ``arg_name=on``.
 However, short-form booleans are deprecated and full explicit ``arg_name=on``
 form is preferred.
 
-``-smp`` (Unsupported "parameter=1" SMP configurations) (since 9.0)
-'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
-
-Specified CPU topology parameters must be supported by the machine.
-
-In the SMP configuration, users should provide the CPU topology parameters that
-are supported by the target machine.
-
-However, historically it was allowed for users to specify the unsupported
-topology parameter as "1", which is meaningless. So support for this kind of
-configurations (e.g. -smp drawers=1,books=1,clusters=1 for x86 PC machine) is
-marked deprecated since 9.0, users have to ensure that all the topology members
-described with -smp are supported by the target machine.
-
 QEMU Machine Protocol (QMP) commands
 ------------------------------------
 
Signature · 1 line
2.51.0
#4 lore raw

[PULL 1/9] qtest: Allow and ignore blank lines in input

In reply to Philippe Mathieu-Daudé

From: Peter Maydell <[email protected]>

Currently the code that reads the qtest protocol commands insists that every input line has a command. If it receives a line with nothing but whitespace it will trip an assertion in qtest_process_command().

This is a little awkward for the case where we are feeding qtest a set of bug-reproduction commands via standard input or a file, because it means you need to be careful not to leave a blank line at the start or the end when cutting and pasting the command sequence from a bug report.

Change the code to allow and ignore blank lines in the input.

Message-ID: <[email protected]>

---
 system/qtest.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
system/qtest.c +8 -1
index cbeb7f37728..67e2385f4b0 100644
@@ -69,6 +69,9 @@ static void *qtest_server_send_opaque;
  * so clients should always handle many async messages before the response
  * comes in.
  *
+ * Extra ASCII space characters in command inputs are permitted and ignored.
+ * Lines containing only spaces are permitted and ignored.
+ *
  * Valid requests
  * ^^^^^^^^^^^^^^
  *
@@ -367,7 +370,11 @@ static void qtest_process_command(CharFrontend *chr, gchar **words)
         fprintf(qtest_log_fp, "\n");
     }
 
-    g_assert(command);
+    if (!command) {
+        /* Input line was blank: ignore it */
+        return;
+    }
+
     if (strcmp(words[0], "irq_intercept_out") == 0
         || strcmp(words[0], "irq_intercept_in") == 0) {
         DeviceState *dev;
Signature · 1 line
2.51.0
#5 lore raw

[PULL 4/9] hw/usb: Convert to qemu_create() for a better error message

In reply to Philippe Mathieu-Daudé

From: Markus Armbruster <[email protected]>

The error message changes from

open FILENAME failed

to

Could not create 'FILENAME': REASON

where REASON is the value of strerror(errno).

Message-ID: <[email protected]>

---
 hw/usb/bus.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
hw/usb/bus.c +2 -3
index 8dd2ce415eb..714e33989f4 100644
@@ -259,10 +259,9 @@ static void usb_qdev_realize(DeviceState *qdev, Error **errp)
     }
 
     if (dev->pcap_filename) {
-        int fd = qemu_open_old(dev->pcap_filename,
-                               O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, 0666);
+        int fd = qemu_create(dev->pcap_filename,
+                             O_WRONLY | O_TRUNC | O_BINARY, 0666, errp);
         if (fd < 0) {
-            error_setg(errp, "open %s failed", dev->pcap_filename);
             usb_qdev_unrealize(qdev);
             return;
         }
Signature · 1 line
2.51.0
#6 lore raw

[PULL 7/9] replay: Improve assert in replay_char_read_all_load()

In reply to Philippe Mathieu-Daudé

From: Peter Maydell <[email protected]>

In replay_char_read_all_load() we get a buffer and size from the replay log. We know the size has to fit an int because of how we write the log. However the way we assert this is wrong: we cast the size_t from replay_get_array() to an int and then check that it is non-negative. This misses cases where an over-large size is truncated into a positive value by the cast.

Replace the assertion with checking that the size is in-range before doing the cast.

Coverity complained about the possible overflow: CID 1643440.

Message-ID: <[email protected]>

---
 replay/replay-char.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
replay/replay-char.c +1 -1
index 81dc416e988..4e58dd154af 100644
@@ -126,8 +126,8 @@ int replay_char_read_all_load(uint8_t *buf)
         int res;
         replay_get_array(buf, &size);
         replay_finish_event();
+        assert(size <= INT_MAX);
         res = (int)size;
-        assert(res >= 0);
         return res;
     } else if (replay_next_event_is(EVENT_CHAR_READ_ALL_ERROR)) {
         int res = replay_get_dword();
Signature · 1 line
2.51.0
#7 lore raw

[PULL 6/9] hw/virtio: Use error_setg_file_open() for a better error message

In reply to Philippe Mathieu-Daudé

From: Markus Armbruster <[email protected]>

The error message changes from

vhost-vsock: failed to open vhost device: REASON

to

Could not open '/dev/vhost-vsock': REASON

I think the exact file name is more useful to know than the file's purpose.

Message-ID: <[email protected]>

---
 hw/virtio/vhost-vsock.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/virtio/vhost-vsock.c +1 -2
index 107d88babea..7940b60d8a5 100644
@@ -153,8 +153,7 @@ static void vhost_vsock_device_realize(DeviceState *dev, Error **errp)
     } else {
         vhostfd = open("/dev/vhost-vsock", O_RDWR);
         if (vhostfd < 0) {
-            error_setg_errno(errp, errno,
-                             "vhost-vsock: failed to open vhost device");
+            error_setg_file_open(errp, errno, "/dev/vhost-vsock");
             return;
         }
 
Signature · 1 line
2.51.0
#8 lore raw

[PULL 9/9] hw/aspeed/{xdma, rtc, sdhci}: Fix endianness to DEVICE_LITTLE_ENDIAN

In reply to Philippe Mathieu-Daudé

From: Cédric Le Goater <[email protected]>

When the XDMA, RTC and SDHCI device models of the Aspeed SoCs were first introduced, their MMIO regions inherited of a DEVICE_NATIVE_ENDIAN endianness. It should be DEVICE_LITTLE_ENDIAN. Fix that.

Message-ID: <[email protected]>

---
 hw/misc/aspeed_xdma.c | 2 +-
 hw/rtc/aspeed_rtc.c   | 2 +-
 hw/sd/aspeed_sdhci.c  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
hw/misc/aspeed_xdma.c +1 -1
index cc03c422b0e..c448ad32ff2 100644
@@ -113,7 +113,7 @@ static void aspeed_xdma_write(void *opaque, hwaddr addr, uint64_t val,
 static const MemoryRegionOps aspeed_xdma_ops = {
     .read = aspeed_xdma_read,
     .write = aspeed_xdma_write,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+    .endianness = DEVICE_LITTLE_ENDIAN,
     .valid.min_access_size = 4,
     .valid.max_access_size = 4,
 };
hw/rtc/aspeed_rtc.c +1 -1
index c4feea23a0b..6793e253f47 100644
@@ -131,7 +131,7 @@ static void aspeed_rtc_reset(DeviceState *d)
 static const MemoryRegionOps aspeed_rtc_ops = {
     .read = aspeed_rtc_read,
     .write = aspeed_rtc_write,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+    .endianness = DEVICE_LITTLE_ENDIAN,
 };
 
 static const VMStateDescription vmstate_aspeed_rtc = {
hw/sd/aspeed_sdhci.c +1 -1
index fc38ad39ce1..f5c0c4956aa 100644
@@ -124,7 +124,7 @@ static void aspeed_sdhci_write(void *opaque, hwaddr addr, uint64_t val,
 static const MemoryRegionOps aspeed_sdhci_ops = {
     .read = aspeed_sdhci_read,
     .write = aspeed_sdhci_write,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+    .endianness = DEVICE_LITTLE_ENDIAN,
     .valid.min_access_size = 4,
     .valid.max_access_size = 4,
 };
Signature · 1 line
2.51.0
#9 lore raw

[PULL 8/9] hw/core/machine: Provide a description for aux-ram-share property

In reply to Philippe Mathieu-Daudé

From: Peter Xu <[email protected]>

It was forgotten when being introduced in commit 91792807d1 ("machine:
aux-ram-share option").

Message-ID: <[email protected]>

---
 hw/core/machine.c | 2 ++
 1 file changed, 2 insertions(+)
hw/core/machine.c +2 -0
index 06e0c9a179b..27372bb01ef 100644
@@ -1204,6 +1204,8 @@ static void machine_class_init(ObjectClass *oc, const void *data)
     object_class_property_add_bool(oc, "aux-ram-share",
                                    machine_get_aux_ram_share,
                                    machine_set_aux_ram_share);
+    object_class_property_set_description(oc, "aux-ram-share",
+        "Use anonymous shared memory for auxiliary guest RAMs");
 #endif
 
     object_class_property_add_bool(oc, "usb",
Signature · 1 line
2.51.0
#10 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 10 lines · Philippe Mathieu-Daudé

The following changes since commit a8d023be622cab21e90bca8d9618068f0e49b74b:

   Merge tag 'for-upstream' ofhttps://repo.or.cz/qemu/kevin into staging (2025-11-25 10:25:16 -0800)

are available in the Git repository at:

   https://github.com/philmd/qemu.git tags/hw-misc-20251125

for you to fetch changes up to 57756aa01fe52c50d655929c43d9a80f8214cf1a:

Quoted 7 lines
   hw/aspeed/{xdma, rtc, sdhci}: Fix endianness to DEVICE_LITTLE_ENDIAN (2025-11-25 22:45:30 +0100)

----------------------------------------------------------------
Misc HW patches

Few fixes in hw/; also including qtest and replay fixes.
----------------------------------------------------------------

Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/10.2 as appropriate.

r~