target-info: Add more API for VirtIO cleanups & introduce ARM macros
v6 cover target-info: Add more API for VirtIO cleanups & introduce ARM macros
Rather than re-spinning the whole "single-binary: Make hw/arm/ common" series, restrict to the API additions, but include examples of their usefulness (hundreds of virtio objects removed from default Linux build).
Time passed since I context-switched out of this work so I'm not sure the DEFINE_MACHINE_WITH_INTERFACES() implementation is in the form Zoltan asked.
Philippe Mathieu-Daudé (14):
target/qmp: Use target_cpu_type()
qemu/target-info: Factor target_arch() out qemu/target-info: Add %target_arch field to TargetInfo qemu/target-info: Introduce target_base_arch() qemu/target-info: Add target_endian_mode()
qemu: Convert target_words_bigendian() to TargetInfo API gdbstub/helpers: Replace TARGET_BIG_ENDIAN -> target_big_endian()
qemu: Declare all load/store helpert in 'qemu/bswap.h' hw/virtio: Build various files once hw/core/null-machine: Define machine as generic QOM type hw/arm: Register TYPE_TARGET_ARM/AARCH64_MACHINE QOM interfaces hw/core: Allow ARM/Aarch64 binaries to use the 'none' machine hw/boards: Introduce DEFINE_MACHINE_WITH_INTERFACES() macro hw/arm: Add DEFINE_MACHINE_[ARM_]AARCH64() macros
meson.build | 1 + include/exec/tswap.h | 83 +-------------------------- include/gdbstub/helpers.h | 15 ++--- include/hw/arm/machines-qom.h | 31 ++++++++++ include/hw/boards.h | 6 +- include/qemu/bswap.h | 73 +++++++++++++++++++++++ include/qemu/target-info-impl.h | 8 ++- include/qemu/target-info-qapi.h | 36 ++++++++++++ include/qemu/target-info.h | 10 +++- include/system/memory.h | 1 - include/user/abitypes.h | 1 - target/ppc/mmu-hash64.h | 2 - cpu-target.c | 7 --- hw/acpi/bios-linker-loader.c | 2 - hw/arm/allwinner-r40.c | 1 - hw/arm/boot.c | 2 + hw/arm/npcm7xx.c | 2 +- hw/block/hd-geometry.c | 1 - hw/char/riscv_htif.c | 1 - hw/core/cpu-system.c | 2 +- hw/core/machine-qmp-cmds.c | 8 +-- hw/core/null-machine.c | 20 ++++++- hw/cxl/cxl-events.c | 2 - hw/display/artist.c | 1 + hw/display/ati.c | 1 + hw/display/vga.c | 2 +- hw/net/can/ctucan_core.c | 1 - hw/net/lan9118.c | 1 + hw/net/rtl8139.c | 1 + hw/net/vmxnet3.c | 1 - hw/pci-host/gt64120.c | 1 + hw/pci-host/pnv_phb3.c | 1 + hw/pci-host/pnv_phb4.c | 1 + hw/pci-host/ppce500.c | 1 - hw/pci-host/sh_pci.c | 1 - hw/s390x/s390-pci-inst.c | 1 + hw/sensor/lsm303dlhc_mag.c | 1 - hw/smbios/smbios.c | 1 + hw/vfio/migration-multifd.c | 1 - hw/virtio/virtio-config-io.c | 1 - hw/virtio/virtio-pci.c | 1 + hw/virtio/virtio.c | 2 +- hw/vmapple/virtio-blk.c | 1 - system/memory.c | 1 + system/qtest.c | 1 + target-info-qom.c | 24 ++++++++ target-info-stub.c | 3 + target-info.c | 33 +++++++++++ target/arm/arm-qmp-cmds.c | 3 +- target/arm/cpu.c | 1 - target/arm/machine.c | 12 ++++ target/i386/tcg/system/excp_helper.c | 1 - target/i386/xsave_helper.c | 1 - target/loongarch/loongarch-qmp-cmds.c | 3 +- target/mips/system/mips-qmp-cmds.c | 3 +- target/riscv/vector_helper.c | 1 - tests/tcg/plugins/mem.c | 1 + hw/block/meson.build | 6 +- hw/virtio/meson.build | 20 ++++--- 59 files changed, 302 insertions(+), 149 deletions(-) create mode 100644 include/hw/arm/machines-qom.h create mode 100644 include/qemu/target-info-qapi.h create mode 100644 target-info-qom.c
Signature · 1 line
2.49.0
PATCH v6 1/14 target/qmp: Use target_cpu_type()
--- target/arm/arm-qmp-cmds.c | 3 ++- target/loongarch/loongarch-qmp-cmds.c | 3 ++- target/mips/system/mips-qmp-cmds.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-)
target/arm/arm-qmp-cmds.c +2 -1
@@ -21,6 +21,7 @@*/ #include "qemu/osdep.h" +#include "qemu/target-info.h" #include "hw/boards.h" #include "kvm_arm.h" #include "qapi/error.h"
@@ -241,7 +242,7 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)CpuDefinitionInfoList *cpu_list =NULL ;GSList *list; - list =object_class_get_list (TYPE_ARM_CPU , false); + list =object_class_get_list (target_cpu_type (), false);g_slist_foreach (list, arm_cpu_add_definition, &cpu_list);g_slist_free (list);
target/loongarch/loongarch-qmp-cmds.c +2 -1
@@ -7,6 +7,7 @@*/ #include "qemu/osdep.h" +#include "qemu/target-info.h" #include "qapi/error.h" #include "qapi/qapi-commands-machine.h" #include "cpu.h"
@@ -32,7 +33,7 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)CpuDefinitionInfoList *cpu_list =NULL ;GSList *list; - list =object_class_get_list (TYPE_LOONGARCH_CPU , false); + list =object_class_get_list (target_cpu_type (), false);g_slist_foreach (list, loongarch_cpu_add_definition, &cpu_list);g_slist_free (list);
target/mips/system/mips-qmp-cmds.c +2 -1
@@ -7,6 +7,7 @@*/ #include "qemu/osdep.h" +#include "qemu/target-info.h" #include "qapi/error.h" #include "qapi/qapi-commands-machine.h" #include "cpu.h"
@@ -40,7 +41,7 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)CpuDefinitionInfoList *cpu_list =NULL ;GSList *list; - list =object_class_get_list (TYPE_MIPS_CPU , false); + list =object_class_get_list (target_cpu_type (), false);g_slist_foreach (list, mips_cpu_add_definition, &cpu_list);g_slist_free (list);
Signature · 1 line
2.49.0
Re: [PATCH-for-10.1 v6 01/14] target/qmp: Use target_cpu_type()
Quoted 6 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/arm/arm-qmp-cmds.c | 3 ++- target/loongarch/loongarch-qmp-cmds.c | 3 ++- target/mips/system/mips-qmp-cmds.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-)
r~
PATCH v6 2/14 qemu/target-info: Factor target_arch() out
In reply to Philippe Mathieu-DaudéTo keep "qemu/target-info.h" self-contained to native types, declare target_arch() -- which returns a QAPI type -- in "qemu/target-info-qapi.h".
No logical change.
Keeping native types in "qemu/target-info.h" is necessary to keep building tests such tests/tcg/plugins/mem.c, as per the comment added in commit ecbcc9ead2f ("tests/tcg:
add a system test to check memory instrumentation"):
/*
* plugins should not include anything from QEMU aside from the
* API header. However as this is a test plugin to exercise the
* internals of QEMU and we want to avoid needless code duplication we
* do so here. bswap.h is pretty self-contained although it needs a
* few things provided by compiler.h.
*/
--- include/qemu/target-info-qapi.h | 21 +++++++++++++++++++++ include/qemu/target-info.h | 2 +- hw/core/machine-qmp-cmds.c | 8 +++----- target-info.c | 8 ++++++++ 4 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 include/qemu/target-info-qapi.h
include/qemu/target-info-qapi.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* QEMU target info API (returning QAPI types) +* +* Copyright (c) Linaro +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef QEMU_TARGET_INFO_EXTRA_H +#define QEMU_TARGET_INFO_EXTRA_H + +#include "qapi/qapi-types-machine.h" + +/** +* target_arch: +* +* Returns: QAPI SysEmuTarget enum (i.e. SYS_EMU_TARGET_X86_64). +*/ +SysEmuTarget target_arch (void ); + +#endif
include/qemu/target-info.h +1 -1
@@ -1,5 +1,5 @@/* -* QEMU target info API +* QEMU target info API (returning native types) * * Copyright (c) Linaro *
hw/core/machine-qmp-cmds.c +3 -5
@@ -19,7 +19,7 @@#include "qapi/qobject-input-visitor.h" #include "qapi/type-helpers.h" #include "qemu/uuid.h" -#include "qemu/target-info.h" +#include "qemu/target-info-qapi.h" #include "qom/qom-qobject.h" #include "system/hostmem.h" #include "system/hw_accel.h"
@@ -37,8 +37,7 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp)MachineState *ms =MACHINE (qdev_get_machine ());MachineClass *mc =MACHINE_GET_CLASS (ms);CpuInfoFastList *head =NULL , **tail = &head; -SysEmuTarget target =qapi_enum_parse (&SysEmuTarget_lookup,target_name (), --1 , &error_abort); +SysEmuTarget target =target_arch ();CPUState *cpu;CPU_FOREACH (cpu) {
@@ -139,8 +138,7 @@ QemuTargetInfo *qmp_query_target(Error **errp) {QemuTargetInfo *info =g_malloc0 (sizeof (*info)); - info->arch =qapi_enum_parse (&SysEmuTarget_lookup,target_name (),-1 , - &error_abort); + info->arch =target_arch ();return info; }
target-info.c +8 -0
@@ -8,7 +8,9 @@#include "qemu/osdep.h" #include "qemu/target-info.h" +#include "qemu/target-info-qapi.h" #include "qemu/target-info-impl.h" +#include "qapi/error.h" const char *target_name (void ) {
@@ -20,6 +22,12 @@ unsigned target_long_bits(void)return target_info ()->long_bits; } +SysEmuTarget target_arch (void ) +{ +return qapi_enum_parse (&SysEmuTarget_lookup,target_name (),-1 , + &error_abort); +} +const char *target_cpu_type (void ) {return target_info ()->cpu_type;
Signature · 1 line
2.49.0
Re: [PATCH-for-10.1 v6 02/14] qemu/target-info: Factor target_arch() out
Quoted 19 lines · Philippe Mathieu-Daudé
To keep "
qemu/target-info.h" self-contained to native types, declaretarget_arch()-- which returns a QAPI type -- in "qemu/target-info-qapi.h".No logical change.
Keeping native types in "
qemu/target-info.h" is necessary to keep building tests suchtests/tcg/plugins/mem.c, as per the comment added in commitecbcc9ead2f("tests/tcg:
add a system test to check memory instrumentation"):/*
* plugins should not include anything from QEMU aside from the
* API header. However as this is a test plugin to exercise the
* internals of QEMU and we want to avoid needless code duplication we
* do so here.bswap.his pretty self-contained although it needs a
* few things provided bycompiler.h.
*/
Quoted 8 lines
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- include/qemu/target-info-qapi.h | 21 +++++++++++++++++++++ include/qemu/target-info.h | 2 +- hw/core/machine-qmp-cmds.c | 8 +++----- target-info.c | 8 ++++++++ 4 files changed, 33 insertions(+), 6 deletions(-)create mode 100644
include/qemu/target-info-qapi.h
r~
Re: [PATCH-for-10.1 v6 02/14] qemu/target-info: Factor target_arch() out
In reply to Philippe Mathieu-DaudéQuoted 25 lines · Philippe Mathieu-Daudé
Date: Mon, 7 Jul 2025 19:19:56 +0200
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH-for-10.1 v6 02/14] qemu/target-info: Factortarget_arch()
out
X-Mailer: git-send-email 2.49.0To keep "
qemu/target-info.h" self-contained to native types, declaretarget_arch()-- which returns a QAPI type -- in "qemu/target-info-qapi.h".No logical change.
Keeping native types in "
qemu/target-info.h" is necessary to keep building tests suchtests/tcg/plugins/mem.c, as per the comment added in commitecbcc9ead2f("tests/tcg:
add a system test to check memory instrumentation"):/*
* plugins should not include anything from QEMU aside from the
* API header. However as this is a test plugin to exercise the
* internals of QEMU and we want to avoid needless code duplication we
* do so here.bswap.his pretty self-contained although it needs a
* few things provided bycompiler.h.
*/
Quoted 8 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/qemu/target-info-qapi.h | 21 +++++++++++++++++++++ include/qemu/target-info.h | 2 +- hw/core/machine-qmp-cmds.c | 8 +++----- target-info.c | 8 ++++++++ 4 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 include/qemu/target-info-qapi.h
PATCH v6 3/14 qemu/target-info: Add %target_arch field to TargetInfo
In reply to Philippe Mathieu-Daudé--- include/qemu/target-info-impl.h | 4 +++- target-info-stub.c | 1 + target-info.c | 9 +++++++-- 3 files changed, 11 insertions(+), 3 deletions(-)
include/qemu/target-info-impl.h +3 -1
@@ -9,11 +9,13 @@ #ifndef QEMU_TARGET_INFO_IMPL_H #define QEMU_TARGET_INFO_IMPL_H -#include "qemu/target-info.h" +#include "qapi/qapi-types-machine.h" typedef struct TargetInfo { /* runtime equivalent of TARGET_NAME definition */ const char *target_name; + /* related to TARGET_ARCH definition */ + SysEmuTarget target_arch; /* runtime equivalent of TARGET_LONG_BITS definition */ unsigned long_bits; /* runtime equivalent of CPU_RESOLVING_TYPE definition */
target-info-stub.c +1 -0
@@ -14,6 +14,7 @@static const TargetInfo target_info_stub = { .target_name =TARGET_NAME , + .target_arch =SYS_EMU_TARGET__MAX , .long_bits =TARGET_LONG_BITS , .cpu_type =CPU_RESOLVING_TYPE , .machine_typename =TYPE_MACHINE ,
target-info.c +7 -2
@@ -24,8 +24,13 @@ unsigned target_long_bits(void)SysEmuTarget target_arch (void ) { -return qapi_enum_parse (&SysEmuTarget_lookup,target_name (),-1 , - &error_abort); +SysEmuTarget arch =target_info ()->target_arch; + +if (arch ==SYS_EMU_TARGET__MAX ) { + arch =qapi_enum_parse (&SysEmuTarget_lookup,target_name (),-1 , + &error_abort); + } +return arch; }const char *target_cpu_type (void )
Signature · 1 line
2.49.0
PATCH v6 4/14 qemu/target-info: Introduce target_base_arch()
In reply to Philippe Mathieu-Daudétarget_base_arch() returns the base architecture as in QEMU target/$arch/ path. For example, X86_64 is implemented in the target/i386/ so its QEMU base arch is 'i386'.
--- include/qemu/target-info-impl.h | 2 ++ include/qemu/target-info-qapi.h | 7 +++++++ target-info-stub.c | 1 + target-info.c | 10 ++++++++++ 4 files changed, 20 insertions(+)
include/qemu/target-info-impl.h +2 -0
@@ -16,6 +16,8 @@ typedef struct TargetInfo {const char *target_name;/* related to TARGET_ARCH definition */ SysEmuTarget target_arch; +/* related to TARGET_BASE_ARCH definition (target/${base_arch}/ path) */ +SysEmuTarget target_base_arch;/* runtime equivalent of TARGET_LONG_BITS definition */ unsigned long_bits;/* runtime equivalent of CPU_RESOLVING_TYPE definition */
include/qemu/target-info-qapi.h +7 -0
@@ -18,4 +18,11 @@*/ SysEmuTarget target_arch (void ); +/** +* target_base_arch: +* +* Returns: QAPI SysEmuTarget enum (i.e. SYS_EMU_TARGET_I386). +*/ +SysEmuTarget target_base_arch (void ); +#endif
target-info-stub.c +1 -0
@@ -15,6 +15,7 @@static const TargetInfo target_info_stub = { .target_name =TARGET_NAME , .target_arch =SYS_EMU_TARGET__MAX , + .target_base_arch =SYS_EMU_TARGET__MAX , .long_bits =TARGET_LONG_BITS , .cpu_type =CPU_RESOLVING_TYPE , .machine_typename =TYPE_MACHINE ,
target-info.c +10 -0
@@ -33,6 +33,16 @@ SysEmuTarget target_arch(void)return arch; } +SysEmuTarget target_base_arch (void ) +{ +SysEmuTarget base_arch =target_info ()->target_base_arch; + +if (base_arch ==SYS_EMU_TARGET__MAX ) { + base_arch =target_arch (); + } +return base_arch; +} +const char *target_cpu_type (void ) {return target_info ()->cpu_type;
Signature · 1 line
2.49.0
PATCH v6 5/14 qemu/target-info: Add target_endian_mode()
In reply to Philippe Mathieu-Daudétarget_endian_mode() returns the default endianness (QAPI type) of a target.
--- include/qemu/target-info-impl.h | 2 ++ include/qemu/target-info-qapi.h | 8 ++++++++ target-info-stub.c | 1 + target-info.c | 5 +++++ 4 files changed, 16 insertions(+)
include/qemu/target-info-impl.h +2 -0
@@ -24,6 +24,8 @@ typedef struct TargetInfo {const char *cpu_type;/* QOM typename machines for this binary must implement */ const char *machine_typename; +/* related to TARGET_BIG_ENDIAN definition */ +EndianMode endianness; } TargetInfo;/**
include/qemu/target-info-qapi.h +8 -0
@@ -9,6 +9,7 @@#ifndef QEMU_TARGET_INFO_EXTRA_H #define QEMU_TARGET_INFO_EXTRA_H +#include "qapi/qapi-types-common.h" #include "qapi/qapi-types-machine.h" /**
@@ -25,4 +26,11 @@ SysEmuTarget target_arch(void);*/ SysEmuTarget target_base_arch (void ); +/** +* target_endian_mode: +* +* Returns: QAPI EndianMode enum (i.e. ENDIAN_MODE_LITTLE). +*/ +EndianMode target_endian_mode (void ); +#endif
target-info-stub.c +1 -0
@@ -19,6 +19,7 @@ static const TargetInfo target_info_stub = { .long_bits = TARGET_LONG_BITS, .cpu_type = CPU_RESOLVING_TYPE, .machine_typename = TYPE_MACHINE, + .endianness = TARGET_BIG_ENDIAN ? ENDIAN_MODE_BIG : ENDIAN_MODE_LITTLE, };const TargetInfo *target_info (void )
target-info.c +5 -0
@@ -52,3 +52,8 @@ const char *target_machine_typename(void) {return target_info ()->machine_typename; } + +EndianMode target_endian_mode (void ) +{ +return target_info ()->endianness; +}
Signature · 1 line
2.49.0
PATCH v6 6/14 qemu: Convert target_words_bigendian() to TargetInfo API
In reply to Philippe Mathieu-Daudé--- include/exec/tswap.h | 13 +------------ include/qemu/target-info.h | 8 ++++++++ cpu-target.c | 7 ------- hw/core/cpu-system.c | 2 +- hw/display/vga.c | 2 +- hw/virtio/virtio.c | 2 +- system/memory.c | 1 + system/qtest.c | 1 + target-info.c | 5 +++++ 9 files changed, 19 insertions(+), 22 deletions(-)
include/exec/tswap.h +1 -12
@@ -9,18 +9,7 @@#define TSWAP_H #include "qemu/bswap.h" - -/** -* target_big_endian: -* Returns true if the (default) endianness of the target is big endian, -* false otherwise. Common code should normally never need to know about the -* endianness of the target, so please do *not* use this function unless you -* know very well what you are doing! -*/ -bool target_big_endian (void ); -#ifdef COMPILING_PER_TARGET -#define target_big_endian () TARGET_BIG_ENDIAN -#endif +#include "qemu/target-info.h" /* * If we're in target-specific code, we can hard-code the swapping
include/qemu/target-info.h +8 -0
@@ -38,4 +38,12 @@ const char *target_machine_typename(void);*/ const char *target_cpu_type (void ); +/** +* target_big_endian: +* +* Returns: %true if the (default) endianness of the target is big endian, +* %false otherwise. +*/ +bool target_big_endian (void ); +#endif
cpu-target.c +0 -7
@@ -22,7 +22,6 @@#include "system/accel-ops.h" #include "system/cpus.h" #include "exec/cpu-common.h" -#include "exec/tswap.h" #include "exec/replay-core.h" #include "exec/log.h" #include "hw/core/cpu.h"
@@ -85,9 +84,3 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...)#endif abort (); } - -#undef target_big_endian -bool target_big_endian (void ) -{ -return TARGET_BIG_ENDIAN ; -}
hw/core/cpu-system.c +1 -1
@@ -24,7 +24,7 @@#include "exec/cputlb.h" #include "system/memory.h" #include "exec/tb-flush.h" -#include "exec/tswap.h" +#include "qemu/target-info.h" #include "hw/qdev-core.h" #include "hw/qdev-properties.h" #include "hw/core/sysemu-cpu-ops.h"
hw/display/vga.c +1 -1
@@ -26,7 +26,7 @@#include "qemu/units.h" #include "system/reset.h" #include "qapi/error.h" -#include "exec/tswap.h" +#include "qemu/target-info.h" #include "hw/display/vga.h" #include "hw/i386/x86.h" #include "hw/pci/pci.h"
hw/virtio/virtio.c +1 -1
@@ -20,7 +20,7 @@#include "qemu/log.h" #include "qemu/main-loop.h" #include "qemu/module.h" -#include "exec/tswap.h" +#include "qemu/target-info.h" #include "qom/object_interfaces.h" #include "hw/core/cpu.h" #include "hw/virtio/virtio.h"
system/memory.c +1 -0
@@ -22,6 +22,7 @@#include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/qemu-print.h" +#include "qemu/target-info.h" #include "qom/object.h" #include "trace.h" #include "system/ram_addr.h"
system/qtest.c +1 -0
@@ -29,6 +29,7 @@#include "qemu/error-report.h" #include "qemu/module.h" #include "qemu/cutils.h" +#include "qemu/target-info.h" #include "qom/object_interfaces.h" #define MAX_IRQ 256
target-info.c +5 -0
@@ -57,3 +57,8 @@ EndianMode target_endian_mode(void) {return target_info ()->endianness; } + +bool target_big_endian (void ) +{ +return target_endian_mode () ==ENDIAN_MODE_BIG ; +}
Signature · 1 line
2.49.0
PATCH v6 7/14 gdbstub/helpers: Replace TARGET_BIG_ENDIAN -> target_big_endian()
In reply to Philippe Mathieu-DaudéCheck endianness at runtime to remove the target-specific TARGET_BIG_ENDIAN definition.
--- include/gdbstub/helpers.h | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
include/gdbstub/helpers.h +6 -9
@@ -16,6 +16,7 @@#error "gdbstub helpers should only be included by target specific code"#endif +#include "qemu/target-info.h" #include "exec/tswap.h" #include "cpu-param.h"
@@ -55,18 +56,14 @@ static inline int gdb_get_reg64(GByteArray *buf, uint64_t val)static inline int gdb_get_reg128 (GByteArray *buf,uint64_t val_hi,uint64_t val_lo) { +bool be =target_big_endian ();uint64_t to_quad; -#if TARGET_BIG_ENDIAN - to_quad =tswap64 (val_hi); + + to_quad =tswap64 (be ? val_hi : val_lo);g_byte_array_append (buf, (uint8_t *) &to_quad,8 ); - to_quad =tswap64 (val_lo); + to_quad =tswap64 (be ? val_lo : val_hi);g_byte_array_append (buf, (uint8_t *) &to_quad,8 ); -#else - to_quad =tswap64 (val_lo); -g_byte_array_append (buf, (uint8_t *) &to_quad,8 ); - to_quad =tswap64 (val_hi); -g_byte_array_append (buf, (uint8_t *) &to_quad,8 ); -#endif +return 16 ; }
Signature · 1 line
2.49.0
RFC v6 8/14 qemu: Declare all load/store helpert in 'qemu/bswap.h'
In reply to Philippe Mathieu-DaudéRestrict "exec/tswap.h" to the tswap*() methods,
move the load/store helpers with the other ones
declared in "qemu/bswap.h".
--- include/exec/tswap.h | 70 -------------------------- include/qemu/bswap.h | 73 ++++++++++++++++++++++++++++ include/system/memory.h | 1 - include/user/abitypes.h | 1 - target/ppc/mmu-hash64.h | 2 - hw/acpi/bios-linker-loader.c | 2 - hw/arm/allwinner-r40.c | 1 - hw/arm/boot.c | 2 + hw/arm/npcm7xx.c | 2 +- hw/block/hd-geometry.c | 1 - hw/char/riscv_htif.c | 1 - hw/cxl/cxl-events.c | 2 - hw/display/artist.c | 1 + hw/display/ati.c | 1 + hw/net/can/ctucan_core.c | 1 - hw/net/lan9118.c | 1 + hw/net/rtl8139.c | 1 + hw/net/vmxnet3.c | 1 - hw/pci-host/gt64120.c | 1 + hw/pci-host/pnv_phb3.c | 1 + hw/pci-host/pnv_phb4.c | 1 + hw/pci-host/ppce500.c | 1 - hw/pci-host/sh_pci.c | 1 - hw/s390x/s390-pci-inst.c | 1 + hw/sensor/lsm303dlhc_mag.c | 1 - hw/smbios/smbios.c | 1 + hw/vfio/migration-multifd.c | 1 - hw/virtio/virtio-pci.c | 1 + hw/vmapple/virtio-blk.c | 1 - target/arm/cpu.c | 1 - target/i386/tcg/system/excp_helper.c | 1 - target/i386/xsave_helper.c | 1 - target/riscv/vector_helper.c | 1 - tests/tcg/plugins/mem.c | 1 + 34 files changed, 87 insertions(+), 93 deletions(-)
include/exec/tswap.h +0 -70
@@ -69,74 +69,4 @@ static inline void tswap64s(uint64_t *s) } } -/* Return ld{word}_{le,be}_p following target endianness. */ -#define LOAD_IMPL(word, args...) \ -do { \ - if (target_big_endian()) { \ - return glue(glue(ld, word), _be_p)(args); \ - } else { \ - return glue(glue(ld, word), _le_p)(args); \ - } \ -} while (0) - -static inline int lduw_p (const void *ptr) -{ -LOAD_IMPL (uw, ptr); -} - -static inline int ldsw_p (const void *ptr) -{ -LOAD_IMPL (sw, ptr); -} - -static inline int ldl_p (const void *ptr) -{ -LOAD_IMPL (l, ptr); -} - -static inline uint64_t ldq_p (const void *ptr) -{ -LOAD_IMPL (q, ptr); -} - -static inline uint64_t ldn_p (const void *ptr,int sz) -{ -LOAD_IMPL (n, ptr, sz); -} - -#undef LOAD_IMPL - -/* Call st{word}_{le,be}_p following target endianness. */ -#define STORE_IMPL(word, args...) \ -do { \ - if (target_big_endian()) { \ - glue(glue(st, word), _be_p)(args); \ - } else { \ - glue(glue(st, word), _le_p)(args); \ - } \ -} while (0) - - -static inline void stw_p (void *ptr,uint16_t v) -{ -STORE_IMPL (w, ptr, v); -} - -static inline void stl_p (void *ptr,uint32_t v) -{ -STORE_IMPL (l, ptr, v); -} - -static inline void stq_p (void *ptr,uint64_t v) -{ -STORE_IMPL (q, ptr, v); -} - -static inline void stn_p (void *ptr,int sz,uint64_t v) -{ -STORE_IMPL (n, ptr, sz, v); -} - -#undef STORE_IMPL -#endif /* TSWAP_H */
include/qemu/bswap.h +73 -0
83 lines not on this page · raw message
include/system/memory.h +0 -1
@@ -19,7 +19,6 @@#include "exec/memattrs.h" #include "exec/memop.h" #include "exec/ramlist.h" -#include "exec/tswap.h" #include "qemu/bswap.h" #include "qemu/queue.h" #include "qemu/int128.h"
include/user/abitypes.h +0 -1
@@ -6,7 +6,6 @@#endif #include "exec/cpu-defs.h" -#include "exec/tswap.h" #include "user/tswap-target.h" #ifdef TARGET_ABI32
target/ppc/mmu-hash64.h +0 -2
@@ -1,8 +1,6 @@#ifndef MMU_HASH64_H #define MMU_HASH64_H -#include "exec/tswap.h" -#ifndef CONFIG_USER_ONLY #ifdef TARGET_PPC64
hw/acpi/bios-linker-loader.c +0 -2
@@ -22,8 +22,6 @@#include "hw/acpi/bios-linker-loader.h" #include "hw/nvram/fw_cfg.h" -#include "qemu/bswap.h" -/* * Linker/loader is a paravirtualized interface that passes commands to guest. * The commands can be used to request guest to
hw/arm/allwinner-r40.c +0 -1
@@ -20,7 +20,6 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/error-report.h" -#include "qemu/bswap.h" #include "qemu/module.h" #include "qemu/units.h" #include "hw/boards.h"
hw/arm/boot.c +2 -0
@@ -15,6 +15,7 @@#include "hw/arm/boot.h" #include "hw/arm/linux-boot-if.h" #include "cpu.h" +#include "exec/tswap.h" #include "exec/target_page.h" #include "system/kvm.h" #include "system/tcg.h"
@@ -29,6 +30,7 @@#include "qemu/config-file.h" #include "qemu/option.h" #include "qemu/units.h" +#include "qemu/bswap.h" /* Kernel boot protocol is specified in the kernel docs * Documentation/arm/Booting and Documentation/arm64/booting.txt
hw/arm/npcm7xx.c +1 -1
@@ -24,7 +24,7 @@#include "hw/qdev-clock.h" #include "hw/qdev-properties.h" #include "qapi/error.h" -#include "qemu/bswap.h" +#include "exec/tswap.h" #include "qemu/units.h" #include "system/system.h" #include "target/arm/cpu-qom.h"
hw/block/hd-geometry.c +0 -1
@@ -33,7 +33,6 @@#include "qemu/osdep.h" #include "system/block-backend.h" #include "qapi/qapi-types-block.h" -#include "qemu/bswap.h" #include "hw/block/block.h" #include "trace.h"
hw/char/riscv_htif.c +0 -1
@@ -29,7 +29,6 @@#include "qemu/timer.h" #include "qemu/error-report.h" #include "system/address-spaces.h" -#include "exec/tswap.h" #include "system/dma.h" #include "system/runstate.h" #include "trace.h"
hw/cxl/cxl-events.c +0 -2
@@ -8,8 +8,6 @@*/ #include "qemu/osdep.h" - -#include "qemu/bswap.h" #include "qemu/error-report.h" #include "hw/pci/msi.h" #include "hw/pci/msix.h"
hw/display/artist.c +1 -0
@@ -12,6 +12,7 @@#include "qemu/log.h" #include "qemu/module.h" #include "qemu/units.h" +#include "qemu/bswap.h" #include "qapi/error.h" #include "hw/sysbus.h" #include "hw/loader.h"
hw/display/ati.c +1 -0
@@ -22,6 +22,7 @@#include "vga-access.h" #include "hw/qdev-properties.h" #include "vga_regs.h" +#include "qemu/bswap.h" #include "qemu/log.h" #include "qemu/module.h" #include "qemu/error-report.h"
hw/net/can/ctucan_core.c +0 -1
@@ -28,7 +28,6 @@#include "qemu/osdep.h" #include "qemu/log.h" -#include "qemu/bswap.h" #include "qemu/bitops.h" #include "hw/irq.h" #include "migration/vmstate.h"
hw/net/lan9118.c +1 -0
@@ -21,6 +21,7 @@#include "hw/ptimer.h" #include "hw/qdev-properties.h" #include "qapi/error.h" +#include "qemu/bswap.h" #include "qemu/log.h" #include "qemu/module.h" #include <zlib.h> /* for crc32 */
hw/net/rtl8139.c +1 -0
@@ -57,6 +57,7 @@#include "system/dma.h" #include "qemu/module.h" #include "qemu/timer.h" +#include "qemu/bswap.h" #include "net/net.h" #include "net/eth.h" #include "system/system.h"
hw/net/vmxnet3.c +0 -1
@@ -22,7 +22,6 @@#include "net/tap.h" #include "net/checksum.h" #include "system/system.h" -#include "qemu/bswap.h" #include "qemu/log.h" #include "qemu/module.h" #include "hw/pci/msix.h"
hw/pci-host/gt64120.c +1 -0
@@ -28,6 +28,7 @@#include "qapi/error.h" #include "qemu/units.h" #include "qemu/log.h" +#include "qemu/bswap.h" #include "hw/qdev-properties.h" #include "hw/registerfields.h" #include "hw/pci/pci_device.h"
hw/pci-host/pnv_phb3.c +1 -0
@@ -8,6 +8,7 @@*/ #include "qemu/osdep.h" #include "qemu/log.h" +#include "qemu/bswap.h" #include "qapi/visitor.h" #include "qapi/error.h" #include "hw/pci-host/pnv_phb3_regs.h"
hw/pci-host/pnv_phb4.c +1 -0
@@ -8,6 +8,7 @@*/ #include "qemu/osdep.h" #include "qemu/log.h" +#include "qemu/bswap.h" #include "qapi/visitor.h" #include "qapi/error.h" #include "target/ppc/cpu.h"
hw/pci-host/ppce500.c +0 -1
@@ -20,7 +20,6 @@#include "migration/vmstate.h" #include "hw/pci/pci_device.h" #include "hw/pci/pci_host.h" -#include "qemu/bswap.h" #include "hw/pci-host/ppce500.h" #include "qom/object.h"
hw/pci-host/sh_pci.c +0 -1
@@ -28,7 +28,6 @@#include "hw/irq.h" #include "hw/pci/pci_device.h" #include "hw/pci/pci_host.h" -#include "qemu/bswap.h" #include "qemu/module.h" #include "qom/object.h"
hw/s390x/s390-pci-inst.c +1 -0
@@ -16,6 +16,7 @@#include "exec/target_page.h" #include "system/memory.h" #include "qemu/error-report.h" +#include "qemu/bswap.h" #include "system/hw_accel.h" #include "hw/boards.h" #include "hw/pci/pci_device.h"
hw/sensor/lsm303dlhc_mag.c +0 -1
@@ -28,7 +28,6 @@#include "qapi/visitor.h" #include "qemu/module.h" #include "qemu/log.h" -#include "qemu/bswap.h" enum LSM303DLHCMagReg {LSM303DLHC_MAG_REG_CRA =0x00 ,
hw/smbios/smbios.c +1 -0
@@ -17,6 +17,7 @@#include "qemu/osdep.h" #include "qemu/units.h" +#include "qemu/bswap.h" #include "qapi/error.h" #include "qemu/config-file.h" #include "qemu/module.h"
hw/vfio/migration-multifd.c +0 -1
@@ -13,7 +13,6 @@#include "hw/vfio/vfio-device.h" #include "migration/misc.h" #include "qapi/error.h" -#include "qemu/bswap.h" #include "qemu/error-report.h" #include "qemu/lockable.h" #include "qemu/main-loop.h"
hw/virtio/virtio-pci.c +1 -0
@@ -30,6 +30,7 @@#include "qemu/error-report.h" #include "qemu/log.h" #include "qemu/module.h" +#include "qemu/bswap.h" #include "hw/pci/msi.h" #include "hw/pci/msix.h" #include "hw/loader.h"
hw/vmapple/virtio-blk.c +0 -1
@@ -19,7 +19,6 @@#include "hw/vmapple/vmapple.h" #include "hw/virtio/virtio-blk.h" #include "hw/virtio/virtio-pci.h" -#include "qemu/bswap.h" #include "qemu/log.h" #include "qemu/module.h" #include "qapi/error.h"
target/arm/cpu.c +0 -1
@@ -23,7 +23,6 @@#include "qemu/timer.h" #include "qemu/log.h" #include "exec/page-vary.h" -#include "exec/tswap.h" #include "target/arm/idau.h" #include "qemu/module.h" #include "qapi/error.h"
target/i386/tcg/system/excp_helper.c +0 -1
@@ -25,7 +25,6 @@#include "exec/page-protection.h" #include "exec/target_page.h" #include "exec/tlb-flags.h" -#include "exec/tswap.h" #include "tcg/helper-tcg.h" typedef struct TranslateParams {
target/i386/xsave_helper.c +0 -1
@@ -5,7 +5,6 @@#include "qemu/osdep.h" #include "cpu.h" -#include "exec/tswap.h" void x86_cpu_xsave_all_areas (X86CPU *cpu,void *buf,uint32_t buflen) {
target/riscv/vector_helper.c +0 -1
@@ -27,7 +27,6 @@#include "exec/helper-proto.h" #include "exec/tlb-flags.h" #include "exec/target_page.h" -#include "exec/tswap.h" #include "fpu/softfloat.h" #include "tcg/tcg-gvec-desc.h" #include "internals.h"
tests/tcg/plugins/mem.c +1 -0
@@ -20,6 +20,7 @@* few things provided by compiler.h. */ #include <compiler.h> +#include <stdbool.h> #include <bswap.h> #include <qemu-plugin.h>
Signature · 1 line
2.49.0
Re: [RFC PATCH-for-10.1 v6 08/14] qemu: Declare all load/store helpert in 'qemu/bswap.h'
On 7/7/25 19:20, Philippe Mathieu-Daudé wrote:
Oops typo "helper" in subject.
Quoted 41 lines
Restrict "
exec/tswap.h" to the tswap*() methods,
move the load/store helpers with the other ones
declared in "qemu/bswap.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/tswap.h | 70 -------------------------- include/qemu/bswap.h | 73 ++++++++++++++++++++++++++++ include/system/memory.h | 1 - include/user/abitypes.h | 1 - target/ppc/mmu-hash64.h | 2 - hw/acpi/bios-linker-loader.c | 2 - hw/arm/allwinner-r40.c | 1 - hw/arm/boot.c | 2 + hw/arm/npcm7xx.c | 2 +- hw/block/hd-geometry.c | 1 - hw/char/riscv_htif.c | 1 - hw/cxl/cxl-events.c | 2 - hw/display/artist.c | 1 + hw/display/ati.c | 1 + hw/net/can/ctucan_core.c | 1 - hw/net/lan9118.c | 1 + hw/net/rtl8139.c | 1 + hw/net/vmxnet3.c | 1 - hw/pci-host/gt64120.c | 1 + hw/pci-host/pnv_phb3.c | 1 + hw/pci-host/pnv_phb4.c | 1 + hw/pci-host/ppce500.c | 1 - hw/pci-host/sh_pci.c | 1 - hw/s390x/s390-pci-inst.c | 1 + hw/sensor/lsm303dlhc_mag.c | 1 - hw/smbios/smbios.c | 1 + hw/vfio/migration-multifd.c | 1 - hw/virtio/virtio-pci.c | 1 + hw/vmapple/virtio-blk.c | 1 - target/arm/cpu.c | 1 - target/i386/tcg/system/excp_helper.c | 1 - target/i386/xsave_helper.c | 1 - target/riscv/vector_helper.c | 1 - tests/tcg/plugins/mem.c | 1 + 34 files changed, 87 insertions(+), 93 deletions(-)
PATCH v6 9/14 hw/virtio: Build various files once
In reply to Philippe Mathieu-DaudéNow than various VirtIO files don't use target specific API anymore, we can move them to the system_ss[] source set to build them once.
--- hw/virtio/virtio-config-io.c | 1 - hw/block/meson.build | 6 ++++-- hw/virtio/meson.build | 20 +++++++++++--------- 3 files changed, 15 insertions(+), 12 deletions(-)
hw/virtio/virtio-config-io.c +0 -1
@@ -11,7 +11,6 @@#include "qemu/osdep.h" #include "hw/virtio/virtio.h" -#include "cpu.h" uint32_t virtio_config_readb (VirtIODevice *vdev,uint32_t addr) {
hw/block/meson.build +4 -2
@@ -13,7 +13,9 @@ system_ss.add(when: 'CONFIG_SSI_M25P80', if_true: files('m25p80_sfdp.c')) system_ss.add(when: 'CONFIG_SWIM', if_true: files('swim.c')) system_ss.add(when: 'CONFIG_XEN_BUS', if_true: files('xen-block.c')) -specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c', 'virtio-blk-common.c')) -specific_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk.c', 'virtio-blk-common.c')) +specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c')) +system_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk-common.c')) +specific_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk.c')) +system_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('virtio-blk-common.c')) subdir('dataplane')
hw/virtio/meson.build +11 -9
@@ -1,6 +1,7 @@ system_virtio_ss = ss.source_set() system_virtio_ss.add(files('virtio-bus.c')) system_virtio_ss.add(files('iothread-vq-mapping.c')) +system_virtio_ss.add(files('virtio-config-io.c')) system_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('virtio-pci.c')) system_virtio_ss.add(when: 'CONFIG_VIRTIO_MMIO', if_true: files('virtio-mmio.c')) system_virtio_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('virtio-crypto.c'))
@@ -10,11 +11,11 @@ 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-config-io.c', 'virtio-qmp.c')) +specific_virtio_ss.add(files('virtio-qmp.c')) if have_vhost system_virtio_ss.add(files('vhost.c')) - specific_virtio_ss.add(files('vhost-backend.c', 'vhost-iova-tree.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'))
@@ -43,22 +44,22 @@ if have_vhost endif if have_vhost_vdpa system_virtio_ss.add(files('vhost-vdpa.c')) - specific_virtio_ss.add(files('vhost-shadow-virtqueue.c')) + system_virtio_ss.add(files('vhost-shadow-virtqueue.c')) endif else system_virtio_ss.add(files('vhost-stub.c')) 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')) -specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-user-vsock.c')) -specific_virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-rng.c')) -specific_virtio_ss.add(when: 'CONFIG_VIRTIO_NSM', if_true: [files('virtio-nsm.c', 'cbor-helpers.c'), libcbor]) specific_virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c')) -specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi.c')) -specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_SCMI'], if_true: files('vhost-user-scmi-pci.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]) +system_virtio_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi.c')) virtio_pci_ss = ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c'))
@@ -67,6 +68,7 @@ virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk- virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-user-scsi-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_FS', if_true: files('vhost-user-fs-pci.c')) +virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('virtio-crypto-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VIRTIO_INPUT_HOST', if_true: files('virtio-input-host-pci.c'))
@@ -85,7 +87,7 @@ virtio_pci_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VIRTIO_MD', if_true: files('virtio-md-pci.c')) -specific_virtio_ss.add_all(when: 'CONFIG_VIRTIO_PCI', if_true: virtio_pci_ss) +system_virtio_ss.add_all(when: 'CONFIG_VIRTIO_PCI', if_true: virtio_pci_ss) system_ss.add_all(when: 'CONFIG_VIRTIO', if_true: system_virtio_ss) system_ss.add(when: 'CONFIG_VIRTIO', if_false: files('vhost-stub.c'))
Signature · 1 line
2.49.0
Re: [PATCH-for-10.1 v6 09/14] hw/virtio: Build various files once
Quoted 1 line · Philippe Mathieu-Daudé
Now than various VirtIO files don't use target specific
Typo: than -> that.
Re: [PATCH-for-10.1 v6 09/14] hw/virtio: Build various files once
In reply to Philippe Mathieu-Daudé(Forgot to Cc Manos)
Quoted 111 lines · Philippe Mathieu-Daudé
Now than various VirtIO files don't use target specific API anymore, we can move them to the system_ss[] source set to build them once.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/virtio/virtio-config-io.c | 1 - hw/block/meson.build | 6 ++++-- hw/virtio/meson.build | 20 +++++++++++--------- 3 files changed, 15 insertions(+), 12 deletions(-)hw/virtio/virtio-config-io.c +0
-1@@ -11,7 +11,6 @@#include "qemu/osdep.h" #include "hw/virtio/virtio.h" -#include "cpu.h" uint32_t virtio_config_readb (VirtIODevice *vdev,uint32_t addr) {hw/block/meson.build +4
-2@@ -13,7 +13,9 @@ system_ss.add(when: 'CONFIG_SSI_M25P80', if_true: files('m25p80_sfdp.c')) system_ss.add(when: 'CONFIG_SWIM', if_true: files('swim.c')) system_ss.add(when: 'CONFIG_XEN_BUS', if_true: files('xen-block.c')) -specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c', 'virtio-blk-common.c')) -specific_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk.c', 'virtio-blk-common.c')) +specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c')) +system_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk-common.c')) +specific_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk.c')) +system_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('virtio-blk-common.c')) subdir('dataplane')hw/virtio/meson.build +11
-9@@ -1,6 +1,7 @@ system_virtio_ss = ss.source_set() system_virtio_ss.add(files('virtio-bus.c')) system_virtio_ss.add(files('iothread-vq-mapping.c')) +system_virtio_ss.add(files('virtio-config-io.c')) system_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('virtio-pci.c')) system_virtio_ss.add(when: 'CONFIG_VIRTIO_MMIO', if_true: files('virtio-mmio.c')) system_virtio_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('virtio-crypto.c'))@@ -10,11 +11,11 @@ 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-config-io.c', 'virtio-qmp.c')) +specific_virtio_ss.add(files('virtio-qmp.c')) if have_vhost system_virtio_ss.add(files('vhost.c')) - specific_virtio_ss.add(files('vhost-backend.c', 'vhost-iova-tree.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'))@@ -43,22 +44,22 @@ if have_vhost endif if have_vhost_vdpa system_virtio_ss.add(files('vhost-vdpa.c')) - specific_virtio_ss.add(files('vhost-shadow-virtqueue.c')) + system_virtio_ss.add(files('vhost-shadow-virtqueue.c')) endif else system_virtio_ss.add(files('vhost-stub.c')) 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')) -specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-user-vsock.c')) -specific_virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-rng.c')) -specific_virtio_ss.add(when: 'CONFIG_VIRTIO_NSM', if_true: [files('virtio-nsm.c', 'cbor-helpers.c'), libcbor]) specific_virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c')) -specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi.c')) -specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_SCMI'], if_true: files('vhost-user-scmi-pci.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]) +system_virtio_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi.c')) virtio_pci_ss = ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c'))@@ -67,6 +68,7 @@ virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk- virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-user-scsi-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_FS', if_true: files('vhost-user-fs-pci.c')) +virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('virtio-crypto-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VIRTIO_INPUT_HOST', if_true: files('virtio-input-host-pci.c'))@@ -85,7 +87,7 @@ virtio_pci_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VIRTIO_MD', if_true: files('virtio-md-pci.c')) -specific_virtio_ss.add_all(when: 'CONFIG_VIRTIO_PCI', if_true: virtio_pci_ss) +system_virtio_ss.add_all(when: 'CONFIG_VIRTIO_PCI', if_true: virtio_pci_ss) system_ss.add_all(when: 'CONFIG_VIRTIO', if_true: system_virtio_ss) system_ss.add(when: 'CONFIG_VIRTIO', if_false: files('vhost-stub.c'))
Manos Pitsidianakis
Reviewed-byRe: [PATCH-for-10.1 v6 09/14] hw/virtio: Build various files once
Quoted 116 lines · Philippe Mathieu-Daudé
(Forgot to Cc Manos)
Quoted 111 lines · Philippe Mathieu-Daudé
Now than various VirtIO files don't use target specific API anymore, we can move them to the system_ss[] source set to build them once.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/virtio/virtio-config-io.c | 1 - hw/block/meson.build | 6 ++++-- hw/virtio/meson.build | 20 +++++++++++--------- 3 files changed, 15 insertions(+), 12 deletions(-)hw/virtio/virtio-config-io.c +0
-1@@ -11,7 +11,6 @@#include "qemu/osdep.h" #include "hw/virtio/virtio.h" -#include "cpu.h" uint32_t virtio_config_readb (VirtIODevice *vdev,uint32_t addr) {hw/block/meson.build +4
-2@@ -13,7 +13,9 @@ system_ss.add(when: 'CONFIG_SSI_M25P80', if_true: files('m25p80_sfdp.c')) system_ss.add(when: 'CONFIG_SWIM', if_true: files('swim.c')) system_ss.add(when: 'CONFIG_XEN_BUS', if_true: files('xen-block.c')) -specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c', 'virtio-blk-common.c')) -specific_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk.c', 'virtio-blk-common.c')) +specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c')) +system_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk-common.c')) +specific_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk.c')) +system_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('virtio-blk-common.c')) subdir('dataplane')hw/virtio/meson.build +11
-9@@ -1,6 +1,7 @@ system_virtio_ss = ss.source_set() system_virtio_ss.add(files('virtio-bus.c')) system_virtio_ss.add(files('iothread-vq-mapping.c')) +system_virtio_ss.add(files('virtio-config-io.c')) system_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('virtio-pci.c')) system_virtio_ss.add(when: 'CONFIG_VIRTIO_MMIO', if_true: files('virtio-mmio.c')) system_virtio_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('virtio-crypto.c'))@@ -10,11 +11,11 @@ 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-config-io.c', 'virtio-qmp.c')) +specific_virtio_ss.add(files('virtio-qmp.c')) if have_vhost system_virtio_ss.add(files('vhost.c')) - specific_virtio_ss.add(files('vhost-backend.c', 'vhost-iova-tree.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'))@@ -43,22 +44,22 @@ if have_vhost endif if have_vhost_vdpa system_virtio_ss.add(files('vhost-vdpa.c')) - specific_virtio_ss.add(files('vhost-shadow-virtqueue.c')) + system_virtio_ss.add(files('vhost-shadow-virtqueue.c')) endif else system_virtio_ss.add(files('vhost-stub.c')) 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')) -specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-user-vsock.c')) -specific_virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-rng.c')) -specific_virtio_ss.add(when: 'CONFIG_VIRTIO_NSM', if_true: [files('virtio-nsm.c', 'cbor-helpers.c'), libcbor]) specific_virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c')) -specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi.c')) -specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_SCMI'], if_true: files('vhost-user-scmi-pci.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]) +system_virtio_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi.c')) virtio_pci_ss = ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c'))@@ -67,6 +68,7 @@ virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk- virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-user-scsi-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_FS', if_true: files('vhost-user-fs-pci.c')) +virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('virtio-crypto-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VIRTIO_INPUT_HOST', if_true: files('virtio-input-host-pci.c'))@@ -85,7 +87,7 @@ virtio_pci_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VIRTIO_MD', if_true: files('virtio-md-pci.c')) -specific_virtio_ss.add_all(when: 'CONFIG_VIRTIO_PCI', if_true: virtio_pci_ss) +system_virtio_ss.add_all(when: 'CONFIG_VIRTIO_PCI', if_true: virtio_pci_ss) system_ss.add_all(when: 'CONFIG_VIRTIO', if_true: system_virtio_ss) system_ss.add(when: 'CONFIG_VIRTIO', if_false: files('vhost-stub.c'))
PATCH v6 10/14 hw/core/null-machine: Define machine as generic QOM type
In reply to Philippe Mathieu-DaudéWhile DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.
--- hw/core/null-machine.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
hw/core/null-machine.c +12 -2
@@ -42,8 +42,10 @@ static void machine_none_init(MachineState *mch) } } -static void machine_none_machine_init (MachineClass *mc) +static void null_machine_class_init (ObjectClass *oc,const void *data) { +MachineClass *mc =MACHINE_CLASS (oc); + mc->desc ="empty machine" ; mc->init = machine_none_init; mc->max_cpus =1 ;
@@ -55,4 +57,12 @@ static void machine_none_machine_init(MachineClass *mc) mc->no_cdrom =1 ; } -DEFINE_MACHINE ("none" , machine_none_machine_init) +static const TypeInfo null_machine_types[] = { + { + .name =MACHINE_TYPE_NAME ("none" ), + .parent =TYPE_MACHINE , + .class_init = null_machine_class_init, + }, +}; + +DEFINE_TYPES (null_machine_types)
Signature · 1 line
2.49.0
Re: [PATCH-for-10.1 v6 10/14] hw/core/null-machine: Define machine as generic QOM type
Quoted 31 lines · Philippe Mathieu-Daudé
While
DEFINE_MACHINE()is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the genericDEFINE_TYPES()in preparation to register interfaces.Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Pierrick Bouvier <[email protected]>--- hw/core/null-machine.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)hw/core/null-machine.c +3
-1@@ -42,8 +42,10 @@ static void machine_none_init(MachineState *mch) } } -static void machine_none_machine_init (MachineClass *mc) +static void null_machine_class_init (ObjectClass *oc,const void *data) { +MachineClass *mc =MACHINE_CLASS (oc); + mc->desc ="empty machine" ; mc->init = machine_none_init; mc->max_cpus =1 ;@@ -55,4 +57,12 @@ static void machine_none_machine_init(MachineClass *mc) mc->no_cdrom =1 ; }
hw/core/null-machine.c static void machine_none_machine_init(MachineClass *mc) · line 68
Quoted 10 lines
hw/core/null-machine.c +9
-1-DEFINE_MACHINE ("none" , machine_none_machine_init) +static const TypeInfo null_machine_types[] = { + { + .name =MACHINE_TYPE_NAME ("none" ), + .parent =TYPE_MACHINE , + .class_init = null_machine_class_init, + }, +}; + +DEFINE_TYPES (null_machine_types)
Ought this use DEFINE_MACHINE_WITH_INTERFACES that you introduce later?
r~
Re: [PATCH-for-10.1 v6 10/14] hw/core/null-machine: Define machine as generic QOM type
In reply to Philippe Mathieu-DaudéQuoted 11 lines · Philippe Mathieu-Daudé
Date: Mon, 7 Jul 2025 19:20:04 +0200
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH-for-10.1 v6 10/14] hw/core/null-machine: Define machine as
generic QOM type
X-Mailer: git-send-email 2.49.0While
DEFINE_MACHINE()is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the genericDEFINE_TYPES()in preparation to register interfaces.
Quoted 5 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Pierrick Bouvier <[email protected]>--- hw/core/null-machine.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
PATCH v6 11/14 hw/arm: Register TYPE_TARGET_ARM/AARCH64_MACHINE QOM interfaces
In reply to Philippe Mathieu-DaudéDefine the TYPE_TARGET_ARM_MACHINE and TYPE_TARGET_AARCH64_MACHINE QOM interface names to allow machines to implement them.
Register these interfaces in common code in target_info-qom.c used by all binaries because QOM interfaces must be registered before being checked (see next commit with the 'none' machine).
--- meson.build | 1 + include/hw/arm/machines-qom.h | 18 ++++++++++++++++++ target-info-qom.c | 24 ++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 include/hw/arm/machines-qom.h create mode 100644 target-info-qom.c
meson.build +1 -0
@@ -3879,6 +3879,7 @@ common_ss.add(pagevary) specific_ss.add(files('page-target.c', 'page-vary-target.c')) common_ss.add(files('target-info.c')) +system_ss.add(files('target-info-qom.c')) specific_ss.add(files('target-info-stub.c')) subdir('backends')
include/hw/arm/machines-qom.h new file +18 -0
@@ -0,0 +1,18 @@ +/* +* QOM type definitions for ARM / Aarch64 machines +* +* Copyright (c) Linaro +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_ARM_MACHINES_QOM_H +#define HW_ARM_MACHINES_QOM_H + +#define TYPE_TARGET_ARM_MACHINE \ + "target-info-arm-machine" + +#define TYPE_TARGET_AARCH64_MACHINE \ + "target-info-aarch64-machine" + +#endif
target-info-qom.c new file +24 -0
@@ -0,0 +1,24 @@ +/* +* QEMU binary/target API (QOM types) +* +* Copyright (c) Linaro +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "qom/object.h" +#include "hw/arm/machines-qom.h" + +static const TypeInfo target_info_types[] = { + { + .name =TYPE_TARGET_ARM_MACHINE , + .parent =TYPE_INTERFACE , + }, + { + .name =TYPE_TARGET_AARCH64_MACHINE , + .parent =TYPE_INTERFACE , + }, +}; + +DEFINE_TYPES (target_info_types)
Signature · 1 line
2.49.0
PATCH v6 12/14 hw/core: Allow ARM/Aarch64 binaries to use the 'none' machine
In reply to Philippe Mathieu-DaudéWhen we'll start to use target_machine_typename() to filter machines for the ARM/Aarch64 binaries, the 'none' machine would be filtered out. Register the proper interfaces to keep it available.
--- hw/core/null-machine.c | 6 ++++++ 1 file changed, 6 insertions(+)
hw/core/null-machine.c +6 -0
@@ -16,6 +16,7 @@#include "hw/boards.h" #include "system/address-spaces.h" #include "hw/core/cpu.h" +#include "hw/arm/machines-qom.h" static void machine_none_init (MachineState *mch) {
@@ -62,6 +63,11 @@ static const TypeInfo null_machine_types[] = { .name = MACHINE_TYPE_NAME("none"), .parent = TYPE_MACHINE, .class_init = null_machine_class_init, + .interfaces = (const InterfaceInfo []) { + {TYPE_TARGET_AARCH64_MACHINE }, + {TYPE_TARGET_ARM_MACHINE }, + { }, + }, }, };
Signature · 1 line
2.49.0
Re: [PATCH-for-10.1 v6 12/14] hw/core: Allow ARM/Aarch64 binaries to use the 'none' machine
Quoted 25 lines · Philippe Mathieu-Daudé
When we'll start to use
target_machine_typename()to filter machines for the ARM/Aarch64 binaries, the 'none' machine would be filtered out. Register the proper interfaces to keep it available.Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Pierrick Bouvier <[email protected]>--- hw/core/null-machine.c | 6 ++++++ 1 file changed, 6 insertions(+)hw/core/null-machine.c +1
-0@@ -16,6 +16,7 @@#include "hw/boards.h" #include "system/address-spaces.h" #include "hw/core/cpu.h" +#include "hw/arm/machines-qom.h" static void machine_none_init (MachineState *mch) {@@ -62,6 +63,11 @@ static const TypeInfo null_machine_types[] = { .name = MACHINE_TYPE_NAME("none"),
hw/core/null-machine.c static const TypeInfo null_machine_types[] = { · line 73
Quoted 10 lines
hw/core/null-machine.c +5
-0.parent = TYPE_MACHINE, .class_init = null_machine_class_init, + .interfaces = (const InterfaceInfo []) { + {TYPE_TARGET_AARCH64_MACHINE }, + {TYPE_TARGET_ARM_MACHINE }, + { }, + }, }, };
Ought this use DEFINE_MACHINE_WITH_INTERFACES?
r~
PATCH v6 13/14 hw/boards: Introduce DEFINE_MACHINE_WITH_INTERFACES() macro
In reply to Philippe Mathieu-DaudéDEFINE_MACHINE_WITH_INTERFACES() is similar to DEFINE_MACHINE() but allows to pass a InterfaceInfo[] pointer.
--- include/hw/boards.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
include/hw/boards.h +5 -1
@@ -761,7 +761,7 @@ struct MachineState { } \ } while (0) -#define DEFINE_MACHINE (namestr, machine_initfn) \ +#define DEFINE_MACHINE_WITH_INTERFACES (namestr, machine_initfn, ifaces) \ static void machine_initfn##_class_init(ObjectClass *oc, const void *data) \ { \ MachineClass *mc = MACHINE_CLASS(oc); \
@@ -771,6 +771,7 @@ struct MachineState { .name = MACHINE_TYPE_NAME(namestr), \ .parent = TYPE_MACHINE, \ .class_init = machine_initfn##_class_init, \ + .interfaces = ifaces, \ }; \ static void machine_initfn##_register_types(void) \ { \
@@ -778,6 +779,9 @@ struct MachineState { } \ type_init(machine_initfn##_register_types) +#define DEFINE_MACHINE(namestr, machine_initfn) \ +DEFINE_MACHINE_WITH_INTERFACES (namestr, machine_initfn,NULL ) + extern GlobalProperty hw_compat_10_0[];extern const size_t hw_compat_10_0_len;
Signature · 1 line
2.49.0
RFC v6 14/14 hw/arm: Add DEFINE_MACHINE_[ARM_]AARCH64() macros
In reply to Philippe Mathieu-DaudéA machine defined with the DEFINE_MACHINE_ARM_AARCH64() macro will be available on qemu-system-arm and qemu-system-aarch64 binaries.
One defined with DEFINE_MACHINE_AARCH64() will only be available in the qemu-system-aarch64 binary.
--- include/hw/arm/machines-qom.h | 13 +++++++++++++ target/arm/machine.c | 12 ++++++++++++ 2 files changed, 25 insertions(+)
include/hw/arm/machines-qom.h +13 -0
@@ -9,10 +9,23 @@#ifndef HW_ARM_MACHINES_QOM_H #define HW_ARM_MACHINES_QOM_H +#include "hw/boards.h" +#define TYPE_TARGET_ARM_MACHINE \ "target-info-arm-machine"#define TYPE_TARGET_AARCH64_MACHINE \ "target-info-aarch64-machine" +extern const InterfaceInfo arm_aarch64_machine_interfaces[]; +extern const InterfaceInfo aarch64_machine_interfaces[]; + +#define DEFINE_MACHINE_ARM_AARCH64 (namestr, machine_initfn) \ + DEFINE_MACHINE_WITH_INTERFACES(namestr, machine_initfn, \ + arm_aarch64_machine_interfaces) + +#define DEFINE_MACHINE_AARCH64 (namestr, machine_initfn) \ + DEFINE_MACHINE_WITH_INTERFACES(namestr, machine_initfn, \ + aarch64_machine_interfaces) +#endif
target/arm/machine.c +12 -0
@@ -9,6 +9,7 @@#include "migration/qemu-file-types.h" #include "migration/vmstate.h" #include "target/arm/gtimer.h" +#include "hw/arm/machines-qom.h" static bool vfp_needed (void *opaque) {
@@ -1102,3 +1103,14 @@ const VMStateDescription vmstate_arm_cpu = { NULL } }; + +const InterfaceInfo arm_aarch64_machine_interfaces[] = { + {TYPE_TARGET_ARM_MACHINE }, + {TYPE_TARGET_AARCH64_MACHINE }, + { } +}; + +const InterfaceInfo aarch64_machine_interfaces[] = { + {TYPE_TARGET_AARCH64_MACHINE }, + { } +};
Signature · 1 line
2.49.0
Quoted 7 lines · Philippe Mathieu-Daudé
Rather than re-spinning the whole "single-binary: Make hw/arm/ common" series, restrict to the API additions, but include examples of their usefulness (hundreds of virtio objects removed from default Linux build).
Time passed since I context-switched out of this work so I'm not sure theDEFINE_MACHINE_WITH_INTERFACES()implementation is in the form Zoltan asked.
I think I'd prefer to defer cleanups to post 10.1 - already too much on my plate as I was out sick. Unless there's a reason I'm missing to rush this in? Is there a feature we want in 10.1 that depends on it?
Quoted 82 lines
Philippe Mathieu-Daudé (14):
target/qmp: Usetarget_cpu_type()
qemu/target-info: Factortarget_arch()out qemu/target-info: Add %target_arch field to TargetInfo qemu/target-info: Introducetarget_base_arch()qemu/target-info: Addtarget_endian_mode()
qemu: Converttarget_words_bigendian()to TargetInfo API gdbstub/helpers: ReplaceTARGET_BIG_ENDIAN->target_big_endian()
qemu: Declare all load/store helpert in 'qemu/bswap.h' hw/virtio: Build various files once hw/core/null-machine: Define machine as generic QOM type hw/arm: Register TYPE_TARGET_ARM/AARCH64_MACHINE QOM interfaces hw/core: Allow ARM/Aarch64 binaries to use the 'none' machine hw/boards: IntroduceDEFINE_MACHINE_WITH_INTERFACES()macro hw/arm: Add DEFINE_MACHINE_[ARM_]AARCH64() macrosmeson.build | 1 + include/exec/tswap.h | 83 +-------------------------- include/gdbstub/helpers.h | 15 ++--- include/hw/arm/machines-qom.h | 31 ++++++++++ include/hw/boards.h | 6 +- include/qemu/bswap.h | 73 +++++++++++++++++++++++ include/qemu/target-info-impl.h | 8 ++- include/qemu/target-info-qapi.h | 36 ++++++++++++ include/qemu/target-info.h | 10 +++- include/system/memory.h | 1 - include/user/abitypes.h | 1 - target/ppc/mmu-hash64.h | 2 - cpu-target.c | 7 --- hw/acpi/bios-linker-loader.c | 2 - hw/arm/allwinner-r40.c | 1 - hw/arm/boot.c | 2 + hw/arm/npcm7xx.c | 2 +- hw/block/hd-geometry.c | 1 - hw/char/riscv_htif.c | 1 - hw/core/cpu-system.c | 2 +- hw/core/machine-qmp-cmds.c | 8 +-- hw/core/null-machine.c | 20 ++++++- hw/cxl/cxl-events.c | 2 - hw/display/artist.c | 1 + hw/display/ati.c | 1 + hw/display/vga.c | 2 +- hw/net/can/ctucan_core.c | 1 - hw/net/lan9118.c | 1 + hw/net/rtl8139.c | 1 + hw/net/vmxnet3.c | 1 - hw/pci-host/gt64120.c | 1 + hw/pci-host/pnv_phb3.c | 1 + hw/pci-host/pnv_phb4.c | 1 + hw/pci-host/ppce500.c | 1 - hw/pci-host/sh_pci.c | 1 - hw/s390x/s390-pci-inst.c | 1 + hw/sensor/lsm303dlhc_mag.c | 1 - hw/smbios/smbios.c | 1 + hw/vfio/migration-multifd.c | 1 - hw/virtio/virtio-config-io.c | 1 - hw/virtio/virtio-pci.c | 1 + hw/virtio/virtio.c | 2 +- hw/vmapple/virtio-blk.c | 1 - system/memory.c | 1 + system/qtest.c | 1 + target-info-qom.c | 24 ++++++++ target-info-stub.c | 3 + target-info.c | 33 +++++++++++ target/arm/arm-qmp-cmds.c | 3 +- target/arm/cpu.c | 1 - target/arm/machine.c | 12 ++++ target/i386/tcg/system/excp_helper.c | 1 - target/i386/xsave_helper.c | 1 - target/loongarch/loongarch-qmp-cmds.c | 3 +- target/mips/system/mips-qmp-cmds.c | 3 +- target/riscv/vector_helper.c | 1 - tests/tcg/plugins/mem.c | 1 + hw/block/meson.build | 6 +- hw/virtio/meson.build | 20 ++++--- 59 files changed, 302 insertions(+), 149 deletions(-) create mode 100644 include/hw/arm/machines-qom.h create mode 100644 include/qemu/target-info-qapi.h create mode 100644 target-info-qom.cSignature · 1 line
2.49.0
Quoted 9 lines · Michael S. Tsirkin
Quoted 7 lines · Philippe Mathieu-Daudé
Rather than re-spinning the whole "single-binary: Make hw/arm/ common" series, restrict to the API additions, but include examples of their usefulness (hundreds of virtio objects removed from default Linux build).
Time passed since I context-switched out of this work so I'm not sure theDEFINE_MACHINE_WITH_INTERFACES()implementation is in the form Zoltan asked.
Quoted 4 lines
I think I'd prefer to defer cleanups to post 10.1 - already too much on my plate as I was out sick. Unless there's a reason I'm missing to rush this in? Is there a feature we want in 10.1 that depends on it?
This is all part of reducing the number of duplicate builds of device models which after the stubs VirtIO is the main remaining sub-system due for clean-up:
➜ ./.gitlab-ci.d/check-units.py ./builds/system/compile_commands.json -n 80 Total source files: 3595
Total build units: 5658
Most rebuilt units:
../../dump/win_dump.c built 29 times
../../cpu-target.c built 29 times
../../system/arch_init.c built 29 times
../../system/globals-target.c built 29 times
../../page-target.c built 29 times
../../page-vary-target.c built 29 times
../../target-info-stub.c built 29 times
../../migration/ram.c built 29 times
../../migration/target.c built 29 times
../../monitor/hmp-cmds-target.c built 29 times
../../monitor/hmp-target.c built 29 times
../../accel/accel-target.c built 29 times
../../accel/stubs/hvf-stub.c built 29 times
../../accel/stubs/nvmm-stub.c built 29 times
../../accel/stubs/whpx-stub.c built 29 times
../../accel/qtest/qtest.c built 29 times
../../system/main.c built 29 times
../../hw/i386/kvm/xen-stubs.c built 27 times
../../accel/stubs/xen-stub.c built 27 times
../../accel/stubs/kvm-stub.c built 27 times
../../hw/9pfs/virtio-9p-device.c built 23 times
../../hw/block/virtio-blk.c built 23 times
../../hw/block/virtio-blk-common.c built 23 times
../../hw/char/virtio-serial-bus.c built 23 times
../../hw/net/virtio-net.c built 23 times
../../hw/scsi/virtio-scsi.c built 23 times
../../hw/scsi/vhost-scsi-common.c built 23 times
../../hw/virtio/virtio.c built 23 times
../../hw/virtio/virtio-config-io.c built 23 times
../../hw/virtio/virtio-qmp.c built 23 times
../../hw/virtio/vhost-backend.c built 23 times
../../hw/virtio/vhost-iova-tree.c built 23 times
../../hw/virtio/vhost-user.c built 23 times
../../hw/virtio/vhost-shadow-virtqueue.c built 23 times
../../hw/virtio/virtio-balloon.c built 23 times
../../hw/virtio/vhost-user-fs.c built 23 times
../../hw/virtio/vhost-vsock.c built 23 times
../../hw/virtio/vhost-user-vsock.c built 23 times
../../hw/virtio/virtio-rng.c built 23 times
../../hw/block/vhost-user-blk.c built 22 times
../../hw/vfio/listener.c built 22 times
../../hw/vfio/container-base.c built 22 times
../../hw/vfio/container.c built 22 times
../../hw/vfio/helpers.c built 22 times
../../hw/vfio/pci-quirks.c built 22 times
../../hw/vfio/pci.c built 22 times
../../hw/virtio/vhost-vsock-pci.c built 22 times
../../hw/virtio/vhost-user-vsock-pci.c built 22 times
../../hw/virtio/vhost-user-blk-pci.c built 22 times
../../hw/virtio/vhost-user-scsi-pci.c built 22 times
../../hw/virtio/vhost-scsi-pci.c built 22 times
../../hw/virtio/vhost-user-fs-pci.c built 22 times
../../hw/virtio/virtio-crypto-pci.c built 22 times
../../hw/virtio/virtio-input-host-pci.c built 22 times
../../hw/virtio/virtio-input-pci.c built 22 times
../../hw/virtio/virtio-rng-pci.c built 22 times
../../hw/virtio/virtio-balloon-pci.c built 22 times
../../hw/virtio/virtio-9p-pci.c built 22 times
../../hw/virtio/virtio-scsi-pci.c built 22 times
../../hw/virtio/virtio-blk-pci.c built 22 times
../../hw/virtio/virtio-net-pci.c built 22 times
../../hw/virtio/virtio-serial-pci.c built 22 times
../../hw/virtio/virtio-iommu-pci.c built 22 times
../../hw/virtio/vdpa-dev-pci.c built 22 times
../../tests/unit/iothread.c built 16 times
../../hw/nvram/fw_cfg-acpi.c built 13 times
../../semihosting/guestfd.c built 11 times
../../semihosting/syscalls.c built 11 times
../../tests/qtest/tpm-emu.c built 8 times
../../hw/vfio/platform.c built 7 times
../../tests/qtest/tpm-util.c built 7 times
../../tests/qtest/tpm-tests.c built 7 times
../../hw/virtio/virtio-mem.c built 5 times
../../hw/virtio/virtio-mem-pci.c built 5 times
../../hw/virtio/virtio-md-pci.c built 5 times
../../tests/unit/socket-helpers.c built 5 times
../../tests/unit/io-channel-helpers.c built 5 times
../../fpu/softfloat.c built 4 times
../../semihosting/arm-compat-semi.c built 4 times
../../target/mips/system/addr.c built 4 timesAside from reducing build times and overall load on the CI systems its required to advance the single-binary QEMU build and get us closer to being able to do proper heterogeneous emulation.
I don't think missing 10.1 would be critical for the single binary proof of concept but obviously as with all changes that touch the whole code base the longer the review takes the more time they spend in re-base hell.
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Quoted 10 lines · Michael S. Tsirkin
Quoted 7 lines · Philippe Mathieu-Daudé
Rather than re-spinning the whole "single-binary: Make hw/arm/ common" series, restrict to the API additions, but include examples of their usefulness (hundreds of virtio objects removed from default Linux build).
Time passed since I context-switched out of this work so I'm not sure theDEFINE_MACHINE_WITH_INTERFACES()implementation is in the form Zoltan asked.
Quoted 4 lines
I think I'd prefer to defer cleanups to post 10.1 - already too much on my plate as I was out sick. Unless there's a reason I'm missing to rush this in? Is there a feature we want in 10.1 that depends on it?
Fair enough for the virtio patch.
Hopefully the previous ones (TargetInfo related, not touching virtio) could get in (you don't have to look a them ;P).
Quoted 10 lines
Quoted 10 lines
Philippe Mathieu-Daudé (14):
target/qmp: Usetarget_cpu_type()
qemu/target-info: Factortarget_arch()out qemu/target-info: Add %target_arch field to TargetInfo qemu/target-info: Introducetarget_base_arch()qemu/target-info: Addtarget_endian_mode()
qemu: Converttarget_words_bigendian()to TargetInfo API gdbstub/helpers: ReplaceTARGET_BIG_ENDIAN->target_big_endian()
qemu: Declare all load/store helpert in 'qemu/bswap.h'
Quoted 7 lines · Philippe Mathieu-Daudé
Rather than re-spinning the whole "single-binary: Make hw/arm/ common" series, restrict to the API additions, but include examples of their usefulness (hundreds of virtio objects removed from default Linux build).
Time passed since I context-switched out of this work so I'm not sure theDEFINE_MACHINE_WITH_INTERFACES()implementation is in the form Zoltan asked.
I've sent the patch here:
https://patchew.org/QEMU/[email protected]/3c2aa5b895adbb5244b643a6672603d65dce4298.1751494995.git.balaton@eik.bme.hu/
that will hopefully be merged before the freeze so you can rebase on that.
Regards,
BALATON Zoltan
Quoted 81 lines
Philippe Mathieu-Daudé (14):
target/qmp: Usetarget_cpu_type()
qemu/target-info: Factortarget_arch()out qemu/target-info: Add %target_arch field to TargetInfo qemu/target-info: Introducetarget_base_arch()qemu/target-info: Addtarget_endian_mode()
qemu: Converttarget_words_bigendian()to TargetInfo API gdbstub/helpers: ReplaceTARGET_BIG_ENDIAN->target_big_endian()
qemu: Declare all load/store helpert in 'qemu/bswap.h' hw/virtio: Build various files once hw/core/null-machine: Define machine as generic QOM type hw/arm: Register TYPE_TARGET_ARM/AARCH64_MACHINE QOM interfaces hw/core: Allow ARM/Aarch64 binaries to use the 'none' machine hw/boards: IntroduceDEFINE_MACHINE_WITH_INTERFACES()macro hw/arm: Add DEFINE_MACHINE_[ARM_]AARCH64() macrosmeson.build | 1 + include/exec/tswap.h | 83 +-------------------------- include/gdbstub/helpers.h | 15 ++--- include/hw/arm/machines-qom.h | 31 ++++++++++ include/hw/boards.h | 6 +- include/qemu/bswap.h | 73 +++++++++++++++++++++++ include/qemu/target-info-impl.h | 8 ++- include/qemu/target-info-qapi.h | 36 ++++++++++++ include/qemu/target-info.h | 10 +++- include/system/memory.h | 1 - include/user/abitypes.h | 1 - target/ppc/mmu-hash64.h | 2 - cpu-target.c | 7 --- hw/acpi/bios-linker-loader.c | 2 - hw/arm/allwinner-r40.c | 1 - hw/arm/boot.c | 2 + hw/arm/npcm7xx.c | 2 +- hw/block/hd-geometry.c | 1 - hw/char/riscv_htif.c | 1 - hw/core/cpu-system.c | 2 +- hw/core/machine-qmp-cmds.c | 8 +-- hw/core/null-machine.c | 20 ++++++- hw/cxl/cxl-events.c | 2 - hw/display/artist.c | 1 + hw/display/ati.c | 1 + hw/display/vga.c | 2 +- hw/net/can/ctucan_core.c | 1 - hw/net/lan9118.c | 1 + hw/net/rtl8139.c | 1 + hw/net/vmxnet3.c | 1 - hw/pci-host/gt64120.c | 1 + hw/pci-host/pnv_phb3.c | 1 + hw/pci-host/pnv_phb4.c | 1 + hw/pci-host/ppce500.c | 1 - hw/pci-host/sh_pci.c | 1 - hw/s390x/s390-pci-inst.c | 1 + hw/sensor/lsm303dlhc_mag.c | 1 - hw/smbios/smbios.c | 1 + hw/vfio/migration-multifd.c | 1 - hw/virtio/virtio-config-io.c | 1 - hw/virtio/virtio-pci.c | 1 + hw/virtio/virtio.c | 2 +- hw/vmapple/virtio-blk.c | 1 - system/memory.c | 1 + system/qtest.c | 1 + target-info-qom.c | 24 ++++++++ target-info-stub.c | 3 + target-info.c | 33 +++++++++++ target/arm/arm-qmp-cmds.c | 3 +- target/arm/cpu.c | 1 - target/arm/machine.c | 12 ++++ target/i386/tcg/system/excp_helper.c | 1 - target/i386/xsave_helper.c | 1 - target/loongarch/loongarch-qmp-cmds.c | 3 +- target/mips/system/mips-qmp-cmds.c | 3 +- target/riscv/vector_helper.c | 1 - tests/tcg/plugins/mem.c | 1 + hw/block/meson.build | 6 +- hw/virtio/meson.build | 20 ++++--- 59 files changed, 302 insertions(+), 149 deletions(-)create mode 100644
include/hw/arm/machines-qom.hcreate mode 100644include/qemu/target-info-qapi.hcreate mode 100644target-info-qom.c
Quoted 8 lines · Philippe Mathieu-Daudé
Rather than re-spinning the whole "single-binary: Make hw/arm/ common" series, restrict to the API additions, but include examples of their usefulness (hundreds of virtio objects removed from default Linux build).
Time passed since I context-switched out of this work so I'm not sure theDEFINE_MACHINE_WITH_INTERFACES()implementation is in the form Zoltan asked.
Quoted 10 lines
Philippe Mathieu-Daudé (14):
target/qmp: Usetarget_cpu_type()
qemu/target-info: Factortarget_arch()out qemu/target-info: Add %target_arch field to TargetInfo qemu/target-info: Introducetarget_base_arch()qemu/target-info: Addtarget_endian_mode()
qemu: Converttarget_words_bigendian()to TargetInfo API gdbstub/helpers: ReplaceTARGET_BIG_ENDIAN->target_big_endian()
qemu: Declare all load/store helpert in 'qemu/bswap.h' hw/virtio: Build various files once
Sorry, I cut this branch incorrectly, I should have posted only up to here, as the rest isn't required. I'll respin for clarity.
Quoted 5 lines
hw/core/null-machine: Define machine as generic QOM type hw/arm: Register TYPE_TARGET_ARM/AARCH64_MACHINE QOM interfaces hw/core: Allow ARM/Aarch64 binaries to use the 'none' machine hw/boards: Introduce
DEFINE_MACHINE_WITH_INTERFACES()macro hw/arm: Add DEFINE_MACHINE_[ARM_]AARCH64() macros