git: 64ea2b980884 - main - gve: Fix AdminQ buffer DMA sync directions
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 04 Nov 2026 23:30:19 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=64ea2b980884adcc774b04b2c0d206ced711bd76
commit 64ea2b980884adcc774b04b2c0d206ced711bd76
Author: Tim Hostetler <thostet@google.com>
AuthorDate: 2026-11-04 23:24:59 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-11-04 23:25:16 +0000
gve: Fix AdminQ buffer DMA sync directions
In gve_verify_driver_compatibility(), the driver populates the
gve_driver_info buffer for the device to read. Sync this buffer with
BUS_DMASYNC_PREWRITE instead of BUS_DMASYNC_PREREAD before issuing
the command.
In gve_adminq_describe_device(), the device populates the
gve_device_descriptor buffer for the driver to read. Sync this buffer
with BUS_DMASYNC_PREREAD instead of BUS_DMASYNC_PREWRITE before
issuing the command.
In gve_adminq_get_ptype_map_dqo(), the device populates the
gve_ptype_map buffer for the driver to read. Add the missing
BUS_DMASYNC_PREREAD and BUS_DMASYNC_POSTREAD syncs around the
command.
In normal GCP environments this did not cause a functional failure
because the underlying platforms are DMA cache-coherent and
bus_dmamap_sync() inside gve_adminq_issue_cmd() still provided a
memory barrier before ringing the AdminQ doorbell. However, if bounce
buffers are used, the wrong or missing sync directions would cause the
OS to skip copying between the driver buffer and the bounce buffer in
the expected direction.
Signed-off-by: Tim Hostetler <thostet@google.com>
Reviewed by: markj, Jasper Tran O'Leary <jtranoleary@google.com>
Fixes: 54dfc97b0bd9 ("Add gve, the driver for Google Virtual NIC (gVNIC)")
Fixes: d438b4ef0cfc ("gve: Add DQO RDA support")
Differential Revision: https://reviews.freebsd.org/D61172
---
sys/dev/gve/gve_adminq.c | 6 +++++-
sys/dev/gve/gve_main.c | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/sys/dev/gve/gve_adminq.c b/sys/dev/gve/gve_adminq.c
index 43952308098b..bdb6cfb56ed7 100644
--- a/sys/dev/gve/gve_adminq.c
+++ b/sys/dev/gve/gve_adminq.c
@@ -502,7 +502,7 @@ gve_adminq_describe_device(struct gve_priv *priv)
GVE_ADMINQ_DEVICE_DESCRIPTOR_VERSION);
aq_cmd.describe_device.available_length = htobe32(ADMINQ_SIZE);
- bus_dmamap_sync(desc_mem.tag, desc_mem.map, BUS_DMASYNC_PREWRITE);
+ bus_dmamap_sync(desc_mem.tag, desc_mem.map, BUS_DMASYNC_PREREAD);
rc = gve_adminq_execute_cmd(priv, &aq_cmd);
if (rc != 0)
@@ -703,10 +703,14 @@ gve_adminq_get_ptype_map_dqo(struct gve_priv *priv,
.ptype_map_addr = htobe64(dma.bus_addr),
};
+ bus_dmamap_sync(dma.tag, dma.map, BUS_DMASYNC_PREREAD);
+
err = gve_adminq_execute_cmd(priv, &aq_cmd);
if (err)
goto err;
+ bus_dmamap_sync(dma.tag, dma.map, BUS_DMASYNC_POSTREAD);
+
/* Populate ptype_lut_dqo. */
for (i = 0; i < GVE_NUM_PTYPES; i++) {
ptype_lut_dqo->ptypes[i].l3_type = ptype_map->ptypes[i].l3_type;
diff --git a/sys/dev/gve/gve_main.c b/sys/dev/gve/gve_main.c
index fc88b3dfd014..ae5e99dadd6a 100644
--- a/sys/dev/gve/gve_main.c
+++ b/sys/dev/gve/gve_main.c
@@ -88,7 +88,7 @@ gve_verify_driver_compatibility(struct gve_priv *priv)
"FreeBSD %u", __FreeBSD_version);
bus_dmamap_sync(driver_info_mem.tag, driver_info_mem.map,
- BUS_DMASYNC_PREREAD);
+ BUS_DMASYNC_PREWRITE);
err = gve_adminq_verify_driver_compatibility(priv,
sizeof(struct gve_driver_info), driver_info_mem.bus_addr);