Skip to contentSkip to conversation

Misc HW patches for 2026-11-30

GIT PULL Applied Philippe Mathieu-Daudé 2 participants 13 messages Nov 30 – Dec 1

lore
Share & tools
lore
#0 lore raw

The following changes since commit 9cda597a1a3903d090e8e55e23f5b8a859da88ab:

Merge tag 'pbouvier/pr/fixes_11.2-20261127' of https://gitlab.com/p-b-o/qemu into staging (2026-11-29 13:42:36 -0800)

are available in the Git repository at:

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

for you to fetch changes up to d639f909a00ef9ca1fd367854149158e46fdad22:

hw/net/can/ctucan: send a Ready TXT buffer that has priority 0 (2026-11-30 22:42:44 +0100)

----------------------------------------------------------------
Misc HW patch queue

- Fixes (SD card, SDHCI, SJA1000 CAN, Macintosh VIA)
- Use-after-free in some migration post_load hooks
- Remove compatibility properties for legacy 4.1 machines
----------------------------------------------------------------

Haseeb Ashraf (1):
hw/net/can/sja1000: fix receive FIFO corruption

Peter Maydell (3):
hw/misc/mac_via: register VM change state handler once hw/nvram/spapr_nvram: register VM change state handler once hw/block/pflash_cfi02: register VM change state handler once

Philippe Mathieu-Daudé (4):
hw/sd/sdcard: Fix incoming migration of SPI mode cards hw/sd/sdhci: Cancel queued DMA progression on DAT reset hw/sd/sdhci: Treat Software Reset bits as independent pulses hw/sd/sdhci: Gate Auto CMD12 error status on its enable

Thomas Huth (2):
hw/i386: Remove the code of the obsolete pc-q35-4.1 and pc-i440fx-4.1
machines
hw/virtio: Remove hw_compat_4_1[] array and "x-pcie-flr-init" from
virtio-pci

Yashaswin Sharma Puranik (1):
hw/net/can/ctucan: send a Ready TXT buffer that has priority 0

 include/hw/core/boards.h       |  3 ---
 include/hw/i386/pc.h           |  3 ---
 include/hw/virtio/virtio-pci.h |  4 ----
 hw/block/pflash_cfi02.c        |  2 +-
 hw/core/machine.c              |  5 -----
 hw/i386/pc.c                   |  3 ---
 hw/i386/pc_piix.c              |  9 --------
 hw/i386/pc_q35.c               |  9 --------
 hw/misc/mac_via.c              |  2 +-
 hw/net/can/can_sja1000.c       | 12 ++++++++--
 hw/net/can/ctucan_core.c       |  2 +-
 hw/nvram/spapr_nvram.c         |  2 +-
 hw/sd/sd.c                     |  5 ++++-
 hw/sd/sdhci.c                  | 40 ++++++++++++++++++----------------
 hw/virtio/virtio-pci.c         | 13 +++--------
 15 files changed, 42 insertions(+), 72 deletions(-)
Signature · 1 line
2.55.0
#1 lore raw

[PULL 01/11] hw/sd/sdcard: Fix incoming migration of SPI mode cards

sd_vmstate_pre_load() powers up the card when the OCR state is not part of the migration stream. Since commit b66f73a0cb31, SPI mode cards are already powered up at reset, so the incoming migration of a machine with an SPI mode card aborts in sd_ocr_powerup():

Assertion failed: (!FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP)), function sd_ocr_powerup, file sd.c, line 409.

Only power up the card if it is not already powered up.

Fixes b66f73a0cb31 ("hw/sd: Add SDHC support for SD card SPI-mode")

Message-ID: <[email protected]>

---
 hw/sd/sd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
hw/sd/sd.c +4 -1
index 81dd54beb90a..442a7491096a 100644
@@ -1067,8 +1067,11 @@ static int sd_vmstate_pre_load(void *opaque)
     /* If the OCR state is not included (prior versions, or not
      * needed), then the OCR must be set as powered up. If the OCR state
      * is included, this will be replaced by the state restore.
+     * In SPI mode the card is already powered up after reset.
      */
