* [PATCH 0/5] target_info optimizations
@ 2026-05-11 19:06 Richard Henderson
2026-05-11 19:06 ` [PATCH 1/5] meson: Build target-info-qom.c with -fno-lto Richard Henderson
` (5 more replies)
0 siblings, 6 replies; 14+ messages in thread
From: Richard Henderson @ 2026-05-11 19:06 UTC (permalink / raw)
To: qemu-devel; +Cc: pierrick.bouvier, philmd
Based-on: 20260509005453.3984184-1-pierrick.bouvier@oss.qualcomm.com
("[PATCH v5 0/6] single-binary: deduplicate target_info()")
Allow TargetInfo accesses to resolve to a direct structure access.
Arrange for the structure to appear const to the majority of qemu.
For user-only, the structure actually is const; for system, the
structure is initialized early.
r~
Richard Henderson (5):
meson: Build target-info-qom.c with -fno-lto
target-info: Expose target_info as const data
target-info: Merge target-info-impl.h into target-info.h
target-info: Merge target-info-qapi.h into target-info.h
target-info: Inline accessors
include/qemu/target-info-impl.h | 44 -----------
include/qemu/target-info-init.h | 45 ++++++++---
include/qemu/target-info-qapi.h | 29 -------
include/qemu/target-info-qom.h | 2 +-
include/qemu/target-info.h | 123 +++++++++++++++++++++++++++---
configs/targets/aarch64-softmmu.c | 18 +----
configs/targets/arm-softmmu.c | 18 +----
hw/core/machine-qmp-cmds.c | 1 -
hw/uefi/ovmf-log.c | 2 +-
hw/virtio/virtio-mem.c | 2 +-
page-vary-common.c | 10 +--
page-vary-system.c | 8 +-
system/arch_init.c | 2 +-
target-info-qom.c | 13 ++--
target-info-stub.c | 27 +------
target-info.c | 95 -----------------------
meson.build | 13 ++--
17 files changed, 179 insertions(+), 273 deletions(-)
delete mode 100644 include/qemu/target-info-impl.h
delete mode 100644 include/qemu/target-info-qapi.h
delete mode 100644 target-info.c
--
2.43.0
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/5] meson: Build target-info-qom.c with -fno-lto
2026-05-11 19:06 [PATCH 0/5] target_info optimizations Richard Henderson
@ 2026-05-11 19:06 ` Richard Henderson
2026-05-11 19:38 ` Pierrick Bouvier
2026-05-11 19:06 ` [PATCH 2/5] target-info: Expose target_info as const data Richard Henderson
` (4 subsequent siblings)
5 siblings, 1 reply; 14+ messages in thread
From: Richard Henderson @ 2026-05-11 19:06 UTC (permalink / raw)
To: qemu-devel; +Cc: pierrick.bouvier, philmd
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
meson.build | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/meson.build b/meson.build
index 5fbdc75a0f..9a804dc810 100644
--- a/meson.build
+++ b/meson.build
@@ -3852,20 +3852,24 @@ subdir('system')
# without lto, not even the alias is required -- we simply use different
# declarations in different compilation units.
pagevary = files('page-vary-common.c')
+tinfoqom = files('target-info-qom.c')
if get_option('b_lto')
- pagevary_flags = ['-fno-lto']
+ nolto_flags = ['-fno-lto']
if get_option('cfi')
- pagevary_flags += '-fno-sanitize=cfi-icall'
+ nolto_flags += '-fno-sanitize=cfi-icall'
endif
pagevary = static_library('page-vary-common', sources: pagevary + genh,
- c_args: pagevary_flags)
+ c_args: nolto_flags)
pagevary = declare_dependency(link_with: pagevary)
+ tinfoqom = static_library('target-info-qom', sources: tinfoqom + genh,
+ c_args: nolto_flags)
+ tinfoqom = declare_dependency(link_with: tinfoqom)
endif
common_ss.add(pagevary)
system_ss.add(files('page-vary-system.c'))
common_ss.add(files('target-info.c'))
-system_ss.add(files('target-info-qom.c'))
+system_ss.add(tinfoqom)
subdir('backends')
subdir('configs/targets')
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/5] target-info: Expose target_info as const data
2026-05-11 19:06 [PATCH 0/5] target_info optimizations Richard Henderson
2026-05-11 19:06 ` [PATCH 1/5] meson: Build target-info-qom.c with -fno-lto Richard Henderson
@ 2026-05-11 19:06 ` Richard Henderson
2026-05-12 2:22 ` Pierrick Bouvier
2026-05-11 19:06 ` [PATCH 3/5] target-info: Merge target-info-impl.h into target-info.h Richard Henderson
` (3 subsequent siblings)
5 siblings, 1 reply; 14+ messages in thread
From: Richard Henderson @ 2026-05-11 19:06 UTC (permalink / raw)
To: qemu-devel; +Cc: pierrick.bouvier, philmd
Expose a const TargetInfo structure instead of a function
returning a const pointer.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/target-info-impl.h | 11 ++++----
include/qemu/target-info-init.h | 45 ++++++++++++++++++++++---------
configs/targets/aarch64-softmmu.c | 18 +++----------
configs/targets/arm-softmmu.c | 18 +++----------
page-vary-common.c | 8 ++----
page-vary-system.c | 6 ++---
target-info-qom.c | 11 +++-----
target-info-stub.c | 28 ++++---------------
target-info.c | 12 ++++-----
9 files changed, 65 insertions(+), 92 deletions(-)
diff --git a/include/qemu/target-info-impl.h b/include/qemu/target-info-impl.h
index c917d546ea..df94af4ef3 100644
--- a/include/qemu/target-info-impl.h
+++ b/include/qemu/target-info-impl.h
@@ -34,11 +34,10 @@ typedef struct TargetInfo {
bool page_bits_vary;
} TargetInfo;
-/**
- * target_info:
- *
- * Returns: The TargetInfo structure definition for this target binary.
- */
-const TargetInfo *target_info(void);
+extern
+#ifndef NONCONST_TARGET_INFO
+const
+#endif
+TargetInfo target_info;
#endif
diff --git a/include/qemu/target-info-init.h b/include/qemu/target-info-init.h
index a539d14d78..a70edeac21 100644
--- a/include/qemu/target-info-init.h
+++ b/include/qemu/target-info-init.h
@@ -20,30 +20,51 @@ static void register_##info(void) \
module_init(register_##info, MODULE_INIT_TARGET_INFO)
#ifdef COMPILING_PER_TARGET
+
+#ifndef TARGET_PAGE_BITS_VARY
+# define DEF_TARGET_INFO_PB \
+ .page_bits_init = TARGET_PAGE_BITS
+#elif defined(TARGET_PAGE_BITS_LEGACY)
+# define DEF_TARGET_INFO_PB \
+ .page_bits_vary = true, .page_bits_init = TARGET_PAGE_BITS_LEGACY
+#else
+# define DEF_TARGET_INFO_PB \
+ .page_bits_vary = true
+#endif
+
+#define DEF_TARGET_INFO_VAR(DECL, TYPE, MACHINE) \
+const TargetInfo DECL = { \
+ .target_name = TARGET_NAME, \
+ .target_arch = glue(SYS_EMU_TARGET_, TARGET_ARCH), \
+ .long_bits = TARGET_LONG_BITS, \
+ .cpu_type = TYPE, \
+ .machine_typename = MACHINE, \
+ .endianness = TARGET_BIG_ENDIAN ? ENDIAN_MODE_BIG : ENDIAN_MODE_LITTLE, \
+ DEF_TARGET_INFO_PB, \
+};
+
#ifdef CONFIG_USER_ONLY
/*
* User mode does not support multiple targets in the same binary, so just
* define target_info().
*/
-#define target_info_init(ti_var) \
-const TargetInfo *target_info(void) \
-{ \
- return &ti_var; \
-}
+#define DEF_TARGET_INFO(DECL, TYPE, MACHINE) \
+ DEF_TARGET_INFO_VAR(target_info, TYPE, MACHINE)
#else /* CONFIG_USER_ONLY */
#include "qemu/target-info-qom.h"
#include "qom/object.h"
-#define target_info_init(ti_var) \
-static const TypeInfo ti_var##_type_info = { \
- .name = TYPE_TARGET_INFO"-"TARGET_NAME, \
- .parent = TYPE_TARGET_INFO, \
- .class_data = &ti_var, \
-}; \
-DEFINE_TARGET_INFO_TYPE(ti_var##_type_info)
+#define DEF_TARGET_INFO(DECL, TYPE, MACHINE) \
+ static DEF_TARGET_INFO_VAR(DECL, TYPE, MACHINE) \
+ static const TypeInfo DECL##_type_info = { \
+ .name = TYPE_TARGET_INFO"-"TARGET_NAME, \
+ .parent = TYPE_TARGET_INFO, \
+ .class_data = &DECL, \
+ }; \
+ DEFINE_TARGET_INFO_TYPE(DECL##_type_info)
#endif /* CONFIG_USER_ONLY */
#endif /* COMPILING_PER_TARGET */
diff --git a/configs/targets/aarch64-softmmu.c b/configs/targets/aarch64-softmmu.c
index 75d95b0e74..4f43f3e89a 100644
--- a/configs/targets/aarch64-softmmu.c
+++ b/configs/targets/aarch64-softmmu.c
@@ -7,21 +7,11 @@
*/
#include "qemu/osdep.h"
-#include "qemu/target-info-impl.h"
-#include "qemu/target-info-init.h"
#include "hw/arm/machines-qom.h"
#include "target/arm/cpu-qom.h"
#include "target/arm/cpu-param.h"
+#include "qemu/target-info-impl.h"
+#include "qemu/target-info-init.h"
-static const TargetInfo target_info_aarch64_system = {
- .target_name = "aarch64",
- .target_arch = SYS_EMU_TARGET_AARCH64,
- .long_bits = 64,
- .cpu_type = TYPE_ARM_CPU,
- .machine_typename = TYPE_TARGET_AARCH64_MACHINE,
- .endianness = ENDIAN_MODE_LITTLE,
- .page_bits_vary = true,
- .page_bits_init = TARGET_PAGE_BITS_LEGACY,
-};
-
-target_info_init(target_info_aarch64_system)
+DEF_TARGET_INFO(target_info_aarch64_system,
+ TYPE_ARM_CPU, TYPE_TARGET_AARCH64_MACHINE)
diff --git a/configs/targets/arm-softmmu.c b/configs/targets/arm-softmmu.c
index 73546fa573..8272ce58fd 100644
--- a/configs/targets/arm-softmmu.c
+++ b/configs/targets/arm-softmmu.c
@@ -7,21 +7,11 @@
*/
#include "qemu/osdep.h"
-#include "qemu/target-info-impl.h"
-#include "qemu/target-info-init.h"
#include "hw/arm/machines-qom.h"
#include "target/arm/cpu-qom.h"
#include "target/arm/cpu-param.h"
+#include "qemu/target-info-impl.h"
+#include "qemu/target-info-init.h"
-static const TargetInfo target_info_arm_system = {
- .target_name = "arm",
- .target_arch = SYS_EMU_TARGET_ARM,
- .long_bits = 32,
- .cpu_type = TYPE_ARM_CPU,
- .machine_typename = TYPE_TARGET_ARM_MACHINE,
- .endianness = ENDIAN_MODE_LITTLE,
- .page_bits_vary = true,
- .page_bits_init = TARGET_PAGE_BITS_LEGACY,
-};
-
-target_info_init(target_info_arm_system)
+DEF_TARGET_INFO(target_info_arm_system,
+ TYPE_ARM_CPU, TYPE_TARGET_ARM_MACHINE)
diff --git a/page-vary-common.c b/page-vary-common.c
index ddd0863378..b4e8cdf405 100644
--- a/page-vary-common.c
+++ b/page-vary-common.c
@@ -29,10 +29,8 @@ TargetPageBits target_page;
bool set_preferred_target_page_bits(int bits)
{
- const TargetInfo *ti = target_info();
-
assert(bits >= TARGET_PAGE_BITS_MIN);
- if (ti->page_bits_vary) {
+ if (target_info.page_bits_vary) {
/*
* The target page size is the lowest common denominator for all
@@ -55,9 +53,7 @@ void finalize_target_page_bits(void)
int bits = target_page.bits;
if (bits == 0) {
- const TargetInfo *ti = target_info();
-
- bits = ti->page_bits_init;
+ bits = target_info.page_bits_init;
assert(bits != 0);
target_page.bits = bits;
}
diff --git a/page-vary-system.c b/page-vary-system.c
index 6c49c10e23..b2a1c45deb 100644
--- a/page-vary-system.c
+++ b/page-vary-system.c
@@ -26,8 +26,6 @@ QEMU_BUILD_BUG_ON(TLB_FLAGS_MASK & ((1u < TARGET_PAGE_BITS_MIN) - 1));
int migration_legacy_page_bits(void)
{
- const TargetInfo *ti = target_info();
-
- assert(ti->page_bits_init >= TARGET_PAGE_BITS_MIN);
- return ti->page_bits_init;
+ assert(target_info.page_bits_init >= TARGET_PAGE_BITS_MIN);
+ return target_info.page_bits_init;
}
diff --git a/target-info-qom.c b/target-info-qom.c
index 52dfc8aee4..abaf7507a0 100644
--- a/target-info-qom.c
+++ b/target-info-qom.c
@@ -6,6 +6,8 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/
+#define NONCONST_TARGET_INFO
+
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qom/object.h"
@@ -44,12 +46,7 @@ static const TypeInfo target_info_parent_type = {
DEFINE_TARGET_INFO_TYPE(target_info_parent_type)
-static const TargetInfo *target_info_ptr;
-
-const TargetInfo *target_info(void)
-{
- return target_info_ptr;
-}
+TargetInfo target_info;
void target_info_qom_set_target(void)
{
@@ -62,5 +59,5 @@ void target_info_qom_set_target(void)
"more than one target-info is available");
}
- target_info_ptr = TARGET_INFO_CLASS(targets->data)->target_info;
+ target_info = *TARGET_INFO_CLASS(targets->data)->target_info;
}
diff --git a/target-info-stub.c b/target-info-stub.c
index 22b7911201..813d562058 100644
--- a/target-info-stub.c
+++ b/target-info-stub.c
@@ -7,13 +7,13 @@
*/
#include "qemu/osdep.h"
+#include "cpu.h"
+#include "hw/core/boards.h"
+#include "exec/cpu-defs.h"
+#include "exec/page-vary.h"
#include "qemu/target-info.h"
#include "qemu/target-info-impl.h"
#include "qemu/target-info-init.h"
-#include "hw/core/boards.h"
-#include "cpu.h"
-#include "exec/cpu-defs.h"
-#include "exec/page-vary.h"
/* Validate correct placement of CPUArchState. */
QEMU_BUILD_BUG_ON(offsetof(ArchCPU, parent_obj) != 0);
@@ -24,22 +24,4 @@ QEMU_BUILD_BUG_ON(offsetof(ArchCPU, env) != sizeof(CPUState));
QEMU_BUILD_BUG_ON(TARGET_PAGE_BITS < TARGET_PAGE_BITS_MIN);
#endif
-static const TargetInfo target_info_stub = {
- .target_name = TARGET_NAME,
- .target_arch = glue(SYS_EMU_TARGET_, TARGET_ARCH),
- .long_bits = TARGET_LONG_BITS,
- .cpu_type = CPU_RESOLVING_TYPE,
- .machine_typename = TYPE_MACHINE,
- .endianness = TARGET_BIG_ENDIAN ? ENDIAN_MODE_BIG : ENDIAN_MODE_LITTLE,
-#ifdef TARGET_PAGE_BITS_VARY
- .page_bits_vary = true,
-# ifdef TARGET_PAGE_BITS_LEGACY
- .page_bits_init = TARGET_PAGE_BITS_LEGACY,
-# endif
-#else
- .page_bits_vary = false,
- .page_bits_init = TARGET_PAGE_BITS,
-#endif
-};
-
-target_info_init(target_info_stub)
+DEF_TARGET_INFO(target_info_stub, CPU_RESOLVING_TYPE, TYPE_MACHINE)
diff --git a/target-info.c b/target-info.c
index 28c458fc7a..6bd3f9485f 100644
--- a/target-info.c
+++ b/target-info.c
@@ -14,32 +14,32 @@
const char *target_name(void)
{
- return target_info()->target_name;
+ return target_info.target_name;
}
unsigned target_long_bits(void)
{
- return target_info()->long_bits;
+ return target_info.long_bits;
}
SysEmuTarget target_arch(void)
{
- return target_info()->target_arch;
+ return target_info.target_arch;
}
const char *target_cpu_type(void)
{
- return target_info()->cpu_type;
+ return target_info.cpu_type;
}
const char *target_machine_typename(void)
{
- return target_info()->machine_typename;
+ return target_info.machine_typename;
}
EndianMode target_endian_mode(void)
{
- return target_info()->endianness;
+ return target_info.endianness;
}
bool target_big_endian(void)
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 3/5] target-info: Merge target-info-impl.h into target-info.h
2026-05-11 19:06 [PATCH 0/5] target_info optimizations Richard Henderson
2026-05-11 19:06 ` [PATCH 1/5] meson: Build target-info-qom.c with -fno-lto Richard Henderson
2026-05-11 19:06 ` [PATCH 2/5] target-info: Expose target_info as const data Richard Henderson
@ 2026-05-11 19:06 ` Richard Henderson
2026-05-12 2:25 ` Pierrick Bouvier
2026-05-12 3:20 ` Philippe Mathieu-Daudé
2026-05-11 19:06 ` [PATCH 4/5] target-info: Merge target-info-qapi.h " Richard Henderson
` (2 subsequent siblings)
5 siblings, 2 replies; 14+ messages in thread
From: Richard Henderson @ 2026-05-11 19:06 UTC (permalink / raw)
To: qemu-devel; +Cc: pierrick.bouvier, philmd
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/target-info-impl.h | 43 -------------------------------
include/qemu/target-info-qom.h | 2 +-
include/qemu/target-info.h | 31 ++++++++++++++++++++++
configs/targets/aarch64-softmmu.c | 2 +-
configs/targets/arm-softmmu.c | 2 +-
page-vary-common.c | 2 +-
page-vary-system.c | 2 +-
target-info-qom.c | 2 +-
target-info-stub.c | 1 -
target-info.c | 1 -
10 files changed, 37 insertions(+), 51 deletions(-)
delete mode 100644 include/qemu/target-info-impl.h
diff --git a/include/qemu/target-info-impl.h b/include/qemu/target-info-impl.h
deleted file mode 100644
index df94af4ef3..0000000000
--- a/include/qemu/target-info-impl.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * QEMU TargetInfo structure definition
- *
- * Copyright (c) Linaro
- *
- * SPDX-License-Identifier: GPL-2.0-or-later
- */
-
-#ifndef QEMU_TARGET_INFO_IMPL_H
-#define QEMU_TARGET_INFO_IMPL_H
-
-#include "qapi/qapi-types-common.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 */
- const char *cpu_type;
- /* QOM typename machines for this binary must implement */
- const char *machine_typename;
- /* related to TARGET_BIG_ENDIAN definition */
- EndianMode endianness;
- /*
- * runtime equivalent of
- * TARGET_PAGE_BITS_VARY ? TARGET_PAGE_BITS_LEGACY : TARGET_PAGE_BITS
- */
- unsigned page_bits_init;
- /* runtime equivalent of TARGET_PAGE_BITS_VARY definition */
- bool page_bits_vary;
-} TargetInfo;
-
-extern
-#ifndef NONCONST_TARGET_INFO
-const
-#endif
-TargetInfo target_info;
-
-#endif
diff --git a/include/qemu/target-info-qom.h b/include/qemu/target-info-qom.h
index 91be415ed3..fedb1a2914 100644
--- a/include/qemu/target-info-qom.h
+++ b/include/qemu/target-info-qom.h
@@ -9,7 +9,7 @@
#ifndef QEMU_TARGET_INFO_QOM_H
#define QEMU_TARGET_INFO_QOM_H
-#include "qemu/target-info-impl.h"
+#include "qemu/target-info.h"
#include "qom/object.h"
#define TYPE_TARGET_INFO "target-info"
diff --git a/include/qemu/target-info.h b/include/qemu/target-info.h
index 23c997de54..c9f7f2aa26 100644
--- a/include/qemu/target-info.h
+++ b/include/qemu/target-info.h
@@ -9,6 +9,37 @@
#ifndef QEMU_TARGET_INFO_H
#define QEMU_TARGET_INFO_H
+#include "qapi/qapi-types-common.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 */
+ const char *cpu_type;
+ /* QOM typename machines for this binary must implement */
+ const char *machine_typename;
+ /* related to TARGET_BIG_ENDIAN definition */
+ EndianMode endianness;
+ /*
+ * runtime equivalent of
+ * TARGET_PAGE_BITS_VARY ? TARGET_PAGE_BITS_LEGACY : TARGET_PAGE_BITS
+ */
+ unsigned page_bits_init;
+ /* runtime equivalent of TARGET_PAGE_BITS_VARY definition */
+ bool page_bits_vary;
+} TargetInfo;
+
+extern
+#ifndef NONCONST_TARGET_INFO
+const
+#endif
+TargetInfo target_info;
+
/**
* target_name:
*
diff --git a/configs/targets/aarch64-softmmu.c b/configs/targets/aarch64-softmmu.c
index 4f43f3e89a..f0631353ee 100644
--- a/configs/targets/aarch64-softmmu.c
+++ b/configs/targets/aarch64-softmmu.c
@@ -10,7 +10,7 @@
#include "hw/arm/machines-qom.h"
#include "target/arm/cpu-qom.h"
#include "target/arm/cpu-param.h"
-#include "qemu/target-info-impl.h"
+#include "qemu/target-info.h"
#include "qemu/target-info-init.h"
DEF_TARGET_INFO(target_info_aarch64_system,
diff --git a/configs/targets/arm-softmmu.c b/configs/targets/arm-softmmu.c
index 8272ce58fd..606b42befa 100644
--- a/configs/targets/arm-softmmu.c
+++ b/configs/targets/arm-softmmu.c
@@ -10,7 +10,7 @@
#include "hw/arm/machines-qom.h"
#include "target/arm/cpu-qom.h"
#include "target/arm/cpu-param.h"
-#include "qemu/target-info-impl.h"
+#include "qemu/target-info.h"
#include "qemu/target-info-init.h"
DEF_TARGET_INFO(target_info_arm_system,
diff --git a/page-vary-common.c b/page-vary-common.c
index b4e8cdf405..ec07b91d96 100644
--- a/page-vary-common.c
+++ b/page-vary-common.c
@@ -20,7 +20,7 @@
#define IN_PAGE_VARY 1
#include "qemu/osdep.h"
-#include "qemu/target-info-impl.h"
+#include "qemu/target-info.h"
#include "exec/page-vary.h"
/* WARNING: This file must *not* be complied with -flto. */
diff --git a/page-vary-system.c b/page-vary-system.c
index b2a1c45deb..ccc242b498 100644
--- a/page-vary-system.c
+++ b/page-vary-system.c
@@ -20,7 +20,7 @@
#include "qemu/osdep.h"
#include "exec/page-vary.h"
#include "exec/tlb-flags.h"
-#include "qemu/target-info-impl.h"
+#include "qemu/target-info.h"
QEMU_BUILD_BUG_ON(TLB_FLAGS_MASK & ((1u < TARGET_PAGE_BITS_MIN) - 1));
diff --git a/target-info-qom.c b/target-info-qom.c
index abaf7507a0..f7a03d78d4 100644
--- a/target-info-qom.c
+++ b/target-info-qom.c
@@ -11,7 +11,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qom/object.h"
-#include "qemu/target-info-impl.h"
+#include "qemu/target-info.h"
#include "qemu/target-info-init.h"
#include "qemu/target-info-qom.h"
#include "hw/arm/machines-qom.h"
diff --git a/target-info-stub.c b/target-info-stub.c
index 813d562058..edd4b78aa2 100644
--- a/target-info-stub.c
+++ b/target-info-stub.c
@@ -12,7 +12,6 @@
#include "exec/cpu-defs.h"
#include "exec/page-vary.h"
#include "qemu/target-info.h"
-#include "qemu/target-info-impl.h"
#include "qemu/target-info-init.h"
/* Validate correct placement of CPUArchState. */
diff --git a/target-info.c b/target-info.c
index 6bd3f9485f..3679e3ddd6 100644
--- a/target-info.c
+++ b/target-info.c
@@ -9,7 +9,6 @@
#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)
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 4/5] target-info: Merge target-info-qapi.h into target-info.h
2026-05-11 19:06 [PATCH 0/5] target_info optimizations Richard Henderson
` (2 preceding siblings ...)
2026-05-11 19:06 ` [PATCH 3/5] target-info: Merge target-info-impl.h into target-info.h Richard Henderson
@ 2026-05-11 19:06 ` Richard Henderson
2026-05-12 2:25 ` Pierrick Bouvier
2026-05-11 19:06 ` [PATCH 5/5] target-info: Inline accessors Richard Henderson
2026-05-12 2:14 ` [PATCH 0/5] target_info optimizations Pierrick Bouvier
5 siblings, 1 reply; 14+ messages in thread
From: Richard Henderson @ 2026-05-11 19:06 UTC (permalink / raw)
To: qemu-devel; +Cc: pierrick.bouvier, philmd
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/target-info-qapi.h | 29 -----------------------------
include/qemu/target-info.h | 14 ++++++++++++++
hw/core/machine-qmp-cmds.c | 1 -
hw/uefi/ovmf-log.c | 2 +-
hw/virtio/virtio-mem.c | 2 +-
system/arch_init.c | 2 +-
target-info.c | 1 -
7 files changed, 17 insertions(+), 34 deletions(-)
delete mode 100644 include/qemu/target-info-qapi.h
diff --git a/include/qemu/target-info-qapi.h b/include/qemu/target-info-qapi.h
deleted file mode 100644
index d5ce052323..0000000000
--- a/include/qemu/target-info-qapi.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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-common.h"
-#include "qapi/qapi-types-machine.h"
-
-/**
- * target_arch:
- *
- * Returns: QAPI SysEmuTarget enum (e.g. SYS_EMU_TARGET_X86_64).
- */
-SysEmuTarget target_arch(void);
-
-/**
- * target_endian_mode:
- *
- * Returns: QAPI EndianMode enum (e.g. ENDIAN_MODE_LITTLE).
- */
-EndianMode target_endian_mode(void);
-
-#endif
diff --git a/include/qemu/target-info.h b/include/qemu/target-info.h
index c9f7f2aa26..d8d2194d9b 100644
--- a/include/qemu/target-info.h
+++ b/include/qemu/target-info.h
@@ -69,6 +69,13 @@ const char *target_machine_typename(void);
*/
const char *target_cpu_type(void);
+/**
+ * target_endian_mode:
+ *
+ * Returns: QAPI EndianMode enum (e.g. ENDIAN_MODE_LITTLE).
+ */
+EndianMode target_endian_mode(void);
+
/**
* target_big_endian:
*
@@ -81,6 +88,13 @@ const char *target_cpu_type(void);
*/
bool target_big_endian(void);
+/**
+ * target_arch:
+ *
+ * Returns: QAPI SysEmuTarget enum (e.g. SYS_EMU_TARGET_X86_64).
+ */
+SysEmuTarget target_arch(void);
+
/**
* target_base_arm:
*
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index e62cb4ec88..3583a60ee8 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -21,7 +21,6 @@
#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"
diff --git a/hw/uefi/ovmf-log.c b/hw/uefi/ovmf-log.c
index 3a24afd941..ed351149f1 100644
--- a/hw/uefi/ovmf-log.c
+++ b/hw/uefi/ovmf-log.c
@@ -8,7 +8,7 @@
#include "qemu/osdep.h"
#include "qemu/units.h"
-#include "qemu/target-info-qapi.h"
+#include "qemu/target-info.h"
#include "hw/core/boards.h"
#include "hw/i386/x86.h"
#include "hw/arm/virt.h"
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index a4b71974a1..3d285eaf60 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -15,7 +15,7 @@
#include "qemu/cutils.h"
#include "qemu/error-report.h"
#include "qemu/units.h"
-#include "qemu/target-info-qapi.h"
+#include "qemu/target-info.h"
#include "system/numa.h"
#include "system/system.h"
#include "system/ramblock.h"
diff --git a/system/arch_init.c b/system/arch_init.c
index 1ad2f3d6f7..6fa5ae2160 100644
--- a/system/arch_init.c
+++ b/system/arch_init.c
@@ -24,7 +24,7 @@
#include "qemu/osdep.h"
#include "qemu/base-arch-defs.h"
#include "qemu/bitops.h"
-#include "qemu/target-info-qapi.h"
+#include "qemu/target-info.h"
bool qemu_arch_available(uint32_t arch_bitmask)
{
diff --git a/target-info.c b/target-info.c
index 3679e3ddd6..f02a033584 100644
--- a/target-info.c
+++ b/target-info.c
@@ -8,7 +8,6 @@
#include "qemu/osdep.h"
#include "qemu/target-info.h"
-#include "qemu/target-info-qapi.h"
#include "qapi/error.h"
const char *target_name(void)
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 5/5] target-info: Inline accessors
2026-05-11 19:06 [PATCH 0/5] target_info optimizations Richard Henderson
` (3 preceding siblings ...)
2026-05-11 19:06 ` [PATCH 4/5] target-info: Merge target-info-qapi.h " Richard Henderson
@ 2026-05-11 19:06 ` Richard Henderson
2026-05-12 2:26 ` Pierrick Bouvier
2026-05-12 2:14 ` [PATCH 0/5] target_info optimizations Pierrick Bouvier
5 siblings, 1 reply; 14+ messages in thread
From: Richard Henderson @ 2026-05-11 19:06 UTC (permalink / raw)
To: qemu-devel; +Cc: pierrick.bouvier, philmd
Move the entire contents of target-info.c into target-info.h,
marking each function inline.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/target-info.h | 82 +++++++++++++++++++++++++++------
target-info.c | 93 --------------------------------------
meson.build | 1 -
3 files changed, 68 insertions(+), 108 deletions(-)
delete mode 100644 target-info.c
diff --git a/include/qemu/target-info.h b/include/qemu/target-info.h
index d8d2194d9b..2c9f5c78fb 100644
--- a/include/qemu/target-info.h
+++ b/include/qemu/target-info.h
@@ -45,14 +45,20 @@ TargetInfo target_info;
*
* Returns: Canonical target name (i.e. "i386").
*/
-const char *target_name(void);
+static inline const char *target_name(void)
+{
+ return target_info.target_name;
+}
/**
* target_long_bits:
*
* Returns: number of bits in a long type for this target (i.e. 64).
*/
-unsigned target_long_bits(void);
+static inline unsigned target_long_bits(void)
+{
+ return target_info.long_bits;
+}
/**
* target_machine_typename:
@@ -60,21 +66,30 @@ unsigned target_long_bits(void);
* Returns: Name of the QOM interface implemented by machines
* usable on this target binary.
*/
-const char *target_machine_typename(void);
+static inline const char *target_machine_typename(void)
+{
+ return target_info.machine_typename;
+}
/**
* target_cpu_type:
*
* Returns: target CPU base QOM type name (i.e. TYPE_X86_CPU).
*/
-const char *target_cpu_type(void);
+static inline const char *target_cpu_type(void)
+{
+ return target_info.cpu_type;
+}
/**
* target_endian_mode:
*
* Returns: QAPI EndianMode enum (e.g. ENDIAN_MODE_LITTLE).
*/
-EndianMode target_endian_mode(void);
+static inline EndianMode target_endian_mode(void)
+{
+ return target_info.endianness;
+}
/**
* target_big_endian:
@@ -86,62 +101,101 @@ EndianMode target_endian_mode(void);
* the target, so please do *not* use this function unless you know very
* well what you are doing!
*/
-bool target_big_endian(void);
+static inline bool target_big_endian(void)
+{
+ return target_endian_mode() == ENDIAN_MODE_BIG;
+}
/**
* target_arch:
*
* Returns: QAPI SysEmuTarget enum (e.g. SYS_EMU_TARGET_X86_64).
*/
-SysEmuTarget target_arch(void);
+static inline SysEmuTarget target_arch(void)
+{
+ return target_info.target_arch;
+}
/**
* target_base_arm:
*
* Returns whether the target architecture is ARM or Aarch64.
*/
-bool target_base_arm(void);
+static inline bool target_base_arm(void)
+{
+ switch (target_arch()) {
+ case SYS_EMU_TARGET_ARM:
+ case SYS_EMU_TARGET_AARCH64:
+ return true;
+ default:
+ return false;
+ }
+}
/**
* target_arm:
*
* Returns whether the target architecture is ARM (32-bit, not Aarch64).
*/
-bool target_arm(void);
+static inline bool target_arm(void)
+{
+ return target_arch() == SYS_EMU_TARGET_ARM;
+}
/**
* target_aarch64:
*
* Returns whether the target architecture is Aarch64.
*/
-bool target_aarch64(void);
+static inline bool target_aarch64(void)
+{
+ return target_arch() == SYS_EMU_TARGET_AARCH64;
+}
/**
* target_base_ppc:
*
* Returns whether the target architecture is PowerPC 32-bit or 64-bit.
*/
-bool target_base_ppc(void);
+static inline bool target_base_ppc(void)
+{
+ switch (target_arch()) {
+ case SYS_EMU_TARGET_PPC:
+ case SYS_EMU_TARGET_PPC64:
+ return true;
+ default:
+ return false;
+ }
+}
/**
* target_ppc:
*
* Returns whether the target architecture is PowerPC 32-bit.
*/
-bool target_ppc(void);
+static inline bool target_ppc(void)
+{
+ return target_arch() == SYS_EMU_TARGET_PPC;
+}
/**
* target_ppc64:
*
* Returns whether the target architecture is PowerPC 64-bit.
*/
-bool target_ppc64(void);
+static inline bool target_ppc64(void)
+{
+ return target_arch() == SYS_EMU_TARGET_PPC64;
+}
/**
* target_s390x:
*
* Returns whether the target architecture is S390x.
*/
-bool target_s390x(void);
+static inline bool target_s390x(void)
+{
+ return target_arch() == SYS_EMU_TARGET_S390X;
+}
#endif
diff --git a/target-info.c b/target-info.c
deleted file mode 100644
index f02a033584..0000000000
--- a/target-info.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * QEMU target info helpers
- *
- * Copyright (c) Linaro
- *
- * SPDX-License-Identifier: GPL-2.0-or-later
- */
-
-#include "qemu/osdep.h"
-#include "qemu/target-info.h"
-#include "qapi/error.h"
-
-const char *target_name(void)
-{
- return target_info.target_name;
-}
-
-unsigned target_long_bits(void)
-{
- return target_info.long_bits;
-}
-
-SysEmuTarget target_arch(void)
-{
- return target_info.target_arch;
-}
-
-const char *target_cpu_type(void)
-{
- return target_info.cpu_type;
-}
-
-const char *target_machine_typename(void)
-{
- return target_info.machine_typename;
-}
-
-EndianMode target_endian_mode(void)
-{
- return target_info.endianness;
-}
-
-bool target_big_endian(void)
-{
- return target_endian_mode() == ENDIAN_MODE_BIG;
-}
-
-bool target_base_arm(void)
-{
- switch (target_arch()) {
- case SYS_EMU_TARGET_ARM:
- case SYS_EMU_TARGET_AARCH64:
- return true;
- default:
- return false;
- }
-}
-
-bool target_arm(void)
-{
- return target_arch() == SYS_EMU_TARGET_ARM;
-}
-
-bool target_aarch64(void)
-{
- return target_arch() == SYS_EMU_TARGET_AARCH64;
-}
-
-bool target_base_ppc(void)
-{
- switch (target_arch()) {
- case SYS_EMU_TARGET_PPC:
- case SYS_EMU_TARGET_PPC64:
- return true;
- default:
- return false;
- }
-}
-
-bool target_ppc(void)
-{
- return target_arch() == SYS_EMU_TARGET_PPC;
-}
-
-bool target_ppc64(void)
-{
- return target_arch() == SYS_EMU_TARGET_PPC64;
-}
-
-bool target_s390x(void)
-{
- return target_arch() == SYS_EMU_TARGET_S390X;
-}
diff --git a/meson.build b/meson.build
index 9a804dc810..aad149cdb4 100644
--- a/meson.build
+++ b/meson.build
@@ -3868,7 +3868,6 @@ endif
common_ss.add(pagevary)
system_ss.add(files('page-vary-system.c'))
-common_ss.add(files('target-info.c'))
system_ss.add(tinfoqom)
subdir('backends')
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 1/5] meson: Build target-info-qom.c with -fno-lto
2026-05-11 19:06 ` [PATCH 1/5] meson: Build target-info-qom.c with -fno-lto Richard Henderson
@ 2026-05-11 19:38 ` Pierrick Bouvier
2026-05-11 20:08 ` Richard Henderson
0 siblings, 1 reply; 14+ messages in thread
From: Pierrick Bouvier @ 2026-05-11 19:38 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: philmd
On 5/11/2026 12:06 PM, Richard Henderson wrote:
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> meson.build | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
Why?
Does LTO breaks anything in this case?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/5] meson: Build target-info-qom.c with -fno-lto
2026-05-11 19:38 ` Pierrick Bouvier
@ 2026-05-11 20:08 ` Richard Henderson
0 siblings, 0 replies; 14+ messages in thread
From: Richard Henderson @ 2026-05-11 20:08 UTC (permalink / raw)
To: Pierrick Bouvier, qemu-devel; +Cc: philmd
On 5/11/26 14:38, Pierrick Bouvier wrote:
> On 5/11/2026 12:06 PM, Richard Henderson wrote:
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>> meson.build | 12 ++++++++----
>> 1 file changed, 8 insertions(+), 4 deletions(-)
>>
>
> Why?
> Does LTO breaks anything in this case?
If the definition of target_info is available to lto, it will unify the const declaration
with the non-const definition. It will also constant propagate the
default-zero-initializer to the uses.
The gcc bug reference in the meson.build comment may or may not be instructive.
r~
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 0/5] target_info optimizations
2026-05-11 19:06 [PATCH 0/5] target_info optimizations Richard Henderson
` (4 preceding siblings ...)
2026-05-11 19:06 ` [PATCH 5/5] target-info: Inline accessors Richard Henderson
@ 2026-05-12 2:14 ` Pierrick Bouvier
5 siblings, 0 replies; 14+ messages in thread
From: Pierrick Bouvier @ 2026-05-12 2:14 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: philmd
On 5/11/2026 12:06 PM, Richard Henderson wrote:
> Based-on: 20260509005453.3984184-1-pierrick.bouvier@oss.qualcomm.com
> ("[PATCH v5 0/6] single-binary: deduplicate target_info()")
>
> Allow TargetInfo accesses to resolve to a direct structure access.
> Arrange for the structure to appear const to the majority of qemu.
> For user-only, the structure actually is const; for system, the
> structure is initialized early.
>
It would be nice, if possible, to see those optimizations driven by a
concrete benchmark. We had to deal with several premature optimizations
along our road on the single-binary, and it would be great to not repeat
the same thing again on this new component.
>
> r~
>
>
> Richard Henderson (5):
> meson: Build target-info-qom.c with -fno-lto
> target-info: Expose target_info as const data
> target-info: Merge target-info-impl.h into target-info.h
> target-info: Merge target-info-qapi.h into target-info.h
> target-info: Inline accessors
>
> include/qemu/target-info-impl.h | 44 -----------
> include/qemu/target-info-init.h | 45 ++++++++---
> include/qemu/target-info-qapi.h | 29 -------
> include/qemu/target-info-qom.h | 2 +-
> include/qemu/target-info.h | 123 +++++++++++++++++++++++++++---
> configs/targets/aarch64-softmmu.c | 18 +----
> configs/targets/arm-softmmu.c | 18 +----
> hw/core/machine-qmp-cmds.c | 1 -
> hw/uefi/ovmf-log.c | 2 +-
> hw/virtio/virtio-mem.c | 2 +-
> page-vary-common.c | 10 +--
> page-vary-system.c | 8 +-
> system/arch_init.c | 2 +-
> target-info-qom.c | 13 ++--
> target-info-stub.c | 27 +------
> target-info.c | 95 -----------------------
> meson.build | 13 ++--
> 17 files changed, 179 insertions(+), 273 deletions(-)
> delete mode 100644 include/qemu/target-info-impl.h
> delete mode 100644 include/qemu/target-info-qapi.h
> delete mode 100644 target-info.c
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/5] target-info: Expose target_info as const data
2026-05-11 19:06 ` [PATCH 2/5] target-info: Expose target_info as const data Richard Henderson
@ 2026-05-12 2:22 ` Pierrick Bouvier
0 siblings, 0 replies; 14+ messages in thread
From: Pierrick Bouvier @ 2026-05-12 2:22 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: philmd
On 5/11/2026 12:06 PM, Richard Henderson wrote:
> Expose a const TargetInfo structure instead of a function
> returning a const pointer.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> include/qemu/target-info-impl.h | 11 ++++----
> include/qemu/target-info-init.h | 45 ++++++++++++++++++++++---------
> configs/targets/aarch64-softmmu.c | 18 +++----------
> configs/targets/arm-softmmu.c | 18 +++----------
> page-vary-common.c | 8 ++----
> page-vary-system.c | 6 ++---
> target-info-qom.c | 11 +++-----
> target-info-stub.c | 28 ++++---------------
> target-info.c | 12 ++++-----
> 9 files changed, 65 insertions(+), 92 deletions(-)
>
...
> diff --git a/configs/targets/aarch64-softmmu.c b/configs/targets/aarch64-softmmu.c
> index 75d95b0e74..4f43f3e89a 100644
> --- a/configs/targets/aarch64-softmmu.c
> +++ b/configs/targets/aarch64-softmmu.c
> @@ -7,21 +7,11 @@
> */
>
> #include "qemu/osdep.h"
> -#include "qemu/target-info-impl.h"
> -#include "qemu/target-info-init.h"
> #include "hw/arm/machines-qom.h"
> #include "target/arm/cpu-qom.h"
> #include "target/arm/cpu-param.h"
> +#include "qemu/target-info-impl.h"
> +#include "qemu/target-info-init.h"
>
> -static const TargetInfo target_info_aarch64_system = {
> - .target_name = "aarch64",
> - .target_arch = SYS_EMU_TARGET_AARCH64,
> - .long_bits = 64,
> - .cpu_type = TYPE_ARM_CPU,
> - .machine_typename = TYPE_TARGET_AARCH64_MACHINE,
> - .endianness = ENDIAN_MODE_LITTLE,
> - .page_bits_vary = true,
> - .page_bits_init = TARGET_PAGE_BITS_LEGACY,
> -};
> -
> -target_info_init(target_info_aarch64_system)
> +DEF_TARGET_INFO(target_info_aarch64_system,
> + TYPE_ARM_CPU, TYPE_TARGET_AARCH64_MACHINE)
While it's definitely less code to type, I don't think it's really good
to bury that under yet another macro. Code repetition is not always a
bad thing, as long as it's not code we'll have to modify everyday. Those
definitions will probably never be modified in the future.
In a single grep, developer can directly see the specifics of this
target, without having to guess any header name or refer to another
file. As well, the target_info_init patterns follows the x_init pattern
coming from module_init.
Regards,
Pierrick
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/5] target-info: Merge target-info-impl.h into target-info.h
2026-05-11 19:06 ` [PATCH 3/5] target-info: Merge target-info-impl.h into target-info.h Richard Henderson
@ 2026-05-12 2:25 ` Pierrick Bouvier
2026-05-12 3:20 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 14+ messages in thread
From: Pierrick Bouvier @ 2026-05-12 2:25 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: philmd
On 5/11/2026 12:06 PM, Richard Henderson wrote:
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> include/qemu/target-info-impl.h | 43 -------------------------------
> include/qemu/target-info-qom.h | 2 +-
> include/qemu/target-info.h | 31 ++++++++++++++++++++++
> configs/targets/aarch64-softmmu.c | 2 +-
> configs/targets/arm-softmmu.c | 2 +-
> page-vary-common.c | 2 +-
> page-vary-system.c | 2 +-
> target-info-qom.c | 2 +-
> target-info-stub.c | 1 -
> target-info.c | 1 -
> 10 files changed, 37 insertions(+), 51 deletions(-)
> delete mode 100644 include/qemu/target-info-impl.h
>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 4/5] target-info: Merge target-info-qapi.h into target-info.h
2026-05-11 19:06 ` [PATCH 4/5] target-info: Merge target-info-qapi.h " Richard Henderson
@ 2026-05-12 2:25 ` Pierrick Bouvier
0 siblings, 0 replies; 14+ messages in thread
From: Pierrick Bouvier @ 2026-05-12 2:25 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: philmd
On 5/11/2026 12:06 PM, Richard Henderson wrote:
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> include/qemu/target-info-qapi.h | 29 -----------------------------
> include/qemu/target-info.h | 14 ++++++++++++++
> hw/core/machine-qmp-cmds.c | 1 -
> hw/uefi/ovmf-log.c | 2 +-
> hw/virtio/virtio-mem.c | 2 +-
> system/arch_init.c | 2 +-
> target-info.c | 1 -
> 7 files changed, 17 insertions(+), 34 deletions(-)
> delete mode 100644 include/qemu/target-info-qapi.h
>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 5/5] target-info: Inline accessors
2026-05-11 19:06 ` [PATCH 5/5] target-info: Inline accessors Richard Henderson
@ 2026-05-12 2:26 ` Pierrick Bouvier
0 siblings, 0 replies; 14+ messages in thread
From: Pierrick Bouvier @ 2026-05-12 2:26 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: philmd
On 5/11/2026 12:06 PM, Richard Henderson wrote:
> Move the entire contents of target-info.c into target-info.h,
> marking each function inline.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> include/qemu/target-info.h | 82 +++++++++++++++++++++++++++------
> target-info.c | 93 --------------------------------------
> meson.build | 1 -
> 3 files changed, 68 insertions(+), 108 deletions(-)
> delete mode 100644 target-info.c
>
> diff --git a/include/qemu/target-info.h b/include/qemu/target-info.h
> index d8d2194d9b..2c9f5c78fb 100644
> --- a/include/qemu/target-info.h
> +++ b/include/qemu/target-info.h
> @@ -45,14 +45,20 @@ TargetInfo target_info;
> *
> * Returns: Canonical target name (i.e. "i386").
> */
> -const char *target_name(void);
> +static inline const char *target_name(void)
> +{
> + return target_info.target_name;
> +}
>
> /**
> * target_long_bits:
> *
> * Returns: number of bits in a long type for this target (i.e. 64).
> */
> -unsigned target_long_bits(void);
> +static inline unsigned target_long_bits(void)
> +{
> + return target_info.long_bits;
> +}
>
> /**
> * target_machine_typename:
> @@ -60,21 +66,30 @@ unsigned target_long_bits(void);
> * Returns: Name of the QOM interface implemented by machines
> * usable on this target binary.
> */
> -const char *target_machine_typename(void);
> +static inline const char *target_machine_typename(void)
> +{
> + return target_info.machine_typename;
> +}
>
> /**
> * target_cpu_type:
> *
> * Returns: target CPU base QOM type name (i.e. TYPE_X86_CPU).
> */
> -const char *target_cpu_type(void);
> +static inline const char *target_cpu_type(void)
> +{
> + return target_info.cpu_type;
> +}
>
> /**
> * target_endian_mode:
> *
> * Returns: QAPI EndianMode enum (e.g. ENDIAN_MODE_LITTLE).
> */
> -EndianMode target_endian_mode(void);
> +static inline EndianMode target_endian_mode(void)
> +{
> + return target_info.endianness;
> +}
>
> /**
> * target_big_endian:
> @@ -86,62 +101,101 @@ EndianMode target_endian_mode(void);
> * the target, so please do *not* use this function unless you know very
> * well what you are doing!
> */
> -bool target_big_endian(void);
> +static inline bool target_big_endian(void)
> +{
> + return target_endian_mode() == ENDIAN_MODE_BIG;
> +}
>
> /**
> * target_arch:
> *
> * Returns: QAPI SysEmuTarget enum (e.g. SYS_EMU_TARGET_X86_64).
> */
> -SysEmuTarget target_arch(void);
> +static inline SysEmuTarget target_arch(void)
> +{
> + return target_info.target_arch;
> +}
>
> /**
> * target_base_arm:
> *
> * Returns whether the target architecture is ARM or Aarch64.
> */
> -bool target_base_arm(void);
> +static inline bool target_base_arm(void)
> +{
> + switch (target_arch()) {
> + case SYS_EMU_TARGET_ARM:
> + case SYS_EMU_TARGET_AARCH64:
> + return true;
> + default:
> + return false;
> + }
> +}
>
> /**
> * target_arm:
> *
> * Returns whether the target architecture is ARM (32-bit, not Aarch64).
> */
> -bool target_arm(void);
> +static inline bool target_arm(void)
> +{
> + return target_arch() == SYS_EMU_TARGET_ARM;
> +}
>
> /**
> * target_aarch64:
> *
> * Returns whether the target architecture is Aarch64.
> */
> -bool target_aarch64(void);
> +static inline bool target_aarch64(void)
> +{
> + return target_arch() == SYS_EMU_TARGET_AARCH64;
> +}
>
> /**
> * target_base_ppc:
> *
> * Returns whether the target architecture is PowerPC 32-bit or 64-bit.
> */
> -bool target_base_ppc(void);
> +static inline bool target_base_ppc(void)
> +{
> + switch (target_arch()) {
> + case SYS_EMU_TARGET_PPC:
> + case SYS_EMU_TARGET_PPC64:
> + return true;
> + default:
> + return false;
> + }
> +}
>
> /**
> * target_ppc:
> *
> * Returns whether the target architecture is PowerPC 32-bit.
> */
> -bool target_ppc(void);
> +static inline bool target_ppc(void)
> +{
> + return target_arch() == SYS_EMU_TARGET_PPC;
> +}
>
> /**
> * target_ppc64:
> *
> * Returns whether the target architecture is PowerPC 64-bit.
> */
> -bool target_ppc64(void);
> +static inline bool target_ppc64(void)
> +{
> + return target_arch() == SYS_EMU_TARGET_PPC64;
> +}
>
> /**
> * target_s390x:
> *
> * Returns whether the target architecture is S390x.
> */
> -bool target_s390x(void);
> +static inline bool target_s390x(void)
> +{
> + return target_arch() == SYS_EMU_TARGET_S390X;
> +}
>
> #endif
> diff --git a/target-info.c b/target-info.c
> deleted file mode 100644
> index f02a033584..0000000000
> --- a/target-info.c
> +++ /dev/null
> @@ -1,93 +0,0 @@
> -/*
> - * QEMU target info helpers
> - *
> - * Copyright (c) Linaro
> - *
> - * SPDX-License-Identifier: GPL-2.0-or-later
> - */
> -
> -#include "qemu/osdep.h"
> -#include "qemu/target-info.h"
> -#include "qapi/error.h"
> -
> -const char *target_name(void)
> -{
> - return target_info.target_name;
> -}
> -
> -unsigned target_long_bits(void)
> -{
> - return target_info.long_bits;
> -}
> -
> -SysEmuTarget target_arch(void)
> -{
> - return target_info.target_arch;
> -}
> -
> -const char *target_cpu_type(void)
> -{
> - return target_info.cpu_type;
> -}
> -
> -const char *target_machine_typename(void)
> -{
> - return target_info.machine_typename;
> -}
> -
> -EndianMode target_endian_mode(void)
> -{
> - return target_info.endianness;
> -}
> -
> -bool target_big_endian(void)
> -{
> - return target_endian_mode() == ENDIAN_MODE_BIG;
> -}
> -
> -bool target_base_arm(void)
> -{
> - switch (target_arch()) {
> - case SYS_EMU_TARGET_ARM:
> - case SYS_EMU_TARGET_AARCH64:
> - return true;
> - default:
> - return false;
> - }
> -}
> -
> -bool target_arm(void)
> -{
> - return target_arch() == SYS_EMU_TARGET_ARM;
> -}
> -
> -bool target_aarch64(void)
> -{
> - return target_arch() == SYS_EMU_TARGET_AARCH64;
> -}
> -
> -bool target_base_ppc(void)
> -{
> - switch (target_arch()) {
> - case SYS_EMU_TARGET_PPC:
> - case SYS_EMU_TARGET_PPC64:
> - return true;
> - default:
> - return false;
> - }
> -}
> -
> -bool target_ppc(void)
> -{
> - return target_arch() == SYS_EMU_TARGET_PPC;
> -}
> -
> -bool target_ppc64(void)
> -{
> - return target_arch() == SYS_EMU_TARGET_PPC64;
> -}
> -
> -bool target_s390x(void)
> -{
> - return target_arch() == SYS_EMU_TARGET_S390X;
> -}
> diff --git a/meson.build b/meson.build
> index 9a804dc810..aad149cdb4 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -3868,7 +3868,6 @@ endif
> common_ss.add(pagevary)
> system_ss.add(files('page-vary-system.c'))
>
> -common_ss.add(files('target-info.c'))
> system_ss.add(tinfoqom)
>
> subdir('backends')
We could evaluate the added performance of this, once we have a
benchmark, with/without target_info being an indirect function call or a
structure access.
Regards,
Pierrick
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/5] target-info: Merge target-info-impl.h into target-info.h
2026-05-11 19:06 ` [PATCH 3/5] target-info: Merge target-info-impl.h into target-info.h Richard Henderson
2026-05-12 2:25 ` Pierrick Bouvier
@ 2026-05-12 3:20 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-05-12 3:20 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: pierrick.bouvier
Hi,
On 11/5/26 21:06, Richard Henderson wrote:
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> include/qemu/target-info-impl.h | 43 -------------------------------
> include/qemu/target-info-qom.h | 2 +-
> include/qemu/target-info.h | 31 ++++++++++++++++++++++
> configs/targets/aarch64-softmmu.c | 2 +-
> configs/targets/arm-softmmu.c | 2 +-
> page-vary-common.c | 2 +-
> page-vary-system.c | 2 +-
> target-info-qom.c | 2 +-
> target-info-stub.c | 1 -
> target-info.c | 1 -
> 10 files changed, 37 insertions(+), 51 deletions(-)
> delete mode 100644 include/qemu/target-info-impl.h
> diff --git a/include/qemu/target-info.h b/include/qemu/target-info.h
> index 23c997de54..c9f7f2aa26 100644
> --- a/include/qemu/target-info.h
> +++ b/include/qemu/target-info.h
> @@ -9,6 +9,37 @@
> #ifndef QEMU_TARGET_INFO_H
> #define QEMU_TARGET_INFO_H
>
> +#include "qapi/qapi-types-common.h"
> +#include "qapi/qapi-types-machine.h"
Per commit 0af00042a92 ("qemu/target-info: Factor target_arch() out"):
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.
*/
Is that no longuer necessary?
> +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 */
> + const char *cpu_type;
> + /* QOM typename machines for this binary must implement */
> + const char *machine_typename;
> + /* related to TARGET_BIG_ENDIAN definition */
> + EndianMode endianness;
> + /*
> + * runtime equivalent of
> + * TARGET_PAGE_BITS_VARY ? TARGET_PAGE_BITS_LEGACY : TARGET_PAGE_BITS
> + */
> + unsigned page_bits_init;
> + /* runtime equivalent of TARGET_PAGE_BITS_VARY definition */
> + bool page_bits_vary;
> +} TargetInfo;
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-05-12 3:21 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-11 19:06 [PATCH 0/5] target_info optimizations Richard Henderson
2026-05-11 19:06 ` [PATCH 1/5] meson: Build target-info-qom.c with -fno-lto Richard Henderson
2026-05-11 19:38 ` Pierrick Bouvier
2026-05-11 20:08 ` Richard Henderson
2026-05-11 19:06 ` [PATCH 2/5] target-info: Expose target_info as const data Richard Henderson
2026-05-12 2:22 ` Pierrick Bouvier
2026-05-11 19:06 ` [PATCH 3/5] target-info: Merge target-info-impl.h into target-info.h Richard Henderson
2026-05-12 2:25 ` Pierrick Bouvier
2026-05-12 3:20 ` Philippe Mathieu-Daudé
2026-05-11 19:06 ` [PATCH 4/5] target-info: Merge target-info-qapi.h " Richard Henderson
2026-05-12 2:25 ` Pierrick Bouvier
2026-05-11 19:06 ` [PATCH 5/5] target-info: Inline accessors Richard Henderson
2026-05-12 2:26 ` Pierrick Bouvier
2026-05-12 2:14 ` [PATCH 0/5] target_info optimizations Pierrick Bouvier
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.