- kvm-rbd-Run-co-BH-CB-in-the-coroutine-s-AioContext.patch [RHEL-79118] - kvm-curl-Fix-coroutine-waking.patch [RHEL-79118] - kvm-block-io-Take-reqs_lock-for-tracked_requests.patch [RHEL-79118] - kvm-qcow2-Re-initialize-lock-in-invalidate_cache.patch [RHEL-79118] - kvm-qcow2-Fix-cache_clean_timer.patch [RHEL-79118] - kvm-net-bundle-all-offloads-in-a-single-struct.patch [RHEL-143785] - kvm-linux-headers-deal-with-counted_by-annotation.patch [RHEL-143785] - kvm-linux-headers-Update-to-Linux-v6.17-rc1.patch [RHEL-143785] - kvm-virtio-introduce-extended-features-type.patch [RHEL-143785] - kvm-virtio-serialize-extended-features-state.patch [RHEL-143785] - kvm-virtio-add-support-for-negotiating-extended-features.patch [RHEL-143785] - kvm-virtio-pci-implement-support-for-extended-features.patch [RHEL-143785] - kvm-vhost-add-support-for-negotiating-extended-features.patch [RHEL-143785] - kvm-qmp-update-virtio-features-map-to-support-extended-f.patch [RHEL-143785] - kvm-vhost-backend-implement-extended-features-support.patch [RHEL-143785] - kvm-vhost-net-implement-extended-features-support.patch [RHEL-143785] - kvm-virtio-net-implement-extended-features-support.patch [RHEL-143785] - kvm-net-implement-tunnel-probing.patch [RHEL-143785] - kvm-net-implement-UDP-tunnel-features-offloading.patch [RHEL-143785] - Resolves: RHEL-79118 ([network-storage][rbd][core-dump]installation of guest failed sometimes with multiqueue enabled [rhel10]) - Resolves: RHEL-143785 (backport support for GSO over UDP tunnel offload)
202 lines
6.3 KiB
Diff
202 lines
6.3 KiB
Diff
From 4c9ae4b3a9e2c556dcf284924a154ed85534d77f Mon Sep 17 00:00:00 2001
|
|
From: Paolo Abeni <pabeni@redhat.com>
|
|
Date: Mon, 22 Sep 2025 16:18:18 +0200
|
|
Subject: [PATCH 09/19] virtio: introduce extended features type
|
|
|
|
RH-Author: Laurent Vivier <lvivier@redhat.com>
|
|
RH-MergeRequest: 456: backport support for GSO over UDP tunnel offload
|
|
RH-Jira: RHEL-143785
|
|
RH-Acked-by: Cindy Lu <lulu@redhat.com>
|
|
RH-Acked-by: MST <mst@redhat.com>
|
|
RH-Commit: [4/14] fa4ef2d101589c700358f90be08943f1198503e4 (lvivier/qemu-kvm-centos)
|
|
|
|
JIRA: https://issues.redhat.com/browse/RHEL-143785
|
|
|
|
The virtio specifications allows for up to 128 bits for the
|
|
device features. Soon we are going to use some of the 'extended'
|
|
bits features (bit 64 and above) for the virtio net driver.
|
|
|
|
Represent the virtio features bitmask with a fixed size array, and
|
|
introduce a few helpers to help manipulate them.
|
|
|
|
Most drivers will keep using only 64 bits features space: use union
|
|
to allow them access the lower part of the extended space without any
|
|
per driver change.
|
|
|
|
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
|
|
Acked-by: Jason Wang <jasowang@redhat.com>
|
|
Acked-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|
Tested-by: Lei Yang <leiyang@redhat.com>
|
|
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
Message-ID: <6a9bbb5eb33830f20afbcb7e64d300af4126dd98.1758549625.git.pabeni@redhat.com>
|
|
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
(cherry picked from commit b15a61fdae976eb1ca8f2deee6a63dc3407d7ec6)
|
|
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
|
|
---
|
|
include/hw/virtio/virtio-features.h | 126 ++++++++++++++++++++++++++++
|
|
include/hw/virtio/virtio.h | 7 +-
|
|
2 files changed, 130 insertions(+), 3 deletions(-)
|
|
create mode 100644 include/hw/virtio/virtio-features.h
|
|
|
|
diff --git a/include/hw/virtio/virtio-features.h b/include/hw/virtio/virtio-features.h
|
|
new file mode 100644
|
|
index 0000000000..e29b7fe48f
|
|
--- /dev/null
|
|
+++ b/include/hw/virtio/virtio-features.h
|
|
@@ -0,0 +1,126 @@
|
|
+/*
|
|
+ * Virtio features helpers
|
|
+ *
|
|
+ * Copyright 2025 Red Hat, Inc.
|
|
+ *
|
|
+ * SPDX-License-Identifier: GPL-2.0-or-later
|
|
+ */
|
|
+
|
|
+#ifndef QEMU_VIRTIO_FEATURES_H
|
|
+#define QEMU_VIRTIO_FEATURES_H
|
|
+
|
|
+#include "qemu/bitops.h"
|
|
+
|
|
+#define VIRTIO_FEATURES_FMT "%016"PRIx64"%016"PRIx64
|
|
+#define VIRTIO_FEATURES_PR(f) (f)[1], (f)[0]
|
|
+
|
|
+#define VIRTIO_FEATURES_MAX 128
|
|
+#define VIRTIO_FEATURES_BIT(b) BIT_ULL((b) % 64)
|
|
+#define VIRTIO_FEATURES_U64(b) ((b) / 64)
|
|
+#define VIRTIO_FEATURES_NU32S (VIRTIO_FEATURES_MAX / 32)
|
|
+#define VIRTIO_FEATURES_NU64S (VIRTIO_FEATURES_MAX / 64)
|
|
+
|
|
+#define VIRTIO_DECLARE_FEATURES(name) \
|
|
+ union { \
|
|
+ uint64_t name; \
|
|
+ uint64_t name##_ex[VIRTIO_FEATURES_NU64S]; \
|
|
+ }
|
|
+
|
|
+#define VIRTIO_DEFINE_PROP_FEATURE(_name, _state, _field, _bit, _defval) \
|
|
+ DEFINE_PROP_BIT64(_name, _state, _field[VIRTIO_FEATURES_U64(_bit)], \
|
|
+ (_bit) % 64, _defval)
|
|
+
|
|
+static inline void virtio_features_clear(uint64_t *features)
|
|
+{
|
|
+ memset(features, 0, sizeof(features[0]) * VIRTIO_FEATURES_NU64S);
|
|
+}
|
|
+
|
|
+static inline void virtio_features_from_u64(uint64_t *features, uint64_t from)
|
|
+{
|
|
+ virtio_features_clear(features);
|
|
+ features[0] = from;
|
|
+}
|
|
+
|
|
+static inline bool virtio_has_feature_ex(const uint64_t *features,
|
|
+ unsigned int fbit)
|
|
+{
|
|
+ assert(fbit < VIRTIO_FEATURES_MAX);
|
|
+ return features[VIRTIO_FEATURES_U64(fbit)] & VIRTIO_FEATURES_BIT(fbit);
|
|
+}
|
|
+
|
|
+static inline void virtio_add_feature_ex(uint64_t *features,
|
|
+ unsigned int fbit)
|
|
+{
|
|
+ assert(fbit < VIRTIO_FEATURES_MAX);
|
|
+ features[VIRTIO_FEATURES_U64(fbit)] |= VIRTIO_FEATURES_BIT(fbit);
|
|
+}
|
|
+
|
|
+static inline void virtio_clear_feature_ex(uint64_t *features,
|
|
+ unsigned int fbit)
|
|
+{
|
|
+ assert(fbit < VIRTIO_FEATURES_MAX);
|
|
+ features[VIRTIO_FEATURES_U64(fbit)] &= ~VIRTIO_FEATURES_BIT(fbit);
|
|
+}
|
|
+
|
|
+static inline bool virtio_features_equal(const uint64_t *f1,
|
|
+ const uint64_t *f2)
|
|
+{
|
|
+ return !memcmp(f1, f2, sizeof(uint64_t) * VIRTIO_FEATURES_NU64S);
|
|
+}
|
|
+
|
|
+static inline bool virtio_features_use_ex(const uint64_t *features)
|
|
+{
|
|
+ int i;
|
|
+
|
|
+ for (i = 1; i < VIRTIO_FEATURES_NU64S; ++i) {
|
|
+ if (features[i]) {
|
|
+ return true;
|
|
+ }
|
|
+ }
|
|
+ return false;
|
|
+}
|
|
+
|
|
+static inline bool virtio_features_empty(const uint64_t *features)
|
|
+{
|
|
+ return !virtio_features_use_ex(features) && !features[0];
|
|
+}
|
|
+
|
|
+static inline void virtio_features_copy(uint64_t *to, const uint64_t *from)
|
|
+{
|
|
+ memcpy(to, from, sizeof(to[0]) * VIRTIO_FEATURES_NU64S);
|
|
+}
|
|
+
|
|
+static inline bool virtio_features_andnot(uint64_t *to, const uint64_t *f1,
|
|
+ const uint64_t *f2)
|
|
+{
|
|
+ uint64_t diff = 0;
|
|
+ int i;
|
|
+
|
|
+ for (i = 0; i < VIRTIO_FEATURES_NU64S; i++) {
|
|
+ to[i] = f1[i] & ~f2[i];
|
|
+ diff |= to[i];
|
|
+ }
|
|
+ return diff;
|
|
+}
|
|
+
|
|
+static inline void virtio_features_and(uint64_t *to, const uint64_t *f1,
|
|
+ const uint64_t *f2)
|
|
+{
|
|
+ int i;
|
|
+
|
|
+ for (i = 0; i < VIRTIO_FEATURES_NU64S; i++) {
|
|
+ to[i] = f1[i] & f2[i];
|
|
+ }
|
|
+}
|
|
+
|
|
+static inline void virtio_features_or(uint64_t *to, const uint64_t *f1,
|
|
+ const uint64_t *f2)
|
|
+{
|
|
+ int i;
|
|
+
|
|
+ for (i = 0; i < VIRTIO_FEATURES_NU64S; i++) {
|
|
+ to[i] = f1[i] | f2[i];
|
|
+ }
|
|
+}
|
|
+
|
|
+#endif
|
|
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
|
|
index c594764f23..39e4059a66 100644
|
|
--- a/include/hw/virtio/virtio.h
|
|
+++ b/include/hw/virtio/virtio.h
|
|
@@ -16,6 +16,7 @@
|
|
|
|
#include "system/memory.h"
|
|
#include "hw/qdev-core.h"
|
|
+#include "hw/virtio/virtio-features.h"
|
|
#include "net/net.h"
|
|
#include "migration/vmstate.h"
|
|
#include "qemu/event_notifier.h"
|
|
@@ -121,9 +122,9 @@ struct VirtIODevice
|
|
* backend (e.g. vhost) and could potentially be a subset of the
|
|
* total feature set offered by QEMU.
|
|
*/
|
|
- uint64_t host_features;
|
|
- uint64_t guest_features;
|
|
- uint64_t backend_features;
|
|
+ VIRTIO_DECLARE_FEATURES(host_features);
|
|
+ VIRTIO_DECLARE_FEATURES(guest_features);
|
|
+ VIRTIO_DECLARE_FEATURES(backend_features);
|
|
|
|
size_t config_len;
|
|
void *config;
|
|
--
|
|
2.47.3
|
|
|