* [PATCH v4 0/9] single-binary: hw/virtio
@ 2026-02-03 20:56 Pierrick Bouvier
2026-02-03 20:56 ` [PATCH v4 1/9] hw/virtio: Constify virtio_is_big_endian() argument Pierrick Bouvier
` (10 more replies)
0 siblings, 11 replies; 23+ messages in thread
From: Pierrick Bouvier @ 2026-02-03 20:56 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, qemu-ppc, Stefano Garzarella,
Pierrick Bouvier, Nicholas Piggin, Michael S. Tsirkin,
Harsh Prateek Bora
This series eliminates target specifics in hw/virtio and replace them with
runtime functions where needed.
Performance has been measured with this automated fio benchmark, with
original instructions from Stefan [1].
$ git clone https://github.com/pbo-linaro/qemu-linux-stack -b x86_64_io_benchmark
$ cd qemu-linux-stack
$ ./build.sh
$ ./run.sh /path/to/qemu-system-x86_64
[1] https://lore.kernel.org/qemu-devel/20260202185233.GC405548@fedora/
Results are on 20 runs and expressed in kIOPS:
reference: mean=239.2 std_dev=3.48
with_series: mean=238.5 std_dev=3.46
Performance is on par, and within standard deviation.
v4
--
- Include Philippe patches computing once device endianness to skip runtime
checks on every access.
Philippe Mathieu-Daudé (3):
hw/virtio: Constify virtio_is_big_endian() argument
hw/virtio: Introduce VirtIODevice::access_is_big_endian boolean field
hw/virtio: Use VirtIODevice::access_is_big_endian field
Pierrick Bouvier (6):
target-info: add target_base_ppc, target_ppc and target_ppc64
include/hw/virtio/virtio-access.h: remove target specifics define
include/hw/ppc/spapr: extract SPAPR_MAX_RAM_SLOTS in a new header
hw/virtio/vhost-user: make compilation unit common
hw/virtio/virtio-qmp: make compilation unit common
hw/virtio/: make all compilation units common
include/hw/ppc/spapr.h | 8 +---
include/hw/ppc/spapr_common.h | 16 +++++++
include/hw/virtio/virtio-access.h | 50 +++++++++++-----------
include/hw/virtio/virtio.h | 7 +++-
include/qemu/target-info.h | 21 ++++++++++
hw/virtio/vhost-user.c | 11 ++---
hw/virtio/virtio-qmp.c | 70 -------------------------------
hw/virtio/virtio.c | 5 ++-
target-info.c | 21 ++++++++++
hw/virtio/meson.build | 17 ++++----
10 files changed, 104 insertions(+), 122 deletions(-)
create mode 100644 include/hw/ppc/spapr_common.h
--
2.47.3
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v4 1/9] hw/virtio: Constify virtio_is_big_endian() argument
2026-02-03 20:56 [PATCH v4 0/9] single-binary: hw/virtio Pierrick Bouvier
@ 2026-02-03 20:56 ` Pierrick Bouvier
2026-02-03 20:56 ` [PATCH v4 2/9] hw/virtio: Introduce VirtIODevice::access_is_big_endian boolean field Pierrick Bouvier
` (9 subsequent siblings)
10 siblings, 0 replies; 23+ messages in thread
From: Pierrick Bouvier @ 2026-02-03 20:56 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, qemu-ppc, Stefano Garzarella,
Pierrick Bouvier, Nicholas Piggin, Michael S. Tsirkin,
Harsh Prateek Bora
From: Philippe Mathieu-Daudé <philmd@linaro.org>
VirtIODevice argument is accessed read-only, make it const.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
include/hw/virtio/virtio.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 27cd98d2fe1..65872f2c54c 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -468,7 +468,7 @@ static inline bool virtio_host_has_feature(VirtIODevice *vdev,
return virtio_has_feature(vdev->host_features, fbit);
}
-static inline bool virtio_is_big_endian(VirtIODevice *vdev)
+static inline bool virtio_is_big_endian(const VirtIODevice *vdev)
{
if (!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
assert(vdev->device_endian != VIRTIO_DEVICE_ENDIAN_UNKNOWN);
--
2.47.3
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v4 2/9] hw/virtio: Introduce VirtIODevice::access_is_big_endian boolean field
2026-02-03 20:56 [PATCH v4 0/9] single-binary: hw/virtio Pierrick Bouvier
2026-02-03 20:56 ` [PATCH v4 1/9] hw/virtio: Constify virtio_is_big_endian() argument Pierrick Bouvier
@ 2026-02-03 20:56 ` Pierrick Bouvier
2026-02-03 20:56 ` [PATCH v4 3/9] hw/virtio: Use VirtIODevice::access_is_big_endian field Pierrick Bouvier
` (8 subsequent siblings)
10 siblings, 0 replies; 23+ messages in thread
From: Pierrick Bouvier @ 2026-02-03 20:56 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, qemu-ppc, Stefano Garzarella,
Pierrick Bouvier, Nicholas Piggin, Michael S. Tsirkin,
Harsh Prateek Bora
From: Philippe Mathieu-Daudé <philmd@linaro.org>
VirtIODevice::access_is_big_endian boolean field, initialized on
device reset, represents whether load/store accesses are ordered
using big endianness.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
include/hw/virtio/virtio.h | 5 +++++
hw/virtio/virtio.c | 1 +
2 files changed, 6 insertions(+)
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 65872f2c54c..6c05f1febcc 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -154,6 +154,11 @@ struct VirtIODevice
VMChangeStateEntry *vmstate;
char *bus_name;
uint8_t device_endian;
+ /**
+ * @access_is_big_endian: whether load/store memory accesses are ordered
+ * using big endianness. Might change during device resets.
+ */
+ bool access_is_big_endian;
/**
* @user_guest_notifier_mask: gate usage of ->guest_notifier_mask() callback.
* This is used to suppress the masking of guest updates for
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 3dc9423eae9..df2887e7296 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -3248,6 +3248,7 @@ void virtio_reset(void *opaque)
/* System reset */
vdev->device_endian = virtio_default_endian();
}
+ vdev->access_is_big_endian = virtio_access_is_big_endian(vdev);
if (k->get_vhost) {
struct vhost_dev *hdev = k->get_vhost(vdev);
--
2.47.3
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v4 3/9] hw/virtio: Use VirtIODevice::access_is_big_endian field
2026-02-03 20:56 [PATCH v4 0/9] single-binary: hw/virtio Pierrick Bouvier
2026-02-03 20:56 ` [PATCH v4 1/9] hw/virtio: Constify virtio_is_big_endian() argument Pierrick Bouvier
2026-02-03 20:56 ` [PATCH v4 2/9] hw/virtio: Introduce VirtIODevice::access_is_big_endian boolean field Pierrick Bouvier
@ 2026-02-03 20:56 ` Pierrick Bouvier
2026-02-03 22:11 ` Philippe Mathieu-Daudé
2026-02-06 4:37 ` Pierrick Bouvier
2026-02-03 20:56 ` [PATCH v4 4/9] target-info: add target_base_ppc, target_ppc and target_ppc64 Pierrick Bouvier
` (7 subsequent siblings)
10 siblings, 2 replies; 23+ messages in thread
From: Pierrick Bouvier @ 2026-02-03 20:56 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, qemu-ppc, Stefano Garzarella,
Pierrick Bouvier, Nicholas Piggin, Michael S. Tsirkin,
Harsh Prateek Bora
From: Philippe Mathieu-Daudé <philmd@linaro.org>
Endianness access is constant between device resets.
Use the field instead of calling the same function.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
include/hw/virtio/virtio-access.h | 24 ++++++++++++------------
hw/virtio/virtio.c | 4 ++--
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-access.h
index cd17d0c87eb..f3b4d0075b5 100644
--- a/include/hw/virtio/virtio-access.h
+++ b/include/hw/virtio/virtio-access.h
@@ -42,7 +42,7 @@ static inline bool virtio_access_is_big_endian(VirtIODevice *vdev)
static inline void virtio_stw_p(VirtIODevice *vdev, void *ptr, uint16_t v)
{
- if (virtio_access_is_big_endian(vdev)) {
+ if (vdev->access_is_big_endian) {
stw_be_p(ptr, v);
} else {
stw_le_p(ptr, v);
@@ -51,7 +51,7 @@ static inline void virtio_stw_p(VirtIODevice *vdev, void *ptr, uint16_t v)
static inline void virtio_stl_p(VirtIODevice *vdev, void *ptr, uint32_t v)
{
- if (virtio_access_is_big_endian(vdev)) {
+ if (vdev->access_is_big_endian) {
stl_be_p(ptr, v);
} else {
stl_le_p(ptr, v);
@@ -60,7 +60,7 @@ static inline void virtio_stl_p(VirtIODevice *vdev, void *ptr, uint32_t v)
static inline void virtio_stq_p(VirtIODevice *vdev, void *ptr, uint64_t v)
{
- if (virtio_access_is_big_endian(vdev)) {
+ if (vdev->access_is_big_endian) {
stq_be_p(ptr, v);
} else {
stq_le_p(ptr, v);
@@ -69,7 +69,7 @@ static inline void virtio_stq_p(VirtIODevice *vdev, void *ptr, uint64_t v)
static inline int virtio_lduw_p(VirtIODevice *vdev, const void *ptr)
{
- if (virtio_access_is_big_endian(vdev)) {
+ if (vdev->access_is_big_endian) {
return lduw_be_p(ptr);
} else {
return lduw_le_p(ptr);
@@ -78,7 +78,7 @@ static inline int virtio_lduw_p(VirtIODevice *vdev, const void *ptr)
static inline int virtio_ldl_p(VirtIODevice *vdev, const void *ptr)
{
- if (virtio_access_is_big_endian(vdev)) {
+ if (vdev->access_is_big_endian) {
return ldl_be_p(ptr);
} else {
return ldl_le_p(ptr);
@@ -87,7 +87,7 @@ static inline int virtio_ldl_p(VirtIODevice *vdev, const void *ptr)
static inline uint64_t virtio_ldq_p(VirtIODevice *vdev, const void *ptr)
{
- if (virtio_access_is_big_endian(vdev)) {
+ if (vdev->access_is_big_endian) {
return ldq_be_p(ptr);
} else {
return ldq_le_p(ptr);
@@ -97,9 +97,9 @@ static inline uint64_t virtio_ldq_p(VirtIODevice *vdev, const void *ptr)
static inline uint16_t virtio_tswap16(VirtIODevice *vdev, uint16_t s)
{
#if HOST_BIG_ENDIAN
- return virtio_access_is_big_endian(vdev) ? s : bswap16(s);
+ return vdev->access_is_big_endian ? s : bswap16(s);
#else
- return virtio_access_is_big_endian(vdev) ? bswap16(s) : s;
+ return vdev->access_is_big_endian ? bswap16(s) : s;
#endif
}
@@ -111,9 +111,9 @@ static inline void virtio_tswap16s(VirtIODevice *vdev, uint16_t *s)
static inline uint32_t virtio_tswap32(VirtIODevice *vdev, uint32_t s)
{
#if HOST_BIG_ENDIAN
- return virtio_access_is_big_endian(vdev) ? s : bswap32(s);
+ return vdev->access_is_big_endian ? s : bswap32(s);
#else
- return virtio_access_is_big_endian(vdev) ? bswap32(s) : s;
+ return vdev->access_is_big_endian ? bswap32(s) : s;
#endif
}
@@ -125,9 +125,9 @@ static inline void virtio_tswap32s(VirtIODevice *vdev, uint32_t *s)
static inline uint64_t virtio_tswap64(VirtIODevice *vdev, uint64_t s)
{
#if HOST_BIG_ENDIAN
- return virtio_access_is_big_endian(vdev) ? s : bswap64(s);
+ return vdev->access_is_big_endian ? s : bswap64(s);
#else
- return virtio_access_is_big_endian(vdev) ? bswap64(s) : s;
+ return vdev->access_is_big_endian ? bswap64(s) : s;
#endif
}
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index df2887e7296..f08e94843ea 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -220,7 +220,7 @@ static inline uint16_t virtio_lduw_phys_cached(VirtIODevice *vdev,
MemoryRegionCache *cache,
hwaddr pa)
{
- if (virtio_access_is_big_endian(vdev)) {
+ if (vdev->access_is_big_endian) {
return lduw_be_phys_cached(cache, pa);
}
return lduw_le_phys_cached(cache, pa);
@@ -230,7 +230,7 @@ static inline void virtio_stw_phys_cached(VirtIODevice *vdev,
MemoryRegionCache *cache,
hwaddr pa, uint16_t value)
{
- if (virtio_access_is_big_endian(vdev)) {
+ if (vdev->access_is_big_endian) {
stw_be_phys_cached(cache, pa, value);
} else {
stw_le_phys_cached(cache, pa, value);
--
2.47.3
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v4 4/9] target-info: add target_base_ppc, target_ppc and target_ppc64
2026-02-03 20:56 [PATCH v4 0/9] single-binary: hw/virtio Pierrick Bouvier
` (2 preceding siblings ...)
2026-02-03 20:56 ` [PATCH v4 3/9] hw/virtio: Use VirtIODevice::access_is_big_endian field Pierrick Bouvier
@ 2026-02-03 20:56 ` Pierrick Bouvier
2026-02-03 20:56 ` [PATCH v4 5/9] include/hw/virtio/virtio-access.h: remove target specifics define Pierrick Bouvier
` (6 subsequent siblings)
10 siblings, 0 replies; 23+ messages in thread
From: Pierrick Bouvier @ 2026-02-03 20:56 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, qemu-ppc, Stefano Garzarella,
Pierrick Bouvier, Nicholas Piggin, Michael S. Tsirkin,
Harsh Prateek Bora
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
include/qemu/target-info.h | 21 +++++++++++++++++++++
target-info.c | 21 +++++++++++++++++++++
2 files changed, 42 insertions(+)
diff --git a/include/qemu/target-info.h b/include/qemu/target-info.h
index 62359622232..e3287334304 100644
--- a/include/qemu/target-info.h
+++ b/include/qemu/target-info.h
@@ -71,4 +71,25 @@ bool target_arm(void);
*/
bool target_aarch64(void);
+/**
+ * target_base_ppc:
+ *
+ * Returns whether the target architecture is PowerPC 32-bit or 64-bit.
+ */
+bool target_base_ppc(void);
+
+/**
+ * target_ppc:
+ *
+ * Returns whether the target architecture is PowerPC 32-bit.
+ */
+bool target_ppc(void);
+
+/**
+ * target_ppc64:
+ *
+ * Returns whether the target architecture is PowerPC 64-bit.
+ */
+bool target_ppc64(void);
+
#endif
diff --git a/target-info.c b/target-info.c
index 24696ff4111..5a6d7282524 100644
--- a/target-info.c
+++ b/target-info.c
@@ -73,3 +73,24 @@ bool target_aarch64(void)
{
return target_arch() == SYS_EMU_TARGET_AARCH64;
}
+
+bool target_base_ppc(void)
+{
+ switch (target_arch()) {
+ case SYS_EMU_TARGET_PPC:
+ case SYS_EMU_TARGET_PPC64:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool target_ppc(void)
+{
+ return target_arch() == SYS_EMU_TARGET_PPC;
+}
+
+bool target_ppc64(void)
+{
+ return target_arch() == SYS_EMU_TARGET_PPC64;
+}
--
2.47.3
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v4 5/9] include/hw/virtio/virtio-access.h: remove target specifics define
2026-02-03 20:56 [PATCH v4 0/9] single-binary: hw/virtio Pierrick Bouvier
` (3 preceding siblings ...)
2026-02-03 20:56 ` [PATCH v4 4/9] target-info: add target_base_ppc, target_ppc and target_ppc64 Pierrick Bouvier
@ 2026-02-03 20:56 ` Pierrick Bouvier
2026-02-04 2:10 ` Richard Henderson
2026-02-03 20:56 ` [PATCH v4 6/9] include/hw/ppc/spapr: extract SPAPR_MAX_RAM_SLOTS in a new header Pierrick Bouvier
` (5 subsequent siblings)
10 siblings, 1 reply; 23+ messages in thread
From: Pierrick Bouvier @ 2026-02-03 20:56 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, qemu-ppc, Stefano Garzarella,
Pierrick Bouvier, Nicholas Piggin, Michael S. Tsirkin,
Harsh Prateek Bora
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
include/hw/virtio/virtio-access.h | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-access.h
index f3b4d0075b5..1bea3445979 100644
--- a/include/hw/virtio/virtio-access.h
+++ b/include/hw/virtio/virtio-access.h
@@ -17,27 +17,27 @@
#define QEMU_VIRTIO_ACCESS_H
#include "exec/hwaddr.h"
+#include "qemu/target-info.h"
#include "system/memory_cached.h"
#include "hw/virtio/virtio.h"
#include "hw/virtio/virtio-bus.h"
-#if defined(TARGET_PPC64) || defined(TARGET_ARM)
-#define LEGACY_VIRTIO_IS_BIENDIAN 1
-#endif
-
static inline bool virtio_access_is_big_endian(VirtIODevice *vdev)
{
-#if defined(LEGACY_VIRTIO_IS_BIENDIAN)
- return virtio_is_big_endian(vdev);
-#elif TARGET_BIG_ENDIAN
- if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
- /* Devices conforming to VIRTIO 1.0 or later are always LE. */
- return false;
+ if (target_ppc64() || target_base_arm()) {
+ return virtio_is_big_endian(vdev);
}
- return true;
-#else
+
+ if (target_big_endian()) {
+ if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
+ /* Devices conforming to VIRTIO 1.0 or later are always LE. */
+ return false;
+ } else {
+ return true;
+ }
+ }
+
return false;
-#endif
}
static inline void virtio_stw_p(VirtIODevice *vdev, void *ptr, uint16_t v)
--
2.47.3
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v4 6/9] include/hw/ppc/spapr: extract SPAPR_MAX_RAM_SLOTS in a new header
2026-02-03 20:56 [PATCH v4 0/9] single-binary: hw/virtio Pierrick Bouvier
` (4 preceding siblings ...)
2026-02-03 20:56 ` [PATCH v4 5/9] include/hw/virtio/virtio-access.h: remove target specifics define Pierrick Bouvier
@ 2026-02-03 20:56 ` Pierrick Bouvier
2026-02-03 20:56 ` [PATCH v4 7/9] hw/virtio/vhost-user: make compilation unit common Pierrick Bouvier
` (4 subsequent siblings)
10 siblings, 0 replies; 23+ messages in thread
From: Pierrick Bouvier @ 2026-02-03 20:56 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, qemu-ppc, Stefano Garzarella,
Pierrick Bouvier, Nicholas Piggin, Michael S. Tsirkin,
Harsh Prateek Bora
Allow to include it from common code (vhost-user, in next commit), else
it pulls ppc/cpu.h which has target specifics.
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
include/hw/ppc/spapr.h | 8 +-------
include/hw/ppc/spapr_common.h | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 7 deletions(-)
create mode 100644 include/hw/ppc/spapr_common.h
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 5476ac7ce7b..b022f8dd25d 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -4,6 +4,7 @@
#include "qemu/units.h"
#include "system/dma.h"
#include "hw/core/boards.h"
+#include "hw/ppc/spapr_common.h"
#include "hw/ppc/spapr_drc.h"
#include "hw/mem/pc-dimm.h"
#include "hw/ppc/spapr_ovec.h"
@@ -946,13 +947,6 @@ int spapr_rtc_import_offset(SpaprRtcState *rtc, int64_t legacy_offset);
#define SPAPR_MEMORY_BLOCK_SIZE ((hwaddr)1 << 28) /* 256MB */
-/*
- * This defines the maximum number of DIMM slots we can have for sPAPR
- * guest. This is not defined by sPAPR but we are defining it to 32 slots
- * based on default number of slots provided by PowerPC kernel.
- */
-#define SPAPR_MAX_RAM_SLOTS 32
-
/* 1GB alignment for hotplug memory region */
#define SPAPR_DEVICE_MEM_ALIGN (1 * GiB)
diff --git a/include/hw/ppc/spapr_common.h b/include/hw/ppc/spapr_common.h
new file mode 100644
index 00000000000..d799927ff5c
--- /dev/null
+++ b/include/hw/ppc/spapr_common.h
@@ -0,0 +1,16 @@
+/*
+ * Common definitions for PPC SPAPR
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef HW_SPAPR_COMMON_H
+#define HW_SPAPR_COMMON_H
+
+/*
+ * This defines the maximum number of DIMM slots we can have for sPAPR
+ * guest. This is not defined by sPAPR but we are defining it to 32 slots
+ * based on default number of slots provided by PowerPC kernel.
+ */
+#define SPAPR_MAX_RAM_SLOTS 32
+
+#endif /* HW_SPAPR_COMMON_H */
--
2.47.3
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v4 7/9] hw/virtio/vhost-user: make compilation unit common
2026-02-03 20:56 [PATCH v4 0/9] single-binary: hw/virtio Pierrick Bouvier
` (5 preceding siblings ...)
2026-02-03 20:56 ` [PATCH v4 6/9] include/hw/ppc/spapr: extract SPAPR_MAX_RAM_SLOTS in a new header Pierrick Bouvier
@ 2026-02-03 20:56 ` Pierrick Bouvier
2026-02-03 20:56 ` [PATCH v4 8/9] hw/virtio/virtio-qmp: " Pierrick Bouvier
` (3 subsequent siblings)
10 siblings, 0 replies; 23+ messages in thread
From: Pierrick Bouvier @ 2026-02-03 20:56 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, qemu-ppc, Stefano Garzarella,
Pierrick Bouvier, Nicholas Piggin, Michael S. Tsirkin,
Harsh Prateek Bora
PPC architectures use a custom value for VHOST_USER_MAX_RAM_SLOTS (32
instead of 512).
vhost_user struct and several functions use VHOST_USER_MAX_RAM_SLOTS to
define stack allocated buffers. To avoid changing all functions to use
heap allocated buffers, we keep this max, and simply add a
target_base_ppc() conditional for the single place where size really
matters.
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
hw/virtio/vhost-user.c | 11 ++++-------
hw/virtio/meson.build | 3 +--
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 63fa9a1b4b1..c8a004c6d2d 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -44,13 +44,8 @@
#define VHOST_USER_F_PROTOCOL_FEATURES 30
#define VHOST_USER_BACKEND_MAX_FDS 8
-#if defined(TARGET_PPC) || defined(TARGET_PPC64)
-#include "hw/ppc/spapr.h"
-#define VHOST_USER_MAX_RAM_SLOTS SPAPR_MAX_RAM_SLOTS
-
-#else
+#include "hw/ppc/spapr_common.h"
#define VHOST_USER_MAX_RAM_SLOTS 512
-#endif
/*
* Maximum size of virtio device config space
@@ -2280,7 +2275,9 @@ static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque,
return -EINVAL;
}
- u->user->memory_slots = MIN(ram_slots, VHOST_USER_MAX_RAM_SLOTS);
+ const uint64_t vhost_user_max_ram_slots = target_base_ppc() ?
+ SPAPR_MAX_RAM_SLOTS : VHOST_USER_MAX_RAM_SLOTS;
+ u->user->memory_slots = MIN(ram_slots, vhost_user_max_ram_slots);
}
}
diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build
index affd66887db..ee397aaf196 100644
--- a/hw/virtio/meson.build
+++ b/hw/virtio/meson.build
@@ -17,8 +17,7 @@ if have_vhost
system_virtio_ss.add(files('vhost.c'))
system_virtio_ss.add(files('vhost-backend.c', 'vhost-iova-tree.c'))
if have_vhost_user
- # fixme - this really should be generic
- specific_virtio_ss.add(files('vhost-user.c'))
+ system_virtio_ss.add(files('vhost-user.c'))
system_virtio_ss.add(files('vhost-user-base.c'))
# MMIO Stubs
--
2.47.3
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v4 8/9] hw/virtio/virtio-qmp: make compilation unit common
2026-02-03 20:56 [PATCH v4 0/9] single-binary: hw/virtio Pierrick Bouvier
` (6 preceding siblings ...)
2026-02-03 20:56 ` [PATCH v4 7/9] hw/virtio/vhost-user: make compilation unit common Pierrick Bouvier
@ 2026-02-03 20:56 ` Pierrick Bouvier
2026-02-03 20:56 ` [PATCH v4 9/9] hw/virtio/: make all compilation units common Pierrick Bouvier
` (2 subsequent siblings)
10 siblings, 0 replies; 23+ messages in thread
From: Pierrick Bouvier @ 2026-02-03 20:56 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, qemu-ppc, Stefano Garzarella,
Pierrick Bouvier, Nicholas Piggin, Michael S. Tsirkin,
Harsh Prateek Bora
All compile time conditionals have no impact at runtime, since they are
representing only possible features for devices present at runtime.
In case they are not present, associated features table will never be
used. In case they are present but some features are not, matching bits
will never be enabled, so those entries will be unused.
Thus, simply expose everything and call it a day.
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
hw/virtio/virtio-qmp.c | 70 ------------------------------------------
hw/virtio/meson.build | 2 +-
2 files changed, 1 insertion(+), 71 deletions(-)
diff --git a/hw/virtio/virtio-qmp.c b/hw/virtio/virtio-qmp.c
index 968299fda0c..f9cdca50d99 100644
--- a/hw/virtio/virtio-qmp.c
+++ b/hw/virtio/virtio-qmp.c
@@ -33,21 +33,17 @@
#include "standard-headers/linux/virtio_vsock.h"
#include "standard-headers/linux/virtio_gpio.h"
-#include CONFIG_DEVICES
-
#define FEATURE_ENTRY(name, desc) (qmp_virtio_feature_map_t) \
{ .virtio_bit = name, .feature_desc = desc }
/* Virtio transport features mapping */
static const qmp_virtio_feature_map_t virtio_transport_map[] = {
/* Virtio device transport features */
-#ifndef VIRTIO_CONFIG_NO_LEGACY
FEATURE_ENTRY(VIRTIO_F_NOTIFY_ON_EMPTY, \
"VIRTIO_F_NOTIFY_ON_EMPTY: Notify when device runs out of avail. "
"descs. on VQ"),
FEATURE_ENTRY(VIRTIO_F_ANY_LAYOUT, \
"VIRTIO_F_ANY_LAYOUT: Device accepts arbitrary desc. layouts"),
-#endif /* !VIRTIO_CONFIG_NO_LEGACY */
FEATURE_ENTRY(VIRTIO_F_VERSION_1, \
"VIRTIO_F_VERSION_1: Device compliant for v1 spec (legacy)"),
FEATURE_ENTRY(VIRTIO_F_IOMMU_PLATFORM, \
@@ -149,7 +145,6 @@ static const qmp_virtio_feature_map_t virtio_config_status_map[] = {
};
/* virtio-blk features mapping */
-#ifdef CONFIG_VIRTIO_BLK
static const qmp_virtio_feature_map_t virtio_blk_feature_map[] = {
FEATURE_ENTRY(VIRTIO_BLK_F_SIZE_MAX, \
"VIRTIO_BLK_F_SIZE_MAX: Max segment size is size_max"),
@@ -173,7 +168,6 @@ static const qmp_virtio_feature_map_t virtio_blk_feature_map[] = {
"VIRTIO_BLK_F_SECURE_ERASE: Secure erase supported"),
FEATURE_ENTRY(VIRTIO_BLK_F_ZONED, \
"VIRTIO_BLK_F_ZONED: Zoned block devices"),
-#ifndef VIRTIO_BLK_NO_LEGACY
FEATURE_ENTRY(VIRTIO_BLK_F_BARRIER, \
"VIRTIO_BLK_F_BARRIER: Request barriers supported"),
FEATURE_ENTRY(VIRTIO_BLK_F_SCSI, \
@@ -183,7 +177,6 @@ static const qmp_virtio_feature_map_t virtio_blk_feature_map[] = {
FEATURE_ENTRY(VIRTIO_BLK_F_CONFIG_WCE, \
"VIRTIO_BLK_F_CONFIG_WCE: Cache writeback and writethrough modes "
"supported"),
-#endif /* !VIRTIO_BLK_NO_LEGACY */
FEATURE_ENTRY(VHOST_F_LOG_ALL, \
"VHOST_F_LOG_ALL: Logging write descriptors supported"),
FEATURE_ENTRY(VHOST_USER_F_PROTOCOL_FEATURES, \
@@ -191,10 +184,8 @@ static const qmp_virtio_feature_map_t virtio_blk_feature_map[] = {
"negotiation supported"),
{ -1, "" }
};
-#endif
/* virtio-serial features mapping */
-#ifdef CONFIG_VIRTIO_SERIAL
static const qmp_virtio_feature_map_t virtio_serial_feature_map[] = {
FEATURE_ENTRY(VIRTIO_CONSOLE_F_SIZE, \
"VIRTIO_CONSOLE_F_SIZE: Host providing console size"),
@@ -204,10 +195,8 @@ static const qmp_virtio_feature_map_t virtio_serial_feature_map[] = {
"VIRTIO_CONSOLE_F_EMERG_WRITE: Emergency write supported"),
{ -1, "" }
};
-#endif
/* virtio-gpu features mapping */
-#ifdef CONFIG_VIRTIO_GPU
static const qmp_virtio_feature_map_t virtio_gpu_feature_map[] = {
FEATURE_ENTRY(VIRTIO_GPU_F_VIRGL, \
"VIRTIO_GPU_F_VIRGL: Virgl 3D mode supported"),
@@ -227,10 +216,8 @@ static const qmp_virtio_feature_map_t virtio_gpu_feature_map[] = {
"negotiation supported"),
{ -1, "" }
};
-#endif
/* virtio-input features mapping */
-#ifdef CONFIG_VIRTIO_INPUT
static const qmp_virtio_feature_map_t virtio_input_feature_map[] = {
FEATURE_ENTRY(VHOST_F_LOG_ALL, \
"VHOST_F_LOG_ALL: Logging write descriptors supported"),
@@ -239,10 +226,8 @@ static const qmp_virtio_feature_map_t virtio_input_feature_map[] = {
"negotiation supported"),
{ -1, "" }
};
-#endif
/* virtio-net features mapping */
-#ifdef CONFIG_VIRTIO_NET
static const qmp_virtio_feature_map_t virtio_net_feature_map[] = {
FEATURE_ENTRY(VIRTIO_NET_F_CSUM, \
"VIRTIO_NET_F_CSUM: Device handling packets with partial checksum "
@@ -313,10 +298,8 @@ static const qmp_virtio_feature_map_t virtio_net_feature_map[] = {
"device with same MAC addr. supported"),
FEATURE_ENTRY(VIRTIO_NET_F_SPEED_DUPLEX, \
"VIRTIO_NET_F_SPEED_DUPLEX: Device set linkspeed and duplex"),
-#ifndef VIRTIO_NET_NO_LEGACY
FEATURE_ENTRY(VIRTIO_NET_F_GSO, \
"VIRTIO_NET_F_GSO: Handling GSO-type packets supported"),
-#endif /* !VIRTIO_NET_NO_LEGACY */
FEATURE_ENTRY(VHOST_NET_F_VIRTIO_NET_HDR, \
"VHOST_NET_F_VIRTIO_NET_HDR: Virtio-net headers for RX and TX "
"packets supported"),
@@ -341,10 +324,8 @@ static const qmp_virtio_feature_map_t virtio_net_feature_map[] = {
"header"),
{ -1, "" }
};
-#endif
/* virtio-scsi features mapping */
-#ifdef CONFIG_VIRTIO_SCSI
static const qmp_virtio_feature_map_t virtio_scsi_feature_map[] = {
FEATURE_ENTRY(VIRTIO_SCSI_F_INOUT, \
"VIRTIO_SCSI_F_INOUT: Requests including read and writable data "
@@ -364,10 +345,8 @@ static const qmp_virtio_feature_map_t virtio_scsi_feature_map[] = {
"negotiation supported"),
{ -1, "" }
};
-#endif
/* virtio/vhost-user-fs features mapping */
-#ifdef CONFIG_VHOST_USER_FS
static const qmp_virtio_feature_map_t virtio_fs_feature_map[] = {
FEATURE_ENTRY(VHOST_F_LOG_ALL, \
"VHOST_F_LOG_ALL: Logging write descriptors supported"),
@@ -376,10 +355,8 @@ static const qmp_virtio_feature_map_t virtio_fs_feature_map[] = {
"negotiation supported"),
{ -1, "" }
};
-#endif
/* virtio/vhost-user-i2c features mapping */
-#ifdef CONFIG_VIRTIO_I2C_ADAPTER
static const qmp_virtio_feature_map_t virtio_i2c_feature_map[] = {
FEATURE_ENTRY(VIRTIO_I2C_F_ZERO_LENGTH_REQUEST, \
"VIRTIO_I2C_F_ZERO_LEGNTH_REQUEST: Zero length requests supported"),
@@ -390,10 +367,8 @@ static const qmp_virtio_feature_map_t virtio_i2c_feature_map[] = {
"negotiation supported"),
{ -1, "" }
};
-#endif
/* virtio/vhost-vsock features mapping */
-#ifdef CONFIG_VHOST_VSOCK
static const qmp_virtio_feature_map_t virtio_vsock_feature_map[] = {
FEATURE_ENTRY(VIRTIO_VSOCK_F_SEQPACKET, \
"VIRTIO_VSOCK_F_SEQPACKET: SOCK_SEQPACKET supported"),
@@ -404,10 +379,8 @@ static const qmp_virtio_feature_map_t virtio_vsock_feature_map[] = {
"negotiation supported"),
{ -1, "" }
};
-#endif
/* virtio-balloon features mapping */
-#ifdef CONFIG_VIRTIO_BALLOON
static const qmp_virtio_feature_map_t virtio_balloon_feature_map[] = {
FEATURE_ENTRY(VIRTIO_BALLOON_F_MUST_TELL_HOST, \
"VIRTIO_BALLOON_F_MUST_TELL_HOST: Tell host before reclaiming "
@@ -424,19 +397,15 @@ static const qmp_virtio_feature_map_t virtio_balloon_feature_map[] = {
"VIRTIO_BALLOON_F_REPORTING: Page reporting VQ enabled"),
{ -1, "" }
};
-#endif
/* virtio-crypto features mapping */
-#ifdef CONFIG_VIRTIO_CRYPTO
static const qmp_virtio_feature_map_t virtio_crypto_feature_map[] = {
FEATURE_ENTRY(VHOST_F_LOG_ALL, \
"VHOST_F_LOG_ALL: Logging write descriptors supported"),
{ -1, "" }
};
-#endif
/* virtio-iommu features mapping */
-#ifdef CONFIG_VIRTIO_IOMMU
static const qmp_virtio_feature_map_t virtio_iommu_feature_map[] = {
FEATURE_ENTRY(VIRTIO_IOMMU_F_INPUT_RANGE, \
"VIRTIO_IOMMU_F_INPUT_RANGE: Range of available virtual addrs. "
@@ -458,15 +427,11 @@ static const qmp_virtio_feature_map_t virtio_iommu_feature_map[] = {
"available"),
{ -1, "" }
};
-#endif
/* virtio-mem features mapping */
-#ifdef CONFIG_VIRTIO_MEM
static const qmp_virtio_feature_map_t virtio_mem_feature_map[] = {
-#ifndef CONFIG_ACPI
FEATURE_ENTRY(VIRTIO_MEM_F_ACPI_PXM, \
"VIRTIO_MEM_F_ACPI_PXM: node_id is an ACPI PXM and is valid"),
-#endif /* !CONFIG_ACPI */
FEATURE_ENTRY(VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE, \
"VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE: Unplugged memory cannot be "
"accessed"),
@@ -475,10 +440,8 @@ static const qmp_virtio_feature_map_t virtio_mem_feature_map[] = {
"plugged when suspending+resuming"),
{ -1, "" }
};
-#endif
/* virtio-rng features mapping */
-#ifdef CONFIG_VIRTIO_RNG
static const qmp_virtio_feature_map_t virtio_rng_feature_map[] = {
FEATURE_ENTRY(VHOST_F_LOG_ALL, \
"VHOST_F_LOG_ALL: Logging write descriptors supported"),
@@ -487,10 +450,8 @@ static const qmp_virtio_feature_map_t virtio_rng_feature_map[] = {
"negotiation supported"),
{ -1, "" }
};
-#endif
/* virtio/vhost-gpio features mapping */
-#ifdef CONFIG_VHOST_USER_GPIO
static const qmp_virtio_feature_map_t virtio_gpio_feature_map[] = {
FEATURE_ENTRY(VIRTIO_GPIO_F_IRQ, \
"VIRTIO_GPIO_F_IRQ: Device supports interrupts on GPIO lines"),
@@ -499,7 +460,6 @@ static const qmp_virtio_feature_map_t virtio_gpio_feature_map[] = {
"negotiation supported"),
{ -1, "" }
};
-#endif
#define CONVERT_FEATURES(type, map, is_status, bitmap) \
({ \
@@ -595,96 +555,66 @@ VirtioDeviceFeatures *qmp_decode_features(uint16_t device_id,
/* device features */
switch (device_id) {
-#ifdef CONFIG_VIRTIO_SERIAL
case VIRTIO_ID_CONSOLE:
features->dev_features =
CONVERT_FEATURES_EX(strList, virtio_serial_feature_map, bitmap);
break;
-#endif
-#ifdef CONFIG_VIRTIO_BLK
case VIRTIO_ID_BLOCK:
features->dev_features =
CONVERT_FEATURES_EX(strList, virtio_blk_feature_map, bitmap);
break;
-#endif
-#ifdef CONFIG_VIRTIO_GPU
case VIRTIO_ID_GPU:
features->dev_features =
CONVERT_FEATURES_EX(strList, virtio_gpu_feature_map, bitmap);
break;
-#endif
-#ifdef CONFIG_VIRTIO_NET
case VIRTIO_ID_NET:
features->dev_features =
CONVERT_FEATURES_EX(strList, virtio_net_feature_map, bitmap);
break;
-#endif
-#ifdef CONFIG_VIRTIO_SCSI
case VIRTIO_ID_SCSI:
features->dev_features =
CONVERT_FEATURES_EX(strList, virtio_scsi_feature_map, bitmap);
break;
-#endif
-#ifdef CONFIG_VIRTIO_BALLOON
case VIRTIO_ID_BALLOON:
features->dev_features =
CONVERT_FEATURES_EX(strList, virtio_balloon_feature_map, bitmap);
break;
-#endif
-#ifdef CONFIG_VIRTIO_IOMMU
case VIRTIO_ID_IOMMU:
features->dev_features =
CONVERT_FEATURES_EX(strList, virtio_iommu_feature_map, bitmap);
break;
-#endif
-#ifdef CONFIG_VIRTIO_INPUT
case VIRTIO_ID_INPUT:
features->dev_features =
CONVERT_FEATURES_EX(strList, virtio_input_feature_map, bitmap);
break;
-#endif
-#ifdef CONFIG_VHOST_USER_FS
case VIRTIO_ID_FS:
features->dev_features =
CONVERT_FEATURES_EX(strList, virtio_fs_feature_map, bitmap);
break;
-#endif
-#ifdef CONFIG_VHOST_VSOCK
case VIRTIO_ID_VSOCK:
features->dev_features =
CONVERT_FEATURES_EX(strList, virtio_vsock_feature_map, bitmap);
break;
-#endif
-#ifdef CONFIG_VIRTIO_CRYPTO
case VIRTIO_ID_CRYPTO:
features->dev_features =
CONVERT_FEATURES_EX(strList, virtio_crypto_feature_map, bitmap);
break;
-#endif
-#ifdef CONFIG_VIRTIO_MEM
case VIRTIO_ID_MEM:
features->dev_features =
CONVERT_FEATURES_EX(strList, virtio_mem_feature_map, bitmap);
break;
-#endif
-#ifdef CONFIG_VIRTIO_I2C_ADAPTER
case VIRTIO_ID_I2C_ADAPTER:
features->dev_features =
CONVERT_FEATURES_EX(strList, virtio_i2c_feature_map, bitmap);
break;
-#endif
-#ifdef CONFIG_VIRTIO_RNG
case VIRTIO_ID_RNG:
features->dev_features =
CONVERT_FEATURES_EX(strList, virtio_rng_feature_map, bitmap);
break;
-#endif
-#ifdef CONFIG_VHOST_USER_GPIO
case VIRTIO_ID_GPIO:
features->dev_features =
CONVERT_FEATURES_EX(strList, virtio_gpio_feature_map, bitmap);
break;
-#endif
/* No features */
case VIRTIO_ID_9P:
case VIRTIO_ID_PMEM:
diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build
index ee397aaf196..d913b94e1ca 100644
--- a/hw/virtio/meson.build
+++ b/hw/virtio/meson.build
@@ -11,7 +11,7 @@ system_virtio_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev.c')
specific_virtio_ss = ss.source_set()
specific_virtio_ss.add(files('virtio.c'))
-specific_virtio_ss.add(files('virtio-qmp.c'))
+system_virtio_ss.add(files('virtio-qmp.c'))
if have_vhost
system_virtio_ss.add(files('vhost.c'))
--
2.47.3
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v4 9/9] hw/virtio/: make all compilation units common
2026-02-03 20:56 [PATCH v4 0/9] single-binary: hw/virtio Pierrick Bouvier
` (7 preceding siblings ...)
2026-02-03 20:56 ` [PATCH v4 8/9] hw/virtio/virtio-qmp: " Pierrick Bouvier
@ 2026-02-03 20:56 ` Pierrick Bouvier
2026-02-05 5:27 ` [PATCH v4 0/9] single-binary: hw/virtio Pierrick Bouvier
2026-02-06 22:21 ` Pierrick Bouvier
10 siblings, 0 replies; 23+ messages in thread
From: Pierrick Bouvier @ 2026-02-03 20:56 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, qemu-ppc, Stefano Garzarella,
Pierrick Bouvier, Nicholas Piggin, Michael S. Tsirkin,
Harsh Prateek Bora
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
hw/virtio/meson.build | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build
index d913b94e1ca..4f308beb961 100644
--- a/hw/virtio/meson.build
+++ b/hw/virtio/meson.build
@@ -9,8 +9,7 @@ system_virtio_ss.add(when: 'CONFIG_VHOST_VSOCK_COMMON', if_true: files('vhost-vs
system_virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu.c'))
system_virtio_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev.c'))
-specific_virtio_ss = ss.source_set()
-specific_virtio_ss.add(files('virtio.c'))
+system_virtio_ss.add(files('virtio.c'))
system_virtio_ss.add(files('virtio-qmp.c'))
if have_vhost
@@ -52,10 +51,10 @@ endif
system_virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-user-vsock.c'))
system_virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-rng.c'))
-specific_virtio_ss.add(when: 'CONFIG_VIRTIO_BALLOON', if_true: files('virtio-balloon.c'))
-specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_FS', if_true: files('vhost-user-fs.c'))
-specific_virtio_ss.add(when: 'CONFIG_VIRTIO_PMEM', if_true: files('virtio-pmem.c'))
-specific_virtio_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock.c'))
+system_virtio_ss.add(when: 'CONFIG_VIRTIO_BALLOON', if_true: files('virtio-balloon.c'))
+system_virtio_ss.add(when: 'CONFIG_VHOST_USER_FS', if_true: files('vhost-user-fs.c'))
+system_virtio_ss.add(when: 'CONFIG_VIRTIO_PMEM', if_true: files('virtio-pmem.c'))
+system_virtio_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock.c'))
system_virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c'))
system_virtio_ss.add(when: 'CONFIG_VIRTIO_NSM', if_true: files('virtio-nsm.c'))
system_virtio_ss.add(when: 'CONFIG_VIRTIO_NSM', if_true: [files('cbor-helpers.c'), libcbor])
@@ -97,5 +96,4 @@ system_ss.add(when: ['CONFIG_VIRTIO_MD', 'CONFIG_VIRTIO_PCI'],
system_ss.add(files('virtio-hmp-cmds.c'))
-specific_ss.add_all(when: 'CONFIG_VIRTIO', if_true: specific_virtio_ss)
system_ss.add(when: 'CONFIG_ACPI', if_true: files('virtio-acpi.c'))
--
2.47.3
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v4 3/9] hw/virtio: Use VirtIODevice::access_is_big_endian field
2026-02-03 20:56 ` [PATCH v4 3/9] hw/virtio: Use VirtIODevice::access_is_big_endian field Pierrick Bouvier
@ 2026-02-03 22:11 ` Philippe Mathieu-Daudé
2026-02-03 22:38 ` BALATON Zoltan
2026-02-06 4:37 ` Pierrick Bouvier
1 sibling, 1 reply; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-02-03 22:11 UTC (permalink / raw)
To: Pierrick Bouvier, qemu-devel
Cc: qemu-ppc, Stefano Garzarella, Nicholas Piggin, Michael S. Tsirkin,
Harsh Prateek Bora
On 3/2/26 21:56, Pierrick Bouvier wrote:
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
>
> Endianness access is constant between device resets.
> Use the field instead of calling the same function.
Maybe we should justify here, simply adding from your v3 comment:
When doing automated benchmark with fio (see instructions
in [*]) this resulted in a +1.4% speedup vs existing code.
[*] https://lore.kernel.org/qemu-devel/20260202185233.GC405548@fedora/
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
> include/hw/virtio/virtio-access.h | 24 ++++++++++++------------
> hw/virtio/virtio.c | 4 ++--
> 2 files changed, 14 insertions(+), 14 deletions(-)
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v4 3/9] hw/virtio: Use VirtIODevice::access_is_big_endian field
2026-02-03 22:11 ` Philippe Mathieu-Daudé
@ 2026-02-03 22:38 ` BALATON Zoltan
2026-02-03 22:45 ` Pierrick Bouvier
0 siblings, 1 reply; 23+ messages in thread
From: BALATON Zoltan @ 2026-02-03 22:38 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Pierrick Bouvier, qemu-devel, qemu-ppc, Stefano Garzarella,
Nicholas Piggin, Michael S. Tsirkin, Harsh Prateek Bora
[-- Attachment #1: Type: text/plain, Size: 1184 bytes --]
On Tue, 3 Feb 2026, Philippe Mathieu-Daudé wrote:
> On 3/2/26 21:56, Pierrick Bouvier wrote:
>> From: Philippe Mathieu-Daudé <philmd@linaro.org>
>>
>> Endianness access is constant between device resets.
>> Use the field instead of calling the same function.
>
> Maybe we should justify here, simply adding from your v3 comment:
>
> When doing automated benchmark with fio (see instructions
> in [*]) this resulted in a +1.4% speedup vs existing code.
>
> [*] https://lore.kernel.org/qemu-devel/20260202185233.GC405548@fedora/
What does existing code refer to here? According to cover letter it's
within 0.003% of existing speed so not actually faster but only a tiny bit
slower. The speed up above maybe from previous version of the series
without this patch so maybe clarify that more if you include this in the
commit message.
Regards,
BALATON Zoltan
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> ---
>> include/hw/virtio/virtio-access.h | 24 ++++++++++++------------
>> hw/virtio/virtio.c | 4 ++--
>> 2 files changed, 14 insertions(+), 14 deletions(-)
>
>
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v4 3/9] hw/virtio: Use VirtIODevice::access_is_big_endian field
2026-02-03 22:38 ` BALATON Zoltan
@ 2026-02-03 22:45 ` Pierrick Bouvier
0 siblings, 0 replies; 23+ messages in thread
From: Pierrick Bouvier @ 2026-02-03 22:45 UTC (permalink / raw)
To: BALATON Zoltan, Philippe Mathieu-Daudé
Cc: qemu-devel, qemu-ppc, Stefano Garzarella, Nicholas Piggin,
Michael S. Tsirkin, Harsh Prateek Bora
On 2/3/26 2:38 PM, BALATON Zoltan wrote:
> On Tue, 3 Feb 2026, Philippe Mathieu-Daudé wrote:
>> On 3/2/26 21:56, Pierrick Bouvier wrote:
>>> From: Philippe Mathieu-Daudé <philmd@linaro.org>
>>>
>>> Endianness access is constant between device resets.
>>> Use the field instead of calling the same function.
>>
>> Maybe we should justify here, simply adding from your v3 comment:
>>
>> When doing automated benchmark with fio (see instructions
>> in [*]) this resulted in a +1.4% speedup vs existing code.
>>
>> [*] https://lore.kernel.org/qemu-devel/20260202185233.GC405548@fedora/
>
> What does existing code refer to here? According to cover letter it's
> within 0.003% of existing speed so not actually faster but only a tiny bit
> slower. The speed up above maybe from previous version of the series
> without this patch so maybe clarify that more if you include this in the
> commit message.
>
Existing is upstream/master.
+1.4% is with this patch.
End result is -0.3% with the full series applied.
> Regards,
> BALATON Zoltan
>
>>>
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>>> ---
>>> include/hw/virtio/virtio-access.h | 24 ++++++++++++------------
>>> hw/virtio/virtio.c | 4 ++--
>>> 2 files changed, 14 insertions(+), 14 deletions(-)
>>
>>
>>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v4 5/9] include/hw/virtio/virtio-access.h: remove target specifics define
2026-02-03 20:56 ` [PATCH v4 5/9] include/hw/virtio/virtio-access.h: remove target specifics define Pierrick Bouvier
@ 2026-02-04 2:10 ` Richard Henderson
2026-02-04 16:37 ` Pierrick Bouvier
0 siblings, 1 reply; 23+ messages in thread
From: Richard Henderson @ 2026-02-04 2:10 UTC (permalink / raw)
To: Pierrick Bouvier, qemu-devel
Cc: Philippe Mathieu-Daudé, qemu-ppc, Stefano Garzarella,
Nicholas Piggin, Michael S. Tsirkin, Harsh Prateek Bora
On 2/4/26 06:56, Pierrick Bouvier wrote:
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
> include/hw/virtio/virtio-access.h | 26 +++++++++++++-------------
> 1 file changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-access.h
> index f3b4d0075b5..1bea3445979 100644
> --- a/include/hw/virtio/virtio-access.h
> +++ b/include/hw/virtio/virtio-access.h
> @@ -17,27 +17,27 @@
> #define QEMU_VIRTIO_ACCESS_H
>
> #include "exec/hwaddr.h"
> +#include "qemu/target-info.h"
> #include "system/memory_cached.h"
> #include "hw/virtio/virtio.h"
> #include "hw/virtio/virtio-bus.h"
>
> -#if defined(TARGET_PPC64) || defined(TARGET_ARM)
> -#define LEGACY_VIRTIO_IS_BIENDIAN 1
> -#endif
> -
> static inline bool virtio_access_is_big_endian(VirtIODevice *vdev)
> {
> -#if defined(LEGACY_VIRTIO_IS_BIENDIAN)
> - return virtio_is_big_endian(vdev);
> -#elif TARGET_BIG_ENDIAN
> - if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
> - /* Devices conforming to VIRTIO 1.0 or later are always LE. */
> - return false;
> + if (target_ppc64() || target_base_arm()) {
> + return virtio_is_big_endian(vdev);
Why use two predicates like this, effectively calling target_arch() twice?
Surely it's better to do
switch (target_arch()) {
case SYS_EMU_TARGET_ARM:
case SYS_EMU_TARGET_AARCH64:
case SYS_EMU_TARGET_PPC64:
return virtio_is_big_endian(vdev);
default:
break;
}
Definitely with a comment saying this is about legacy behaviour.
And does VIRTIO_F_VERSION_1 really not take priority?
r~
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v4 5/9] include/hw/virtio/virtio-access.h: remove target specifics define
2026-02-04 2:10 ` Richard Henderson
@ 2026-02-04 16:37 ` Pierrick Bouvier
2026-02-05 18:54 ` Pierrick Bouvier
0 siblings, 1 reply; 23+ messages in thread
From: Pierrick Bouvier @ 2026-02-04 16:37 UTC (permalink / raw)
To: Richard Henderson, qemu-devel
Cc: Philippe Mathieu-Daudé, qemu-ppc, Stefano Garzarella,
Nicholas Piggin, Michael S. Tsirkin, Harsh Prateek Bora
On 2/3/26 6:10 PM, Richard Henderson wrote:
> On 2/4/26 06:56, Pierrick Bouvier wrote:
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> ---
>> include/hw/virtio/virtio-access.h | 26 +++++++++++++-------------
>> 1 file changed, 13 insertions(+), 13 deletions(-)
>>
>> diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-access.h
>> index f3b4d0075b5..1bea3445979 100644
>> --- a/include/hw/virtio/virtio-access.h
>> +++ b/include/hw/virtio/virtio-access.h
>> @@ -17,27 +17,27 @@
>> #define QEMU_VIRTIO_ACCESS_H
>>
>> #include "exec/hwaddr.h"
>> +#include "qemu/target-info.h"
>> #include "system/memory_cached.h"
>> #include "hw/virtio/virtio.h"
>> #include "hw/virtio/virtio-bus.h"
>>
>> -#if defined(TARGET_PPC64) || defined(TARGET_ARM)
>> -#define LEGACY_VIRTIO_IS_BIENDIAN 1
>> -#endif
>> -
>> static inline bool virtio_access_is_big_endian(VirtIODevice *vdev)
>> {
>> -#if defined(LEGACY_VIRTIO_IS_BIENDIAN)
>> - return virtio_is_big_endian(vdev);
>> -#elif TARGET_BIG_ENDIAN
>> - if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
>> - /* Devices conforming to VIRTIO 1.0 or later are always LE. */
>> - return false;
>> + if (target_ppc64() || target_base_arm()) {
>> + return virtio_is_big_endian(vdev);
>
> Why use two predicates like this, effectively calling target_arch() twice?
> Surely it's better to do
>
Yes it can, I simply wrote the simplest change possible. Since this
function is called only once now at reset time, it definitely looks like
premature optimization IMHO.
> switch (target_arch()) {
> case SYS_EMU_TARGET_ARM:
> case SYS_EMU_TARGET_AARCH64:
> case SYS_EMU_TARGET_PPC64:
> return virtio_is_big_endian(vdev);
> default:
> break;
> }
>
> Definitely with a comment saying this is about legacy behaviour.
> And does VIRTIO_F_VERSION_1 really not take priority?
>
Not sure about this one, but current implementation has same behaviour
than previous ifdef based one.
In case that's wrong, I would be happy to change it.
>
> r~
Regards,
Pierrick
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v4 0/9] single-binary: hw/virtio
2026-02-03 20:56 [PATCH v4 0/9] single-binary: hw/virtio Pierrick Bouvier
` (8 preceding siblings ...)
2026-02-03 20:56 ` [PATCH v4 9/9] hw/virtio/: make all compilation units common Pierrick Bouvier
@ 2026-02-05 5:27 ` Pierrick Bouvier
2026-02-05 6:43 ` Michael S. Tsirkin
2026-02-06 22:21 ` Pierrick Bouvier
10 siblings, 1 reply; 23+ messages in thread
From: Pierrick Bouvier @ 2026-02-05 5:27 UTC (permalink / raw)
To: qemu-devel, Michael S. Tsirkin
Cc: Philippe Mathieu-Daudé, qemu-ppc, Stefano Garzarella,
Nicholas Piggin, Michael S. Tsirkin, Harsh Prateek Bora
On 2/3/26 12:56 PM, Pierrick Bouvier wrote:
> This series eliminates target specifics in hw/virtio and replace them with
> runtime functions where needed.
>
> Performance has been measured with this automated fio benchmark, with
> original instructions from Stefan [1].
>
> $ git clone https://github.com/pbo-linaro/qemu-linux-stack -b x86_64_io_benchmark
> $ cd qemu-linux-stack
> $ ./build.sh
> $ ./run.sh /path/to/qemu-system-x86_64
>
> [1] https://lore.kernel.org/qemu-devel/20260202185233.GC405548@fedora/
>
> Results are on 20 runs and expressed in kIOPS:
> reference: mean=239.2 std_dev=3.48
> with_series: mean=238.5 std_dev=3.46
>
> Performance is on par, and within standard deviation.
>
Does it look better to you Michael?
Regards,
Pierrick
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v4 0/9] single-binary: hw/virtio
2026-02-05 5:27 ` [PATCH v4 0/9] single-binary: hw/virtio Pierrick Bouvier
@ 2026-02-05 6:43 ` Michael S. Tsirkin
2026-02-05 17:17 ` Pierrick Bouvier
0 siblings, 1 reply; 23+ messages in thread
From: Michael S. Tsirkin @ 2026-02-05 6:43 UTC (permalink / raw)
To: Pierrick Bouvier
Cc: qemu-devel, Philippe Mathieu-Daudé, qemu-ppc,
Stefano Garzarella, Nicholas Piggin, Harsh Prateek Bora
On Wed, Feb 04, 2026 at 09:27:10PM -0800, Pierrick Bouvier wrote:
> On 2/3/26 12:56 PM, Pierrick Bouvier wrote:
> > This series eliminates target specifics in hw/virtio and replace them with
> > runtime functions where needed.
> >
> > Performance has been measured with this automated fio benchmark, with
> > original instructions from Stefan [1].
> >
> > $ git clone https://github.com/pbo-linaro/qemu-linux-stack -b x86_64_io_benchmark
> > $ cd qemu-linux-stack
> > $ ./build.sh
> > $ ./run.sh /path/to/qemu-system-x86_64
> >
> > [1] https://lore.kernel.org/qemu-devel/20260202185233.GC405548@fedora/
> >
> > Results are on 20 runs and expressed in kIOPS:
> > reference: mean=239.2 std_dev=3.48
> > with_series: mean=238.5 std_dev=3.46
> >
> > Performance is on par, and within standard deviation.
> >
>
> Does it look better to you Michael?
>
> Regards,
> Pierrick
better for sure. is there a reason you dropped stefanha
from CC? he suggested these tests...
--
MST
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v4 0/9] single-binary: hw/virtio
2026-02-05 6:43 ` Michael S. Tsirkin
@ 2026-02-05 17:17 ` Pierrick Bouvier
2026-02-05 18:38 ` Stefan Hajnoczi
0 siblings, 1 reply; 23+ messages in thread
From: Pierrick Bouvier @ 2026-02-05 17:17 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: qemu-devel, Philippe Mathieu-Daudé, qemu-ppc,
Stefano Garzarella, Nicholas Piggin, Harsh Prateek Bora,
Stefan Hajnoczi
On 2/4/26 10:43 PM, Michael S. Tsirkin wrote:
> On Wed, Feb 04, 2026 at 09:27:10PM -0800, Pierrick Bouvier wrote:
>> On 2/3/26 12:56 PM, Pierrick Bouvier wrote:
>>> This series eliminates target specifics in hw/virtio and replace them with
>>> runtime functions where needed.
>>>
>>> Performance has been measured with this automated fio benchmark, with
>>> original instructions from Stefan [1].
>>>
>>> $ git clone https://github.com/pbo-linaro/qemu-linux-stack -b x86_64_io_benchmark
>>> $ cd qemu-linux-stack
>>> $ ./build.sh
>>> $ ./run.sh /path/to/qemu-system-x86_64
>>>
>>> [1] https://lore.kernel.org/qemu-devel/20260202185233.GC405548@fedora/
>>>
>>> Results are on 20 runs and expressed in kIOPS:
>>> reference: mean=239.2 std_dev=3.48
>>> with_series: mean=238.5 std_dev=3.46
>>>
>>> Performance is on par, and within standard deviation.
>>>
>>
>> Does it look better to you Michael?
>>
>> Regards,
>> Pierrick
>
>
> better for sure. is there a reason you dropped stefanha
> from CC? he suggested these tests...
>
I didn't to that intentionally, it seems like he was not added by
default from the file set when I posted v4.
Stefan, please see cover letter above and let us know if that sounds
acceptable to you.
Regards,
Pierrick
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v4 0/9] single-binary: hw/virtio
2026-02-05 17:17 ` Pierrick Bouvier
@ 2026-02-05 18:38 ` Stefan Hajnoczi
2026-02-06 4:38 ` Pierrick Bouvier
0 siblings, 1 reply; 23+ messages in thread
From: Stefan Hajnoczi @ 2026-02-05 18:38 UTC (permalink / raw)
To: Pierrick Bouvier
Cc: Michael S. Tsirkin, qemu-devel, Philippe Mathieu-Daudé,
qemu-ppc, Stefano Garzarella, Nicholas Piggin, Harsh Prateek Bora
[-- Attachment #1: Type: text/plain, Size: 1521 bytes --]
On Thu, Feb 05, 2026 at 09:17:03AM -0800, Pierrick Bouvier wrote:
> On 2/4/26 10:43 PM, Michael S. Tsirkin wrote:
> > On Wed, Feb 04, 2026 at 09:27:10PM -0800, Pierrick Bouvier wrote:
> > > On 2/3/26 12:56 PM, Pierrick Bouvier wrote:
> > > > This series eliminates target specifics in hw/virtio and replace them with
> > > > runtime functions where needed.
> > > >
> > > > Performance has been measured with this automated fio benchmark, with
> > > > original instructions from Stefan [1].
> > > >
> > > > $ git clone https://github.com/pbo-linaro/qemu-linux-stack -b x86_64_io_benchmark
> > > > $ cd qemu-linux-stack
> > > > $ ./build.sh
> > > > $ ./run.sh /path/to/qemu-system-x86_64
> > > >
> > > > [1] https://lore.kernel.org/qemu-devel/20260202185233.GC405548@fedora/
> > > >
> > > > Results are on 20 runs and expressed in kIOPS:
> > > > reference: mean=239.2 std_dev=3.48
> > > > with_series: mean=238.5 std_dev=3.46
> > > >
> > > > Performance is on par, and within standard deviation.
> > > >
> > >
> > > Does it look better to you Michael?
> > >
> > > Regards,
> > > Pierrick
> >
> >
> > better for sure. is there a reason you dropped stefanha
> > from CC? he suggested these tests...
> >
>
> I didn't to that intentionally, it seems like he was not added by default
> from the file set when I posted v4.
>
> Stefan, please see cover letter above and let us know if that sounds
> acceptable to you.
Yes, the results you posted look fine. Thanks!
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v4 5/9] include/hw/virtio/virtio-access.h: remove target specifics define
2026-02-04 16:37 ` Pierrick Bouvier
@ 2026-02-05 18:54 ` Pierrick Bouvier
0 siblings, 0 replies; 23+ messages in thread
From: Pierrick Bouvier @ 2026-02-05 18:54 UTC (permalink / raw)
To: Richard Henderson, qemu-devel
Cc: Philippe Mathieu-Daudé, qemu-ppc, Stefano Garzarella,
Nicholas Piggin, Michael S. Tsirkin, Harsh Prateek Bora
On 2/4/26 8:37 AM, Pierrick Bouvier wrote:
> On 2/3/26 6:10 PM, Richard Henderson wrote:
>> On 2/4/26 06:56, Pierrick Bouvier wrote:
>>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>>> ---
>>> include/hw/virtio/virtio-access.h | 26 +++++++++++++-------------
>>> 1 file changed, 13 insertions(+), 13 deletions(-)
>>>
>>> diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-access.h
>>> index f3b4d0075b5..1bea3445979 100644
>>> --- a/include/hw/virtio/virtio-access.h
>>> +++ b/include/hw/virtio/virtio-access.h
>>> @@ -17,27 +17,27 @@
>>> #define QEMU_VIRTIO_ACCESS_H
>>>
>>> #include "exec/hwaddr.h"
>>> +#include "qemu/target-info.h"
>>> #include "system/memory_cached.h"
>>> #include "hw/virtio/virtio.h"
>>> #include "hw/virtio/virtio-bus.h"
>>>
>>> -#if defined(TARGET_PPC64) || defined(TARGET_ARM)
>>> -#define LEGACY_VIRTIO_IS_BIENDIAN 1
>>> -#endif
>>> -
>>> static inline bool virtio_access_is_big_endian(VirtIODevice *vdev)
>>> {
>>> -#if defined(LEGACY_VIRTIO_IS_BIENDIAN)
>>> - return virtio_is_big_endian(vdev);
>>> -#elif TARGET_BIG_ENDIAN
>>> - if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
>>> - /* Devices conforming to VIRTIO 1.0 or later are always LE. */
>>> - return false;
>>> + if (target_ppc64() || target_base_arm()) {
>>> + return virtio_is_big_endian(vdev);
>>
>> Why use two predicates like this, effectively calling target_arch() twice?
>> Surely it's better to do
>>
>
> Yes it can, I simply wrote the simplest change possible. Since this
> function is called only once now at reset time, it definitely looks like
> premature optimization IMHO.
>
>> switch (target_arch()) {
>> case SYS_EMU_TARGET_ARM:
>> case SYS_EMU_TARGET_AARCH64:
>> case SYS_EMU_TARGET_PPC64:
>> return virtio_is_big_endian(vdev);
>> default:
>> break;
>> }
>>
>> Definitely with a comment saying this is about legacy behaviour.
>> And does VIRTIO_F_VERSION_1 really not take priority?
>>
>
> Not sure about this one, but current implementation has same behaviour
> than previous ifdef based one.
> In case that's wrong, I would be happy to change it.
>
>>
>> r~
>
> Regards,
> Pierrick
For what it's worth, that's the patch I wrote when I was optimizing this
function and found -1.7% for performance:
commit d497f71b5b1bcc46de97436e1ce31641ff792eb9
Author: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Date: Mon Feb 2 13:53:06 2026 -0800
include/hw/virtio/virtio-access.h: optimize virtio_access_is_big_endian
By following benchmark recommended by Stefan [1], it was found that
previous commit introduced an overhead of 3% for this scenario.
By reading TargetInfo only once and using a jump table, we get to 1.7%.
[1] https://lore.kernel.org/qemu-devel/20260202185233.GC405548@fedora/
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
diff --git a/include/hw/virtio/virtio-access.h
b/include/hw/virtio/virtio-access.h
index 1bea3445979..b7695f56fed 100644
--- a/include/hw/virtio/virtio-access.h
+++ b/include/hw/virtio/virtio-access.h
@@ -24,11 +24,17 @@
static inline bool virtio_access_is_big_endian(VirtIODevice *vdev)
{
- if (target_ppc64() || target_base_arm()) {
+ const TargetInfo *info = target_info();
+ static const int may_be_big_endian[SYS_EMU_TARGET__MAX] = {
+ [SYS_EMU_TARGET_ARM] = 1,
+ [SYS_EMU_TARGET_AARCH64] = 1,
+ [SYS_EMU_TARGET_PPC64] = 1,
+ };
+ if (may_be_big_endian[info->target_arch]) {
return virtio_is_big_endian(vdev);
}
- if (target_big_endian()) {
+ if (info->endianness == ENDIAN_MODE_BIG) {
if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
/* Devices conforming to VIRTIO 1.0 or later are always LE. */
return false;
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v4 3/9] hw/virtio: Use VirtIODevice::access_is_big_endian field
2026-02-03 20:56 ` [PATCH v4 3/9] hw/virtio: Use VirtIODevice::access_is_big_endian field Pierrick Bouvier
2026-02-03 22:11 ` Philippe Mathieu-Daudé
@ 2026-02-06 4:37 ` Pierrick Bouvier
1 sibling, 0 replies; 23+ messages in thread
From: Pierrick Bouvier @ 2026-02-06 4:37 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, qemu-ppc, Stefano Garzarella,
Nicholas Piggin, Michael S. Tsirkin, Harsh Prateek Bora
On 2/3/26 12:56 PM, Pierrick Bouvier wrote:
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
>
> Endianness access is constant between device resets.
> Use the field instead of calling the same function.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
> include/hw/virtio/virtio-access.h | 24 ++++++++++++------------
> hw/virtio/virtio.c | 4 ++--
> 2 files changed, 14 insertions(+), 14 deletions(-)
>
Oops, seems like it's not correct, I found some failing tests bisecting
to this patch. I'll dig into it to see what is happening.
Regards,
Pierrick
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v4 0/9] single-binary: hw/virtio
2026-02-05 18:38 ` Stefan Hajnoczi
@ 2026-02-06 4:38 ` Pierrick Bouvier
0 siblings, 0 replies; 23+ messages in thread
From: Pierrick Bouvier @ 2026-02-06 4:38 UTC (permalink / raw)
To: Stefan Hajnoczi
Cc: Michael S. Tsirkin, qemu-devel, Philippe Mathieu-Daudé,
qemu-ppc, Stefano Garzarella, Nicholas Piggin, Harsh Prateek Bora
On 2/5/26 10:38 AM, Stefan Hajnoczi wrote:
> On Thu, Feb 05, 2026 at 09:17:03AM -0800, Pierrick Bouvier wrote:
>> On 2/4/26 10:43 PM, Michael S. Tsirkin wrote:
>>> On Wed, Feb 04, 2026 at 09:27:10PM -0800, Pierrick Bouvier wrote:
>>>> On 2/3/26 12:56 PM, Pierrick Bouvier wrote:
>>>>> This series eliminates target specifics in hw/virtio and replace them with
>>>>> runtime functions where needed.
>>>>>
>>>>> Performance has been measured with this automated fio benchmark, with
>>>>> original instructions from Stefan [1].
>>>>>
>>>>> $ git clone https://github.com/pbo-linaro/qemu-linux-stack -b x86_64_io_benchmark
>>>>> $ cd qemu-linux-stack
>>>>> $ ./build.sh
>>>>> $ ./run.sh /path/to/qemu-system-x86_64
>>>>>
>>>>> [1] https://lore.kernel.org/qemu-devel/20260202185233.GC405548@fedora/
>>>>>
>>>>> Results are on 20 runs and expressed in kIOPS:
>>>>> reference: mean=239.2 std_dev=3.48
>>>>> with_series: mean=238.5 std_dev=3.46
>>>>>
>>>>> Performance is on par, and within standard deviation.
>>>>>
>>>>
>>>> Does it look better to you Michael?
>>>>
>>>> Regards,
>>>> Pierrick
>>>
>>>
>>> better for sure. is there a reason you dropped stefanha
>>> from CC? he suggested these tests...
>>>
>>
>> I didn't to that intentionally, it seems like he was not added by default
>> from the file set when I posted v4.
>>
>> Stefan, please see cover letter above and let us know if that sounds
>> acceptable to you.
>
> Yes, the results you posted look fine. Thanks!
>
> Stefan
Thanks for your answer.
Please don't pull this for now, I found issues with patch 3, which I
didn't double check before including it in v4, sorry.
I'll find issue and post a v5.
Regards,
Pierrick
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v4 0/9] single-binary: hw/virtio
2026-02-03 20:56 [PATCH v4 0/9] single-binary: hw/virtio Pierrick Bouvier
` (9 preceding siblings ...)
2026-02-05 5:27 ` [PATCH v4 0/9] single-binary: hw/virtio Pierrick Bouvier
@ 2026-02-06 22:21 ` Pierrick Bouvier
10 siblings, 0 replies; 23+ messages in thread
From: Pierrick Bouvier @ 2026-02-06 22:21 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, qemu-ppc, Stefano Garzarella,
Nicholas Piggin, Michael S. Tsirkin, Harsh Prateek Bora
On 2/3/26 12:56 PM, Pierrick Bouvier wrote:
> This series eliminates target specifics in hw/virtio and replace them with
> runtime functions where needed.
>
> Performance has been measured with this automated fio benchmark, with
> original instructions from Stefan [1].
>
> $ git clone https://github.com/pbo-linaro/qemu-linux-stack -b x86_64_io_benchmark
> $ cd qemu-linux-stack
> $ ./build.sh
> $ ./run.sh /path/to/qemu-system-x86_64
>
> [1] https://lore.kernel.org/qemu-devel/20260202185233.GC405548@fedora/
>
> Results are on 20 runs and expressed in kIOPS:
> reference: mean=239.2 std_dev=3.48
> with_series: mean=238.5 std_dev=3.46
>
> Performance is on par, and within standard deviation.
>
> v4
> --
>
> - Include Philippe patches computing once device endianness to skip runtime
> checks on every access.
>
> Philippe Mathieu-Daudé (3):
> hw/virtio: Constify virtio_is_big_endian() argument
> hw/virtio: Introduce VirtIODevice::access_is_big_endian boolean field
> hw/virtio: Use VirtIODevice::access_is_big_endian field
>
> Pierrick Bouvier (6):
> target-info: add target_base_ppc, target_ppc and target_ppc64
> include/hw/virtio/virtio-access.h: remove target specifics define
> include/hw/ppc/spapr: extract SPAPR_MAX_RAM_SLOTS in a new header
> hw/virtio/vhost-user: make compilation unit common
> hw/virtio/virtio-qmp: make compilation unit common
> hw/virtio/: make all compilation units common
>
> include/hw/ppc/spapr.h | 8 +---
> include/hw/ppc/spapr_common.h | 16 +++++++
> include/hw/virtio/virtio-access.h | 50 +++++++++++-----------
> include/hw/virtio/virtio.h | 7 +++-
> include/qemu/target-info.h | 21 ++++++++++
> hw/virtio/vhost-user.c | 11 ++---
> hw/virtio/virtio-qmp.c | 70 -------------------------------
> hw/virtio/virtio.c | 5 ++-
> target-info.c | 21 ++++++++++
> hw/virtio/meson.build | 17 ++++----
> 10 files changed, 104 insertions(+), 122 deletions(-)
> create mode 100644 include/hw/ppc/spapr_common.h
>
Sent v5 fixing the issue found:
https://lore.kernel.org/qemu-devel/20260206221908.1451528-1-pierrick.bouvier@linaro.org/T/#t
Regards,
Pierrick
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2026-02-06 22:22 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-03 20:56 [PATCH v4 0/9] single-binary: hw/virtio Pierrick Bouvier
2026-02-03 20:56 ` [PATCH v4 1/9] hw/virtio: Constify virtio_is_big_endian() argument Pierrick Bouvier
2026-02-03 20:56 ` [PATCH v4 2/9] hw/virtio: Introduce VirtIODevice::access_is_big_endian boolean field Pierrick Bouvier
2026-02-03 20:56 ` [PATCH v4 3/9] hw/virtio: Use VirtIODevice::access_is_big_endian field Pierrick Bouvier
2026-02-03 22:11 ` Philippe Mathieu-Daudé
2026-02-03 22:38 ` BALATON Zoltan
2026-02-03 22:45 ` Pierrick Bouvier
2026-02-06 4:37 ` Pierrick Bouvier
2026-02-03 20:56 ` [PATCH v4 4/9] target-info: add target_base_ppc, target_ppc and target_ppc64 Pierrick Bouvier
2026-02-03 20:56 ` [PATCH v4 5/9] include/hw/virtio/virtio-access.h: remove target specifics define Pierrick Bouvier
2026-02-04 2:10 ` Richard Henderson
2026-02-04 16:37 ` Pierrick Bouvier
2026-02-05 18:54 ` Pierrick Bouvier
2026-02-03 20:56 ` [PATCH v4 6/9] include/hw/ppc/spapr: extract SPAPR_MAX_RAM_SLOTS in a new header Pierrick Bouvier
2026-02-03 20:56 ` [PATCH v4 7/9] hw/virtio/vhost-user: make compilation unit common Pierrick Bouvier
2026-02-03 20:56 ` [PATCH v4 8/9] hw/virtio/virtio-qmp: " Pierrick Bouvier
2026-02-03 20:56 ` [PATCH v4 9/9] hw/virtio/: make all compilation units common Pierrick Bouvier
2026-02-05 5:27 ` [PATCH v4 0/9] single-binary: hw/virtio Pierrick Bouvier
2026-02-05 6:43 ` Michael S. Tsirkin
2026-02-05 17:17 ` Pierrick Bouvier
2026-02-05 18:38 ` Stefan Hajnoczi
2026-02-06 4:38 ` Pierrick Bouvier
2026-02-06 22:21 ` Pierrick Bouvier
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.