All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 0/9] Misc HW patches for 2026-07-21
@ 2026-07-21 10:39 Philippe Mathieu-Daudé
  2026-07-21 10:39 ` [PULL 1/9] net: Correct padding check in qemu_receive_packet() Philippe Mathieu-Daudé
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-07-21 10:39 UTC (permalink / raw)
  To: qemu-devel

The following changes since commit bd6079a7a1d14de0918a7715ef6db85dc32de3bb:

  Merge tag 'next-pull-request' of https://gitlab.com/peterx/qemu into staging (2026-07-20 11:12:38 -0400)

are available in the Git repository at:

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

for you to fetch changes up to d06edc83b522c68627b83d3178197353c4d548ab:

  vfio/listener: Remove unnecessary 'linux/kvm.h' include (2026-07-21 12:38:48 +0200)

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

Various fixes mostly related to misc hardware devices.

The only CI failure is related to a sphinx error, and there is
already developers looking at that so I ignored it:
https://lore.kernel.org/qemu-devel/20260720222717.33078-1-pierrick.bouvier@oss.qualcomm.com/
----------------------------------------------------------------

Bernhard Beschow (1):
  hw/sd/sdcard: Fix error case for CMD18

Bin Meng (1):
  hw/net/cadence: Return current Cadence GEM queue pointers

Cédric Le Goater (1):
  vfio/listener: Remove unnecessary 'linux/kvm.h' include

Haotian Jiang (1):
  hw/audio/intel-hda: restrict all DMA engine paths to memories

Marc-André Lureau (2):
  hw/display/qxl: validate monitors_config heads[] in phys2virt
  replay: fix use of uninitialized pointer on error

Peter Maydell (1):
  net: Correct padding check in qemu_receive_packet()

Philippe Mathieu-Daudé (1):
  hw/misc/applesmc: Fix a typo setting MSSD key

Richard Henderson (1):
  user/guest-host: Include exec/abi_ptr.h

 include/net/net.h         | 23 +++++++++++++++++++++++
 include/user/guest-host.h |  1 +
 hw/audio/intel-hda.c      |  9 ++++++---
 hw/display/qxl.c          |  2 +-
 hw/misc/applesmc.c        |  6 +++---
 hw/net/cadence_gem.c      | 17 ++++++++++++++++-
 hw/sd/sd.c                |  3 ++-
 hw/vfio/listener.c        |  1 -
 net/net.c                 |  2 +-
 replay/replay-debugging.c | 23 ++++++++++++-----------
 10 files changed, 65 insertions(+), 22 deletions(-)

-- 
2.53.0



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PULL 1/9] net: Correct padding check in qemu_receive_packet()
  2026-07-21 10:39 [PULL 0/9] Misc HW patches for 2026-07-21 Philippe Mathieu-Daudé
@ 2026-07-21 10:39 ` Philippe Mathieu-Daudé
  2026-07-21 10:39 ` [PULL 2/9] hw/display/qxl: validate monitors_config heads[] in phys2virt Philippe Mathieu-Daudé
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-07-21 10:39 UTC (permalink / raw)
  To: qemu-devel

From: Peter Maydell <peter.maydell@linaro.org>

In qemu_receive_packet() we check to see if we should pad a short
packet.  This is doing the wrong test: because this function is used
when the device adds a packet to its own incoming queue (i.e.  for
loopback), we should be checking the NetClientState's own do_not_pad
flag, not that for its peer.

We didn't notice this earlier, because at the moment all the real
peers of a network device (i.e.  the network backends) do not set
do_not_pad, so net_peer_needs_padding() always returns true except in
the corner case where the network device has no peer at all.

The effect of this is that if a network device has no peer (e.g.
because QEMU was started with -net none or with -nodefaults) then we
can still let through the kind of "guest misprograms the network
device to loopback-transmit a short packet and then we mishandle it
in the receive path" bug like #3043 which commit a01344d9d78 was
trying to fix.

Since the distinction between "we should check nc->do_not_pad"
and "we should check nc->peer->do_not_pad" is a bit subtle, add
enough documentation commentary to make it more obvious.

Cc: qemu-stable@nongnu.org
Fixes: a01344d9d78 ("net: pad packets to minimum length in qemu_receive_packet()")
Suggested-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Bin Meng <bin.meng@processmission.com>
Message-ID: <20260629164246.2028947-1-peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
 include/net/net.h | 23 +++++++++++++++++++++++
 net/net.c         |  2 +-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/include/net/net.h b/include/net/net.h
index 45bc86fc86b..9edfacf827c 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -349,9 +349,32 @@ uint32_t net_crc32_le(const uint8_t *p, int len);
     .offset     = vmstate_offset_macaddr(_state, _field),            \
 }
 
+/**
+ * net_peer_needs_padding: Should we pad as we send out packets?
+ * @nc: NetClientState
+ *
+ * Return true if the peer of this NetClientState (i.e. the
+ * destination that qemu_send_packet() etc send to) requires us to pad
+ * out packets that are shorter than the minimum ethernet frame
+ * length.
+ */
 static inline bool net_peer_needs_padding(NetClientState *nc)
 {
   return nc->peer && !nc->peer->do_not_pad;
 }
 
+/**
+ * net_client_needs_padding: Should we pad as we queue packets to ourselves?
+ * @nc: NetClientState
+ *
+ * Return true if this NetClientState requires us to pad out packets
+ * that are shorter than the minimum ethernet frame length.  This is
+ * the check to make in qemu_receive_packet() when we are queuing a
+ * packet back into ourselves (i.e. loopback).
+ */
+static inline bool net_client_needs_padding(NetClientState *nc)
+{
+    return !nc->do_not_pad;
+}
+
 #endif
diff --git a/net/net.c b/net/net.c
index 5c39f8e7b44..0a30579ca4a 100644
--- a/net/net.c
+++ b/net/net.c
@@ -783,7 +783,7 @@ ssize_t qemu_receive_packet(NetClientState *nc, const uint8_t *buf, int size)
         return 0;
     }
 
-    if (net_peer_needs_padding(nc)) {
+    if (net_client_needs_padding(nc)) {
         if (eth_pad_short_frame(min_pkt, &min_pktsz, buf, size)) {
             buf = min_pkt;
             size = min_pktsz;
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PULL 2/9] hw/display/qxl: validate monitors_config heads[] in phys2virt
  2026-07-21 10:39 [PULL 0/9] Misc HW patches for 2026-07-21 Philippe Mathieu-Daudé
  2026-07-21 10:39 ` [PULL 1/9] net: Correct padding check in qemu_receive_packet() Philippe Mathieu-Daudé
