From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: app-emulation/qemu/files/, app-emulation/qemu/
Date: Wed, 07 May 2025 18:41:34 +0000 (UTC) [thread overview]
Message-ID: <1746643218.1f5a19d78df2e9553a62c72a9ea4491229a5dced.sam@gentoo> (raw)
commit: 1f5a19d78df2e9553a62c72a9ea4491229a5dced
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed May 7 18:39:43 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed May 7 18:40:18 2025 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1f5a19d7
app-emulation/qemu: backport virtio-net fixes to 9.2.3
While the first commit has also been backported upstream on the 7.x and
8.x branches, it's fixing something ancient, so not critical to do here.
Closes: https://bugs.gentoo.org/955587
Signed-off-by: Sam James <sam <AT> gentoo.org>
.../qemu/files/qemu-9.2.3-virtio-net.patch | 221 +++++++++++++++++++++
.../{qemu-9.2.3-r2.ebuild => qemu-9.2.3-r3.ebuild} | 1 +
2 files changed, 222 insertions(+)
diff --git a/app-emulation/qemu/files/qemu-9.2.3-virtio-net.patch b/app-emulation/qemu/files/qemu-9.2.3-virtio-net.patch
new file mode 100644
index 000000000000..7adff23b2554
--- /dev/null
+++ b/app-emulation/qemu/files/qemu-9.2.3-virtio-net.patch
@@ -0,0 +1,221 @@
+https://bugs.gentoo.org/955587
+https://gitlab.com/qemu-project/qemu/-/commit/ff765e490eef83480d07673e115060228b01d55e
+https://gitlab.com/qemu-project/qemu/-/commit/af01cf195ba106fe039ab320ce9e8074b4ddd841
+
+From ff765e490eef83480d07673e115060228b01d55e Mon Sep 17 00:00:00 2001
+From: Akihiko Odaki <akihiko.odaki@daynix.com>
+Date: Wed, 8 Jan 2025 21:13:29 +0900
+Subject: [PATCH] virtio-net: Fix num_buffers for version 1
+
+The specification says the device MUST set num_buffers to 1 if
+VIRTIO_NET_F_MRG_RXBUF has not been negotiated.
+
+Fixes: df91055db5c9 ("virtio-net: enable virtio 1.0")
+Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
+Message-Id: <20250108-buffers-v1-1-a0c85ff31aeb@daynix.com>
+Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+Tested-by: Lei Yang <leiyang@redhat.com>
+Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+(cherry picked from commit c17ad4b11bd268a35506cd976884562df6ca69d7)
+Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
+---
+ hw/net/virtio-net.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
+index f8c6ccbec45..78b7d88756c 100644
+--- a/hw/net/virtio-net.c
++++ b/hw/net/virtio-net.c
+@@ -1999,6 +1999,8 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,
+ offsetof(typeof(hdr),
+ virtio_net.hdr.num_buffers),
+ sizeof(hdr.virtio_net.hdr.num_buffers));
++ } else {
++ hdr.virtio_net.hdr.num_buffers = cpu_to_le16(1);
+ }
+
+ guest_offset = n->has_vnet_hdr ?
+--
+GitLab
+
+From af01cf195ba106fe039ab320ce9e8074b4ddd841 Mon Sep 17 00:00:00 2001
+From: Antoine Damhet <adamhet@scaleway.com>
+Date: Tue, 8 Apr 2025 16:53:33 +0200
+Subject: [PATCH] Revert "virtio-net: Copy received header to buffer"
+
+This reverts commit 7987d2be5a8bc3a502f89ba8cf3ac3e09f64d1ce.
+
+The goal was to remove the need to patch the (const) input buffer
+with a recomputed UDP checksum by copying headers to a RW region and
+inject the checksum there. The patch computed the checksum only from the
+header fields (missing the rest of the payload) producing an invalid one
+and making guests fail to acquire a DHCP lease.
+
+Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2727
+Cc: qemu-stable@nongnu.org
+Signed-off-by: Antoine Damhet <adamhet@scaleway.com>
+Acked-by: Michael S. Tsirkin <mst@redhat.com>
+Message-ID: <20250408145345.142947-1-adamhet@scaleway.com>
+Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
+(cherry picked from commit e28fbd1c525db21f0502b85517f49504c9f9dcd8)
+Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
+---
+ hw/net/virtio-net.c | 87 +++++++++++++++++++++------------------------
+ 1 file changed, 40 insertions(+), 47 deletions(-)
+
+diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
+index 78b7d88756c..09ff80c9953 100644
+--- a/hw/net/virtio-net.c
++++ b/hw/net/virtio-net.c
+@@ -1702,44 +1702,41 @@ static void virtio_net_hdr_swap(VirtIODevice *vdev, struct virtio_net_hdr *hdr)
+ * cache.
+ */
+ static void work_around_broken_dhclient(struct virtio_net_hdr *hdr,
+- size_t *hdr_len, const uint8_t *buf,
+- size_t buf_size, size_t *buf_offset)
++ uint8_t *buf, size_t size)
+ {
+ size_t csum_size = ETH_HLEN + sizeof(struct ip_header) +
+ sizeof(struct udp_header);
+
+- buf += *buf_offset;
+- buf_size -= *buf_offset;
+-
+ if ((hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) && /* missing csum */
+- (buf_size >= csum_size && buf_size < 1500) && /* normal sized MTU */
++ (size >= csum_size && size < 1500) && /* normal sized MTU */
+ (buf[12] == 0x08 && buf[13] == 0x00) && /* ethertype == IPv4 */
+ (buf[23] == 17) && /* ip.protocol == UDP */
+ (buf[34] == 0 && buf[35] == 67)) { /* udp.srcport == bootps */
+- memcpy((uint8_t *)hdr + *hdr_len, buf, csum_size);
+- net_checksum_calculate((uint8_t *)hdr + *hdr_len, csum_size, CSUM_UDP);
++ net_checksum_calculate(buf, size, CSUM_UDP);
+ hdr->flags &= ~VIRTIO_NET_HDR_F_NEEDS_CSUM;
+- *hdr_len += csum_size;
+- *buf_offset += csum_size;
+ }
+ }
+
+-static size_t receive_header(VirtIONet *n, struct virtio_net_hdr *hdr,
+- const void *buf, size_t buf_size,
+- size_t *buf_offset)
++static void receive_header(VirtIONet *n, const struct iovec *iov, int iov_cnt,
++ const void *buf, size_t size)
+ {
+- size_t hdr_len = n->guest_hdr_len;
+-
+- memcpy(hdr, buf, sizeof(struct virtio_net_hdr));
+-
+- *buf_offset = n->host_hdr_len;
+- work_around_broken_dhclient(hdr, &hdr_len, buf, buf_size, buf_offset);
++ if (n->has_vnet_hdr) {
++ /* FIXME this cast is evil */
++ void *wbuf = (void *)buf;
++ work_around_broken_dhclient(wbuf, wbuf + n->host_hdr_len,
++ size - n->host_hdr_len);
+
+- if (n->needs_vnet_hdr_swap) {
+- virtio_net_hdr_swap(VIRTIO_DEVICE(n), hdr);
++ if (n->needs_vnet_hdr_swap) {
++ virtio_net_hdr_swap(VIRTIO_DEVICE(n), wbuf);
++ }
++ iov_from_buf(iov, iov_cnt, 0, buf, sizeof(struct virtio_net_hdr));
++ } else {
++ struct virtio_net_hdr hdr = {
++ .flags = 0,
++ .gso_type = VIRTIO_NET_HDR_GSO_NONE
++ };
++ iov_from_buf(iov, iov_cnt, 0, &hdr, sizeof hdr);
+ }
+-
+- return hdr_len;
+ }
+
+ static int receive_filter(VirtIONet *n, const uint8_t *buf, int size)
+@@ -1907,13 +1904,6 @@ static int virtio_net_process_rss(NetClientState *nc, const uint8_t *buf,
+ return (index == new_index) ? -1 : new_index;
+ }
+
+-typedef struct Header {
+- struct virtio_net_hdr_v1_hash virtio_net;
+- struct eth_header eth;
+- struct ip_header ip;
+- struct udp_header udp;
+-} Header;
+-
+ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,
+ size_t size)
+ {
+@@ -1923,15 +1913,15 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,
+ VirtQueueElement *elems[VIRTQUEUE_MAX_SIZE];
+ size_t lens[VIRTQUEUE_MAX_SIZE];
+ struct iovec mhdr_sg[VIRTQUEUE_MAX_SIZE];
+- Header hdr;
++ struct virtio_net_hdr_v1_hash extra_hdr;
+ unsigned mhdr_cnt = 0;
+ size_t offset, i, guest_offset, j;
+ ssize_t err;
+
+- memset(&hdr.virtio_net, 0, sizeof(hdr.virtio_net));
++ memset(&extra_hdr, 0, sizeof(extra_hdr));
+
+ if (n->rss_data.enabled && n->rss_data.enabled_software_rss) {
+- int index = virtio_net_process_rss(nc, buf, size, &hdr.virtio_net);
++ int index = virtio_net_process_rss(nc, buf, size, &extra_hdr);
+ if (index >= 0) {
+ nc = qemu_get_subqueue(n->nic, index % n->curr_queue_pairs);
+ }
+@@ -1996,20 +1986,23 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,
+ if (n->mergeable_rx_bufs) {
+ mhdr_cnt = iov_copy(mhdr_sg, ARRAY_SIZE(mhdr_sg),
+ sg, elem->in_num,
+- offsetof(typeof(hdr),
+- virtio_net.hdr.num_buffers),
+- sizeof(hdr.virtio_net.hdr.num_buffers));
++ offsetof(typeof(extra_hdr), hdr.num_buffers),
++ sizeof(extra_hdr.hdr.num_buffers));
+ } else {
+- hdr.virtio_net.hdr.num_buffers = cpu_to_le16(1);
++ extra_hdr.hdr.num_buffers = cpu_to_le16(1);
+ }
+
+- guest_offset = n->has_vnet_hdr ?
+- receive_header(n, (struct virtio_net_hdr *)&hdr,
+- buf, size, &offset) :
+- n->guest_hdr_len;
+-
+- iov_from_buf(sg, elem->in_num, 0, &hdr, guest_offset);
+- total += guest_offset;
++ receive_header(n, sg, elem->in_num, buf, size);
++ if (n->rss_data.populate_hash) {
++ offset = offsetof(typeof(extra_hdr), hash_value);
++ iov_from_buf(sg, elem->in_num, offset,
++ (char *)&extra_hdr + offset,
++ sizeof(extra_hdr.hash_value) +
++ sizeof(extra_hdr.hash_report));
++ }
++ offset = n->host_hdr_len;
++ total += n->guest_hdr_len;
++ guest_offset = n->guest_hdr_len;
+ } else {
+ guest_offset = 0;
+ }
+@@ -2035,11 +2028,11 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,
+ }
+
+ if (mhdr_cnt) {
+- virtio_stw_p(vdev, &hdr.virtio_net.hdr.num_buffers, i);
++ virtio_stw_p(vdev, &extra_hdr.hdr.num_buffers, i);
+ iov_from_buf(mhdr_sg, mhdr_cnt,
+ 0,
+- &hdr.virtio_net.hdr.num_buffers,
+- sizeof hdr.virtio_net.hdr.num_buffers);
++ &extra_hdr.hdr.num_buffers,
++ sizeof extra_hdr.hdr.num_buffers);
+ }
+
+ for (j = 0; j < i; j++) {
+--
+GitLab
diff --git a/app-emulation/qemu/qemu-9.2.3-r2.ebuild b/app-emulation/qemu/qemu-9.2.3-r3.ebuild
similarity index 99%
rename from app-emulation/qemu/qemu-9.2.3-r2.ebuild
rename to app-emulation/qemu/qemu-9.2.3-r3.ebuild
index ccbc16d88778..d2aa81b37ecc 100644
--- a/app-emulation/qemu/qemu-9.2.3-r2.ebuild
+++ b/app-emulation/qemu/qemu-9.2.3-r3.ebuild
@@ -321,6 +321,7 @@ PATCHES=(
"${FILESDIR}"/${PN}-8.1.0-skip-tests.patch
"${FILESDIR}"/${PN}-8.1.0-find-sphinx.patch
"${FILESDIR}"/${PN}-7.2.16-optionrom-pass-Wl-no-error-rwx-segments.patch
+ "${FILESDIR}"/${PN}-9.2.3-virtio-net.patch
)
QA_PREBUILT="
next reply other threads:[~2025-05-07 18:41 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-07 18:41 Sam James [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-02-26 6:31 [gentoo-commits] repo/gentoo:master commit in: app-emulation/qemu/files/, app-emulation/qemu/ Sam James
2025-02-20 17:17 Sam James
2024-04-29 2:38 Sam James
2023-07-02 23:35 Sam James
2023-07-02 23:01 Sam James
2023-05-18 21:07 Matthias Maier
2023-05-05 18:11 Matthias Maier
2023-02-21 6:50 Sam James
2023-02-04 16:46 Andreas K. Hüttel
2022-12-08 1:22 John Helmert III
2022-11-12 19:43 Andreas K. Hüttel
2022-09-27 17:31 John Helmert III
2022-08-03 18:21 Sam James
2022-07-05 1:05 WANG Xuerui
2022-06-04 3:01 Sam James
2022-05-22 15:59 John Helmert III
2022-03-29 5:38 Sam James
2022-01-01 1:22 John Helmert III
2021-12-21 23:53 John Helmert III
2021-06-26 19:59 Sergei Trofimovich
2021-04-12 19:39 Sergei Trofimovich
2021-02-28 23:24 Sergei Trofimovich
2020-12-12 23:53 Sergei Trofimovich
2020-12-12 8:33 Sergei Trofimovich
2020-12-10 15:03 Sergei Trofimovich
2020-10-21 20:55 Sergei Trofimovich
2020-09-08 7:33 Sergei Trofimovich
2020-04-24 19:59 Sergei Trofimovich
2020-04-16 22:16 Sergei Trofimovich
2019-05-21 3:53 Matthias Maier
2019-05-17 8:58 Matthias Maier
2019-05-17 7:43 Matthias Maier
2019-04-29 6:48 Matthias Maier
2019-02-19 0:19 Matthias Maier
2018-08-19 17:49 Matthias Maier
2018-06-15 14:10 Jason Donenfeld
2018-03-27 15:44 Matthias Maier
2018-03-18 20:02 Matthias Maier
2017-11-12 20:22 Matthias Maier
2017-07-26 17:15 Matthias Maier
2017-05-18 4:20 Matthias Maier
2017-04-25 13:51 Matthias Maier
2017-03-27 4:03 Matthias Maier
2017-02-13 4:58 Matthias Maier
2016-12-29 18:47 Mike Frysinger
2016-11-12 17:29 Matthias Maier
2016-09-27 2:17 Matthias Maier
2016-09-09 5:23 Matthias Maier
2016-09-05 16:45 Matthias Maier
2016-09-05 5:30 Matthias Maier
2016-08-07 14:04 Luca Barbato
2016-06-07 3:02 Mike Frysinger
2016-05-17 4:41 Mike Frysinger
2016-04-23 20:30 Mike Frysinger
2016-03-23 5:25 Mike Frysinger
2015-12-15 5:55 Mike Frysinger
2015-12-08 3:17 Mike Frysinger
2015-11-23 0:41 Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1746643218.1f5a19d78df2e9553a62c72a9ea4491229a5dced.sam@gentoo \
--to=sam@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox