Skip to contentSkip to conversation

Misc HW patches for 2026-03-23

GIT PULL Applied Philippe Mathieu-Daudé 4 participants 34 messages Mar 23 – Mar 24

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

The following changes since commit eb153d8fd3be325a5aa7e1a6a73be8854eeaaf27:

Merge tag 'pull-target-arm-20260323' of https://gitlab.com/pm215/qemu into staging (2026-03-23 10:55:20 +0000)

are available in the Git repository at:

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

for you to fetch changes up to 070fc710251809c4d8d2a84f24527a174e843423:

hw/hyperv: add QEMU_PACKED to uapi structs (2026-03-23 17:50:50 +0100)

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

- Fix guest-triggerable abort in FTGMAC100 Gigabit Ethernet
- Fix uninitialized value in DesignWare I3C controller
- Clear dangling GLib event source tag in virtio-console
- Mark RISC-V specific peripherals as little-endian
- Correct virtual address formatting in monitor
- Improve error handling path in core loader
- Improve error hints in IOMMU FD
- Prevent hang in USB OHCI
- ATI VGA, HyperV & CXL fixes

----------------------------------------------------------------

Alireza Sanaee (1):
hw/cxl: Use HPA in cxl_cfmws_find_device() rather than offset in
window.

Ani Sinha (2):
hw/i386/pc_sysfw: stub out x86_firmware_configure hw/i386/hyperv: add stubs for synic enablement

BALATON Zoltan (8):
ati-vga: Fix colors when frame buffer endianness does not match host
ati-vga: Also switch mode on HW cursor enable bit change
ati-vga: Do not add crtc offset to src and dst data address
ati-vga: Avoid warnings about sign extension
ati-vga: Fix display updates in non-32 bit modes
ati-vga: Add work around for fuloong2e
ati-vga: Simplify pointer image handling
ati-vga: Make sure hardware cursor data is within vram

Cédric Le Goater (1):
hw/net/ftgmac100: Improve DMA error handling

Davidlohr Bueso (2):
hw/cxl: Respect Media Operation max ops discovery semantics hw/cxl: Exclude Discovery from Media Operation Discovery output

Jamin Lin (1):
hw/i3c/dw-i3c: Fix uninitialized data use in short transfer

Jenny Guanni Qu (1):
hw/usb/hcd-ohci: check for MPS=0 to avoid infinite loop

Magnus Kulke (1):
hw/hyperv: add QEMU_PACKED to uapi structs

Matthew Penney (1):
hw/char/virtio-console: clear dangling GLib event source tag

Philippe Mathieu-Daudé (2):
hw/riscv: Mark RISC-V specific peripherals as little-endian
monitor: Correctly display virtual addresses while dumping memory

Pierrick Bouvier (2):
backends/iommufd: report error when /dev/iommu is not available hw/vfio/iommufd: report hint to user when vfio-dev/vfio*/dev is
missing

Sourav Poddar (1):
hw/hyperv: Fix SynIC not initialized except on first vCPU

Trieu Huynh (4):
hw/core/loader: fix error handling for load_image_targphys callers hw/core/loader: fix error handling for get_image_size callers util/event_notifier: fix error handling for event_notifier_init
callers
hw/pci/msix: fix error handling for msix_init callers

 hw/display/ati_int.h           |  1 +
 include/hw/hyperv/hvgdk_mini.h | 35 ++++++++-----
 include/hw/hyperv/hvhdk.h      | 12 ++---
 include/hw/hyperv/hyperv.h     |  1 +
 target/i386/kvm/hyperv.h       |  1 +
 backends/iommufd.c             |  3 ++
 hw/alpha/dp264.c               |  2 +-
 hw/char/ibex_uart.c            |  2 +-
 hw/char/shakti_uart.c          |  2 +-
 hw/char/sifive_uart.c          |  2 +-
 hw/char/virtio-console.c       |  2 +-
 hw/cxl/cxl-host.c              |  7 +--
 hw/cxl/cxl-mailbox-utils.c     | 27 +++++------
 hw/display/ati.c               | 89 +++++++++++++++++++---------------
 hw/display/ati_2d.c            | 47 ++++++++++++------
 hw/hppa/machine.c              |  2 +-
 hw/hyperv/hyperv.c             |  9 +++-
 hw/hyperv/vmbus.c              |  4 +-
 hw/i386/pc_sysfw.c             | 32 ------------
 hw/i386/pc_sysfw_ovmf-stubs.c  |  5 ++
 hw/i386/pc_sysfw_ovmf.c        | 33 +++++++++++++
 hw/i3c/dw-i3c.c                | 14 ++++--
 hw/ipmi/ipmi_bmc_sim.c         |  2 +
 hw/m68k/next-cube.c            | 11 ++++-
 hw/m68k/q800.c                 |  2 +-
 hw/m68k/virt.c                 |  2 +-
 hw/microblaze/boot.c           |  3 +-
 hw/mips/fuloong2e.c            |  1 +
 hw/misc/sifive_e_aon.c         |  2 +-
 hw/misc/sifive_e_prci.c        |  2 +-
 hw/misc/sifive_u_otp.c         |  2 +-
 hw/misc/sifive_u_prci.c        |  2 +-
 hw/net/ftgmac100.c             | 10 +++-
 hw/net/igbvf.c                 |  2 +-
 hw/net/rocker/rocker.c         |  2 +-
 hw/pci/msix.c                  |  2 +-
 hw/remote/proxy.c              | 15 +++++-
 hw/riscv/riscv-iommu.c         |  2 +-
 hw/scsi/megasas.c              | 16 ++++--
 hw/sd/cadence_sdhci.c          |  2 +-
 hw/timer/ibex_timer.c          |  2 +-
 hw/timer/sifive_pwm.c          |  2 +-
 hw/usb/hcd-ohci.c              | 11 +++++
 hw/usb/hcd-xhci-pci.c          | 16 ++++--
 hw/vfio/ap.c                   |  2 +-
 hw/vfio/ccw.c                  |  2 +-
 hw/vfio/iommufd.c              |  5 +-
 hw/vfio/pci-quirks.c           |  2 +-
 hw/vfio/pci.c                  |  2 +-
 hw/virtio/vhost-vdpa.c         |  4 +-
 monitor/hmp-cmds.c             |  2 +-
 target/i386/kvm/hyperv-stub.c  |  5 ++
 target/i386/kvm/hyperv.c       |  9 ++++
 target/i386/kvm/kvm.c          | 12 ++---
 54 files changed, 305 insertions(+), 183 deletions(-)
Signature · 1 line
2.53.0
#1 lore raw

[PULL 01/27] hw/riscv: Mark RISC-V specific peripherals as little-endian