@ 2026-07-21 10:39 ` Philippe Mathieu-Daudé
  2026-07-21 10:39 ` [PULL 3/9] user/guest-host: Include exec/abi_ptr.h Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-07-21 10:39 UTC (permalink / raw)
  To: qemu-devel

From: Marc-André Lureau <marcandre.lureau@redhat.com>

The qxl_phys2virt() call for guest_monitors_config only validates
sizeof(QXLMonitorsConfig), which covers the fixed header (count and
max_allowed) since commit 8efec0ef8bbc ("hw/display/qxl: Pass requested
buffer size to qxl_phys2virt()"), but not the flexible array member
heads[]. When count == 1, heads[0] is accessed without its memory being
validated, allowing a guest to cause an out-of-bounds read.

Include sizeof(QXLHead) in the size passed to qxl_phys2virt() so that
the first head entry is validated within the guest memory slot, preventing
guest-visible memory reading.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4027
Reported-by: Tristan @TristanInSec
Signed-off-by: Marc-Andre Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260715072722.1643289-1-marcandre.lureau@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
 hw/display/qxl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index 74258afa582..3df796175c2 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -270,7 +270,7 @@ static void qxl_spice_monitors_config_async(PCIQXLDevice *qxl, int replay)
     }
 
     cfg = qxl_phys2virt(qxl, qxl->guest_monitors_config, MEMSLOT_GROUP_GUEST,
-                        sizeof(QXLMonitorsConfig));
+                        sizeof(QXLMonitorsConfig) + sizeof(QXLHead));
     if (cfg != NULL && cfg->count == 1) {
         qxl->guest_primary.resized = 1;
         qxl->guest_head0_width  = cfg->heads[0].width;
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PULL 3/9] user/guest-host: Include exec/abi_ptr.h
  2026-07-21 10:39 [PULL 0/9] Misc HW patches for 2026-07-21 Philippe Mathieu-Daudé
  2026-07-21 10:39 ` [PULL 1/9] net: Correct padding check in qemu_receive_packet() Philippe Mathieu-Daudé
  2026-07-21 10:39 ` [PULL 2/9] hw/display/qxl: validate monitors_config heads[] in phys2virt Philippe Mathieu-Daudé