-    sd_ocr_powerup(sd);
+    if (!FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP)) {
+        sd_ocr_powerup(sd);
+    }
 
     return 0;
 }
Signature · 1 line
2.55.0
#2 lore raw

[PULL 02/11] hw/sd/sdhci: Cancel queued DMA progression on DAT reset

In reply to Philippe Mathieu-Daudé

A DAT reset left the transfer timer armed, so the queued DMA continuation restored DAT Line Active after the reset.

Cancel the timer on DAT reset. Software Reset For DAT Line aborts DMA transfers (SD Host Controller v1.00, sections 1.5, 2.2.16).

Fixes d7dfca0807a0 ("hw/sdhci: introduce standard SD host controller")

Message-ID: <[email protected]>

---
 hw/sd/sdhci.c | 1 +
 1 file changed, 1 insertion(+)
hw/sd/sdhci.c +1 -0
index 1e70e1e7dd52..695de6448f89 100644
@@ -1246,6 +1246,7 @@ static inline void sdhci_reset_write(SDHCIState *s, uint8_t value)
         s->norintsts &= ~SDHC_NIS_CMDCMP;
         break;
     case SDHC_RESET_DATA:
+        timer_del(s->transfer_timer);
         s->data_count = 0;
         s->prnsts &= ~(SDHC_SPACE_AVAILABLE | SDHC_DATA_AVAILABLE |
                 SDHC_DOING_READ | SDHC_DOING_WRITE |
Signature · 1 line
2.55.0
#3 lore raw

[PULL 04/11] hw/sd/sdhci: Gate Auto CMD12 error status on its enable

In reply to Philippe Mathieu-Daudé

The Force Event write for Auto CMD12 Error Status (also reached from the Error Interrupt Force Event register) set the Error Interrupt Auto CMD12 bit regardless of the Auto CMD12 Error Status Enable.

Gate it on the enable, as the command-timeout path does.

Fixes d7dfca0807a0 ("hw/sdhci: introduce standard SD host controller")

Message-ID: <[email protected]>

---
 hw/sd/sdhci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/sd/sdhci.c +1 -1
index 9bdc898e7f54..f33e2cec9b3e 100644
@@ -1442,7 +1442,7 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
     case SDHC_FEAER:
         s->acmd12errsts |= value;
         s->errintsts |= (value >> 16) & s->errintstsen;
-        if (s->acmd12errsts) {
+        if (s->acmd12errsts && (s->errintstsen & SDHC_EISEN_CMD12ERR)) {
             s->errintsts |= SDHC_EIS_CMD12ERR;
         }
         if (s->errintsts) {
Signature · 1 line
2.55.0
#4 lore raw

[PULL 05/11] hw/net/can/sja1000: fix receive FIFO corruption

In reply to Philippe Mathieu-Daudé

From: Haseeb Ashraf <[email protected]>

Remote frames carry a DLC but no payload. Do not enqueue payload bytes for RTR frames in PeliCAN or BasicCAN mode, since the release operation otherwise consumes bytes which were never stored and leaves the FIFO misaligned. Preserve the CAN identifier when decoding a BasicCAN RTR frame.

Reset the receive write pointer on both hardware and software reset so the byte and frame counts remain consistent.

Fixes 733210e75465 ("hw/net/can: SJA1000 chip register level emulation for QEMU")

Message-ID: <[email protected]>

---
 hw/net/can/can_sja1000.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
hw/net/can/can_sja1000.c +10 -2
index 922431effbcd..23bec3b2107d 100644
@@ -57,6 +57,7 @@ static void can_sja_software_reset(CanSJA1000State *s)
     s->status_pel  |= 0x34;
 
     s->rxbuf_start = 0x00;
+    s->rx_ptr      = 0x00;
     s->rxmsg_cnt   = 0x00;
     s->rx_cnt      = 0x00;
 }
@@ -69,6 +70,7 @@ void can_sja_hardware_reset(CanSJA1000State *s)
     s->interrupt_pel = 0x00;
     s->clock       = 0x00;
     s->rxbuf_start = 0x00;
+    s->rx_ptr      = 0x00;
     s->rxmsg_cnt   = 0x00;
     s->rx_cnt      = 0x00;
 
@@ -312,7 +314,7 @@ static void buff2frame_bas(const uint8_t *buff, qemu_can_frame *frame)
     frame->flags = 0;
     frame->can_id = ((buff[0] << 3) & (0xff << 3)) + ((buff[1] >> 5) & 0x07);
     if (buff[1] & 0x10) { /* RTR */
-        frame->can_id = QEMU_CAN_RTR_FLAG;
+        frame->can_id |= QEMU_CAN_RTR_FLAG;
     }
     frame->can_dlc = buff[1] & 0x0f;
 
@@ -345,6 +347,8 @@ static int frame2buff_pel(const qemu_can_frame *frame, uint8_t *buff)
     buff[0] = 0x0f & frame->can_dlc; /* DLC */
     if (frame->can_id & QEMU_CAN_RTR_FLAG) { /* RTR */
         buff[0] |= (1 << 6);
+        /* RTR DLC is the requested length, not payload stored in the FIFO. */
+        dlen = 0;
     }
     if (frame->can_id & QEMU_CAN_EFF_FLAG) { /* EFF */
         buff[0] |= (1 << 7);
@@ -392,6 +396,7 @@ static int frame2buff_bas(const qemu_can_frame *frame, uint8_t *buff)
     buff[1] = extract32(frame->can_id, 0, 3) << 5; /* ID.02~ID.00,xxxxx */
     if (frame->can_id & QEMU_CAN_RTR_FLAG) { /* RTR */
         buff[1] |= (1 << 4);
+        dlen = 0;
     }
     buff[1] |= frame->can_dlc & 0x0f;
     for (i = 0; i < dlen; i++) {
@@ -610,7 +615,10 @@ void can_sja_mem_write(CanSJA1000State *s, hwaddr addr, uint64_t val,
                 }
 
                 tmp8 = s->rx_buff[(s->rxbuf_start + 1) % SJA_RCV_BUF_LEN];
-                count = 2 + (tmp8 & 0x0f);
+                count = 2;
+                if (!(tmp8 & (1 << 4))) { /* DATA */
+                    count += tmp8 & 0x0f;
+                }
 
                 if (DEBUG_FILTER) {
                     qemu_log("[cansja]: message released from "
Signature · 1 line
2.55.0
#5 lore raw

[PULL 06/11] hw/i386: Remove the code of the obsolete pc-q35-4.1 and pc-i440fx-4.1 machines

In reply to Philippe Mathieu-Daudé

From: Thomas Huth <[email protected]>

These machines have been disabled already since they are older than 6 years. Let's clean up the related code now.

Message-ID: <[email protected]>

---
 include/hw/i386/pc.h | 3 ---
 hw/i386/pc.c         | 3 ---
 hw/i386/pc_piix.c    | 9 ---------
 hw/i386/pc_q35.c     | 9 ---------
 4 files changed, 24 deletions(-)
include/hw/i386/pc.h +0 -3
index 844ae835784f..4aa5b02fe356 100644
@@ -277,9 +277,6 @@ extern const size_t pc_compat_5_0_len;
 extern GlobalProperty pc_compat_4_2[];
 extern const size_t pc_compat_4_2_len;
 
-extern GlobalProperty pc_compat_4_1[];
-extern const size_t pc_compat_4_1_len;
-
 #define DEFINE_PC_MACHINE_EXTENDED(suffix, namestr, initfn, optsfn, issecure) \
     static void pc_machine_##suffix##_class_init(ObjectClass *oc, \
                                                  const void *data) \
hw/i386/pc.c +0 -3
index 4737eb471c14..d14a82106410 100644
@@ -182,9 +182,6 @@ GlobalProperty pc_compat_4_2[] = {
 };
 const size_t pc_compat_4_2_len = G_N_ELEMENTS(pc_compat_4_2);
 
-GlobalProperty pc_compat_4_1[] = {};
-const size_t pc_compat_4_1_len = G_N_ELEMENTS(pc_compat_4_1);
-
 /*
  * @PC_FW_DATA:
  * Size of the chunk of memory at the top of RAM for the BIOS ACPI tables
hw/i386/pc_piix.c +0 -9
index 446590e4e55c..6d04d1c75be7 100644
@@ -622,15 +622,6 @@ static void pc_i440fx_machine_4_2_options(MachineClass *m)
 
 DEFINE_I440FX_MACHINE(4, 2);
 
-static void pc_i440fx_machine_4_1_options(MachineClass *m)
-{
-    pc_i440fx_machine_4_2_options(m);
-    compat_props_add(m->compat_props, hw_compat_4_1, hw_compat_4_1_len);
-    compat_props_add(m->compat_props, pc_compat_4_1, pc_compat_4_1_len);
-}
-
-DEFINE_I440FX_MACHINE(4, 1);
-
 #ifdef CONFIG_XEN
 static void xenfv_machine_4_2_options(MachineClass *m)
 {
hw/i386/pc_q35.c +0 -9
index c3ce9c564922..e6a6c711f473 100644
@@ -598,12 +598,3 @@ static void pc_q35_machine_4_2_options(MachineClass *m)
 }
 
 DEFINE_Q35_MACHINE(4, 2);
-
-static void pc_q35_machine_4_1_options(MachineClass *m)
-{
-    pc_q35_machine_4_2_options(m);
-    compat_props_add(m->compat_props, hw_compat_4_1, hw_compat_4_1_len);
-    compat_props_add(m->compat_props, pc_compat_4_1, pc_compat_4_1_len);
-}
-
-DEFINE_Q35_MACHINE(4, 1);
Signature · 1 line
2.55.0
#6 lore raw

[PULL 03/11] hw/sd/sdhci: Treat Software Reset bits as independent pulses

In reply to Philippe Mathieu-Daudé

Writing Reset CMD and Reset DAT together (0x06) reset nothing, as the register was matched against exact values.

Apply each bit independently. Reset For All still resets everything (SD Host Controller v1.00, section 2.2.16).

Update the IRQ line after reset, since clearing Normal Interrupt Status bits may deassert it.

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

Fixes d7dfca0807a0 ("hw/sdhci: introduce standard SD host controller")

Message-ID: <[email protected]>

---
 hw/sd/sdhci.c | 39 ++++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 19 deletions(-)
hw/sd/sdhci.c +20 -19
index 695de6448f89..9bdc898e7f54 100644
@@ -1237,27 +1237,28 @@ static inline void sdhci_blkgap_write(SDHCIState *s, uint8_t value)
 
 static inline void sdhci_reset_write(SDHCIState *s, uint8_t value)
 {
-    switch (value) {
-    case SDHC_RESET_ALL:
+    /* Each bit is an independent reset; Reset All clears CMD and DAT too */
+    if (value & SDHC_RESET_ALL) {
         sdhci_reset(s);
-        break;
-    case SDHC_RESET_CMD:
-        s->prnsts &= ~SDHC_CMD_INHIBIT;
-        s->norintsts &= ~SDHC_NIS_CMDCMP;
-        break;
-    case SDHC_RESET_DATA:
-        timer_del(s->transfer_timer);
-        s->data_count = 0;
-        s->prnsts &= ~(SDHC_SPACE_AVAILABLE | SDHC_DATA_AVAILABLE |
-                SDHC_DOING_READ | SDHC_DOING_WRITE |
-                SDHC_DATA_INHIBIT | SDHC_DAT_LINE_ACTIVE);
-        s->blkgap &= ~(SDHC_STOP_AT_GAP_REQ | SDHC_CONTINUE_REQ);
-        s->stopped_state = sdhc_not_stopped;
-        s->sdma_boundary_paused = false;
-        s->norintsts &= ~(SDHC_NIS_WBUFRDY | SDHC_NIS_RBUFRDY |
-                SDHC_NIS_DMA | SDHC_NIS_TRSCMP | SDHC_NIS_BLKGAP);
-        break;
+    } else {
+        if (value & SDHC_RESET_CMD) {
+            s->prnsts &= ~SDHC_CMD_INHIBIT;
+            s->norintsts &= ~SDHC_NIS_CMDCMP;
+        }
+        if (value & SDHC_RESET_DATA) {
+            timer_del(s->transfer_timer);
+            s->data_count = 0;
+            s->prnsts &= ~(SDHC_SPACE_AVAILABLE | SDHC_DATA_AVAILABLE |
+                    SDHC_DOING_READ | SDHC_DOING_WRITE |
+                    SDHC_DATA_INHIBIT | SDHC_DAT_LINE_ACTIVE);
+            s->blkgap &= ~(SDHC_STOP_AT_GAP_REQ | SDHC_CONTINUE_REQ);
+            s->stopped_state = sdhc_not_stopped;
+            s->sdma_boundary_paused = false;
+            s->norintsts &= ~(SDHC_NIS_WBUFRDY | SDHC_NIS_RBUFRDY |
+                    SDHC_NIS_DMA | SDHC_NIS_TRSCMP | SDHC_NIS_BLKGAP);
+        }
     }
+    sdhci_update_irq(s);
 }
 
 static void
Signature · 1 line
2.55.0
#7 lore raw

[PULL 09/11] hw/nvram/spapr_nvram: register VM change state handler once

In reply to Philippe Mathieu-Daudé

From: Peter Maydell <[email protected]>

In the spapr_nvram post-load function we register a VM change state handler callback, which is a one-shot (it deletes itself when run).

However, loading twice before the VM resumes means the post_load hook adds the handler again, overwriting the old nvram->vmstate. This can result in a use-after-free on resume because the first-registered callback does not delete itself (which is permitted) but the second-registered callback (which is not).

Follow the pattern used by vapic.c and only register the callback if it has not already been registered.

Fixes cf472f48d57a533c ("spapr: fix spapr-nvram migration")

Message-ID: <[email protected]>

---
 hw/nvram/spapr_nvram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/nvram/spapr_nvram.c +1 -1
index b0f9fe8633f5..0b85412e3e88 100644
@@ -233,7 +233,7 @@ static int spapr_nvram_post_load(void *opaque, int version_id)
 {
     SpaprNvram *nvram = VIO_SPAPR_NVRAM(opaque);
 
-    if (nvram->blk) {
+    if (nvram->blk && !nvram->vmstate) {
         nvram->vmstate = qemu_add_vm_change_state_handler(postload_update_cb,
                                                           nvram);
     }
Signature · 1 line
2.55.0
#8 lore raw

[PULL 07/11] hw/virtio: Remove hw_compat_4_1[] array and "x-pcie-flr-init" from virtio-pci

In reply to Philippe Mathieu-Daudé

From: Thomas Huth <[email protected]>

There is no machine left that is using hw_compat_4_1[], so the array and the "virtio-pci"->"x-pcie-flr-init" setting can be removed now.

Message-ID: <[email protected]>

---
 include/hw/core/boards.h       |  3 ---
 include/hw/virtio/virtio-pci.h |  4 ----
 hw/core/machine.c              |  5 -----
 hw/virtio/virtio-pci.c         | 13 +++----------
 4 files changed, 3 insertions(+), 22 deletions(-)
include/hw/core/boards.h +0 -3
index d0e4ad98201e..a45495db81f1 100644
@@ -893,7 +893,4 @@ extern const size_t hw_compat_5_0_len;
 extern GlobalProperty hw_compat_4_2[];
 extern const size_t hw_compat_4_2_len;
 
-extern GlobalProperty hw_compat_4_1[];
-extern const size_t hw_compat_4_1_len;
-
 #endif
include/hw/virtio/virtio-pci.h +0 -4
index f033237035a2..b2738ceafacc 100644
@@ -35,7 +35,6 @@ enum {
     VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY_BIT,
     VIRTIO_PCI_FLAG_PAGE_PER_VQ_BIT,
     VIRTIO_PCI_FLAG_ATS_BIT,
-    VIRTIO_PCI_FLAG_INIT_FLR_BIT,
     VIRTIO_PCI_FLAG_AER_BIT,
     VIRTIO_PCI_FLAG_ATS_PAGE_ALIGNED_BIT,
     VIRTIO_PCI_FLAG_PM_NO_SOFT_RESET_BIT,
@@ -64,9 +63,6 @@ enum {
 #define VIRTIO_PCI_FLAG_PM_NO_SOFT_RESET \
   (1 << VIRTIO_PCI_FLAG_PM_NO_SOFT_RESET_BIT)
 
-/* Init Function Level Reset capability */
-#define VIRTIO_PCI_FLAG_INIT_FLR (1 << VIRTIO_PCI_FLAG_INIT_FLR_BIT)
-
 /* Advanced Error Reporting capability */
 #define VIRTIO_PCI_FLAG_AER (1 << VIRTIO_PCI_FLAG_AER_BIT)
 
hw/core/machine.c +0 -5
index ed9bf8f5008f..8342a3bb94c4 100644
@@ -235,11 +235,6 @@ GlobalProperty hw_compat_4_2[] = {
 };
 const size_t hw_compat_4_2_len = G_N_ELEMENTS(hw_compat_4_2);
 
-GlobalProperty hw_compat_4_1[] = {
-    { "virtio-pci", "x-pcie-flr-init", "off" },
-};
-const size_t hw_compat_4_1_len = G_N_ELEMENTS(hw_compat_4_1);
-
 MachineState *current_machine;
 
 static char *machine_get_kernel(Object *obj, Error **errp)
hw/virtio/virtio-pci.c +3 -10
index fe2e545c3023..9ff8b63d090e 100644
@@ -799,10 +799,7 @@ static void virtio_write_config(PCIDevice *pci_dev, uint32_t address,
     struct virtio_pci_cfg_cap *cfg;
 
     pci_default_write_config(pci_dev, address, val, len);
-
-    if (proxy->flags & VIRTIO_PCI_FLAG_INIT_FLR) {
-        pcie_cap_flr_write_config(pci_dev, address, val, len);
-    }
+    pcie_cap_flr_write_config(pci_dev, address, val, len);
 
     if (proxy->flags & VIRTIO_PCI_FLAG_ATS) {
         pcie_ats_config_write(pci_dev, address, val, len);
@@ -2309,10 +2306,8 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
             proxy->last_pcie_cap_offset += PCI_EXT_CAP_ATS_SIZEOF;
         }
 
-        if (proxy->flags & VIRTIO_PCI_FLAG_INIT_FLR) {
-            /* Set Function Level Reset capability bit */
-            pcie_cap_flr_init(pci_dev);
-        }
+        /* Set Function Level Reset capability bit */
+        pcie_cap_flr_init(pci_dev);
     } else {
         /*
          * make future invocations of pci_is_express() return false
@@ -2418,8 +2413,6 @@ static const Property virtio_pci_properties[] = {
                     VIRTIO_PCI_FLAG_ATS_PAGE_ALIGNED_BIT, true),
     DEFINE_PROP_BIT("x-pcie-pm-no-soft-reset", VirtIOPCIProxy, flags,
                     VIRTIO_PCI_FLAG_PM_NO_SOFT_RESET_BIT, false),
-    DEFINE_PROP_BIT("x-pcie-flr-init", VirtIOPCIProxy, flags,
-                    VIRTIO_PCI_FLAG_INIT_FLR_BIT, true),
     DEFINE_PROP_BIT("aer", VirtIOPCIProxy, flags,
                     VIRTIO_PCI_FLAG_AER_BIT, false),
 };
Signature · 1 line
2.55.0
#9 lore raw

[PULL 10/11] hw/block/pflash_cfi02: register VM change state handler once

In reply to Philippe Mathieu-Daudé

From: Peter Maydell <[email protected]>

In the pflash_cfi02 post-load function we register a VM change state handler callback, which is a one-shot (it deletes itself when run).

However, loading twice before the VM resumes means the post_load hook adds the handler again, overwriting the old pfl->vmstate. This can result in a use-after-free on resume because the first-registered callback does not delete itself (which is permitted) but the second-registered callback (which is not).

Follow the pattern used by vapic.c and only register the callback if it has not already been registered.

Fixes be71ba48d5c632 ("hw/block/pflash_cfi02: Add migration support")

Message-ID: <[email protected]>

---
 hw/block/pflash_cfi02.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/pflash_cfi02.c +1 -1
index 8d130e14d1c1..28e8c27d72e8 100644
@@ -1070,7 +1070,7 @@ static int pflash_post_load(void *opaque, int version_id)
 {
     PFlashCFI02 *pfl = opaque;
 
-    if (!pfl->ro) {
+    if (!pfl->ro && !pfl->vmstate) {
         pfl->vmstate = qemu_add_vm_change_state_handler(postload_update_cb, pfl);
     }
 
Signature · 1 line
2.55.0
#10 lore raw

[PULL 11/11] hw/net/can/ctucan: send a Ready TXT buffer that has priority 0

In reply to Philippe Mathieu-Daudé

From: Yashaswin Sharma Puranik <[email protected]>

ctucan_send_ready_buffers() starts each round with tx_prio_max = 0 and takes a Ready buffer only when its priority is higher. A Ready buffer with priority 0 is never picked. It stays Ready and the frame is never sent.

The CTU CAN FD datasheet (v2.7.0, section 2.9) has no such rule. The Ready buffer with the highest priority is sent, and of two buffers with equal priority the one with the lower index goes first. TX_PRIORITY resets to 0 for every buffer but the first. Linux does not hit this with four buffers, because it rotates the priorities 7 down to 4.

Select the first Ready buffer regardless of its priority. Replace it only for a strictly higher priority, so that the lower index still goes first when priorities are equal.

Fixes aa406e8b7ecd ("hw/net/can: CTU CAN FD IP open hardware core emulation.")

Message-ID: <[email protected]>

---
 hw/net/can/ctucan_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/can/ctucan_core.c +1 -1
index f6ff4ad2003d..380a3ee21d39 100644
@@ -259,7 +259,7 @@ static void ctucan_send_ready_buffers(CtuCanCoreState *s)
                 continue;
             }
             prio = (s->tx_priority.u32 >> (i * 4)) & 0x7;
-            if (tx_prio_max < prio) {
+            if (tx_prio_max < prio || buff2tx_idx == -1) {
                 tx_prio_max = prio;
                 buff2tx_idx = i;
             }
Signature · 1 line
2.55.0
#11 lore raw

[PULL 08/11] hw/misc/mac_via: register VM change state handler once

In reply to Philippe Mathieu-Daudé

From: Peter Maydell <[email protected]>

In the mac_via post-load function we register a VM change state handler callback, which is a one-shot (it deletes itself when run).

However, loading twice before the VM resumes means the post_load hook adds the handler again, overwriting the old v1s->vmstate. This can result in a use-after-free on resume because the first-registered callback does not delete itself (which is permitted) but the second-registered callback (which is not).

Follow the pattern used by vapic.c and only register the callback if it has not already been registered.

Fixes eb064db94ccd62f054 ("q800: add a block backend to the PRAM")

Message-ID: <[email protected]>

---
 hw/misc/mac_via.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/misc/mac_via.c +1 -1
index 26ee230dcc4a..dfc7d304ffc0 100644
@@ -1192,7 +1192,7 @@ static int via1_post_load(void *opaque, int version_id)
 {
     MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(opaque);
 
-    if (v1s->blk) {
+    if (v1s->blk && !v1s->vmstate) {
         v1s->vmstate = qemu_add_vm_change_state_handler(
                            via1_postload_update_cb, v1s);
     }
Signature · 1 line
2.55.0
#12 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 10 lines · Philippe Mathieu-Daudé

The following changes since commit 9cda597a1a3903d090e8e55e23f5b8a859da88ab:

   Merge tag 'pbouvier/pr/fixes_11.2-20261127' ofhttps://gitlab.com/p-b-o/qemu into staging (2026-11-29 13:42:36 -0800)

are available in the Git repository at:

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

for you to fetch changes up to d639f909a00ef9ca1fd367854149158e46fdad22:

Quoted 8 lines

hw/net/can/ctucan: send a Ready TXT buffer that has priority 0 (2026-11-30 22:42:44 +0100)

----------------------------------------------------------------
Misc HW patch queue

- Fixes (SD card, SDHCI, SJA1000 CAN, Macintosh VIA)
- Use-after-free in some migration post_load hooks
- Remove compatibility properties for legacy 4.1 machines

Applied, thanks.

r~