target-info: Add more API for VirtIO cleanups
v8 cover target-info: Add more API for VirtIO cleanups
Missing review: #6 (gdbstub)
Since v7:
- Fixed e.g. typo
- Keep "do *not* use target_big_endian()" warning
- Do not use tswap() in gdbstub
Since v6:
- Added R-b tags
- Fixed typos
- Dropped "Introduce target_base_arch()" because unused so far
- Dropped unrelated patches
Philippe Mathieu-Daudé (8):
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: 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 helper in 'qemu/bswap.h' hw/virtio: Build various files once
include/exec/tswap.h | 83 +-------------------------- include/gdbstub/helpers.h | 48 ++++++++++------ include/qemu/bswap.h | 73 +++++++++++++++++++++++ include/qemu/target-info-impl.h | 6 +- include/qemu/target-info-qapi.h | 29 ++++++++++ include/qemu/target-info.h | 14 ++++- 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/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-stub.c | 2 + target-info.c | 23 ++++++++ target/arm/arm-qmp-cmds.c | 3 +- target/arm/cpu.c | 1 - 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 ++++--- 53 files changed, 218 insertions(+), 156 deletions(-) create mode 100644 include/qemu/target-info-qapi.h
Signature · 1 line
2.49.0
PATCH RESEND v8 1/8 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
PATCH RESEND v8 2/8 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 (e.g. 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
PATCH RESEND v8 3/8 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 RESEND v8 4/8 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
@@ -22,6 +22,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" /**
@@ -18,4 +19,11 @@*/ SysEmuTarget target_arch (void ); +/** +* target_endian_mode: +* +* Returns: QAPI EndianMode enum (e.g. ENDIAN_MODE_LITTLE). +*/ +EndianMode target_endian_mode (void ); +#endif
target-info-stub.c +1 -0
@@ -18,6 +18,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
@@ -42,3 +42,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 RESEND v8 5/8 qemu: Convert target_words_bigendian() to TargetInfo API
In reply to Philippe Mathieu-Daudé--- include/exec/tswap.h | 13 +------------ include/qemu/target-info.h | 12 ++++++++++++ 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, 23 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 +12 -0
@@ -38,4 +38,16 @@ 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. +* +* 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 ); +#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
@@ -47,3 +47,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 RESEND v8 6/8 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. Use cpu_to_[be,le]XX() from "qemu/bswap.h" instead of tswapXX() from "exec/tswap.h".
--- include/gdbstub/helpers.h | 48 +++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 19 deletions(-)
include/gdbstub/helpers.h +29 -19
@@ -16,7 +16,8 @@#error "gdbstub helpers should only be included by target specific code"#endif -#include "exec/tswap.h" +#include "qemu/bswap.h" +#include "qemu/target-info.h" #include "cpu-param.h" /*
@@ -33,40 +34,49 @@ static inline int gdb_get_reg8(GByteArray *buf, uint8_t val)static inline int gdb_get_reg16 (GByteArray *buf,uint16_t val) { -uint16_t to_word =tswap16 (val); -g_byte_array_append (buf, (uint8_t *) &to_word,2 ); +if (target_big_endian ()) { +cpu_to_be16s (&val); + }else { +cpu_to_le16s (&val); + } +g_byte_array_append (buf, (uint8_t *) &val,2 );return 2 ; }static inline int gdb_get_reg32 (GByteArray *buf,uint32_t val) { -uint32_t to_long =tswap32 (val); -g_byte_array_append (buf, (uint8_t *) &to_long,4 ); +if (target_big_endian ()) { +cpu_to_be32s (&val); + }else { +cpu_to_le32s (&val); + } +g_byte_array_append (buf, (uint8_t *) &val,4 );return 4 ; }static inline int gdb_get_reg64 (GByteArray *buf,uint64_t val) { -uint64_t to_quad =tswap64 (val); -g_byte_array_append (buf, (uint8_t *) &to_quad,8 ); +if (target_big_endian ()) { +cpu_to_be64s (&val); + }else { +cpu_to_le64s (&val); + } +g_byte_array_append (buf, (uint8_t *) &val,8 );return 8 ; }static inline int gdb_get_reg128 (GByteArray *buf,uint64_t val_hi,uint64_t val_lo) { -uint64_t to_quad; -#if TARGET_BIG_ENDIAN - to_quad =tswap64 (val_hi); -g_byte_array_append (buf, (uint8_t *) &to_quad,8 ); - to_quad =tswap64 (val_lo); -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 +uint64_t tmp[2 ]; +if (target_big_endian ()) { + tmp[0 ] =cpu_to_be64 (val_hi); + tmp[1 ] =cpu_to_be64 (val_lo); + }else { + tmp[0 ] =cpu_to_le64 (val_lo); + tmp[1 ] =cpu_to_le64 (val_hi); + } +g_byte_array_append (buf, (uint8_t *)&tmp,16 );return 16 ; }
Signature · 1 line
2.49.0
Re: [PATCH-for-10.1 RESEND v8 6/8] gdbstub/helpers: Replace TARGET_BIG_ENDIAN -> target_big_endian()
Quoted 26 lines · Philippe Mathieu-Daudé
Check endianness at runtime to remove the target-specific
TARGET_BIG_ENDIANdefinition. Use cpu_to_[be,le]XX() from "qemu/bswap.h" instead oftswapXX()from "exec/tswap.h".Suggested-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/gdbstub/helpers.h | 48 +++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 19 deletions(-)include/gdbstub/helpers.h +2
-1@@ -16,7 +16,8 @@#error "gdbstub helpers should only be included by target specific code"#endif -#include "exec/tswap.h" +#include "qemu/bswap.h" +#include "qemu/target-info.h" #include "cpu-param.h" /*
include/gdbstub/helpers.h static inline int gdb_get_reg8(GByteArray *buf, uint8_t val) · line 38
Quoted 7 lines
include/gdbstub/helpers.h +2
-2@@ -33,40 +34,49 @@ static inline int gdb_get_reg8(GByteArray *buf, uint8_t val)static inline int gdb_get_reg16 (GByteArray *buf,uint16_t val) { -uint16_t to_word =tswap16 (val); -g_byte_array_append (buf, (uint8_t *) &to_word,2 ); +if (target_big_endian ()) { +cpu_to_be16s (&val);
Unrelated, but that 's' in 'cpu_to_be16s' is non-obvious, I always think it's about signedness which is unrelated to endianness. I guess it stands for "specified". It's more intuitive to call by-value functions 'into' and by-ref 'to' maybe? e.g. uint16_t cpu_into_le16(uint16_t v); and void cpu_to_le16(uint16_t *v);.
Quoted 61 lines
include/gdbstub/helpers.h +25
-17+ }else { +cpu_to_le16s (&val); + } +g_byte_array_append (buf, (uint8_t *) &val,2 );return 2 ; }static inline int gdb_get_reg32 (GByteArray *buf,uint32_t val) { -uint32_t to_long =tswap32 (val); -g_byte_array_append (buf, (uint8_t *) &to_long,4 ); +if (target_big_endian ()) { +cpu_to_be32s (&val); + }else { +cpu_to_le32s (&val); + } +g_byte_array_append (buf, (uint8_t *) &val,4 );return 4 ; }static inline int gdb_get_reg64 (GByteArray *buf,uint64_t val) { -uint64_t to_quad =tswap64 (val); -g_byte_array_append (buf, (uint8_t *) &to_quad,8 ); +if (target_big_endian ()) { +cpu_to_be64s (&val); + }else { +cpu_to_le64s (&val); + } +g_byte_array_append (buf, (uint8_t *) &val,8 );return 8 ; }static inline int gdb_get_reg128 (GByteArray *buf,uint64_t val_hi,uint64_t val_lo) { -uint64_t to_quad; -#if TARGET_BIG_ENDIAN - to_quad =tswap64 (val_hi); -g_byte_array_append (buf, (uint8_t *) &to_quad,8 ); - to_quad =tswap64 (val_lo); -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 +uint64_t tmp[2 ]; +if (target_big_endian ()) { + tmp[0 ] =cpu_to_be64 (val_hi); + tmp[1 ] =cpu_to_be64 (val_lo); + }else { + tmp[0 ] =cpu_to_le64 (val_lo); + tmp[1 ] =cpu_to_le64 (val_hi); + } +g_byte_array_append (buf, (uint8_t *)&tmp,16 );return 16 ; } --
Quoted 2 lines
2.49.0
PATCH RESEND v8 7/8 qemu: Declare all load/store helper 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
PATCH RESEND v8 8/8 hw/virtio: Build various files once
In reply to Philippe Mathieu-DaudéNow that 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