@ 2026-07-21 10:39 ` Philippe Mathieu-Daudé
  2026-07-21 10:39 ` [PULL 4/9] replay: fix use of uninitialized pointer on error Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-07-21 10:39 UTC (permalink / raw)
  To: qemu-devel

From: Richard Henderson <richard.henderson@linaro.org>

The COMPILING_PER_TARGET block uses the abi_ptr type
without including the proper header.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260717232306.378988-2-richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
 include/user/guest-host.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/user/guest-host.h b/include/user/guest-host.h
index 506efc097e0..f136f81f5d9 100644
--- a/include/user/guest-host.h
+++ b/include/user/guest-host.h
@@ -80,6 +80,7 @@ static inline bool guest_range_valid_untagged_vaddr(vaddr start, vaddr len)
 })
 
 #ifdef COMPILING_PER_TARGET
+#include "exec/abi_ptr.h"
 
 /*
  * These functions take the guest virtual address as an abi_ptr.  This
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PULL 4/9] replay: fix use of uninitialized pointer on error
  2026-07-21 10:39 [PULL 0/9] Misc HW patches for 2026-07-21 Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2026-07-21 10:39 ` [PULL 3/9] user/guest-host: Include exec/abi_ptr.h Philippe Mathieu-Daudé
@ 2026-07-21 10:39 ` Philippe Mathieu-Daudé
  2026-07-21 10:40 ` [PULL 5/9] hw/misc/applesmc: Fix a typo setting MSSD key Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-07-21 10:39 UTC (permalink / raw)
  To: qemu-devel

From: Marc-André Lureau <marcandre.lureau@redhat.com>

When bdrv_snapshot_list() returns a negative error code, sn_tab is
uninitialized. The loop does not execute (since i=0 < negative is
false), but the code falls through to g_free(sn_tab) which frees
an uninitialized pointer.

Fixes: f6baed3d1485 ("replay: implement replay-seek command")
Signed-off-by: Marc-Andre Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260719113216.1177594-1-marcandre.lureau@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
 replay/replay-debugging.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/replay/replay-debugging.c b/replay/replay-debugging.c
index 11053640021..7b904a14165 100644
--- a/replay/replay-debugging.c
+++ b/replay/replay-debugging.c
@@ -139,9 +139,8 @@ static char *replay_find_nearest_snapshot(int64_t icount,
                                           int64_t *snapshot_icount)
 {
     BlockDriverState *bs;
-    QEMUSnapshotInfo *sn_tab;
+    g_autofree QEMUSnapshotInfo *sn_tab = NULL;
     QEMUSnapshotInfo *nearest = NULL;
-    char *ret = NULL;
     int rv;
     int nb_sns, i;
 
@@ -149,15 +148,19 @@ static char *replay_find_nearest_snapshot(int64_t icount,
 
     bs = bdrv_all_find_vmstate_bs(NULL, false, NULL, NULL);
     if (!bs) {
-        goto fail;
+        return NULL;
     }
 
     nb_sns = bdrv_snapshot_list(bs, &sn_tab);
+    if (nb_sns < 0) {
+        return NULL;
+    }
 
     for (i = 0; i < nb_sns; i++) {
         rv = bdrv_all_has_snapshot(sn_tab[i].name, false, NULL, NULL);
-        if (rv < 0)
-            goto fail;
+        if (rv < 0) {
+            return NULL;
+        }
         if (rv == 1) {
             if (sn_tab[i].icount != -1ULL
                 && sn_tab[i].icount <= icount
@@ -166,14 +169,12 @@ static char *replay_find_nearest_snapshot(int64_t icount,
             }
         }
     }
-    if (nearest) {
-        ret = g_strdup(nearest->name);
-        *snapshot_icount = nearest->icount;
+    if (!nearest) {
+        return NULL;
     }
-    g_free(sn_tab);
 
-fail:
-    return ret;
+    *snapshot_icount = nearest->icount;
+    return g_strdup(nearest->name);
 }
 
 static void replay_seek(int64_t icount, QEMUTimerCB callback, Error **errp)
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PULL 5/9] hw/misc/applesmc: Fix a typo setting MSSD key
  2026-07-21 10:39 [PULL 0/9] Misc HW patches for 2026-07-21 Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2026-07-21 10:39 ` [PULL 4/9] replay: fix use of uninitialized pointer on error Philippe Mathieu-Daudé
@ 2026-07-21 10:40 ` Philippe Mathieu-Daudé
  2026-07-21 10:40 ` [PULL 6/9] hw/net/cadence: Return current Cadence GEM queue pointers Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-07-21 10:40 UTC (permalink / raw)
  To: qemu-devel

In commit 1ddda5cd364 we meant to set MSSD=3, but due
to a typo we ended setting MSSD=0. Convert the two other
NATJ and MSSP keys to use hexadecimal notation to avoid
similar copy/paste typos.

Cc: qemu-stable@nongnu.org
Fixes: 1ddda5cd364 ("AppleSMC device emulation")
Reported-by: Matthew Jackson <matthew@pq.io>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Alexander Graf <agraf@csgraf.de>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Message-Id: <20260720115336.75063-1-philmd@oss.qualcomm.com>
---
 hw/misc/applesmc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/misc/applesmc.c b/hw/misc/applesmc.c
index fd96f5f245f..d004e8b4431 100644
--- a/hw/misc/applesmc.c
+++ b/hw/misc/applesmc.c
@@ -333,9 +333,9 @@ static void applesmc_isa_realize(DeviceState *dev, Error **errp)
     applesmc_add_key(s, "REV ", 6, "\x01\x13\x0f\x00\x00\x03");
     applesmc_add_key(s, "OSK0", 32, s->osk);
     applesmc_add_key(s, "OSK1", 32, s->osk + 32);
-    applesmc_add_key(s, "NATJ", 1, "\0");
-    applesmc_add_key(s, "MSSP", 1, "\0");
-    applesmc_add_key(s, "MSSD", 1, "\0x3");
+    applesmc_add_key(s, "NATJ", 1, "\x00");
+    applesmc_add_key(s, "MSSP", 1, "\x00");
+    applesmc_add_key(s, "MSSD", 1, "\x03");
 }
 
 static void applesmc_unrealize(DeviceState *dev)
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PULL 6/9] hw/net/cadence: Return current Cadence GEM queue pointers
  2026-07-21 10:39 [PULL 0/9] Misc HW patches for 2026-07-21 Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2026-07-21 10:40 ` [PULL 5/9] hw/misc/applesmc: Fix a typo setting MSSD key Philippe Mathieu-Daudé
@ 2026-07-21 10:40 ` Philippe Mathieu-Daudé
  2026-07-21 10:40 ` [PULL 7/9] hw/sd/sdcard: Fix error case for CMD18 Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-07-21 10:40 UTC (permalink / raw)
  To: qemu-devel

From: Bin Meng <bin.meng@processmission.com>

Cadence GEM queue pointer registers are programmed with the descriptor
ring base, but reads return the descriptor currently being accessed.
The model tracked the current positions separately while continuing to
return the configured base.

The Linux macb driver uses the transmit queue pointer when recovering
from a used-buffer interrupt. A stale priority-queue pointer can make
the driver restart DMA before that queue handles its completion
interrupt, causing queue 0 to repeatedly raise TX_USED.

The primary queue has had this mismatch since the initial model.
Priority queue support later copied the same register-read behavior.

A single-queue machine usually handles TX_COMPLETE before TX_USED and
empties the software queue before the restart check, which kept the
issue hidden there.

Return the current RX and TX descriptor positions on queue-pointer reads
and clear those positions on reset.

Fixes: e9f186e514a7 ("cadence_gem: initial version of device model")
Fixes: 6710172501be ("cadence_gem: Add queue support")
Cc: qemu-stable@nongnu.org
Signed-off-by: Bin Meng <bin.meng@processmission.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260720120731.2022475-1-bin.meng@processmission.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
 hw/net/cadence_gem.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
index b568fa3392d..39e3620ef5b 100644
--- a/hw/net/cadence_gem.c
+++ b/hw/net/cadence_gem.c
@@ -1469,6 +1469,8 @@ static void gem_reset(DeviceState *d)
 
     /* Set post reset register values */
     memset(&s->regs[0], 0, sizeof(s->regs));