These devices are only used by the RISC-V targets, which are only built as little-endian. Therefore the DEVICE_NATIVE_ENDIAN definition expand to DEVICE_LITTLE_ENDIAN (besides, the DEVICE_BIG_ENDIAN case isn't tested). Simplify directly using DEVICE_LITTLE_ENDIAN.

Message-Id: <[email protected]>

---
 hw/char/ibex_uart.c     | 2 +-
 hw/char/shakti_uart.c   | 2 +-
 hw/char/sifive_uart.c   | 2 +-
 hw/misc/sifive_e_aon.c  | 2 +-
 hw/misc/sifive_e_prci.c | 2 +-
 hw/misc/sifive_u_otp.c  | 2 +-
 hw/misc/sifive_u_prci.c | 2 +-
 hw/riscv/riscv-iommu.c  | 2 +-
 hw/sd/cadence_sdhci.c   | 2 +-
 hw/timer/ibex_timer.c   | 2 +-
 hw/timer/sifive_pwm.c   | 2 +-
 11 files changed, 11 insertions(+), 11 deletions(-)
hw/char/ibex_uart.c +1 -1
index 127d219df3c..26ed1aea140 100644
@@ -470,7 +470,7 @@ static void fifo_trigger_update(void *opaque)
 static const MemoryRegionOps ibex_uart_ops = {
     .read = ibex_uart_read,
     .write = ibex_uart_write,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+    .endianness = DEVICE_LITTLE_ENDIAN,
     .impl.min_access_size = 4,
     .impl.max_access_size = 4,
 };
hw/char/shakti_uart.c +1 -1
index 2d1bc9cb8e2..d38920a03a0 100644
@@ -103,7 +103,7 @@ static void shakti_uart_write(void *opaque, hwaddr addr,
 static const MemoryRegionOps shakti_uart_ops = {
     .read = shakti_uart_read,
     .write = shakti_uart_write,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+    .endianness = DEVICE_LITTLE_ENDIAN,
     .impl = {.min_access_size = 1, .max_access_size = 4},
     .valid = {.min_access_size = 1, .max_access_size = 4},
 };
hw/char/sifive_uart.c +1 -1
index 4c30fbf5685..b4de662d616 100644
@@ -236,7 +236,7 @@ static void fifo_trigger_update(void *opaque)
 static const MemoryRegionOps sifive_uart_ops = {
     .read = sifive_uart_read,
     .write = sifive_uart_write,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+    .endianness = DEVICE_LITTLE_ENDIAN,
     .valid = {
         .min_access_size = 4,
         .max_access_size = 4
hw/misc/sifive_e_aon.c +1 -1
index e78f4f56725..ff2a7c18235 100644
@@ -250,7 +250,7 @@ sifive_e_aon_write(void *opaque, hwaddr addr,
 static const MemoryRegionOps sifive_e_aon_ops = {
     .read = sifive_e_aon_read,
     .write = sifive_e_aon_write,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+    .endianness = DEVICE_LITTLE_ENDIAN,
     .impl = {
         .min_access_size = 4,
         .max_access_size = 4
hw/misc/sifive_e_prci.c +1 -1
index 400664aabae..a4a60e7b406 100644
@@ -75,7 +75,7 @@ static void sifive_e_prci_write(void *opaque, hwaddr addr,
 static const MemoryRegionOps sifive_e_prci_ops = {
     .read = sifive_e_prci_read,
     .write = sifive_e_prci_write,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+    .endianness = DEVICE_LITTLE_ENDIAN,
     .valid = {
         .min_access_size = 4,
         .max_access_size = 4
hw/misc/sifive_u_otp.c +1 -1
index 7205374bc39..cececd4f7a8 100644
@@ -187,7 +187,7 @@ static void sifive_u_otp_write(void *opaque, hwaddr addr,
 static const MemoryRegionOps sifive_u_otp_ops = {
     .read = sifive_u_otp_read,
     .write = sifive_u_otp_write,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+    .endianness = DEVICE_LITTLE_ENDIAN,
     .valid = {
         .min_access_size = 4,
         .max_access_size = 4
hw/misc/sifive_u_prci.c +1 -1
index f51588623ab..4674d5925ea 100644
@@ -112,7 +112,7 @@ static void sifive_u_prci_write(void *opaque, hwaddr addr,
 static const MemoryRegionOps sifive_u_prci_ops = {
     .read = sifive_u_prci_read,
     .write = sifive_u_prci_write,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+    .endianness = DEVICE_LITTLE_ENDIAN,
     .valid = {
         .min_access_size = 4,
         .max_access_size = 4
hw/riscv/riscv-iommu.c +1 -1
index 225394ea838..c3c9ed6469a 100644
@@ -2375,7 +2375,7 @@ static MemTxResult riscv_iommu_mmio_read(void *opaque, hwaddr addr,
 static const MemoryRegionOps riscv_iommu_mmio_ops = {
     .read_with_attrs = riscv_iommu_mmio_read,
     .write_with_attrs = riscv_iommu_mmio_write,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+    .endianness = DEVICE_LITTLE_ENDIAN,
     .impl = {
         .min_access_size = 4,
         .max_access_size = 8,
hw/sd/cadence_sdhci.c +1 -1
index d576855a1a8..8476baf67fb 100644
@@ -122,7 +122,7 @@ static void cadence_sdhci_write(void *opaque, hwaddr addr, uint64_t val,
 static const MemoryRegionOps cadence_sdhci_ops = {
     .read = cadence_sdhci_read,
     .write = cadence_sdhci_write,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+    .endianness = DEVICE_LITTLE_ENDIAN,
     .impl = {
         .min_access_size = 4,
         .max_access_size = 4,
hw/timer/ibex_timer.c +1 -1
index ee186521893..0f12531934d 100644
@@ -234,7 +234,7 @@ static void ibex_timer_write(void *opaque, hwaddr addr,
 static const MemoryRegionOps ibex_timer_ops = {
     .read = ibex_timer_read,
     .write = ibex_timer_write,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+    .endianness = DEVICE_LITTLE_ENDIAN,
     .impl.min_access_size = 4,
     .impl.max_access_size = 4,
 };
hw/timer/sifive_pwm.c +1 -1
index 780eaa50799..4f4f566cd4b 100644
@@ -388,7 +388,7 @@ static void sifive_pwm_reset(DeviceState *dev)
 static const MemoryRegionOps sifive_pwm_ops = {
     .read = sifive_pwm_read,
     .write = sifive_pwm_write,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+    .endianness = DEVICE_LITTLE_ENDIAN,
 };
 
 static const VMStateDescription vmstate_sifive_pwm = {
Signature · 1 line
2.53.0
#2 lore raw

[PULL 02/27] hw/cxl: Use HPA in cxl_cfmws_find_device() rather than offset in window.

In reply to Philippe Mathieu-Daudé

From: Alireza Sanaee <[email protected]>

This function will shortly be used to help find if there is a route to a device, serving an HPA, under a particular fixed memory window. Rather than having that new use case subtract the base address in the caller, only to add it again in cxl_cfmws_find_device(), push the responsibility for calculating the HPA to the caller.

This also reduces the inconsistency in the meaning of the hwaddr addr parameter between this function and the calls made within it that access the HDM decoders that operating on HPA.

Message-ID: <[email protected]>

---
 hw/cxl/cxl-host.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
hw/cxl/cxl-host.c +2 -5
index f3479b19914..a94b893e999 100644
@@ -168,9 +168,6 @@ static PCIDevice *cxl_cfmws_find_device(CXLFixedWindow *fw, hwaddr addr)
     bool target_found;
     PCIDevice *rp, *d;
 
-    /* Address is relative to memory region. Convert to HPA */
-    addr += fw->base;
-
     rb_index = (addr / cxl_decode_ig(fw->enc_int_gran)) % fw->num_targets;
     hb = PCI_HOST_BRIDGE(fw->target_hbs[rb_index]->cxl_host_bridge);
     if (!hb || !hb->bus || !pci_bus_is_cxl(hb->bus)) {
@@ -254,7 +251,7 @@ static MemTxResult cxl_read_cfmws(void *opaque, hwaddr addr, uint64_t *data,
     CXLFixedWindow *fw = opaque;
     PCIDevice *d;
 
-    d = cxl_cfmws_find_device(fw, addr);
+    d = cxl_cfmws_find_device(fw, addr + fw->base);
     if (d == NULL) {
         *data = 0;
         /* Reads to invalid address return poison */
@@ -271,7 +268,7 @@ static MemTxResult cxl_write_cfmws(void *opaque, hwaddr addr,
     CXLFixedWindow *fw = opaque;
     PCIDevice *d;
 
-    d = cxl_cfmws_find_device(fw, addr);
+    d = cxl_cfmws_find_device(fw, addr + fw->base);
     if (d == NULL) {
         /* Writes to invalid address are silent */
         return MEMTX_OK;
Signature · 1 line
2.53.0
#3 lore raw

[PULL 04/27] hw/i3c/dw-i3c: Fix uninitialized data use in short transfer

In reply to Philippe Mathieu-Daudé

From: Jamin Lin <[email protected]>

Coverity reports that dw_i3c_short_transfer() may pass an uninitialized buffer to dw_i3c_send().

The immediate cause is the use of data[len] += arg.byte0, which reads from an uninitialized element of the buffer. Replace this with a simple assignment.

Additionally, avoid calling dw_i3c_send() when the constructed payload length is zero. In that case the transfer has no data phase, so the controller can transition to the idle state directly.

This resolves the Coverity UNINIT warning and clarifies the handling of zero-length short transfers.

Resolves: Coverity CID 1645555

Message-ID: <[email protected]>

---
 hw/i3c/dw-i3c.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
hw/i3c/dw-i3c.c +10 -4
index e9bdfd6af2a..d87d42be891 100644
@@ -1213,7 +1213,7 @@ static void dw_i3c_short_transfer(DWI3C *s, DWI3CTransferCmd cmd,
          * ignored.
          */
         if (cmd.dbp) {
-            data[len] += arg.byte0;
+            data[len] = arg.byte0;
             len++;
         }
     }
@@ -1228,10 +1228,16 @@ static void dw_i3c_short_transfer(DWI3C *s, DWI3CTransferCmd cmd,
         len++;
     }
 
-    if (dw_i3c_send(s, data, len, &bytes_sent, is_i2c)) {
-        err = DW_I3C_RESP_QUEUE_ERR_I2C_NACK;
+    if (len > 0) {
+        if (dw_i3c_send(s, data, len, &bytes_sent, is_i2c)) {
+            err = DW_I3C_RESP_QUEUE_ERR_I2C_NACK;
+        } else {
+            /* Only go to an idle state on a successful transfer. */
+            ARRAY_FIELD_DP32(s->regs, PRESENT_STATE, CM_TFR_ST_STATUS,
+                             DW_I3C_TRANSFER_STATE_IDLE);
+        }
     } else {
-        /* Only go to an idle state on a successful transfer. */
+        /* No payload bytes for this short transfer. */
         ARRAY_FIELD_DP32(s->regs, PRESENT_STATE, CM_TFR_ST_STATUS,
                          DW_I3C_TRANSFER_STATE_IDLE);
     }
Signature · 1 line
2.53.0
#4 lore raw

[PULL 03/27] hw/char/virtio-console: clear dangling GLib event source tag

In reply to Philippe Mathieu-Daudé

From: Matthew Penney <[email protected]>

Clear dangling GLib event source tag when virtio-console is unrealized. This prevents a stale tag from being used, and maintains consistency with the rest of virtio-console.

Message-ID: <[email protected]>

---
 hw/char/virtio-console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/char/virtio-console.c +1 -1
index 25db0f019b8..efe7cd6772e 100644
@@ -257,7 +257,7 @@ static void virtconsole_unrealize(DeviceState *dev)
     VirtConsole *vcon = VIRTIO_CONSOLE(dev);
 
     if (vcon->watch) {
-        g_source_remove(vcon->watch);
+        g_clear_handle_id(&vcon->watch, g_source_remove);
     }
 }
 
Signature · 1 line
2.53.0
#5 lore raw

[PULL 05/27] hw/core/loader: fix error handling for load_image_targphys callers

In reply to Philippe Mathieu-Daudé

From: Trieu Huynh <[email protected]>

Use QEMU's Error API to handle load_image_targphys() failures consistently across callers.

- Use &error_fatal for callers that previously passed NULL, ensuring the process exits early on failure instead of continuing in an invalid state.
- No functional changes.

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

Message-ID: <[email protected]>

---
 hw/alpha/dp264.c     |  2 +-
 hw/hppa/machine.c    |  2 +-
 hw/m68k/next-cube.c  | 11 +++++++++--
 hw/m68k/q800.c       |  2 +-
 hw/m68k/virt.c       |  2 +-
 hw/microblaze/boot.c |  3 ++-
 6 files changed, 15 insertions(+), 7 deletions(-)
hw/alpha/dp264.c +1 -1
index 98219f04569..2ab3c147471 100644
@@ -190,7 +190,7 @@ static void clipper_init(MachineState *machine)
             /* Put the initrd image as high in memory as possible.  */
             initrd_base = (ram_size - initrd_size) & TARGET_PAGE_MASK;
             load_image_targphys(initrd_filename, initrd_base,
-                                ram_size - initrd_base, NULL);
+                                ram_size - initrd_base, &error_fatal);
 
             address_space_stq_le(&address_space_memory, param_offset + 0x100,
                                  initrd_base + 0xfffffc0000000000ULL,
hw/hppa/machine.c +1 -1
index 318ebfeee46..3663bac53bd 100644
@@ -527,7 +527,7 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
             }
 
             load_image_targphys(initrd_filename, initrd_base, initrd_size,
-                                NULL);
+                                &error_fatal);
             cpu[0]->env.initrd_base = initrd_base;
             cpu[0]->env.initrd_end  = initrd_base + initrd_size;
         }
hw/m68k/next-cube.c +9 -2
index 26177c7b867..4bfe5bcf569 100644
@@ -1326,9 +1326,16 @@ static void next_cube_init(MachineState *machine)
     memory_region_init_alias(&m->rom2, NULL, "next.rom2", &m->rom, 0x0,
                              0x20000);
     memory_region_add_subregion(sysmem, 0x0, &m->rom2);
-    if (load_image_targphys(bios_name, 0x01000000, 0x20000, NULL) < 8) {
+    Error *local_err = NULL;
+    if (load_image_targphys(bios_name, 0x01000000, 0x20000, &local_err) < 8) {
         if (!qtest_enabled()) {
-            error_report("Failed to load firmware '%s'.", bios_name);
+            if (local_err) {
+                error_report_err(local_err);
+            } else {
+                error_report("Firmware image '%s' is too short.", bios_name);
+            }
+        } else {
+            error_free(local_err);
         }
     } else {
         uint8_t *ptr;
hw/m68k/q800.c +1 -1
index ded531394e6..c0d78eb7d71 100644
@@ -633,7 +633,7 @@ static void q800_machine_init(MachineState *machine)
 
             initrd_base = (ram_size - initrd_size) & TARGET_PAGE_MASK;
             load_image_targphys(initrd_filename, initrd_base,
-                                ram_size - initrd_base, NULL);
+                                ram_size - initrd_base, &error_fatal);
             BOOTINFO2(param_ptr, BI_RAMDISK, initrd_base,
                       initrd_size);
         } else {
hw/m68k/virt.c +1 -1
index e67900c727d..ffe6e234155 100644
@@ -292,7 +292,7 @@ static void virt_init(MachineState *machine)
 
             initrd_base = (ram_size - initrd_size) & TARGET_PAGE_MASK;
             load_image_targphys(initrd_filename, initrd_base,
-                                ram_size - initrd_base, NULL);
+                                ram_size - initrd_base, &error_fatal);
             BOOTINFO2(param_ptr, BI_RAMDISK, initrd_base,
                       initrd_size);
         } else {
hw/microblaze/boot.c +2 -1
index a6f9ebab90c..4ad5ffd34bd 100644
@@ -38,6 +38,7 @@
 #include "hw/core/loader.h"
 #include "elf.h"
 #include "qemu/cutils.h"
+#include "qapi/error.h"
 
 #include "boot.h"
 
@@ -171,7 +172,7 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, bool is_little_endian,
         /* Not an ELF image nor an u-boot image, try a RAW image.  */
         if (kernel_size < 0) {
             kernel_size = load_image_targphys(kernel_filename, ddr_base,
-                                              ramsize, NULL);
+                                              ramsize, &error_fatal);
             boot_info.bootstrap_pc = ddr_base;
             high = (ddr_base + kernel_size + 3) & ~3;
         }
Signature · 1 line
2.53.0
#6 lore raw

[PULL 06/27] hw/core/loader: fix error handling for get_image_size callers

In reply to Philippe Mathieu-Daudé

From: Trieu Huynh <[email protected]>

Check the return value of get_image_size() and report failures for non-mandatory file such as FRU image.

- Use ret < 0 to detect failures in getting image size.
- No functional changes.

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

Message-ID: <[email protected]>

---
 hw/ipmi/ipmi_bmc_sim.c | 2 ++
 1 file changed, 2 insertions(+)
hw/ipmi/ipmi_bmc_sim.c +2 -0
index 012e2ee4fe2..fd875491f55 100644
@@ -2561,6 +2561,8 @@ static void ipmi_fru_init(IPMIFru *fru)
             g_free(fru->data);
             fru->data = NULL;
         }
+    } else {
+        error_report("Could not get file size '%s'", fru->filename);
     }
 
 out:
Signature · 1 line
2.53.0
#7 lore raw

[PULL 07/27] util/event_notifier: fix error handling for event_notifier_init callers

In reply to Philippe Mathieu-Daudé

From: Trieu Huynh <[email protected]>

Check return value of event_notifier_init() and return early on failure instead of continuing with invalid state.
- Use ret < 0 to handle negative return value.
- No functional changes.

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

Message-ID: <[email protected]>

---
 hw/hyperv/hyperv.c     |  4 ++--
 hw/hyperv/vmbus.c      |  4 ++--
 hw/remote/proxy.c      | 15 +++++++++++++--
 hw/vfio/ap.c           |  2 +-
 hw/vfio/ccw.c          |  2 +-
 hw/vfio/pci-quirks.c   |  2 +-
 hw/vfio/pci.c          |  2 +-
 hw/virtio/vhost-vdpa.c |  4 ++--
 8 files changed, 23 insertions(+), 12 deletions(-)
hw/hyperv/hyperv.c +2 -2
index 27e323a8196..aa278b179e6 100644
@@ -439,7 +439,7 @@ HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint,
         sint_route->staged_msg->cb_data = cb_data;
 
         r = event_notifier_init(ack_notifier, false);
-        if (r) {
+        if (r < 0) {
             goto cleanup_err_sint;
         }
         event_notifier_set_handler(ack_notifier, sint_ack_handler);
@@ -453,7 +453,7 @@ HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint,
 
     /* We need to setup a GSI for this SintRoute */
     r = event_notifier_init(&sint_route->sint_set_notifier, false);
-    if (r) {
+    if (r < 0) {
         goto cleanup_err_sint;
     }
 
hw/hyperv/vmbus.c +2 -2
index 64abe4c4c16..5388f4277f3 100644
@@ -1432,7 +1432,7 @@ static void open_channel(VMBusChannel *chan)
         goto put_gpadl;
     }
 
-    if (event_notifier_init(&chan->notifier, 0)) {
+    if (event_notifier_init(&chan->notifier, 0) < 0) {
         goto put_gpadl;
     }
 
@@ -2450,7 +2450,7 @@ static void vmbus_realize(BusState *bus, Error **errp)
     }
 
     ret = event_notifier_init(&vmbus->notifier, 0);
-    if (ret != 0) {
+    if (ret < 0) {
         error_setg(errp, "event notifier failed to init with %d", ret);
         goto remove_msg_handler;
     }
hw/remote/proxy.c +13 -2
index 5081d67e7f4..e91566509f3 100644
@@ -52,9 +52,20 @@ static void setup_irqfd(PCIProxyDev *dev)
     PCIDevice *pci_dev = PCI_DEVICE(dev);
     MPQemuMsg msg;
     Error *local_err = NULL;
+    int ret = 0;
 
-    event_notifier_init(&dev->intr, 0);
-    event_notifier_init(&dev->resample, 0);
+    ret = event_notifier_init(&dev->intr, 0);
+    if (ret < 0) {
+        error_report("Failed to init intr notifier: %s", strerror(-ret));
+        return;
+    }
+
+    ret = event_notifier_init(&dev->resample, 0);
+    if (ret < 0) {
+        error_report("Failed to init resample notifier: %s", strerror(-ret));
+        event_notifier_cleanup(&dev->intr);
+        return;
+    }
 
     memset(&msg, 0, sizeof(MPQemuMsg));
     msg.cmd = MPQEMU_CMD_SET_IRQFD;
hw/vfio/ap.c +1 -1
index e58a0169af9..5c8f3056530 100644
@@ -180,7 +180,7 @@ static bool vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,
         return false;
     }
 
-    if (event_notifier_init(notifier, 0)) {
+    if (event_notifier_init(notifier, 0) < 0) {
         error_setg_errno(errp, errno,
                          "vfio: Unable to init event notifier for irq (%d)",
                          irq);
hw/vfio/ccw.c +1 -1
index 2251facb356..ce9c014e6a7 100644
@@ -418,7 +418,7 @@ static bool vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev,
         return false;
     }
 
-    if (event_notifier_init(notifier, 0)) {
+    if (event_notifier_init(notifier, 0) < 0) {
         error_setg_errno(errp, errno,
                          "vfio: Unable to init event notifier for irq (%d)",
                          irq);
hw/vfio/pci-quirks.c +1 -1
index 7b907b9360d..66e02b15a48 100644
@@ -318,7 +318,7 @@ static VFIOIOEventFD *vfio_ioeventfd_init(VFIOPCIDevice *vdev,
 
     ioeventfd = g_malloc0(sizeof(*ioeventfd));
 
-    if (event_notifier_init(&ioeventfd->e, 0)) {
+    if (event_notifier_init(&ioeventfd->e, 0) < 0) {
         g_free(ioeventfd);
         return NULL;
     }
hw/vfio/pci.c +1 -1
index 94c174a773f..1945751ffd4 100644
@@ -70,7 +70,7 @@ static bool vfio_notifier_init(VFIOPCIDevice *vdev, EventNotifier *e,
     }
 
     ret = event_notifier_init(e, 0);
-    if (ret) {
+    if (ret < 0) {
         error_setg_errno(errp, -ret, "vfio_notifier_init %s failed", name);
         return false;
     }
hw/virtio/vhost-vdpa.c +2 -2
index 2f8f11df869..9c7634e2439 100644
@@ -1075,13 +1075,13 @@ static int vhost_vdpa_svq_set_fds(struct vhost_dev *dev,
     int r;
 
     r = event_notifier_init(&svq->hdev_kick, 0);
-    if (r != 0) {
+    if (r < 0) {
         error_setg_errno(errp, -r, "Couldn't create kick event notifier");
         goto err_init_hdev_kick;
     }
 
     r = event_notifier_init(&svq->hdev_call, 0);
-    if (r != 0) {
+    if (r < 0) {
         error_setg_errno(errp, -r, "Couldn't create call event notifier");
         goto err_init_hdev_call;
     }
Signature · 1 line
2.53.0
#8 lore raw

[PULL 08/27] hw/pci/msix: fix error handling for msix_init callers

In reply to Philippe Mathieu-Daudé

From: Trieu Huynh <[email protected]>

Check return value of msix_init() and return early on failure instead of continuing with invalid state.
- Use ret < 0 to handle negative return value.
- Use errp parameter to handle failure instead of NULL.
- No functional changes.

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

Message-ID: <[email protected]>

---
 hw/net/igbvf.c         |  2 +-
 hw/net/rocker/rocker.c |  2 +-
 hw/pci/msix.c          |  2 +-
 hw/scsi/megasas.c      | 16 +++++++++++-----
 hw/usb/hcd-xhci-pci.c  | 16 +++++++++++-----
 5 files changed, 25 insertions(+), 13 deletions(-)
hw/net/igbvf.c +1 -1
index 48d56e43aca..9a165c7063e 100644
@@ -260,7 +260,7 @@ static void igbvf_pci_realize(PCIDevice *dev, Error **errp)
 
     ret = msix_init(dev, IGBVF_MSIX_VEC_NUM, &s->msix, IGBVF_MSIX_BAR_IDX, 0,
         &s->msix, IGBVF_MSIX_BAR_IDX, 0x2000, 0x70, errp);
-    if (ret) {
+    if (ret < 0) {
         return;
     }
 
hw/net/rocker/rocker.c +1 -1
index 4a7056bd45e..910dce901b6 100644
@@ -1228,7 +1228,7 @@ static int rocker_msix_init(Rocker *r, Error **errp)
                     &r->msix_bar,
                     ROCKER_PCI_MSIX_BAR_IDX, ROCKER_PCI_MSIX_PBA_OFFSET,
                     0, errp);
-    if (err) {
+    if (err < 0) {
         return err;
     }
 
hw/pci/msix.c +1 -1
index b35476d0577..1b23eaf1007 100644
@@ -432,7 +432,7 @@ int msix_init_exclusive_bar(PCIDevice *dev, uint32_t nentries,
                     0, &dev->msix_exclusive_bar,
                     bar_nr, bar_pba_offset,
                     0, errp);
-    if (ret) {
+    if (ret < 0) {
         return ret;
     }
 
hw/scsi/megasas.c +11 -5
index f62e420a91e..a29742d4493 100644
@@ -2380,11 +2380,17 @@ static void megasas_scsi_realize(PCIDevice *dev, Error **errp)
     memory_region_init_io(&s->queue_io, OBJECT(s), &megasas_queue_ops, s,
                           "megasas-queue", 0x40000);
 
-    if (megasas_use_msix(s) &&
-        msix_init(dev, 15, &s->mmio_io, b->mmio_bar, 0x2000,
-                  &s->mmio_io, b->mmio_bar, 0x3800, 0x68, NULL)) {
-        /* TODO: check msix_init's error, and should fail on msix=on */
-        s->msix = ON_OFF_AUTO_OFF;
+    if (megasas_use_msix(s)) {
+        ret = msix_init(dev, 15, &s->mmio_io, b->mmio_bar, 0x2000,
+                        &s->mmio_io, b->mmio_bar, 0x3800, 0x68,
+                        s->msix == ON_OFF_AUTO_ON ? errp : NULL);
+
+        if (ret < 0) {
+            if (s->msix == ON_OFF_AUTO_ON) {
+                return;
+            }
+            s->msix = ON_OFF_AUTO_OFF;
+        }
     }
 
     if (pci_is_express(dev)) {
hw/usb/hcd-xhci-pci.c +11 -5
index aa570506fc1..c5446a4a5e1 100644
@@ -173,11 +173,17 @@ static void usb_xhci_pci_realize(struct PCIDevice *dev, Error **errp)
     }
 
     if (s->msix != ON_OFF_AUTO_OFF) {
-        /* TODO check for errors, and should fail when msix=on */
-        msix_init(dev, s->xhci.numintrs,
-                  &s->xhci.mem, 0, OFF_MSIX_TABLE,
-                  &s->xhci.mem, 0, OFF_MSIX_PBA,
-                  0x90, NULL);
+        ret = msix_init(dev, s->xhci.numintrs,
+                        &s->xhci.mem, 0, OFF_MSIX_TABLE,
+                        &s->xhci.mem, 0, OFF_MSIX_PBA,
+                        0x90, s->msix == ON_OFF_AUTO_ON ? errp : NULL);
+
+        if (ret < 0) {
+            if (s->msix == ON_OFF_AUTO_ON) {
+                return;
+            }
+            s->msix = ON_OFF_AUTO_OFF;
+        }
     }
     s->xhci.as = pci_get_address_space(dev);
 }
Signature · 1 line
2.53.0
#9 lore raw

[PULL 09/27] hw/i386/pc_sysfw: stub out x86_firmware_configure

In reply to Philippe Mathieu-Daudé

From: Ani Sinha <[email protected]>

x86_firmware_configure requires ovmf support. Add a stub for this function call for cases where OVMF is not supported.

Message-ID: <[email protected]>

[PMD: Remove "kvm/tdx.h" include line]
---
 hw/i386/pc_sysfw.c            | 32 --------------------------------
 hw/i386/pc_sysfw_ovmf-stubs.c |  5 +++++
 hw/i386/pc_sysfw_ovmf.c       | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 38 insertions(+), 32 deletions(-)
hw/i386/pc_sysfw.c +0 -32
index d8a86756ca4..1a41a5972bd 100644
@@ -37,7 +37,6 @@
 #include "hw/block/flash.h"
 #include "system/kvm.h"
 #include "target/i386/sev.h"
-#include "kvm/tdx.h"
 
 #define FLASH_SECTOR_SIZE 4096
 
@@ -283,34 +282,3 @@ void pc_system_firmware_init(PCMachineState *pcms,
         }
     }
 }
-
-void x86_firmware_configure(hwaddr gpa, void *ptr, int size)
-{
-    int ret;
-
-    /*
-     * OVMF places a GUIDed structures in the flash, so
-     * search for them
-     */
-    pc_system_parse_ovmf_flash(ptr, size);
-
-    if (sev_enabled()) {
-
-        /* Copy the SEV metadata table (if it exists) */
-        pc_system_parse_sev_metadata(ptr, size);
-
-        ret = sev_es_save_reset_vector(ptr, size);
-        if (ret) {
-            error_report("failed to locate and/or save reset vector");
-            exit(1);
-        }
-
-        sev_encrypt_flash(gpa, ptr, size, &error_fatal);
-    } else if (is_tdx_vm()) {
-        ret = tdx_parse_tdvf(ptr, size);
-        if (ret) {
-            error_report("failed to parse TDVF for TDX VM");
-            exit(1);
-        }
-    }
-}
hw/i386/pc_sysfw_ovmf-stubs.c +5 -0
index aabe78b2710..b53906a0521 100644
@@ -24,3 +24,8 @@ void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, size_t flash_size)
 {
     g_assert_not_reached();
 }
+
+void x86_firmware_configure(hwaddr gpa, void *ptr, int size)
+{
+    g_assert_not_reached();
+}
hw/i386/pc_sysfw_ovmf.c +33 -0
index da947c3ca41..2f7d15c9f3e 100644
@@ -28,6 +28,8 @@
 #include "hw/i386/pc.h"
 #include "exec/target_page.h"
 #include "cpu.h"
+#include "target/i386/sev.h"
+#include "kvm/tdx.h"
 
 #define OVMF_TABLE_FOOTER_GUID "96b582de-1fb2-45f7-baea-a366c55a082d"
 
@@ -160,3 +162,34 @@ bool pc_system_ovmf_table_find(const char *entry, uint8_t **data,
     }
     return false;
 }
+
+void x86_firmware_configure(hwaddr gpa, void *ptr, int size)
+{
+    int ret;
+
+    /*
+     * OVMF places a GUIDed structures in the flash, so
+     * search for them
+     */
+    pc_system_parse_ovmf_flash(ptr, size);
+
+    if (sev_enabled()) {
+
+        /* Copy the SEV metadata table (if it exists) */
+        pc_system_parse_sev_metadata(ptr, size);
+
+        ret = sev_es_save_reset_vector(ptr, size);
+        if (ret) {
+            error_report("failed to locate and/or save reset vector");
+            exit(1);
+        }
+
+        sev_encrypt_flash(gpa, ptr, size, &error_fatal);
+    } else if (is_tdx_vm()) {
+        ret = tdx_parse_tdvf(ptr, size);
+        if (ret) {
+            error_report("failed to parse TDVF for TDX VM");
+            exit(1);
+        }
+    }
+}
Signature · 1 line
2.53.0
#10 lore raw

[PULL 10/27] hw/i386/hyperv: add stubs for synic enablement

In reply to Philippe Mathieu-Daudé

From: Ani Sinha <[email protected]>

Add a new call hyperv_enable_synic() that can be called whether or not CONFIG_HYPERV is enabled. This way genetic code in i396/kvm.c can call this function to enable synic for hyperv. For non-hyperv cases, the stub will be a noop.

Message-ID: <[email protected]>

---
 target/i386/kvm/hyperv.h      |  1 +
 target/i386/kvm/hyperv-stub.c |  5 +++++
 target/i386/kvm/hyperv.c      |  9 +++++++++
 target/i386/kvm/kvm.c         | 12 +++++-------
 4 files changed, 20 insertions(+), 7 deletions(-)
target/i386/kvm/hyperv.h +1 -0
index e45a4512fe9..a393a5d4283 100644
@@ -23,6 +23,7 @@ int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit);
 #endif
 
 int hyperv_x86_synic_add(X86CPU *cpu);
+int hyperv_enable_synic(X86CPU *cpu);
 void hyperv_x86_synic_reset(X86CPU *cpu);
 void hyperv_x86_synic_update(X86CPU *cpu);
 
target/i386/kvm/hyperv-stub.c +5 -0
index 5836f53c23b..767a4c7e1a1 100644
@@ -61,3 +61,8 @@ uint64_t hyperv_syndbg_query_options(void)
 {
     return 0;
 }
+
+int hyperv_enable_synic(X86CPU *cpu)
+{
+    return 0;
+}
target/i386/kvm/hyperv.c +9 -0
index f7a81bd2700..bd3c26d02b5 100644
@@ -24,6 +24,15 @@ int hyperv_x86_synic_add(X86CPU *cpu)
     return 0;
 }
 
+int hyperv_enable_synic(X86CPU *cpu)
+{
+    int ret = 0;
+    if (!hyperv_is_synic_enabled()) {
+        ret = hyperv_x86_synic_add(cpu);
+    }
+    return ret;
+}
+
 /*
  * All devices possibly using SynIC have to be reset before calling this to let
  * them remove their SINT routes first.
target/i386/kvm/kvm.c +5 -7
index a29f757c168..9e352882c8c 100644
@@ -1754,13 +1754,11 @@ static int hyperv_init_vcpu(X86CPU *cpu)
             return ret;
         }
 
-        if (!hyperv_is_synic_enabled()) {
-            ret = hyperv_x86_synic_add(cpu);
-            if (ret < 0) {
-                error_report("failed to create HyperV SynIC: %s",
-                             strerror(-ret));
-                return ret;
-            }
+        ret = hyperv_enable_synic(cpu);
+        if (ret < 0) {
+            error_report("failed to create HyperV SynIC: %s",
+                         strerror(-ret));
+            return ret;
         }
     }
 
Signature · 1 line
2.53.0
#11 lore raw

[PULL 11/27] hw/cxl: Respect Media Operation max ops discovery semantics

In reply to Philippe Mathieu-Daudé

From: Davidlohr Bueso <[email protected]>

The Discovery rejects requests where start_index + num_ops exceeds the total number of supported operations. Per CXL 4.0 Table 8-332, num_ops is the "Maximum number of Media Operation to return" - a maximum, not an exact count. The device should return up to that many entries, not reject the request.

Cap num_ops to the available entries from start_index instead of erroring the command.

Fixes 77a8e9fe0ecb ("hw/cxl/cxl-mailbox-utils: Add support for Media operations discovery commands cxl r3.2 (8.2.10.9.5.3)")

Message-ID: <[email protected]>

---
 hw/cxl/cxl-mailbox-utils.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)
hw/cxl/cxl-mailbox-utils.c +11 -14
index c83b5f90d4d..a5b70cd01c0 100644
@@ -2675,6 +2675,7 @@ static CXLRetCode media_operations_discovery(uint8_t *payload_in,
     } QEMU_PACKED *media_op_in_disc_pl = (void *)payload_in;
     struct media_op_discovery_out_pl *media_out_pl =
         (struct media_op_discovery_out_pl *)payload_out;
+    int total = ARRAY_SIZE(media_op_matrix);
     int num_ops, start_index, i;
     int count = 0;
 
@@ -2691,24 +2692,20 @@ static CXLRetCode media_operations_discovery(uint8_t *payload_in,
      * sub class command.
      */
     if (media_op_in_disc_pl->dpa_range_count ||
-        start_index + num_ops > ARRAY_SIZE(media_op_matrix)) {
+        start_index >= total) {
         return CXL_MBOX_INVALID_INPUT;
     }
 
     media_out_pl->dpa_range_granularity = CXL_CACHE_LINE_SIZE;
-    media_out_pl->total_supported_operations =
-                                     ARRAY_SIZE(media_op_matrix);
-    if (num_ops > 0) {
-        for (i = start_index; i < start_index + num_ops; i++) {
-            media_out_pl->entry[count].media_op_class =
-                    media_op_matrix[i].media_op_class;
-            media_out_pl->entry[count].media_op_subclass =
-                        media_op_matrix[i].media_op_subclass;
-            count++;
-            if (count == num_ops) {
-                break;
-            }
-        }
+    media_out_pl->total_supported_operations = total;
+
+    num_ops = MIN(num_ops, total - start_index);
+    for (i = 0; i < num_ops; i++) {
+        media_out_pl->entry[count].media_op_class =
+                media_op_matrix[start_index + i].media_op_class;
+        media_out_pl->entry[count].media_op_subclass =
+                media_op_matrix[start_index + i].media_op_subclass;
+        count++;
     }
 
     media_out_pl->num_of_supported_operations = count;
Signature · 1 line
2.53.0
#12 lore raw

[PULL 13/27] backends/iommufd: report error when /dev/iommu is not available

In reply to Philippe Mathieu-Daudé

From: Pierrick Bouvier <[email protected]>

In case current kernel does not support /dev/iommu, qemu will probably fail first because /sys/bus/pci/devices/*/vfio-dev/ is not present, since QEMU opens it before /dev/iommu.

Instead, report an error directly when completing an iommufd object, to inform user that kernel does not support it, with a hint about missing CONFIG_IOMMUFD. We can't do this from initialize as there is no way to return an error, and we don't want to abort at this step.

Message-ID: <[email protected]>

---
 backends/iommufd.c | 3 +++
 1 file changed, 3 insertions(+)
backends/iommufd.c +3 -0
index acfab907c03..e1fee16acf2 100644
@@ -82,6 +82,9 @@ static void iommufd_backend_complete(UserCreatable *uc, Error **errp)
         } else {
             cpr_save_fd(name, 0, be->fd);
         }
+    } else if (!g_file_test("/dev/iommu", G_FILE_TEST_EXISTS)) {
+        error_setg(errp, "/dev/iommu does not exist"
+                         " (is your kernel config missing CONFIG_IOMMUFD?)");
     }
 }
 
Signature · 1 line
2.53.0
#13 lore raw

[PULL 12/27] hw/cxl: Exclude Discovery from Media Operation Discovery output

In reply to Philippe Mathieu-Daudé

From: Davidlohr Bueso <[email protected]>

Per CXL 4.0 Table 8-331, the Discovery operation "returns a list of all Media Operations that the device supports, with the exception of the Discovery operation (Class=0, Subclass=0)."

Filter out Discovery entries when building the output list and adjust total_supported_operations accordingly.

Fixes 77a8e9fe0ecb ("hw/cxl/cxl-mailbox-utils: Add support for Media operations discovery commands cxl r3.2 (8.2.10.9.5.3)")

Message-ID: <[email protected]>

---
 hw/cxl/cxl-mailbox-utils.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
hw/cxl/cxl-mailbox-utils.c +5 -3
index a5b70cd01c0..d8ba7e86252 100644
@@ -2675,7 +2675,7 @@ static CXLRetCode media_operations_discovery(uint8_t *payload_in,
     } QEMU_PACKED *media_op_in_disc_pl = (void *)payload_in;
     struct media_op_discovery_out_pl *media_out_pl =
         (struct media_op_discovery_out_pl *)payload_out;
-    int total = ARRAY_SIZE(media_op_matrix);
+    int total = ARRAY_SIZE(media_op_matrix) - 1; /* exclude Discovery */
     int num_ops, start_index, i;
     int count = 0;
 
@@ -2701,10 +2701,12 @@ static CXLRetCode media_operations_discovery(uint8_t *payload_in,
 
     num_ops = MIN(num_ops, total - start_index);
     for (i = 0; i < num_ops; i++) {
+        int idx = start_index + i + 1; /* skip Discovery (first entry) */
+
         media_out_pl->entry[count].media_op_class =
-                media_op_matrix[start_index + i].media_op_class;
+                media_op_matrix[idx].media_op_class;
         media_out_pl->entry[count].media_op_subclass =
-                media_op_matrix[start_index + i].media_op_subclass;
+                media_op_matrix[idx].media_op_subclass;
         count++;
     }
 
Signature · 1 line
2.53.0
#14 lore raw

[PULL 16/27] hw/usb/hcd-ohci: check for MPS=0 to avoid infinite loop

In reply to Philippe Mathieu-Daudé

From: Jenny Guanni Qu <[email protected]>

When a guest sets MaxPacketSize to 0 in an OHCI Endpoint Descriptor, ohci_service_td() transfers 0 bytes per iteration. The Transfer Descriptor never completes because CBP never advances toward BE, causing ohci_service_ed_list() to loop indefinitely and hang QEMU.

Add a check for MPS==0 after extracting the field from ED flags. If MPS is zero, call ohci_die() to reset the controller and return an error, preventing the infinite loop.

Message-ID: <[email protected]>

---
 hw/usb/hcd-ohci.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
hw/usb/hcd-ohci.c +11 -0
index 1aeed9286f5..6ed8046fc20 100644
@@ -956,6 +956,17 @@ static int ohci_service_td(OHCIState *ohci, struct ohci_ed *ed)
         if (len && dir != OHCI_TD_DIR_IN) {
             /* The endpoint may not allow us to transfer it all now */
             pktlen = (ed->flags & OHCI_ED_MPS_MASK) >> OHCI_ED_MPS_SHIFT;
+            /*
+             * The OHCI spec does not say what to do if the guest hands us
+             * an endpoint descriptor which specifies a MaximumPacketSize
+             * of zero, which would mean we can never actually make forward
+             * progress transferring data to it. We choose to treat it as
+             * an error.
+             */
+            if (pktlen == 0) {
+                ohci_die(ohci);
+                return 1;
+            }
             if (pktlen > len) {
                 pktlen = len;
             }
Signature · 1 line
2.53.0
#15 lore raw

[PULL 17/27] ati-vga: Fix colors when frame buffer endianness does not match host

In reply to Philippe Mathieu-Daudé

From: BALATON Zoltan <[email protected]>

When writing pixels we have to take into account if the frame buffer endianness matches the host endianness or we need to swap to correct endianness. This caused wrong colors e.g. with PPC Linux guest that uses big endian frame buffer when running on little endian host.

Message-ID: <759ed5e3b019cce94e9a4ef003f1fc2e0cea2ec1.1774110169.git.balaton@eik.bme.hu>

---
 hw/display/ati_2d.c | 40 +++++++++++++++++++++++++++++-----------
 1 file changed, 29 insertions(+), 11 deletions(-)
hw/display/ati_2d.c +29 -11
index 37fe6c17ee9..0cbbdc33f47 100644
@@ -50,6 +50,7 @@ typedef struct {
     bool host_data_active;
     bool left_to_right;
     bool top_to_bottom;
+    bool need_swap;
     uint32_t frgd_clr;
     const uint8_t *palette;
     const uint8_t *vram_end;
@@ -89,6 +90,7 @@ static void setup_2d_blt_ctx(const ATIVGAState *s, ATI2DCtx *ctx)
     ctx->host_data_active = s->host_data.active;
     ctx->left_to_right = s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT;
     ctx->top_to_bottom = s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM;
+    ctx->need_swap = HOST_BIG_ENDIAN != s->vga.big_endian_fb ? true : false;
     ctx->frgd_clr = s->regs.dp_brush_frgd_clr;
     ctx->palette = s->vga.palette;
     ctx->dst_offset = s->regs.dst_offset;
@@ -131,6 +133,17 @@ static void setup_2d_blt_ctx(const ATIVGAState *s, ATI2DCtx *ctx)
             (ctx->top_to_bottom ? 'v' : '^'));
 }
 
+static uint32_t make_filler(int bpp, uint32_t color)
+{
+    if (bpp < 24) {
+        color |= color << 16;
+        if (bpp < 15) {
+            color |= color << 8;
+        }
+    }
+    return color;
+}
+
 static bool ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_pixman)
 {
     QemuRect vis_src, vis_dst;
@@ -255,7 +268,7 @@ static bool ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_pixman)
 
         switch (ctx->rop3) {
         case ROP3_PATCOPY:
-            filler = ctx->frgd_clr;
+            filler = make_filler(ctx->bpp, ctx->frgd_clr);
             break;
         case ROP3_BLACKNESS:
             filler = 0xffUL << 24 | rgb_to_pixel32(ctx->palette[0],
@@ -268,10 +281,12 @@ static bool ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_pixman)
                                                    ctx->palette[5]);
             break;
         }
-
         DPRINTF("pixman_fill(%p, %ld, %d, %d, %d, %d, %d, %x)\n",
                 ctx->dst_bits, ctx->dst_stride / sizeof(uint32_t), ctx->bpp,
                 vis_dst.x, vis_dst.y, vis_dst.width, vis_dst.height, filler);
+        if (ctx->need_swap) {
+            bswap32s(&filler);
+        }
 #ifdef CONFIG_PIXMAN
         if (!(use_pixman & BIT(0)) ||
             !pixman_fill((uint32_t *)ctx->dst_bits,
@@ -325,11 +340,8 @@ void ati_2d_blt(ATIVGAState *s)
 bool ati_host_data_flush(ATIVGAState *s)
 {
     ATI2DCtx ctx, chunk;
-    uint32_t fg = s->regs.dp_src_frgd_clr;
-    uint32_t bg = s->regs.dp_src_bkgd_clr;
     unsigned bypp, pix_count, row, col, idx;
     uint8_t pix_buf[ATI_HOST_DATA_ACC_BITS * sizeof(uint32_t)];
-    uint32_t byte_pix_order = s->regs.dp_datatype & DP_BYTE_PIX_ORDER;
     uint32_t src_source = s->regs.dp_mix & DP_SRC_SOURCE;
     uint32_t src_datatype = s->regs.dp_datatype & DP_SRC_DATATYPE;
 
@@ -360,21 +372,27 @@ bool ati_host_data_flush(ATIVGAState *s)
     }
 
     bypp = ctx.bpp / 8;
-
+    pix_count = ATI_HOST_DATA_ACC_BITS;
     if (src_datatype == SRC_COLOR) {
-        pix_count = ATI_HOST_DATA_ACC_BITS / ctx.bpp;
-        memcpy(pix_buf, &s->host_data.acc[0], sizeof(s->host_data.acc));
+        pix_count /= ctx.bpp;
+        memcpy(pix_buf, s->host_data.acc, sizeof(s->host_data.acc));
     } else {
-        pix_count = ATI_HOST_DATA_ACC_BITS;
         /* Expand monochrome bits to color pixels */
+        uint32_t byte_pix_order = s->regs.dp_datatype & DP_BYTE_PIX_ORDER;
+        uint32_t fg = make_filler(ctx.bpp, s->regs.dp_src_frgd_clr);
+        uint32_t bg = make_filler(ctx.bpp, s->regs.dp_src_bkgd_clr);
+
+        if (ctx.need_swap) {
+            bswap32s(&fg);
+            bswap32s(&bg);
+        }
         idx = 0;
         for (int word = 0; word < 4; word++) {
             for (int byte = 0; byte < 4; byte++) {
                 uint8_t byte_val = s->host_data.acc[word] >> (byte * 8);
                 for (int i = 0; i < 8; i++) {
                     bool is_fg = byte_val & BIT(byte_pix_order ? i : 7 - i);
-                    uint32_t color = is_fg ? fg : bg;
-                    stn_he_p(&pix_buf[idx], bypp, color);
+                    stn_he_p(&pix_buf[idx], bypp, is_fg ? fg : bg);
                     idx += bypp;
                 }
             }
Signature · 1 line
2.53.0
#16 lore raw

Re: [PULL 17/27] ati-vga: Fix colors when frame buffer endianness does not match host

Quoted 8 lines · Philippe Mathieu-Daudé

From: BALATON Zoltan <[email protected]>

When writing pixels we have to take into account if the frame buffer endianness matches the host endianness or we need to swap to correct endianness. This caused wrong colors e.g. with PPC Linux guest that uses big endian frame buffer when running on little endian host.

Quoted 5 lines

Message-ID: <759ed5e3b019cce94e9a4ef003f1fc2e0cea2ec1.1774110169.git.balaton@eik.bme.hu>

Hi; Coverity flags this as possibly-wrong code (CID 1645969:

hw/display/ati_2d.c static void setup_2d_blt_ctx(const ATIVGAState *s, ATI2DCtx *ctx) · line 93

Quoted 5 lines
hw/display/ati_2d.c +1 -0
@@ -89,6 +90,7 @@ static void setup_2d_blt_ctx(const ATIVGAState *s, ATI2DCtx *ctx)
     ctx->host_data_active = s->host_data.active;
     ctx->left_to_right = s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT;
     ctx->top_to_bottom = s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM;
+    ctx->need_swap = HOST_BIG_ENDIAN != s->vga.big_endian_fb ? true : false;

The issue is that != is higher priority than ?:, and people often write "X != A ? B : C" when they wanted "X != (A ? B : C)" but they get "(X != A) ? B : C". Either way, using parentheses helps clarify for readers.

The priority is actually right for this particular case, but the expression is unnecessarily complex: we could write more simply:

  ctx->need_swap = (HOST_BIG_ENDIAN != s->vga.big_endian_fb);

I've marked the issue in Coverity as false-positive, but we might consider changing the code also.

-- PMM

#17 lore raw

Re: [PULL 17/27] ati-vga: Fix colors when frame buffer endianness does not match host

Quoted 9 lines · Peter Maydell
Quoted 8 lines · Philippe Mathieu-Daudé

From: BALATON Zoltan <[email protected]>

When writing pixels we have to take into account if the frame buffer endianness matches the host endianness or we need to swap to correct endianness. This caused wrong colors e.g. with PPC Linux guest that uses big endian frame buffer when running on little endian host.

Quoted 7 lines
Quoted 5 lines

Message-ID: <759ed5e3b019cce94e9a4ef003f1fc2e0cea2ec1.1774110169.git.balaton@eik.bme.hu>

Hi; Coverity flags this as possibly-wrong code (CID 1645969:

You probably meant to cc me too but now I'm registered for QEMU in coverity as well so I got the warning too.

Quoted 11 lines

hw/display/ati_2d.c static void setup_2d_blt_ctx(const ATIVGAState *s, ATI2DCtx *ctx) · line 93

Quoted 5 lines
hw/display/ati_2d.c +1 -0
@@ -89,6 +90,7 @@ static void setup_2d_blt_ctx(const ATIVGAState *s, ATI2DCtx *ctx)
     ctx->host_data_active = s->host_data.active;
     ctx->left_to_right = s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT;
     ctx->top_to_bottom = s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM;
+    ctx->need_swap = HOST_BIG_ENDIAN != s->vga.big_endian_fb ? true : false;

The issue is that != is higher priority than ?:, and people often write "X != A ? B : C" when they wanted "X != (A ? B : C)" but they get "(X != A) ? B : C". Either way, using parentheses helps clarify for readers.

Quoted 1 line

The priority is actually right for this particular case, but the

Yes I omitted the parenthesis as it's not needed here but will include it in the future.

Quoted 3 lines

expression is unnecessarily complex: we could write more simply:

ctx->need_swap = (HOST_BIG_ENDIAN != s->vga.big_endian_fb);

I thought about that but too late and did not want to redo the series. I'll send a patch and check the other issue reported as well if it's a problem or can be avoided.

Quoted 2 lines

I've marked the issue in Coverity as false-positive, but we might consider changing the code also.

Thank you,
BALATON Zoltan

#18 lore raw

[PULL 15/27] hw/hyperv: Fix SynIC not initialized except on first vCPU

In reply to Philippe Mathieu-Daudé

From: Sourav Poddar <[email protected]>

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")

Message-ID: <[email protected]>

[PMD: Reworded subject]
---
 include/hw/hyperv/hyperv.h | 1 +
 hw/hyperv/hyperv.c         | 5 +++++
 target/i386/kvm/hyperv.c   | 2 +-
 3 files changed, 7 insertions(+), 1 deletion(-)
include/hw/hyperv/hyperv.h +1 -0
index 63a8b65278f..23091301d06 100644
@@ -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.
hw/hyperv/hyperv.c +5 -0
index aa278b179e6..a42c2850e35 100644
@@ -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)
 {
target/i386/kvm/hyperv.c +1 -1
index bd3c26d02b5..420c76b5ff5 100644
@@ -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;
Signature · 1 line
2.53.0
#19 lore raw

[PULL 19/27] ati-vga: Do not add crtc offset to src and dst data address

In reply to Philippe Mathieu-Daudé

From: BALATON Zoltan <[email protected]>

Drivers seem to program these registers with values that already include the crtc offset so this is not needed. This fixes blit outside of vram errors with non-0 crtc offset.

Message-ID: <7d96c67f864845893d4903b988a4da7c7b010f66.1774110169.git.balaton@eik.bme.hu>

---
 hw/display/ati_2d.c | 2 --
 1 file changed, 2 deletions(-)
hw/display/ati_2d.c +0 -2
index 0cbbdc33f47..cf2d4a08e29 100644
@@ -110,7 +110,6 @@ static void setup_2d_blt_ctx(const ATIVGAState *s, ATI2DCtx *ctx)
     ctx->dst_stride = s->regs.dst_pitch;
     ctx->dst_bits = s->vga.vram_ptr + s->regs.dst_offset;
     if (s->dev_id == PCI_DEVICE_ID_ATI_RAGE128_PF) {
-        ctx->dst_bits += s->regs.crtc_offset & 0x07ffffff;
         ctx->dst_stride *= ctx->bpp;
     }
 
@@ -121,7 +120,6 @@ static void setup_2d_blt_ctx(const ATIVGAState *s, ATI2DCtx *ctx)
     ctx->src_stride = s->regs.src_pitch;
     ctx->src_bits = s->vga.vram_ptr + s->regs.src_offset;
     if (s->dev_id == PCI_DEVICE_ID_ATI_RAGE128_PF) {
-        ctx->src_bits += s->regs.crtc_offset & 0x07ffffff;
         ctx->src_stride *= ctx->bpp;
     }
     DPRINTF("%d %d %d, %d %d %d, (%d,%d) -> (%d,%d) %dx%d %c %c\n",
Signature · 1 line
2.53.0
#20 lore raw

[PULL 18/27] ati-vga: Also switch mode on HW cursor enable bit change

In reply to Philippe Mathieu-Daudé

From: BALATON Zoltan <[email protected]>

This does nothing for most drivers but works around issue and fixes output with the Solaris R128 driver that only sets display parameters after enabling CRT controller which we would miss otherwise.

Message-ID: <ad3f415749178984c764f4ba810c663d1299ddfd.1774110169.git.balaton@eik.bme.hu>

---
 hw/display/ati.c | 1 +
 1 file changed, 1 insertion(+)
hw/display/ati.c +1 -0
index 05cf507bd47..1a6a5ad4fd6 100644
@@ -617,6 +617,7 @@ static void ati_mm_write(void *opaque, hwaddr addr,
         ati_reg_write_offs(&s->regs.crtc_gen_cntl,
                            addr - CRTC_GEN_CNTL, data, size);
         if ((val & CRTC2_CUR_EN) != (s->regs.crtc_gen_cntl & CRTC2_CUR_EN)) {
+            ati_vga_switch_mode(s);
             if (s->cursor_guest_mode) {
                 s->vga.force_shadow = !!(s->regs.crtc_gen_cntl & CRTC2_CUR_EN);
             } else {
Signature · 1 line
2.53.0
#21 lore raw

[PULL 14/27] hw/vfio/iommufd: report hint to user when vfio-dev/vfio*/dev is missing

In reply to Philippe Mathieu-Daudé

From: Pierrick Bouvier <[email protected]>

Give a hint about missing kernel config CONFIG_VFIO_DEVICE_CDEV.

Message-ID: <[email protected]>

---
 hw/vfio/iommufd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
hw/vfio/iommufd.c +4 -1
index 131612eb836..3e33dfbb356 100644
@@ -274,7 +274,10 @@ static int iommufd_cdev_getfd(const char *sysfs_path, Error **errp)
     }
 
     if (!g_file_get_contents(vfio_dev_path, &contents, &length, NULL)) {
-        error_setg(errp, "failed to load \"%s\"", vfio_dev_path);
+        error_setg(errp,
+                   "failed to load \"%s\""
+                   " (is your kernel config missing CONFIG_VFIO_DEVICE_CDEV?)",
+                   vfio_dev_path);
         goto out_close_dir;
     }
 
Signature · 1 line
2.53.0
#22 lore raw

[PULL 20/27] ati-vga: Avoid warnings about sign extension

In reply to Philippe Mathieu-Daudé

From: BALATON Zoltan <[email protected]>

Coverity reports several possible sign extension errors (latest is CID 1645615). These cannot happen because the values are limited when writing the registers and only 32 bits of the return value matter but change type of the variable storing the return value to uint32_t to avoid these warnings. Also change DEFAULT_SC_BOTTOM_RIGHT register read to match what other similar registers do for consistency.

Message-ID: <9a3263a06bc72aa5a56bafe0a11ad189d5f60528.1774110169.git.balaton@eik.bme.hu>

---
 hw/display/ati.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/display/ati.c +4 -4
index 1a6a5ad4fd6..a070f7af296 100644
@@ -265,7 +265,7 @@ static void ati_vga_vblank_irq(void *opaque)
     ati_vga_update_irq(s);
 }
 
-static inline uint64_t ati_reg_read_offs(uint32_t reg, int offs,
+static inline uint32_t ati_reg_read_offs(uint32_t reg, int offs,
                                          unsigned int size)
 {
     if (offs == 0 && size == 4) {
@@ -278,7 +278,7 @@ static inline uint64_t ati_reg_read_offs(uint32_t reg, int offs,
 static uint64_t ati_mm_read(void *opaque, hwaddr addr, unsigned int size)
 {
     ATIVGAState *s = opaque;
-    uint64_t val = 0;
+    uint32_t val = 0;
 
     switch (addr) {
     case MM_INDEX:
@@ -513,8 +513,8 @@ static uint64_t ati_mm_read(void *opaque, hwaddr addr, unsigned int size)
         val |= s->regs.default_tile << 16;
         break;
     case DEFAULT_SC_BOTTOM_RIGHT:
-        val = (s->regs.default_sc_bottom << 16) |
-              s->regs.default_sc_right;
+        val = s->regs.default_sc_right;
+        val |= s->regs.default_sc_bottom << 16;
         break;
     case SC_TOP:
         val = s->regs.sc_top;
Signature · 1 line
2.53.0
#23 lore raw

[PULL 21/27] ati-vga: Fix display updates in non-32 bit modes

In reply to Philippe Mathieu-Daudé

From: BALATON Zoltan <[email protected]>

The memory_region_set_dirty used to mark changes should use stride value in vram which is normally only the same as surface_stride in 32 bit modes. This caused missed updates in 8 and 16 bit modes.

Message-ID: <6e1b83ef3fe7a1ebc246b474eb2b0c7cd05d5deb.1774110169.git.balaton@eik.bme.hu>

---
 hw/display/ati_2d.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
hw/display/ati_2d.c +3 -2
index cf2d4a08e29..23527b2c505 100644
@@ -70,6 +70,7 @@ static void ati_set_dirty(VGACommonState *vga, const ATI2DCtx *ctx)
 {
     DisplaySurface *ds = qemu_console_surface(vga->con);
 
+    (void)ds;
     DPRINTF("%p %u ds: %p %d %d rop: %x\n", vga->vram_ptr, vga->vbe_start_addr,
             surface_data(ds), surface_stride(ds), surface_bits_per_pixel(ds),
             ctx->rop3 >> 16);
@@ -78,8 +79,8 @@ static void ati_set_dirty(VGACommonState *vga, const ATI2DCtx *ctx)
         vga->vbe_regs[VBE_DISPI_INDEX_YRES] * vga->vbe_line_offset) {
         memory_region_set_dirty(&vga->vram,
                                 vga->vbe_start_addr + ctx->dst_offset +
-                                ctx->dst.y * surface_stride(ds),
-                                ctx->dst.height * surface_stride(ds));
+                                ctx->dst.y * ctx->dst_stride,
+                                ctx->dst.height * ctx->dst_stride);
     }
 }
 
Signature · 1 line
2.53.0
#24 lore raw

[PULL 23/27] ati-vga: Simplify pointer image handling

In reply to Philippe Mathieu-Daudé

From: BALATON Zoltan <[email protected]>

Rewrite reading of mouse pointer image. I am not sure this is entirely correct but appears to work at least on little endian host with PPC guests using little or big endian frame buffer (MorphOS and MacOS) but still produces broken pointer image with Linux where I am not sure if it is a guest driver bug or still missing something.

Message-ID: <b9de530074b954d661a0eb9b8b4ad82a66085456.1774110169.git.balaton@eik.bme.hu>

[PMD: Replaced BIT() -> BIT_ULL() in ati_cursor_draw_line()]
---
 hw/display/ati.c | 57 ++++++++++++++++++++++--------------------------
 1 file changed, 26 insertions(+), 31 deletions(-)
hw/display/ati.c +26 -31
index f74dd1efc0b..c054c9aa7a2 100644
@@ -141,27 +141,24 @@ static void ati_vga_switch_mode(ATIVGAState *s)
 /* Used by host side hardware cursor */
 static void ati_cursor_define(ATIVGAState *s)
 {
-    uint8_t data[1024];
+    uint64_t data[128];
     uint32_t srcoff;
-    int i, j, idx = 0;
 
     if ((s->regs.cur_offset & BIT(31)) || s->cursor_guest_mode) {
         return; /* Do not update cursor if locked or rendered by guest */
     }
     /* FIXME handle cur_hv_offs correctly */
-    srcoff = s->regs.cur_offset -
-        (s->regs.cur_hv_offs >> 16) - (s->regs.cur_hv_offs & 0xffff) * 16;
-    for (i = 0; i < 64; i++) {
-        for (j = 0; j < 8; j++, idx++) {
-            data[idx] = vga_read_byte(&s->vga, srcoff + i * 16 + j);
-            data[512 + idx] = vga_read_byte(&s->vga, srcoff + i * 16 + j + 8);
-        }
+    srcoff = s->regs.cur_offset - (s->regs.cur_hv_offs >> 16) -
+             (s->regs.cur_hv_offs & 0xffff) * 16;
+    for (int i = 0; i < 64; i++, srcoff += 16) {
+        data[i] = ldq_le_p(&s->vga.vram_ptr[srcoff]);
+        data[i + 64] = ldq_le_p(&s->vga.vram_ptr[srcoff + 8]);
     }
     if (!s->cursor) {
         s->cursor = cursor_alloc(64, 64);
     }
     cursor_set_mono(s->cursor, s->regs.cur_color1, s->regs.cur_color0,
-                    &data[512], 1, &data[0]);
+                    (uint8_t *)&data[64], 1, (uint8_t *)&data[0]);
     dpy_cursor_define(s->vga.con, s->cursor);
 }
 
@@ -196,9 +193,9 @@ static void ati_cursor_invalidate(VGACommonState *vga)
 static void ati_cursor_draw_line(VGACommonState *vga, uint8_t *d, int scr_y)
 {
     ATIVGAState *s = container_of(vga, ATIVGAState, vga);
-    uint32_t srcoff;
+    uint32_t h, srcoff, color;
+    uint64_t abits, xbits, mask;
     uint32_t *dp = (uint32_t *)d;
-    int i, j, h, idx = 0;
 
     if (!(s->regs.crtc_gen_cntl & CRTC2_CUR_EN) ||
         scr_y < vga->hw_cursor_y || scr_y >= vga->hw_cursor_y + 64 ||
@@ -209,26 +206,24 @@ static void ati_cursor_draw_line(VGACommonState *vga, uint8_t *d, int scr_y)
     srcoff = s->cursor_offset + (scr_y - vga->hw_cursor_y) * 16;
     dp = &dp[vga->hw_cursor_x];
     h = ((s->regs.crtc_h_total_disp >> 16) + 1) * 8;
-    for (i = 0; i < 8; i++) {
-        uint32_t color;
-        uint8_t abits = vga_read_byte(vga, srcoff + i);
-        uint8_t xbits = vga_read_byte(vga, srcoff + i + 8);
-        for (j = 0; j < 8; j++, abits <<= 1, xbits <<= 1, idx++) {
-            if (vga->hw_cursor_x + idx >= h) {
-                return; /* end of screen, don't span to next line */
-            }
-            if (abits & BIT(7)) {
-                if (xbits & BIT(7)) {
-                    color = dp[idx] ^ 0xffffffff; /* complement */
-                } else {
-                    continue; /* transparent, no change */
-                }
-            } else {
-                color = (xbits & BIT(7) ? s->regs.cur_color1 :
-                                          s->regs.cur_color0) | 0xff000000;
-            }
-            dp[idx] = color;
+    abits = ldq_be_p(&vga->vram_ptr[srcoff]);
+    xbits = ldq_be_p(&vga->vram_ptr[srcoff + 8]);
+    mask = BIT_ULL(63);
+    for (int i = 0; i < 64; i++, mask >>= 1) {
+        if (vga->hw_cursor_x + i >= h) {
+            return; /* end of screen, don't span to next line */
         }
+        if (abits & mask) {
+            if (xbits & mask) {
+                color = dp[i] ^ 0xffffffff; /* complement */
+            } else {
+                continue; /* transparent, no change */
+            }
+        } else {
+            color = (xbits & mask ? s->regs.cur_color1 :
+                                    s->regs.cur_color0) | 0xff000000;
+        }
+        dp[i] = color;
     }
 }
 
Signature · 1 line
2.53.0
#25 lore raw

[PULL 22/27] ati-vga: Add work around for fuloong2e

In reply to Philippe Mathieu-Daudé

From: BALATON Zoltan <[email protected]>

With the linear aperture size fixed to match real card fuloong2e no longer works due to running out of PCI memory because only one PCI bus is emulated on that machine. Add a property to allow fuloong2e to set a smaller linear aperture size to work around that problem until the machine model is improved.

Message-ID: <47cbdc7ad2291f22467f9fc86e7287eb8983c927.1774110169.git.balaton@eik.bme.hu>

---
 hw/display/ati_int.h |  1 +
 hw/display/ati.c     | 17 +++++++++++++----
 hw/mips/fuloong2e.c  |  1 +
 3 files changed, 15 insertions(+), 4 deletions(-)
hw/display/ati_int.h +1 -0
index 21b74511e08..0c48934d33b 100644
@@ -119,6 +119,7 @@ struct ATIVGAState {
     QEMUTimer vblank_timer;
     bitbang_i2c_interface bbi2c;
     I2CDDCState i2cddc;
+    uint64_t linear_aper_sz;
     MemoryRegion linear_aper;
     MemoryRegion io;
     MemoryRegion mm;
hw/display/ati.c +13 -4
index a070f7af296..f74dd1efc0b 100644
@@ -1059,7 +1059,6 @@ static void ati_vga_realize(PCIDevice *dev, Error **errp)
     ATIVGAState *s = ATI_VGA(dev);
     VGACommonState *vga = &s->vga;
     I2CBus *i2cbus;
-    uint64_t aper_size;
 
 #ifndef CONFIG_PIXMAN
     if (s->use_pixman != 0) {
@@ -1123,10 +1122,19 @@ static void ati_vga_realize(PCIDevice *dev, Error **errp)
      * Rage128 the upper half of the aperture is reserved for an AGP
      * window (which we do not emulate.)
      */
-    aper_size = s->dev_id == PCI_DEVICE_ID_ATI_RAGE128_PF ?
-                ATI_RAGE128_LINEAR_APER_SIZE : ATI_R100_LINEAR_APER_SIZE;
+    if (!s->linear_aper_sz) {
+        if (s->dev_id == PCI_DEVICE_ID_ATI_RAGE128_PF) {
+            s->linear_aper_sz = ATI_RAGE128_LINEAR_APER_SIZE;
+        } else {
+            s->linear_aper_sz = ATI_R100_LINEAR_APER_SIZE;
+        }
+    }
+    if (s->linear_aper_sz < 16 * MiB) {
+        error_setg(errp, "x-linear-aper-size is too small (minimum 16 MiB)");
+        return;
+    }
     memory_region_init(&s->linear_aper, OBJECT(dev), "ati-linear-aperture0",
-                       aper_size);
+                       s->linear_aper_sz);
     memory_region_add_subregion(&s->linear_aper, 0, &vga->vram);
 
     pci_register_bar(dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->linear_aper);
@@ -1171,6 +1179,7 @@ static const Property ati_vga_properties[] = {
     DEFINE_PROP_BOOL("guest_hwcursor", ATIVGAState, cursor_guest_mode, false),
     /* this is a debug option, prefer PROP_UINT over PROP_BIT for simplicity */
     DEFINE_PROP_UINT8("x-pixman", ATIVGAState, use_pixman, DEFAULT_X_PIXMAN),
+    DEFINE_PROP_UINT64("x-linear-aper-size", ATIVGAState, linear_aper_sz, 0),
     DEFINE_EDID_PROPERTIES(ATIVGAState, i2cddc.edid_info),
 };
 
hw/mips/fuloong2e.c +1 -0
index d0efe36f7ce..72ad4507dfa 100644
@@ -316,6 +316,7 @@ static void mips_fuloong2e_init(MachineState *machine)
         dev = DEVICE(pci_dev);
         qdev_prop_set_uint32(dev, "vgamem_mb", 16);
         qdev_prop_set_uint16(dev, "x-device-id", 0x5159);
+        qdev_prop_set_uint64(dev, "x-linear-aper-size", 16 * MiB);
         pci_realize_and_unref(pci_dev, pci_bus, &error_fatal);
     }
 
Signature · 1 line
2.53.0
#26 lore raw

[PULL 24/27] ati-vga: Make sure hardware cursor data is within vram

In reply to Philippe Mathieu-Daudé

From: BALATON Zoltan <[email protected]>

Add check to make sure we don't read past the end of vram when getting mouse pointer image.

Message-ID: <2ecf42bdeb96a4206b27dc39b3ff13cc8a6190d0.1774110169.git.balaton@eik.bme.hu>

---
 hw/display/ati.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/display/ati.c +6 -0
index c054c9aa7a2..fc19737d1f0 100644
@@ -150,6 +150,9 @@ static void ati_cursor_define(ATIVGAState *s)
     /* FIXME handle cur_hv_offs correctly */
     srcoff = s->regs.cur_offset - (s->regs.cur_hv_offs >> 16) -
              (s->regs.cur_hv_offs & 0xffff) * 16;
+    if (srcoff + 64 * 16 > s->vga.vram_size) {
+        return;
+    }
     for (int i = 0; i < 64; i++, srcoff += 16) {
         data[i] = ldq_le_p(&s->vga.vram_ptr[srcoff]);
         data[i + 64] = ldq_le_p(&s->vga.vram_ptr[srcoff + 8]);
@@ -204,6 +207,9 @@ static void ati_cursor_draw_line(VGACommonState *vga, uint8_t *d, int scr_y)
     }
     /* FIXME handle cur_hv_offs correctly */
     srcoff = s->cursor_offset + (scr_y - vga->hw_cursor_y) * 16;
+    if (srcoff + 16 > s->vga.vram_size) {
+        return;
+    }
     dp = &dp[vga->hw_cursor_x];
     h = ((s->regs.crtc_h_total_disp >> 16) + 1) * 8;
     abits = ldq_be_p(&vga->vram_ptr[srcoff]);
Signature · 1 line
2.53.0
#27 lore raw

[PULL 25/27] hw/net/ftgmac100: Improve DMA error handling

In reply to Philippe Mathieu-Daudé

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

Currently, DMA memory operation errors in the ftgmac100 model are not all tested and this can lead to a guest-triggerable denial of service as described in https://gitlab.com/qemu-project/qemu/-/work_items/3335.

To fix this, check the return value of ftgmac100_write_bd() in the TX path and exit the TX loop on error to prevent further processing. In the event of a DMA error, also set FTGMAC100_INT_AHB_ERR interrupt flag as appropriate.

The FTGMAC100_INT_AHB_ERR interrupt status bit only applies to the AST2400 SoC; on newer Aspeed SoCs, it is a reserved bit. Nevertheless, since it is supported by the Linux driver and it should be safe to use in the QEMU implementation across all SoCs.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3335

Message-ID: <[email protected]>

---
 hw/net/ftgmac100.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
hw/net/ftgmac100.c +8 -2
index d29f7dcd171..2f05bba11d0 100644
@@ -624,7 +624,10 @@ static void ftgmac100_do_tx(FTGMAC100State *s, uint64_t tx_ring,
         bd.des0 &= ~FTGMAC100_TXDES0_TXDMA_OWN;
 
         /* Write back the modified descriptor.  */
-        ftgmac100_write_bd(&bd, addr);
+        if (ftgmac100_write_bd(&bd, addr)) {
+            s->isr |= FTGMAC100_INT_AHB_ERR;
+            break;
+        }
         /* Advance to the next descriptor.  */
         if (bd.des0 & s->txdes0_edotr) {
             addr = tx_ring;
@@ -1134,7 +1137,10 @@ static ssize_t ftgmac100_receive(NetClientState *nc, const uint8_t *buf,
             bd.des0 |= flags | FTGMAC100_RXDES0_LRS;
             s->isr |= FTGMAC100_INT_RPKT_BUF;
         }
-        ftgmac100_write_bd(&bd, addr);
+        if (ftgmac100_write_bd(&bd, addr)) {
+            s->isr |= FTGMAC100_INT_AHB_ERR;
+            break;
+        }
         if (bd.des0 & s->rxdes0_edorr) {
             addr = s->rx_ring;
         } else {
Signature · 1 line
2.53.0
#28 lore raw

Re: [PULL 25/27] hw/net/ftgmac100: Improve DMA error handling

Hello,

Quoted 11 lines · Philippe Mathieu-Daudé

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

Currently, DMA memory operation errors in the ftgmac100 model are not all tested and this can lead to a guest-triggerable denial of service as described in https://gitlab.com/qemu-project/qemu/-/work_items/3335.

To fix this, check the return value of ftgmac100_write_bd() in the TX path and exit the TX loop on error to prevent further processing. In the event of a DMA error, also set FTGMAC100_INT_AHB_ERR interrupt flag as appropriate.

Quoted 6 lines

The FTGMAC100_INT_AHB_ERR interrupt status bit only applies to the AST2400 SoC; on newer Aspeed SoCs, it is a reserved bit. Nevertheless, since it is supported by the Linux driver and it should be safe to use in the QEMU implementation across all SoCs.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3335

Philippe,

You can certainly apply the fixes, but I don't see any email from you about it. However, I indicated that I was applying it to aspeed-next as part of this series:

https://lore.kernel.org/qemu-devel/[email protected]/

There is reason for it. The SMC patch is required to fix issue 3335. The patch should say so, I agree. My bad.

I see that some VFIO patches are also included. I appreciate your help, but please contact the maintainers before, I believe I am responsive enough to requests ? I will rework the aspeed PR I had prepared and update the VFIO tree.

Thanks,

C.

Quoted 37 lines

Message-ID: <[email protected]>

---
  hw/net/ftgmac100.c | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)
hw/net/ftgmac100.c +8 -2
index d29f7dcd171..2f05bba11d0 100644
@@ -624,7 +624,10 @@ static void ftgmac100_do_tx(FTGMAC100State *s, uint64_t tx_ring,
          bd.des0 &= ~FTGMAC100_TXDES0_TXDMA_OWN;
 
          /* Write back the modified descriptor.  */
-        ftgmac100_write_bd(&bd, addr);
+        if (ftgmac100_write_bd(&bd, addr)) {
+            s->isr |= FTGMAC100_INT_AHB_ERR;
+            break;
+        }
          /* Advance to the next descriptor.  */
          if (bd.des0 & s->txdes0_edotr) {
              addr = tx_ring;
@@ -1134,7 +1137,10 @@ static ssize_t ftgmac100_receive(NetClientState *nc, const uint8_t *buf,
              bd.des0 |= flags | FTGMAC100_RXDES0_LRS;
              s->isr |= FTGMAC100_INT_RPKT_BUF;
          }
-        ftgmac100_write_bd(&bd, addr);
+        if (ftgmac100_write_bd(&bd, addr)) {
+            s->isr |= FTGMAC100_INT_AHB_ERR;
+            break;
+        }
          if (bd.des0 & s->rxdes0_edorr) {
              addr = s->rx_ring;
          } else {
#29 lore raw

Re: [PULL 25/27] hw/net/ftgmac100: Improve DMA error handling

Hi Cédric,

Quoted 31 lines · Cédric Le Goater

Hello,

Quoted 11 lines · Philippe Mathieu-Daudé

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

Currently, DMA memory operation errors in the ftgmac100 model are not all tested and this can lead to a guest-triggerable denial of service as described in https://gitlab.com/qemu-project/qemu/-/work_items/3335.

To fix this, check the return value of ftgmac100_write_bd() in the TX path and exit the TX loop on error to prevent further processing. In the event of a DMA error, also set FTGMAC100_INT_AHB_ERR interrupt flag as appropriate.

Quoted 6 lines

The FTGMAC100_INT_AHB_ERR interrupt status bit only applies to the AST2400 SoC; on newer Aspeed SoCs, it is a reserved bit. Nevertheless, since it is supported by the Linux driver and it should be safe to use in the QEMU implementation across all SoCs.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3335

Philippe,

You can certainly apply the fixes, but I don't see any email from you about it. However, I indicated that I was applying it to aspeed-next as part of this series:

  https://lore.kernel.org/qemu-devel/20260323125545.577653-1-
[email protected]/

Quoted 7 lines

There is reason for it. The SMC patch is required to fix issue 3335. The patch should say so, I agree. My bad.

I see that some VFIO patches are also included. I appreciate your help, but please contact the maintainers before, I believe I am responsive enough to requests ? I will rework the aspeed PR I had prepared and update the VFIO tree.

I understood your aspeed-next branch was for the first queue to apply after 11.0, not for fixes before, and this one felt worthwhile fix. Indeed I should have replied to the patch with that justification and you'd have cleared any doubts. I apologize for having stepped over your maintenance area. This shouldn't reproduce.

Regards,

Phil.

Quoted 5 lines

Thanks,

C.

#30 lore raw

Re: [PULL 25/27] hw/net/ftgmac100: Improve DMA error handling

Quoted 41 lines · Philippe Mathieu-Daudé

Hi Cédric,

Quoted 30 lines · Cédric Le Goater

Hello,

Quoted 11 lines · Philippe Mathieu-Daudé

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

Currently, DMA memory operation errors in the ftgmac100 model are not all tested and this can lead to a guest-triggerable denial of service as described in https://gitlab.com/qemu-project/qemu/-/work_items/3335.

To fix this, check the return value of ftgmac100_write_bd() in the TX path and exit the TX loop on error to prevent further processing. In the event of a DMA error, also set FTGMAC100_INT_AHB_ERR interrupt flag as appropriate.

Quoted 6 lines

The FTGMAC100_INT_AHB_ERR interrupt status bit only applies to the AST2400 SoC; on newer Aspeed SoCs, it is a reserved bit. Nevertheless, since it is supported by the Linux driver and it should be safe to use in the QEMU implementation across all SoCs.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3335

Philippe,

You can certainly apply the fixes, but I don't see any email from you about it. However, I indicated that I was applying it to aspeed-next as part of this series:

   https://lore.kernel.org/qemu-devel/20260323125545.577653-1- [email protected]/

Quoted 7 lines

There is reason for it. The SMC patch is required to fix issue 3335. The patch should say so, I agree. My bad.

I see that some VFIO patches are also included. I appreciate your help, but please contact the maintainers before, I believe I am responsive enough to requests ? I will rework the aspeed PR I had prepared and update the VFIO tree.

Quoted 5 lines

I understood your aspeed-next branch was for the first queue to apply after 11.0, not for fixes before, and this one felt worthwhile fix. Indeed I should have replied to the patch with that justification and you'd have cleared any doubts. I apologize for having stepped over your maintenance area. This shouldn't reproduce.

I am sure it will :) No harm done. Just some slight frustration on my side.

Cheers,

C.

#31 lore raw

[PULL 27/27] hw/hyperv: add QEMU_PACKED to uapi structs

In reply to Philippe Mathieu-Daudé

From: Magnus Kulke <[email protected]>

The uapi definitions are marked with __packed hints in the kernel headers, since we want to keep the contract of the Microsoft Hypervisor ABI explicit, we should also added them in our vendored files, with a few notable exceptions where the attribute is a noop.

Message-ID: <[email protected]>

[PMD: Do not include "qemu/compiler.h"]
---
 include/hw/hyperv/hvgdk_mini.h | 35 +++++++++++++++++++++-------------
 include/hw/hyperv/hvhdk.h      | 12 ++++++------
 2 files changed, 28 insertions(+), 19 deletions(-)
include/hw/hyperv/hvgdk_mini.h +22 -13
index cb52cc9de28..c3a8f33280a 100644
@@ -211,7 +211,7 @@ enum hv_intercept_type {
 struct hv_u128 {
     uint64_t low_part;
     uint64_t high_part;
-};
+} QEMU_PACKED;
 
 union hv_x64_xmm_control_status_register {
     struct hv_u128 as_uint128;
@@ -326,13 +326,13 @@ typedef struct hv_x64_segment_register {
         };
         uint16_t attributes;
     };
-} hv_x64_segment_register;
+} QEMU_PACKED hv_x64_segment_register;
 
 typedef struct hv_x64_table_register {
     uint16_t pad[3];
     uint16_t limit;
     uint64_t base;
-} hv_x64_table_register;
+} QEMU_PACKED hv_x64_table_register;
 
 union hv_x64_fp_control_status_register {
     struct hv_u128 as_uint128;
@@ -416,6 +416,10 @@ typedef union hv_register_value {
     union hv_x64_register_sev_control sev_control;
 } hv_register_value;
 
+/*
+ * This struct is __packed in the kernel. Since all members are naturally
+ * aligned, we can omit QEMU_PACKED to avoid address-of-packed-member warnings.
+ */
 typedef struct hv_register_assoc {
     uint32_t name;         /* enum hv_register_name */
     uint32_t reserved1;
@@ -439,7 +443,7 @@ typedef struct hv_input_get_vp_registers {
     uint8_t  rsvd_z8;
     uint16_t rsvd_z16;
     uint32_t names[];
-} hv_input_get_vp_registers;
+} QEMU_PACKED hv_input_get_vp_registers;
 
 typedef struct hv_input_set_vp_registers {
     uint64_t partition_id;
@@ -448,7 +452,7 @@ typedef struct hv_input_set_vp_registers {
     uint8_t  rsvd_z8;
     uint16_t rsvd_z16;
     struct hv_register_assoc elements[];
-} hv_input_set_vp_registers;
+} QEMU_PACKED hv_input_set_vp_registers;
 
 union hv_interrupt_control {
     uint64_t as_uint64;
@@ -468,7 +472,7 @@ struct hv_input_assert_virtual_interrupt {
     uint8_t target_vtl;
     uint8_t rsvd_z0;
     uint16_t rsvd_z1;
-};
+} QEMU_PACKED;
 
 /* /dev/mshv */
 #define MSHV_CREATE_PARTITION   _IOW(MSHV_IOCTL, 0x00, struct mshv_create_partition)
@@ -487,6 +491,11 @@ struct hv_input_assert_virtual_interrupt {
  ********************************
  */
 
+/*
+ * This struct is __packed in the kernel, but since all members are naturally
+ * aligned, so we can omit QEMU_PACKED to avoid address-of-packed-member
+ * warnings.
+ */
 struct hv_local_interrupt_controller_state {
     /* HV_X64_INTERRUPT_CONTROLLER_STATE */
     uint32_t apic_id;
@@ -644,7 +653,7 @@ struct hv_x64_intercept_message_header {
     struct hv_x64_segment_register cs_segment;
     uint64_t rip;
     uint64_t rflags;
-};
+} QEMU_PACKED;
 
 union hv_x64_io_port_access_info {
     uint8_t as_uint8;
@@ -669,7 +678,7 @@ typedef struct hv_x64_io_port_intercept_message {
     uint64_t rcx;
     uint64_t rsi;
     uint64_t rdi;
-} hv_x64_io_port_intercept_message;
+} QEMU_PACKED hv_x64_io_port_intercept_message;
 
 union hv_x64_memory_access_info {
     uint8_t as_uint8;
@@ -692,7 +701,7 @@ struct hv_x64_memory_intercept_message {
     uint64_t guest_virtual_address;
     uint64_t guest_physical_address;
     uint8_t instruction_bytes[16];
-};
+} QEMU_PACKED;
 
 union hv_message_flags {
     uint8_t asu8;
@@ -711,14 +720,14 @@ struct hv_message_header {
         uint64_t sender;
         union hv_port_id port;
     };
-};
+} QEMU_PACKED;
 
 struct hv_message {
     struct hv_message_header header;
     union {
         uint64_t payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
     } u;
-};
+} QEMU_PACKED;
 
 /* From  github.com/rust-vmm/mshv-bindings/src/x86_64/regs.rs */
 
@@ -731,13 +740,13 @@ struct hv_cpuid_entry {
     uint32_t ecx;
     uint32_t edx;
     uint32_t padding[3];
-};
+} QEMU_PACKED;
 
 struct hv_cpuid {
     uint32_t nent;
     uint32_t padding;
     struct hv_cpuid_entry entries[0];
-};
+} QEMU_PACKED;
 
 #define IA32_MSR_TSC            0x00000010
 #define IA32_MSR_EFER           0xC0000080
include/hw/hyperv/hvhdk.h +6 -6
index 866c8211bfe..41af7438471 100644
@@ -16,7 +16,7 @@ struct hv_input_set_partition_property {
     uint32_t property_code; /* enum hv_partition_property_code */
     uint32_t padding;
     uint64_t property_value;
-};
+} QEMU_PACKED;
 
 union hv_partition_synthetic_processor_features {
     uint64_t as_uint64[HV_PARTITION_SYNTHETIC_PROCESSOR_FEATURES_BANKS];
@@ -201,12 +201,12 @@ typedef struct hv_input_translate_virtual_address {
     uint32_t padding;
     uint64_t control_flags;
     uint64_t gva_page;
-} hv_input_translate_virtual_address;
+} QEMU_PACKED hv_input_translate_virtual_address;
 
 typedef struct hv_output_translate_virtual_address {
     union hv_translate_gva_result translation_result;
     uint64_t gpa_page;
-} hv_output_translate_virtual_address;
+} QEMU_PACKED hv_output_translate_virtual_address;
 
 typedef struct hv_register_x64_cpuid_result_parameters {
     struct {
@@ -226,13 +226,13 @@ typedef struct hv_register_x64_cpuid_result_parameters {
         uint32_t edx;
         uint32_t edx_mask;
     } result;
-} hv_register_x64_cpuid_result_parameters;
+} QEMU_PACKED hv_register_x64_cpuid_result_parameters;
 
 typedef struct hv_register_x64_msr_result_parameters {
     uint32_t msr_index;
     uint32_t access_type;
     uint32_t action; /* enum hv_unimplemented_msr_action */
-} hv_register_x64_msr_result_parameters;
+} QEMU_PACKED hv_register_x64_msr_result_parameters;
 
 union hv_register_intercept_result_parameters {
     struct hv_register_x64_cpuid_result_parameters cpuid;
@@ -244,6 +244,6 @@ typedef struct hv_input_register_intercept_result {
     uint32_t vp_index;
     uint32_t intercept_type; /* enum hv_intercept_type */
     union hv_register_intercept_result_parameters parameters;
-} hv_input_register_intercept_result;
+} QEMU_PACKED hv_input_register_intercept_result;
 
 #endif /* HW_HYPERV_HVHDK_H */
Signature · 1 line
2.53.0
#32 lore raw

[PULL 26/27] monitor: Correctly display virtual addresses while dumping memory

In reply to Philippe Mathieu-Daudé

While reworking the address format width in commit 6ad593a75a8 we introduce a bug, leading to addresses being displayed with too many zeroes:

  $ qemu-system-ppc -monitor stdio -S
  QEMU 10.2.90 monitor - type 'help' for more information
  (qemu) x/x 0
  0000000000000000000000000000000000000000000000000000000000000000: 0x00000000
  (qemu) x/x 0xfff00000
  00000000000000000000000000000000000000000000000000000000fff00000: 0x60000000
  $ qemu-system-ppc64 -monitor stdio -S
  QEMU 10.2.90 monitor - type 'help' for more information
  (qemu) x/x 0
  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000: 0x00000000

Correct the format width to restore the previous behavior:

  $ qemu-system-ppc -monitor stdio -S
  QEMU 10.2.90 monitor - type 'help' for more information
  (qemu) x/x 0
  00000000: 0x00000000
  $ qemu-system-ppc64 -monitor stdio -S
  QEMU 10.2.90 monitor - type 'help' for more information
  (qemu) x/x 0
  0000000000000000: 0x00000000
Fixes 6ad593a75a8 ("monitor/hmp: Use plain uint64_t @addr argument in memory_dump()")

Message-Id: <[email protected]>

---
 monitor/hmp-cmds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
monitor/hmp-cmds.c +1 -1
index bad034937a9..bc26b39d708 100644
@@ -537,7 +537,7 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize,
     uint8_t buf[16];
     uint64_t v;
     CPUState *cs = mon_get_cpu(mon);
-    const unsigned int addr_width = is_physical ? 8 : (target_long_bits() * 2);
+    const unsigned int addr_width = is_physical ? 8 : (target_long_bits() / 4);
     const bool big_endian = target_big_endian();
 
     if (!cs && (format == 'i' || !is_physical)) {
Signature · 1 line
2.53.0
#33 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 26 lines · Philippe Mathieu-Daudé

The following changes since commit eb153d8fd3be325a5aa7e1a6a73be8854eeaaf27:

Merge tag 'pull-target-arm-20260323' of https://gitlab.com/pm215/qemu into staging (2026-03-23 10:55:20 +0000)

are available in the Git repository at:

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

for you to fetch changes up to 070fc710251809c4d8d2a84f24527a174e843423:

hw/hyperv: add QEMU_PACKED to uapi structs (2026-03-23 17:50:50 +0100)

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

- Fix guest-triggerable abort in FTGMAC100 Gigabit Ethernet
- Fix uninitialized value in DesignWare I3C controller
- Clear dangling GLib event source tag in virtio-console
- Mark RISC-V specific peripherals as little-endian
- Correct virtual address formatting in monitor
- Improve error handling path in core loader
- Improve error hints in IOMMU FD
- Prevent hang in USB OHCI
- ATI VGA, HyperV & CXL fixes

Quoted 1 line

----------------------------------------------------------------

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/11.0
for any user-visible changes.

-- PMM