+    memset(&s->rx_desc_addr[0], 0, sizeof(s->rx_desc_addr));
+    memset(&s->tx_desc_addr[0], 0, sizeof(s->tx_desc_addr));
     s->regs[R_NWCFG] = 0x00080000;
     s->regs[R_NWSTATUS] = 0x00000006;
     s->regs[R_DMACFG] = 0x00020784;
@@ -1593,9 +1595,22 @@ static uint64_t gem_read(void *opaque, hwaddr offset, unsigned size)
     offset >>= 2;
     retval = s->regs[offset];
 
-    DB_PRINT("offset: 0x%04x read: 0x%08x\n", (unsigned)offset*4, retval);
+    DB_PRINT("offset: 0x%04x read: 0x%08x\n", (unsigned)offset * 4,
+             retval);
 
     switch (offset) {
+    case R_RXQBASE:
+        retval = s->rx_desc_addr[0];
+        break;
+    case R_TXQBASE:
+        retval = s->tx_desc_addr[0];
+        break;
+    case R_TRANSMIT_Q1_PTR ... R_TRANSMIT_Q7_PTR:
+        retval = s->tx_desc_addr[offset - R_TRANSMIT_Q1_PTR + 1];
+        break;
+    case R_RECEIVE_Q1_PTR ... R_RECEIVE_Q7_PTR:
+        retval = s->rx_desc_addr[offset - R_RECEIVE_Q1_PTR + 1];
+        break;
     case R_ISR:
         DB_PRINT("lowering irqs on ISR read\n");
         /* The interrupts get updated at the end of the function. */
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PULL 7/9] hw/sd/sdcard: Fix error case for CMD18
  2026-07-21 10:39 [PULL 0/9] Misc HW patches for 2026-07-21 Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2026-07-21 10:40 ` [PULL 6/9] hw/net/cadence: Return current Cadence GEM queue pointers Philippe Mathieu-Daudé
@ 2026-07-21 10:40 ` Philippe Mathieu-Daudé
  2026-07-21 10:40 ` [PULL 8/9] hw/audio/intel-hda: restrict all DMA engine paths to memories Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-07-21 10:40 UTC (permalink / raw)
  To: qemu-devel

From: Bernhard Beschow <shentey@gmail.com>

In commit 468fa450a7e0 ("hw/sd: Switch read/write primitive to
buf+len"), `sd_read_byte()` changed its contract to return the read size
rather than the read value (and was renamed to `sd_read_data()`
accordingly). In an error case, however, `sd_read_data()` returns 0 by
means of `dummy_byte` which is the code for the old contract. Moreover,
`sdbus_read_data()` asserts the virtual method `read_data()` (and thus
`sd_read_data()`) to return a non-zero size, i.e. to make progress and
not loop forever. Fix the code to behave like the "DAT read illegal for
command" case.

Fixes: 468fa450a7e0 ("hw/sd: Switch read/write primitive to buf+len")
Reviewed-by: Bin Meng <bin.meng@processmission.com>
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260720201133.24796-2-shentey@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
 hw/sd/sd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 33607570043..a30c541df07 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -2860,7 +2860,8 @@ static size_t sd_read_data(SDState *sd, void *buf, size_t length)
         if (sd->data_offset == 0) {
             if (!address_in_range(sd, "READ_MULTIPLE_BLOCK",
                                   sd->data_start, io_len)) {
-                return dummy_byte;
+                *value = dummy_byte;
+                return length;
             }
             partition_access = sd->ext_csd[EXT_CSD_PART_CONFIG]
                     & EXT_CSD_PART_CONFIG_ACC_MASK;
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PULL 8/9] hw/audio/intel-hda: restrict all DMA engine paths to memories
  2026-07-21 10:39 [PULL 0/9] Misc HW patches for 2026-07-21 Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2026-07-21 10:40 ` [PULL 7/9] hw/sd/sdcard: Fix error case for CMD18 Philippe Mathieu-Daudé
@ 2026-07-21 10:40 ` Philippe Mathieu-Daudé
  2026-07-21 10:40 ` [PULL 9/9] vfio/listener: Remove unnecessary 'linux/kvm.h' include Philippe Mathieu-Daudé
  2026-07-21 16:01 ` [PULL 0/9] Misc HW patches for 2026-07-21 Stefan Hajnoczi
  9 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-07-21 10:40 UTC (permalink / raw)
  To: qemu-devel

From: Haotian Jiang <jianghaotian.sunday@gmail.com>

CVE-2021-3611 (commit 79fa99831d) restricted the DMA engine to memories
by setting attrs.memory=true, but only applied this to intel_hda_response.
Three other DMA engine access points still use MEMTXATTRS_UNSPECIFIED,
allowing a malicious guest to trigger DMA-to-self-MMIO reentry:

  - intel_hda_xfer (line 398): called from the audio timer callback
    (hda_codec_xfer -> bus->xfer), so the MemReentrancyGuard does not
    fire (engaged_in_io is false outside MMIO dispatch). A guest that
    points a BDL entry at the HDA controller's own MMIO BAR can write
    audio samples to device registers, triggering whandler side effects
    such as starting/stopping streams or injecting codec commands via
    CORBWP.
  - intel_hda_parse_bdl (line 478): uses pci_dma_read which hardcodes
    MEMTXATTRS_UNSPECIFIED. A guest-controlled BDL base address can
    point at controller MMIO, allowing the DMA engine to read device
    registers as BDL descriptors.
  - intel_hda_corb_run (line 333): ldl_le_pci_dma reads the CORB ring
    with MEMTXATTRS_UNSPECIFIED, allowing the DMA engine to read
    controller MMIO as CORB entries.

Fix all three by passing {.memory = true} explicitly, matching the
fix already applied to intel_hda_response. For intel_hda_parse_bdl,
replace pci_dma_read with pci_dma_rw to pass the controlled attrs.

Fixes: 79fa99831d ("hw/audio/intel-hda: Restrict DMA engine to memories (not MMIO devices)")
Reported-by: Haotian Jiang of Tencent Security (Yunding Lab) <jianghaotian.sunday@gmail.com>
Signed-off-by: Haotian Jiang <jianghaotian.sunday@gmail.com>
Cc: qemu-stable@nongnu.org
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260721060941.2989396-1-jianghaotian.sunday@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
 hw/audio/intel-hda.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index d7c2c3c2fd4..3d361a4976c 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -305,6 +305,7 @@ static int intel_hda_send_command(IntelHDAState *d, uint32_t verb)
 
 static void intel_hda_corb_run(IntelHDAState *d)
 {
+    const MemTxAttrs attrs = { .memory = true };
     hwaddr addr;
     uint32_t rp, verb;
 
@@ -330,7 +331,7 @@ static void intel_hda_corb_run(IntelHDAState *d)
 
         rp = (d->corb_rp + 1) & 0xff;
         addr = intel_hda_addr(d->corb_lbase, d->corb_ubase);
-        ldl_le_pci_dma(&d->pci, addr + 4 * rp, &verb, MEMTXATTRS_UNSPECIFIED);
+        ldl_le_pci_dma(&d->pci, addr + 4 * rp, &verb, attrs);
         d->corb_rp = rp;
 
         dprint(d, 2, "%s: [rp 0x%x] verb 0x%08x\n", __func__, rp, verb);
@@ -395,7 +396,7 @@ static void intel_hda_response(HDACodecDevice *dev, bool solicited, uint32_t res
 static bool intel_hda_xfer(HDACodecDevice *dev, uint32_t stnr, bool output,
                            uint8_t *buf, uint32_t len)
 {
-    const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
+    const MemTxAttrs attrs = { .memory = true };
     HDACodecBus *bus = HDA_BUS(dev->qdev.parent_bus);
     IntelHDAState *d = container_of(bus, IntelHDAState, codecs);
     hwaddr addr;
@@ -466,6 +467,7 @@ static bool intel_hda_xfer(HDACodecDevice *dev, uint32_t stnr, bool output,
 
 static void intel_hda_parse_bdl(IntelHDAState *d, IntelHDAStream *st)
 {
+    const MemTxAttrs attrs = { .memory = true };
     hwaddr addr;
     uint8_t buf[16];
     uint32_t i;
@@ -475,7 +477,8 @@ static void intel_hda_parse_bdl(IntelHDAState *d, IntelHDAStream *st)
     g_free(st->bpl);
     st->bpl = g_new(bpl, st->bentries);
     for (i = 0; i < st->bentries; i++, addr += 16) {
-        pci_dma_read(&d->pci, addr, buf, 16);
+        pci_dma_rw(&d->pci, addr, buf, 16,
+                   DMA_DIRECTION_TO_DEVICE, attrs);
         st->bpl[i].addr  = le64_to_cpu(*(uint64_t *)buf);
         st->bpl[i].len   = le32_to_cpu(*(uint32_t *)(buf + 8));
         st->bpl[i].flags = le32_to_cpu(*(uint32_t *)(buf + 12));
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PULL 9/9] vfio/listener: Remove unnecessary 'linux/kvm.h' include
  2026-07-21 10:39 [PULL 0/9] Misc HW patches for 2026-07-21 Philippe Mathieu-Daudé
                   ` (7 preceding siblings ...)
  2026-07-21 10:40 ` [PULL 8/9] hw/audio/intel-hda: restrict all DMA engine paths to memories Philippe Mathieu-Daudé
@ 2026-07-21 10:40 ` Philippe Mathieu-Daudé
  2026-07-21 16:01 ` [PULL 0/9] Misc HW patches for 2026-07-21 Stefan Hajnoczi
  9 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-07-21 10:40 UTC (permalink / raw)
  To: qemu-devel

From: Cédric Le Goater <clg@redhat.com>

Since commit d0e8bccafc23 ("hw/vfio/listener.c: remove CONFIG_KVM"),
the linux/kvm.h include is unconditional. This breaks the build on
targets that lack asm/kvm.h such as sparc and sparc64:

  In file included from ../hw/vfio/listener.c:23:
  linux-headers/linux/kvm.h:16:10: fatal error: asm/kvm.h: No such file or directory

This include is not needed in listener.c which only uses kvm_enabled()
and kvm_get_max_memslots(), both are declared in "system/kvm.h".
Remove it.

Fixes: d0e8bccafc23 ("hw/vfio/listener.c: remove CONFIG_KVM")
Cc: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>"
Suggested-by: Alex Williamson <alex@shazbot.org>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
Tested-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260721062745.3793066-1-clg@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
 hw/vfio/listener.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/vfio/listener.c b/hw/vfio/listener.c
index c19600e980a..008f488a3e7 100644
--- a/hw/vfio/listener.c
+++ b/hw/vfio/listener.c
@@ -20,7 +20,6 @@
 
 #include "qemu/osdep.h"
 #include <sys/ioctl.h>
-#include <linux/kvm.h>
 #include <linux/vfio.h>
 
 #include "exec/target_page.h"
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PULL 0/9] Misc HW patches for 2026-07-21
  2026-07-21 10:39 [PULL 0/9] Misc HW patches for 2026-07-21 Philippe Mathieu-Daudé
                   ` (8 preceding siblings ...)
  2026-07-21 10:40 ` [PULL 9/9] vfio/listener: Remove unnecessary 'linux/kvm.h' include Philippe Mathieu-Daudé
@ 2026-07-21 16:01 ` Stefan Hajnoczi
  9 siblings, 0 replies; 11+ messages in thread
From: Stefan Hajnoczi @ 2026-07-21 16:01 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 116 bytes --]

Applied, thanks.

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-07-21 16:02 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-21 10:39 [PULL 0/9] Misc HW patches for 2026-07-21 Philippe Mathieu-Daudé
2026-07-21 10:39 ` [PULL 1/9] net: Correct padding check in qemu_receive_packet() Philippe Mathieu-Daudé
2026-07-21 10:39 ` [PULL 2/9] hw/display/qxl: validate monitors_config heads[] in phys2virt Philippe Mathieu-Daudé
2026-07-21 10:39 ` [PULL 3/9] user/guest-host: Include exec/abi_ptr.h Philippe Mathieu-Daudé
2026-07-21 10:39 ` [PULL 4/9] replay: fix use of uninitialized pointer on error Philippe Mathieu-Daudé
2026-07-21 10:40 ` [PULL 5/9] hw/misc/applesmc: Fix a typo setting MSSD key Philippe Mathieu-Daudé
2026-07-21 10:40 ` [PULL 6/9] hw/net/cadence: Return current Cadence GEM queue pointers Philippe Mathieu-Daudé
2026-07-21 10:40 ` [PULL 7/9] hw/sd/sdcard: Fix error case for CMD18 Philippe Mathieu-Daudé
2026-07-21 10:40 ` [PULL 8/9] hw/audio/intel-hda: restrict all DMA engine paths to memories Philippe Mathieu-Daudé
2026-07-21 10:40 ` [PULL 9/9] vfio/listener: Remove unnecessary 'linux/kvm.h' include Philippe Mathieu-Daudé
2026-07-21 16:01 ` [PULL 0/9] Misc HW patches for 2026-07-21 Stefan Hajnoczi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.