* [PATCH 0/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type()
@ 2025-04-17 16:54 Philippe Mathieu-Daudé
2025-04-17 16:54 ` [PATCH 1/7] qemu: Introduce target_cpu_type() Philippe Mathieu-Daudé
` (8 more replies)
0 siblings, 9 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-04-17 16:54 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Yanan Wang, Marc-André Lureau, Zhao Liu,
Marcel Apfelbaum, Daniel P. Berrangé,
Philippe Mathieu-Daudé, Eduardo Habkost, Richard Henderson
(Series fully reviewed, I plan to queue it via my tree)
This series replace the target-specific CPU_RESOLVING_TYPE
by calls to the target-agnostic target_cpu_type() method.
Since RFCv1:
- Split from bigger/unrelated TargetInfo series (Pierrick)
- Added Pierrick R-b tags
- Added commit descriptions
Philippe Mathieu-Daudé (7):
qemu: Introduce target_cpu_type()
cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type()
cpus: Move target-agnostic methods out of cpu-target.c
accel: Implement accel_init_ops_interfaces() for both system/user mode
accel: Include missing 'qemu/accel.h' header in accel-internal.h
accel: Make AccelCPUClass structure target-agnostic
accel: Move target-agnostic code from accel-target.c -> accel-common.c
MAINTAINERS | 4 +-
meson.build | 2 +
accel/{accel-system.h => accel-internal.h} | 10 +-
include/accel/accel-cpu-target.h | 12 +-
include/accel/accel-cpu.h | 23 ++++
include/qemu/target_info.h | 19 +++
accel/accel-common.c | 142 +++++++++++++++++++++
accel/accel-system.c | 4 +-
accel/accel-target.c | 134 -------------------
accel/accel-user.c | 6 +
accel/tcg/tcg-all.c | 5 +-
cpu-target.c | 76 +----------
hw/core/cpu-common.c | 74 +++++++++++
target_info-defs.c | 16 +++
accel/meson.build | 1 +
15 files changed, 299 insertions(+), 229 deletions(-)
rename accel/{accel-system.h => accel-internal.h} (56%)
create mode 100644 include/accel/accel-cpu.h
create mode 100644 include/qemu/target_info.h
create mode 100644 accel/accel-common.c
create mode 100644 target_info-defs.c
--
2.47.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/7] qemu: Introduce target_cpu_type()
2025-04-17 16:54 [PATCH 0/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type() Philippe Mathieu-Daudé
@ 2025-04-17 16:54 ` Philippe Mathieu-Daudé
2025-04-17 16:54 ` [PATCH 2/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type() Philippe Mathieu-Daudé
` (7 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-04-17 16:54 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Yanan Wang, Marc-André Lureau, Zhao Liu,
Marcel Apfelbaum, Daniel P. Berrangé,
Philippe Mathieu-Daudé, Eduardo Habkost, Richard Henderson,
Pierrick Bouvier
Introduce the target_cpu_type() helper to access the
CPU_RESOLVING_TYPE target-specific definition from
target-agnostic code.
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
MAINTAINERS | 2 ++
meson.build | 2 ++
include/qemu/target_info.h | 19 +++++++++++++++++++
target_info-defs.c | 16 ++++++++++++++++
4 files changed, 39 insertions(+)
create mode 100644 include/qemu/target_info.h
create mode 100644 target_info-defs.c
diff --git a/MAINTAINERS b/MAINTAINERS
index c7083ab1d93..07ca088f7e8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -495,6 +495,7 @@ F: include/exec/cpu*.h
F: include/exec/exec-all.h
F: include/exec/target_long.h
F: include/qemu/accel.h
+F: include/qemu/target_info.h
F: include/system/accel-*.h
F: include/system/cpus.h
F: include/accel/accel-cpu-target.h
@@ -503,6 +504,7 @@ F: accel/Makefile.objs
F: accel/stubs/Makefile.objs
F: cpu-common.c
F: cpu-target.c
+F: target_info-defs.c
F: system/cpus.c
Apple Silicon HVF CPUs
diff --git a/meson.build b/meson.build
index bcb9d39a387..ad324d46428 100644
--- a/meson.build
+++ b/meson.build
@@ -3807,6 +3807,8 @@ endif
common_ss.add(pagevary)
specific_ss.add(files('page-target.c', 'page-vary-target.c'))
+specific_ss.add(files('target_info-defs.c'))
+
subdir('backends')
subdir('disas')
subdir('migration')
diff --git a/include/qemu/target_info.h b/include/qemu/target_info.h
new file mode 100644
index 00000000000..a53e632e735
--- /dev/null
+++ b/include/qemu/target_info.h
@@ -0,0 +1,19 @@
+/*
+ * QEMU binary/target helpers
+ *
+ * Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef QEMU_TARGET_INFO_H
+#define QEMU_TARGET_INFO_H
+
+/**
+ * target_cpu_type:
+ *
+ * Returns: target CPU base QOM type name (i.e. TYPE_X86_CPU).
+ */
+const char *target_cpu_type(void);
+
+#endif
diff --git a/target_info-defs.c b/target_info-defs.c
new file mode 100644
index 00000000000..3ee89469855
--- /dev/null
+++ b/target_info-defs.c
@@ -0,0 +1,16 @@
+/*
+ * QEMU binary/target helpers (target specific)
+ *
+ * Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/target_info.h"
+#include "cpu.h"
+
+const char *target_cpu_type(void)
+{
+ return CPU_RESOLVING_TYPE;
+}
--
2.47.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type()
2025-04-17 16:54 [PATCH 0/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type() Philippe Mathieu-Daudé
2025-04-17 16:54 ` [PATCH 1/7] qemu: Introduce target_cpu_type() Philippe Mathieu-Daudé
@ 2025-04-17 16:54 ` Philippe Mathieu-Daudé
2025-04-17 16:54 ` [PATCH 3/7] cpus: Move target-agnostic methods out of cpu-target.c Philippe Mathieu-Daudé
` (6 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-04-17 16:54 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Yanan Wang, Marc-André Lureau, Zhao Liu,
Marcel Apfelbaum, Daniel P. Berrangé,
Philippe Mathieu-Daudé, Eduardo Habkost, Richard Henderson,
Pierrick Bouvier
Replace the target-specific CPU_RESOLVING_TYPE definition
by a call to the target-agnostic target_cpu_type() runtime
helper.
Since the big "cpu.h" is not required anymore in tcg-all.c,
remove it, using the tinier "cpu-param.h" header.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
accel/accel-target.c | 6 ++++--
accel/tcg/tcg-all.c | 5 +++--
cpu-target.c | 7 ++++---
3 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/accel/accel-target.c b/accel/accel-target.c
index 33a539b4cbb..9e9e70be876 100644
--- a/accel/accel-target.c
+++ b/accel/accel-target.c
@@ -25,6 +25,7 @@
#include "qemu/osdep.h"
#include "qemu/accel.h"
+#include "qemu/target_info.h"
#include "cpu.h"
#include "accel/accel-cpu-target.h"
@@ -88,17 +89,18 @@ static void accel_init_cpu_interfaces(AccelClass *ac)
const char *ac_name; /* AccelClass name */
char *acc_name; /* AccelCPUClass name */
ObjectClass *acc; /* AccelCPUClass */
+ const char *cpu_resolving_type = target_cpu_type();
ac_name = object_class_get_name(OBJECT_CLASS(ac));
g_assert(ac_name != NULL);
- acc_name = g_strdup_printf("%s-%s", ac_name, CPU_RESOLVING_TYPE);
+ acc_name = g_strdup_printf("%s-%s", ac_name, cpu_resolving_type);
acc = object_class_by_name(acc_name);
g_free(acc_name);
if (acc) {
object_class_foreach(accel_init_cpu_int_aux,
- CPU_RESOLVING_TYPE, false, acc);
+ cpu_resolving_type, false, acc);
}
}
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index b0d4e3e1362..25df7db5026 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -35,6 +35,7 @@
#include "qapi/qapi-types-common.h"
#include "qapi/qapi-builtin-visit.h"
#include "qemu/units.h"
+#include "qemu/target_info.h"
#if defined(CONFIG_USER_ONLY)
#include "hw/qdev-core.h"
#else
@@ -43,7 +44,7 @@
#endif
#include "accel/tcg/cpu-ops.h"
#include "internal-common.h"
-#include "cpu.h"
+#include "cpu-param.h"
struct TCGState {
@@ -89,7 +90,7 @@ static int tcg_init_machine(MachineState *ms)
unsigned max_threads = 1;
#ifndef CONFIG_USER_ONLY
- CPUClass *cc = CPU_CLASS(object_class_by_name(CPU_RESOLVING_TYPE));
+ CPUClass *cc = CPU_CLASS(object_class_by_name(target_cpu_type()));
bool mttcg_supported = cc->tcg_ops->mttcg_supported;
switch (s->mttcg_enabled) {
diff --git a/cpu-target.c b/cpu-target.c
index c99d208a7c4..1779bb5337d 100644
--- a/cpu-target.c
+++ b/cpu-target.c
@@ -22,6 +22,7 @@
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "qemu/qemu-print.h"
+#include "qemu/target_info.h"
#include "system/accel-ops.h"
#include "system/cpus.h"
#include "exec/cpu-common.h"
@@ -37,7 +38,7 @@ QEMU_BUILD_BUG_ON(offsetof(ArchCPU, env) != sizeof(CPUState));
char *cpu_model_from_type(const char *typename)
{
- const char *suffix = "-" CPU_RESOLVING_TYPE;
+ g_autofree char *suffix = g_strdup_printf("-%s", target_cpu_type());
if (!object_class_by_name(typename)) {
return NULL;
@@ -63,7 +64,7 @@ const char *parse_cpu_option(const char *cpu_option)
exit(1);
}
- oc = cpu_class_by_name(CPU_RESOLVING_TYPE, model_pieces[0]);
+ oc = cpu_class_by_name(target_cpu_type(), model_pieces[0]);
if (oc == NULL) {
error_report("unable to find CPU model '%s'", model_pieces[0]);
g_strfreev(model_pieces);
@@ -92,7 +93,7 @@ static void cpu_list_entry(gpointer data, gpointer user_data)
void list_cpus(void)
{
- CPUClass *cc = CPU_CLASS(object_class_by_name(CPU_RESOLVING_TYPE));
+ CPUClass *cc = CPU_CLASS(object_class_by_name(target_cpu_type()));
if (cc->list_cpus) {
cc->list_cpus();
--
2.47.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/7] cpus: Move target-agnostic methods out of cpu-target.c
2025-04-17 16:54 [PATCH 0/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type() Philippe Mathieu-Daudé
2025-04-17 16:54 ` [PATCH 1/7] qemu: Introduce target_cpu_type() Philippe Mathieu-Daudé
2025-04-17 16:54 ` [PATCH 2/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type() Philippe Mathieu-Daudé
@ 2025-04-17 16:54 ` Philippe Mathieu-Daudé
2025-04-17 16:54 ` [PATCH 4/7] accel: Implement accel_init_ops_interfaces() for both system/user mode Philippe Mathieu-Daudé
` (5 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-04-17 16:54 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Yanan Wang, Marc-André Lureau, Zhao Liu,
Marcel Apfelbaum, Daniel P. Berrangé,
Philippe Mathieu-Daudé, Eduardo Habkost, Richard Henderson,
Pierrick Bouvier
Various methods of cpu-target.c don't use any target-specific
knowledge at all and can be built once in the target-agnostic
cpu-common.c file.
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
cpu-target.c | 77 +-------------------------------------------
hw/core/cpu-common.c | 74 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+), 76 deletions(-)
diff --git a/cpu-target.c b/cpu-target.c
index 1779bb5337d..e018acbf71a 100644
--- a/cpu-target.c
+++ b/cpu-target.c
@@ -19,94 +19,19 @@
#include "qemu/osdep.h"
#include "cpu.h"
-#include "qapi/error.h"
-#include "qemu/error-report.h"
-#include "qemu/qemu-print.h"
-#include "qemu/target_info.h"
#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 "accel/accel-cpu-target.h"
+#include "hw/core/cpu.h"
#include "trace/trace-root.h"
/* Validate correct placement of CPUArchState. */
QEMU_BUILD_BUG_ON(offsetof(ArchCPU, parent_obj) != 0);
QEMU_BUILD_BUG_ON(offsetof(ArchCPU, env) != sizeof(CPUState));
-char *cpu_model_from_type(const char *typename)
-{
- g_autofree char *suffix = g_strdup_printf("-%s", target_cpu_type());
-
- if (!object_class_by_name(typename)) {
- return NULL;
- }
-
- if (g_str_has_suffix(typename, suffix)) {
- return g_strndup(typename, strlen(typename) - strlen(suffix));
- }
-
- return g_strdup(typename);
-}
-
-const char *parse_cpu_option(const char *cpu_option)
-{
- ObjectClass *oc;
- CPUClass *cc;
- gchar **model_pieces;
- const char *cpu_type;
-
- model_pieces = g_strsplit(cpu_option, ",", 2);
- if (!model_pieces[0]) {
- error_report("-cpu option cannot be empty");
- exit(1);
- }
-
- oc = cpu_class_by_name(target_cpu_type(), model_pieces[0]);
- if (oc == NULL) {
- error_report("unable to find CPU model '%s'", model_pieces[0]);
- g_strfreev(model_pieces);
- exit(EXIT_FAILURE);
- }
-
- cpu_type = object_class_get_name(oc);
- cc = CPU_CLASS(oc);
- cc->parse_features(cpu_type, model_pieces[1], &error_fatal);
- g_strfreev(model_pieces);
- return cpu_type;
-}
-
-static void cpu_list_entry(gpointer data, gpointer user_data)
-{
- CPUClass *cc = CPU_CLASS(OBJECT_CLASS(data));
- const char *typename = object_class_get_name(OBJECT_CLASS(data));
- g_autofree char *model = cpu_model_from_type(typename);
-
- if (cc->deprecation_note) {
- qemu_printf(" %s (deprecated)\n", model);
- } else {
- qemu_printf(" %s\n", model);
- }
-}
-
-void list_cpus(void)
-{
- CPUClass *cc = CPU_CLASS(object_class_by_name(target_cpu_type()));
-
- if (cc->list_cpus) {
- cc->list_cpus();
- } else {
- GSList *list;
-
- list = object_class_get_list_sorted(TYPE_CPU, false);
- qemu_printf("Available CPUs:\n");
- g_slist_foreach(list, cpu_list_entry, NULL);
- g_slist_free(list);
- }
-}
-
/* enable or disable single step mode. EXCP_DEBUG is returned by the
CPU loop after each instruction */
void cpu_single_step(CPUState *cpu, int enabled)
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index 9064dd24f82..6d0788331c7 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -25,6 +25,9 @@
#include "qemu/log.h"
#include "qemu/main-loop.h"
#include "qemu/lockcnt.h"
+#include "qemu/error-report.h"
+#include "qemu/qemu-print.h"
+#include "qemu/target_info.h"
#include "exec/log.h"
#include "exec/gdbstub.h"
#include "system/tcg.h"
@@ -152,6 +155,21 @@ ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model)
return NULL;
}
+char *cpu_model_from_type(const char *typename)
+{
+ g_autofree char *suffix = g_strdup_printf("-%s", target_cpu_type());
+
+ if (!object_class_by_name(typename)) {
+ return NULL;
+ }
+
+ if (g_str_has_suffix(typename, suffix)) {
+ return g_strndup(typename, strlen(typename) - strlen(suffix));
+ }
+
+ return g_strdup(typename);
+}
+
static void cpu_common_parse_features(const char *typename, char *features,
Error **errp)
{
@@ -183,6 +201,33 @@ static void cpu_common_parse_features(const char *typename, char *features,
}
}
+const char *parse_cpu_option(const char *cpu_option)
+{
+ ObjectClass *oc;
+ CPUClass *cc;
+ gchar **model_pieces;
+ const char *cpu_type;
+
+ model_pieces = g_strsplit(cpu_option, ",", 2);
+ if (!model_pieces[0]) {
+ error_report("-cpu option cannot be empty");
+ exit(1);
+ }
+
+ oc = cpu_class_by_name(target_cpu_type(), model_pieces[0]);
+ if (oc == NULL) {
+ error_report("unable to find CPU model '%s'", model_pieces[0]);
+ g_strfreev(model_pieces);
+ exit(EXIT_FAILURE);
+ }
+
+ cpu_type = object_class_get_name(oc);
+ cc = CPU_CLASS(oc);
+ cc->parse_features(cpu_type, model_pieces[1], &error_fatal);
+ g_strfreev(model_pieces);
+ return cpu_type;
+}
+
bool cpu_exec_realizefn(CPUState *cpu, Error **errp)
{
if (!accel_cpu_common_realize(cpu, errp)) {
@@ -359,3 +404,32 @@ static void cpu_register_types(void)
}
type_init(cpu_register_types)
+
+static void cpu_list_entry(gpointer data, gpointer user_data)
+{
+ CPUClass *cc = CPU_CLASS(OBJECT_CLASS(data));
+ const char *typename = object_class_get_name(OBJECT_CLASS(data));
+ g_autofree char *model = cpu_model_from_type(typename);
+
+ if (cc->deprecation_note) {
+ qemu_printf(" %s (deprecated)\n", model);
+ } else {
+ qemu_printf(" %s\n", model);
+ }
+}
+
+void list_cpus(void)
+{
+ CPUClass *cc = CPU_CLASS(object_class_by_name(target_cpu_type()));
+
+ if (cc->list_cpus) {
+ cc->list_cpus();
+ } else {
+ GSList *list;
+
+ list = object_class_get_list_sorted(TYPE_CPU, false);
+ qemu_printf("Available CPUs:\n");
+ g_slist_foreach(list, cpu_list_entry, NULL);
+ g_slist_free(list);
+ }
+}
--
2.47.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/7] accel: Implement accel_init_ops_interfaces() for both system/user mode
2025-04-17 16:54 [PATCH 0/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type() Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2025-04-17 16:54 ` [PATCH 3/7] cpus: Move target-agnostic methods out of cpu-target.c Philippe Mathieu-Daudé
@ 2025-04-17 16:54 ` Philippe Mathieu-Daudé
2025-04-17 16:54 ` [PATCH 5/7] accel: Include missing 'qemu/accel.h' header in accel-internal.h Philippe Mathieu-Daudé
` (4 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-04-17 16:54 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Yanan Wang, Marc-André Lureau, Zhao Liu,
Marcel Apfelbaum, Daniel P. Berrangé,
Philippe Mathieu-Daudé, Eduardo Habkost, Richard Henderson,
Pierrick Bouvier
We want to build more common code, moving objects from meson's
specific_ss[] set to common_ss[]. Since the CONFIG_USER_ONLY
definitions isn't applied on the common_ss[] set, it is simpler
to add an empty accel_init_ops_interfaces() stub on user emulation,
removing any CONFIG_USER_ONLY use in accel-target.c.
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
MAINTAINERS | 2 +-
accel/{accel-system.h => accel-internal.h} | 8 ++++----
accel/accel-system.c | 4 ++--
accel/accel-target.c | 10 ++--------
accel/accel-user.c | 6 ++++++
5 files changed, 15 insertions(+), 15 deletions(-)
rename accel/{accel-system.h => accel-internal.h} (56%)
diff --git a/MAINTAINERS b/MAINTAINERS
index 07ca088f7e8..9bd7e63c6cd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -499,7 +499,7 @@ F: include/qemu/target_info.h
F: include/system/accel-*.h
F: include/system/cpus.h
F: include/accel/accel-cpu-target.h
-F: accel/accel-*.c
+F: accel/accel-*.?
F: accel/Makefile.objs
F: accel/stubs/Makefile.objs
F: cpu-common.c
diff --git a/accel/accel-system.h b/accel/accel-internal.h
similarity index 56%
rename from accel/accel-system.h
rename to accel/accel-internal.h
index 2d37c73c97b..03426aa21ee 100644
--- a/accel/accel-system.h
+++ b/accel/accel-internal.h
@@ -1,5 +1,5 @@
/*
- * QEMU System Emulation accel internal functions
+ * QEMU accel internal functions
*
* Copyright 2021 SUSE LLC
*
@@ -7,9 +7,9 @@
* See the COPYING file in the top-level directory.
*/
-#ifndef ACCEL_SYSTEM_H
-#define ACCEL_SYSTEM_H
+#ifndef ACCEL_INTERNAL_H
+#define ACCEL_INTERNAL_H
-void accel_system_init_ops_interfaces(AccelClass *ac);
+void accel_init_ops_interfaces(AccelClass *ac);
#endif /* ACCEL_SYSTEM_H */
diff --git a/accel/accel-system.c b/accel/accel-system.c
index 5df49fbe831..a0f562ae9ff 100644
--- a/accel/accel-system.c
+++ b/accel/accel-system.c
@@ -29,7 +29,7 @@
#include "system/accel-ops.h"
#include "system/cpus.h"
#include "qemu/error-report.h"
-#include "accel-system.h"
+#include "accel-internal.h"
int accel_init_machine(AccelState *accel, MachineState *ms)
{
@@ -63,7 +63,7 @@ void accel_setup_post(MachineState *ms)
}
/* initialize the arch-independent accel operation interfaces */
-void accel_system_init_ops_interfaces(AccelClass *ac)
+void accel_init_ops_interfaces(AccelClass *ac)
{
const char *ac_name;
char *ops_name;
diff --git a/accel/accel-target.c b/accel/accel-target.c
index 9e9e70be876..6fa5c3ef04e 100644
--- a/accel/accel-target.c
+++ b/accel/accel-target.c
@@ -29,10 +29,7 @@
#include "cpu.h"
#include "accel/accel-cpu-target.h"
-
-#ifndef CONFIG_USER_ONLY
-#include "accel-system.h"
-#endif /* !CONFIG_USER_ONLY */
+#include "accel-internal.h"
static const TypeInfo accel_type = {
.name = TYPE_ACCEL,
@@ -106,10 +103,7 @@ static void accel_init_cpu_interfaces(AccelClass *ac)
void accel_init_interfaces(AccelClass *ac)
{
-#ifndef CONFIG_USER_ONLY
- accel_system_init_ops_interfaces(ac);
-#endif /* !CONFIG_USER_ONLY */
-
+ accel_init_ops_interfaces(ac);
accel_init_cpu_interfaces(ac);
}
diff --git a/accel/accel-user.c b/accel/accel-user.c
index 22b6a1a1a89..7d192306a65 100644
--- a/accel/accel-user.c
+++ b/accel/accel-user.c
@@ -9,6 +9,12 @@
#include "qemu/osdep.h"
#include "qemu/accel.h"
+#include "accel-internal.h"
+
+void accel_init_ops_interfaces(AccelClass *ac)
+{
+ /* nothing */
+}
AccelState *current_accel(void)
{
--
2.47.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 5/7] accel: Include missing 'qemu/accel.h' header in accel-internal.h
2025-04-17 16:54 [PATCH 0/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type() Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2025-04-17 16:54 ` [PATCH 4/7] accel: Implement accel_init_ops_interfaces() for both system/user mode Philippe Mathieu-Daudé
@ 2025-04-17 16:54 ` Philippe Mathieu-Daudé
2025-04-17 16:54 ` [PATCH 6/7] accel: Make AccelCPUClass structure target-agnostic Philippe Mathieu-Daudé
` (3 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-04-17 16:54 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Yanan Wang, Marc-André Lureau, Zhao Liu,
Marcel Apfelbaum, Daniel P. Berrangé,
Philippe Mathieu-Daudé, Eduardo Habkost, Richard Henderson,
Pierrick Bouvier
The "qemu/accel.h" header is implicitly pulled in. Include
it explicitly in order to avoid when refactoring unrelated
headers:
accel/accel-internal.h:13:32: error: unknown type name 'AccelClass'
13 | void accel_init_ops_interfaces(AccelClass *ac);
| ^
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
accel/accel-internal.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/accel/accel-internal.h b/accel/accel-internal.h
index 03426aa21ee..d3a4422cbf7 100644
--- a/accel/accel-internal.h
+++ b/accel/accel-internal.h
@@ -10,6 +10,8 @@
#ifndef ACCEL_INTERNAL_H
#define ACCEL_INTERNAL_H
+#include "qemu/accel.h"
+
void accel_init_ops_interfaces(AccelClass *ac);
#endif /* ACCEL_SYSTEM_H */
--
2.47.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 6/7] accel: Make AccelCPUClass structure target-agnostic
2025-04-17 16:54 [PATCH 0/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type() Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2025-04-17 16:54 ` [PATCH 5/7] accel: Include missing 'qemu/accel.h' header in accel-internal.h Philippe Mathieu-Daudé
@ 2025-04-17 16:54 ` Philippe Mathieu-Daudé
2025-04-17 16:54 ` [PATCH 7/7] accel: Move target-agnostic code from accel-target.c -> accel-common.c Philippe Mathieu-Daudé
` (2 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-04-17 16:54 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Yanan Wang, Marc-André Lureau, Zhao Liu,
Marcel Apfelbaum, Daniel P. Berrangé,
Philippe Mathieu-Daudé, Eduardo Habkost, Richard Henderson,
Pierrick Bouvier
Move the target-agnostic parts of "accel/accel-cpu-target.h"
to "accel/accel-cpu.h".
Doing so we need to include missing "hw/core/cpu.h" header
in "accel/accel-cpu.h" otherwise we get:
include/accel/accel-cpu-target.h:39:28: error: unknown type name 'CPUClass'
39 | void (*cpu_class_init)(CPUClass *cc);
| ^
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/accel/accel-cpu-target.h | 12 +-----------
include/accel/accel-cpu.h | 23 +++++++++++++++++++++++
accel/accel-target.c | 1 -
3 files changed, 24 insertions(+), 12 deletions(-)
create mode 100644 include/accel/accel-cpu.h
diff --git a/include/accel/accel-cpu-target.h b/include/accel/accel-cpu-target.h
index 37dde7fae3e..6feb344e29b 100644
--- a/include/accel/accel-cpu-target.h
+++ b/include/accel/accel-cpu-target.h
@@ -21,21 +21,11 @@
*/
#include "qom/object.h"
+#include "accel/accel-cpu.h"
#include "cpu.h"
#define TYPE_ACCEL_CPU "accel-" CPU_RESOLVING_TYPE
#define ACCEL_CPU_NAME(name) (name "-" TYPE_ACCEL_CPU)
-typedef struct AccelCPUClass AccelCPUClass;
DECLARE_CLASS_CHECKERS(AccelCPUClass, ACCEL_CPU, TYPE_ACCEL_CPU)
-typedef struct AccelCPUClass {
- /*< private >*/
- ObjectClass parent_class;
- /*< public >*/
-
- void (*cpu_class_init)(CPUClass *cc);
- void (*cpu_instance_init)(CPUState *cpu);
- bool (*cpu_target_realize)(CPUState *cpu, Error **errp);
-} AccelCPUClass;
-
#endif /* ACCEL_CPU_H */
diff --git a/include/accel/accel-cpu.h b/include/accel/accel-cpu.h
new file mode 100644
index 00000000000..9e7eede7c3c
--- /dev/null
+++ b/include/accel/accel-cpu.h
@@ -0,0 +1,23 @@
+/*
+ * Accelerator interface, specializes CPUClass
+ *
+ * Copyright 2021 SUSE LLC
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef ACCEL_CPU_H
+#define ACCEL_CPU_H
+
+#include "qom/object.h"
+#include "hw/core/cpu.h"
+
+typedef struct AccelCPUClass {
+ ObjectClass parent_class;
+
+ void (*cpu_class_init)(CPUClass *cc);
+ void (*cpu_instance_init)(CPUState *cpu);
+ bool (*cpu_target_realize)(CPUState *cpu, Error **errp);
+} AccelCPUClass;
+
+#endif /* ACCEL_CPU_H */
diff --git a/accel/accel-target.c b/accel/accel-target.c
index 6fa5c3ef04e..769a90230bf 100644
--- a/accel/accel-target.c
+++ b/accel/accel-target.c
@@ -27,7 +27,6 @@
#include "qemu/accel.h"
#include "qemu/target_info.h"
-#include "cpu.h"
#include "accel/accel-cpu-target.h"
#include "accel-internal.h"
--
2.47.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 7/7] accel: Move target-agnostic code from accel-target.c -> accel-common.c
2025-04-17 16:54 [PATCH 0/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type() Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2025-04-17 16:54 ` [PATCH 6/7] accel: Make AccelCPUClass structure target-agnostic Philippe Mathieu-Daudé
@ 2025-04-17 16:54 ` Philippe Mathieu-Daudé
2025-04-17 18:28 ` [PATCH 0/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type() Pierrick Bouvier
2025-04-18 17:42 ` Richard Henderson
8 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-04-17 16:54 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Yanan Wang, Marc-André Lureau, Zhao Liu,
Marcel Apfelbaum, Daniel P. Berrangé,
Philippe Mathieu-Daudé, Eduardo Habkost, Richard Henderson,
Pierrick Bouvier
Various methods of accel-target.c don't use any target-specific
knowledge at all and can be built once in the target-agnostic
accel-common.c file.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
accel/accel-common.c | 142 +++++++++++++++++++++++++++++++++++++++++++
accel/accel-target.c | 129 ---------------------------------------
accel/meson.build | 1 +
3 files changed, 143 insertions(+), 129 deletions(-)
create mode 100644 accel/accel-common.c
diff --git a/accel/accel-common.c b/accel/accel-common.c
new file mode 100644
index 00000000000..f505461fc88
--- /dev/null
+++ b/accel/accel-common.c
@@ -0,0 +1,142 @@
+/*
+ * QEMU accel class, components common to system emulation and user mode
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ * Copyright (c) 2014 Red Hat Inc.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/accel.h"
+#include "qemu/target_info.h"
+#include "accel/accel-cpu.h"
+#include "accel-internal.h"
+
+/* Lookup AccelClass from opt_name. Returns NULL if not found */
+AccelClass *accel_find(const char *opt_name)
+{
+ char *class_name = g_strdup_printf(ACCEL_CLASS_NAME("%s"), opt_name);
+ AccelClass *ac = ACCEL_CLASS(module_object_class_by_name(class_name));
+ g_free(class_name);
+ return ac;
+}
+
+/* Return the name of the current accelerator */
+const char *current_accel_name(void)
+{
+ AccelClass *ac = ACCEL_GET_CLASS(current_accel());
+
+ return ac->name;
+}
+
+static void accel_init_cpu_int_aux(ObjectClass *klass, void *opaque)
+{
+ CPUClass *cc = CPU_CLASS(klass);
+ AccelCPUClass *accel_cpu = opaque;
+
+ /*
+ * The first callback allows accel-cpu to run initializations
+ * for the CPU, customizing CPU behavior according to the accelerator.
+ *
+ * The second one allows the CPU to customize the accel-cpu
+ * behavior according to the CPU.
+ *
+ * The second is currently only used by TCG, to specialize the
+ * TCGCPUOps depending on the CPU type.
+ */
+ cc->accel_cpu = accel_cpu;
+ if (accel_cpu->cpu_class_init) {
+ accel_cpu->cpu_class_init(cc);
+ }
+ if (cc->init_accel_cpu) {
+ cc->init_accel_cpu(accel_cpu, cc);
+ }
+}
+
+/* initialize the arch-specific accel CpuClass interfaces */
+static void accel_init_cpu_interfaces(AccelClass *ac)
+{
+ const char *ac_name; /* AccelClass name */
+ char *acc_name; /* AccelCPUClass name */
+ ObjectClass *acc; /* AccelCPUClass */
+ const char *cpu_resolving_type = target_cpu_type();
+
+ ac_name = object_class_get_name(OBJECT_CLASS(ac));
+ g_assert(ac_name != NULL);
+
+ acc_name = g_strdup_printf("%s-%s", ac_name, cpu_resolving_type);
+ acc = object_class_by_name(acc_name);
+ g_free(acc_name);
+
+ if (acc) {
+ object_class_foreach(accel_init_cpu_int_aux,
+ cpu_resolving_type, false, acc);
+ }
+}
+
+void accel_init_interfaces(AccelClass *ac)
+{
+ accel_init_ops_interfaces(ac);
+ accel_init_cpu_interfaces(ac);
+}
+
+void accel_cpu_instance_init(CPUState *cpu)
+{
+ if (cpu->cc->accel_cpu && cpu->cc->accel_cpu->cpu_instance_init) {
+ cpu->cc->accel_cpu->cpu_instance_init(cpu);
+ }
+}
+
+bool accel_cpu_common_realize(CPUState *cpu, Error **errp)
+{
+ AccelState *accel = current_accel();
+ AccelClass *acc = ACCEL_GET_CLASS(accel);
+
+ /* target specific realization */
+ if (cpu->cc->accel_cpu
+ && cpu->cc->accel_cpu->cpu_target_realize
+ && !cpu->cc->accel_cpu->cpu_target_realize(cpu, errp)) {
+ return false;
+ }
+
+ /* generic realization */
+ if (acc->cpu_common_realize && !acc->cpu_common_realize(cpu, errp)) {
+ return false;
+ }
+
+ return true;
+}
+
+void accel_cpu_common_unrealize(CPUState *cpu)
+{
+ AccelState *accel = current_accel();
+ AccelClass *acc = ACCEL_GET_CLASS(accel);
+
+ /* generic unrealization */
+ if (acc->cpu_common_unrealize) {
+ acc->cpu_common_unrealize(cpu);
+ }
+}
+
+int accel_supported_gdbstub_sstep_flags(void)
+{
+ AccelState *accel = current_accel();
+ AccelClass *acc = ACCEL_GET_CLASS(accel);
+ if (acc->gdbstub_supported_sstep_flags) {
+ return acc->gdbstub_supported_sstep_flags();
+ }
+ return 0;
+}
+
+static const TypeInfo accel_types[] = {
+ {
+ .name = TYPE_ACCEL,
+ .parent = TYPE_OBJECT,
+ .class_size = sizeof(AccelClass),
+ .instance_size = sizeof(AccelState),
+ .abstract = true,
+ },
+};
+
+DEFINE_TYPES(accel_types)
diff --git a/accel/accel-target.c b/accel/accel-target.c
index 769a90230bf..7fd392fbc4a 100644
--- a/accel/accel-target.c
+++ b/accel/accel-target.c
@@ -24,135 +24,7 @@
*/
#include "qemu/osdep.h"
-#include "qemu/accel.h"
-#include "qemu/target_info.h"
-
#include "accel/accel-cpu-target.h"
-#include "accel-internal.h"
-
-static const TypeInfo accel_type = {
- .name = TYPE_ACCEL,
- .parent = TYPE_OBJECT,
- .class_size = sizeof(AccelClass),
- .instance_size = sizeof(AccelState),
- .abstract = true,
-};
-
-/* Lookup AccelClass from opt_name. Returns NULL if not found */
-AccelClass *accel_find(const char *opt_name)
-{
- char *class_name = g_strdup_printf(ACCEL_CLASS_NAME("%s"), opt_name);
- AccelClass *ac = ACCEL_CLASS(module_object_class_by_name(class_name));
- g_free(class_name);
- return ac;
-}
-
-/* Return the name of the current accelerator */
-const char *current_accel_name(void)
-{
- AccelClass *ac = ACCEL_GET_CLASS(current_accel());
-
- return ac->name;
-}
-
-static void accel_init_cpu_int_aux(ObjectClass *klass, void *opaque)
-{
- CPUClass *cc = CPU_CLASS(klass);
- AccelCPUClass *accel_cpu = opaque;
-
- /*
- * The first callback allows accel-cpu to run initializations
- * for the CPU, customizing CPU behavior according to the accelerator.
- *
- * The second one allows the CPU to customize the accel-cpu
- * behavior according to the CPU.
- *
- * The second is currently only used by TCG, to specialize the
- * TCGCPUOps depending on the CPU type.
- */
- cc->accel_cpu = accel_cpu;
- if (accel_cpu->cpu_class_init) {
- accel_cpu->cpu_class_init(cc);
- }
- if (cc->init_accel_cpu) {
- cc->init_accel_cpu(accel_cpu, cc);
- }
-}
-
-/* initialize the arch-specific accel CpuClass interfaces */
-static void accel_init_cpu_interfaces(AccelClass *ac)
-{
- const char *ac_name; /* AccelClass name */
- char *acc_name; /* AccelCPUClass name */
- ObjectClass *acc; /* AccelCPUClass */
- const char *cpu_resolving_type = target_cpu_type();
-
- ac_name = object_class_get_name(OBJECT_CLASS(ac));
- g_assert(ac_name != NULL);
-
- acc_name = g_strdup_printf("%s-%s", ac_name, cpu_resolving_type);
- acc = object_class_by_name(acc_name);
- g_free(acc_name);
-
- if (acc) {
- object_class_foreach(accel_init_cpu_int_aux,
- cpu_resolving_type, false, acc);
- }
-}
-
-void accel_init_interfaces(AccelClass *ac)
-{
- accel_init_ops_interfaces(ac);
- accel_init_cpu_interfaces(ac);
-}
-
-void accel_cpu_instance_init(CPUState *cpu)
-{
- if (cpu->cc->accel_cpu && cpu->cc->accel_cpu->cpu_instance_init) {
- cpu->cc->accel_cpu->cpu_instance_init(cpu);
- }
-}
-
-bool accel_cpu_common_realize(CPUState *cpu, Error **errp)
-{
- AccelState *accel = current_accel();
- AccelClass *acc = ACCEL_GET_CLASS(accel);
-
- /* target specific realization */
- if (cpu->cc->accel_cpu
- && cpu->cc->accel_cpu->cpu_target_realize
- && !cpu->cc->accel_cpu->cpu_target_realize(cpu, errp)) {
- return false;
- }
-
- /* generic realization */
- if (acc->cpu_common_realize && !acc->cpu_common_realize(cpu, errp)) {
- return false;
- }
-
- return true;
-}
-
-void accel_cpu_common_unrealize(CPUState *cpu)
-{
- AccelState *accel = current_accel();
- AccelClass *acc = ACCEL_GET_CLASS(accel);
-
- /* generic unrealization */
- if (acc->cpu_common_unrealize) {
- acc->cpu_common_unrealize(cpu);
- }
-}
-
-int accel_supported_gdbstub_sstep_flags(void)
-{
- AccelState *accel = current_accel();
- AccelClass *acc = ACCEL_GET_CLASS(accel);
- if (acc->gdbstub_supported_sstep_flags) {
- return acc->gdbstub_supported_sstep_flags();
- }
- return 0;
-}
static const TypeInfo accel_cpu_type = {
.name = TYPE_ACCEL_CPU,
@@ -163,7 +35,6 @@ static const TypeInfo accel_cpu_type = {
static void register_accel_types(void)
{
- type_register_static(&accel_type);
type_register_static(&accel_cpu_type);
}
diff --git a/accel/meson.build b/accel/meson.build
index 5eaeb683385..52909314bfa 100644
--- a/accel/meson.build
+++ b/accel/meson.build
@@ -1,3 +1,4 @@
+common_ss.add(files('accel-common.c'))
specific_ss.add(files('accel-target.c'))
system_ss.add(files('accel-system.c', 'accel-blocker.c'))
user_ss.add(files('accel-user.c'))
--
2.47.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 0/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type()
2025-04-17 16:54 [PATCH 0/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type() Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2025-04-17 16:54 ` [PATCH 7/7] accel: Move target-agnostic code from accel-target.c -> accel-common.c Philippe Mathieu-Daudé
@ 2025-04-17 18:28 ` Pierrick Bouvier
2025-04-17 18:29 ` Pierrick Bouvier
2025-04-17 18:38 ` Philippe Mathieu-Daudé
2025-04-18 17:42 ` Richard Henderson
8 siblings, 2 replies; 13+ messages in thread
From: Pierrick Bouvier @ 2025-04-17 18:28 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Paolo Bonzini, Yanan Wang, Marc-André Lureau, Zhao Liu,
Marcel Apfelbaum, Daniel P. Berrangé, Eduardo Habkost,
Richard Henderson
Maybe it would be preferable to focus on providing a minimal but
*complete* TargetInfo before upstreaming any of this, as it's really
blocking the rest of the work for single binary.
Minimal requirements to have a complete series would be:
- Rename QMP TargetInfo struct to use that name
- Be able to query target cpu type (what this series does)
- Be able to query machine cpu type
- Modify generic functions listing machines/cpus to take this into account
- Tag labeled boards/cpu in hw/arm to prove this is working (without
doing any other cleanup to those files and *not* make them common)
- No other additional target information for the v1, let's keep that for
later.
Note: target_cpu_type will not be TYPE_ARM_CPU, as it wrongly wraps
arm32 and aarch64 cpus, while it should correctly identify one or the
other. I suggested TYPE_TARGET_CPU_ARM, TYPE_TARGET_CPU_AARCH64, and
same for machines: TYPE_TARGET_MACHINE_ARM, TYPE_TARGET_MACHINE_AARCH64.
So we can reuse this naming convention with any other target we'll reuse
in the future.
Pierrick
On 4/17/25 09:54, Philippe Mathieu-Daudé wrote:
> (Series fully reviewed, I plan to queue it via my tree)
>
> This series replace the target-specific CPU_RESOLVING_TYPE
> by calls to the target-agnostic target_cpu_type() method.
>
> Since RFCv1:
> - Split from bigger/unrelated TargetInfo series (Pierrick)
> - Added Pierrick R-b tags
> - Added commit descriptions
>
> Philippe Mathieu-Daudé (7):
> qemu: Introduce target_cpu_type()
> cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type()
> cpus: Move target-agnostic methods out of cpu-target.c
> accel: Implement accel_init_ops_interfaces() for both system/user mode
> accel: Include missing 'qemu/accel.h' header in accel-internal.h
> accel: Make AccelCPUClass structure target-agnostic
> accel: Move target-agnostic code from accel-target.c -> accel-common.c
>
> MAINTAINERS | 4 +-
> meson.build | 2 +
> accel/{accel-system.h => accel-internal.h} | 10 +-
> include/accel/accel-cpu-target.h | 12 +-
> include/accel/accel-cpu.h | 23 ++++
> include/qemu/target_info.h | 19 +++
> accel/accel-common.c | 142 +++++++++++++++++++++
> accel/accel-system.c | 4 +-
> accel/accel-target.c | 134 -------------------
> accel/accel-user.c | 6 +
> accel/tcg/tcg-all.c | 5 +-
> cpu-target.c | 76 +----------
> hw/core/cpu-common.c | 74 +++++++++++
> target_info-defs.c | 16 +++
> accel/meson.build | 1 +
> 15 files changed, 299 insertions(+), 229 deletions(-)
> rename accel/{accel-system.h => accel-internal.h} (56%)
> create mode 100644 include/accel/accel-cpu.h
> create mode 100644 include/qemu/target_info.h
> create mode 100644 accel/accel-common.c
> create mode 100644 target_info-defs.c
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type()
2025-04-17 18:28 ` [PATCH 0/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type() Pierrick Bouvier
@ 2025-04-17 18:29 ` Pierrick Bouvier
2025-04-17 18:38 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 13+ messages in thread
From: Pierrick Bouvier @ 2025-04-17 18:29 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Paolo Bonzini, Yanan Wang, Marc-André Lureau, Zhao Liu,
Marcel Apfelbaum, Daniel P. Berrangé, Eduardo Habkost,
Richard Henderson
On 4/17/25 11:28, Pierrick Bouvier wrote:
> Maybe it would be preferable to focus on providing a minimal but
> *complete* TargetInfo before upstreaming any of this, as it's really
> blocking the rest of the work for single binary.
>
> Minimal requirements to have a complete series would be:
> - Rename QMP TargetInfo struct to use that name
> - Be able to query target cpu type (what this series does)
> - Be able to query machine cpu type
s/machine cpu/target machine
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type()
2025-04-17 18:28 ` [PATCH 0/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type() Pierrick Bouvier
2025-04-17 18:29 ` Pierrick Bouvier
@ 2025-04-17 18:38 ` Philippe Mathieu-Daudé
2025-04-17 19:02 ` Pierrick Bouvier
1 sibling, 1 reply; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-04-17 18:38 UTC (permalink / raw)
To: Pierrick Bouvier, qemu-devel
Cc: Paolo Bonzini, Yanan Wang, Marc-André Lureau, Zhao Liu,
Marcel Apfelbaum, Daniel P. Berrangé, Eduardo Habkost,
Richard Henderson
On 17/4/25 20:28, Pierrick Bouvier wrote:
> Maybe it would be preferable to focus on providing a minimal but
> *complete* TargetInfo before upstreaming any of this, as it's really
> blocking the rest of the work for single binary.
I suppose I misunderstood you asking to post these reviewed patches as
separate of the TargetInfo series which need more work:
"I just feel the last 3 commits, and this one, are a bit disconnected
from the series."
https://lore.kernel.org/qemu-devel/0b4376ee-504b-4096-a590-8a509ec7894d@linaro.org/
>
> Minimal requirements to have a complete series would be:
> - Rename QMP TargetInfo struct to use that name
> - Be able to query target cpu type (what this series does)
> - Be able to query machine cpu type
> - Modify generic functions listing machines/cpus to take this into account
> - Tag labeled boards/cpu in hw/arm to prove this is working (without
> doing any other cleanup to those files and *not* make them common)
> - No other additional target information for the v1, let's keep that for
> later.
>
> Note: target_cpu_type will not be TYPE_ARM_CPU, as it wrongly wraps
> arm32 and aarch64 cpus, while it should correctly identify one or the
> other. I suggested TYPE_TARGET_CPU_ARM, TYPE_TARGET_CPU_AARCH64, and
> same for machines: TYPE_TARGET_MACHINE_ARM, TYPE_TARGET_MACHINE_AARCH64.
> So we can reuse this naming convention with any other target we'll reuse
> in the future.
Got it.
>
> Pierrick
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type()
2025-04-17 18:38 ` Philippe Mathieu-Daudé
@ 2025-04-17 19:02 ` Pierrick Bouvier
0 siblings, 0 replies; 13+ messages in thread
From: Pierrick Bouvier @ 2025-04-17 19:02 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Paolo Bonzini, Yanan Wang, Marc-André Lureau, Zhao Liu,
Marcel Apfelbaum, Daniel P. Berrangé, Eduardo Habkost,
Richard Henderson
On 4/17/25 11:38, Philippe Mathieu-Daudé wrote:
> On 17/4/25 20:28, Pierrick Bouvier wrote:
>> Maybe it would be preferable to focus on providing a minimal but
>> *complete* TargetInfo before upstreaming any of this, as it's really
>> blocking the rest of the work for single binary.
>
> I suppose I misunderstood you asking to post these reviewed patches as
> separate of the TargetInfo series which need more work:
>
> "I just feel the last 3 commits, and this one, are a bit disconnected
> from the series."
>
You're right, it meant that the 4 commits (accel: *) are extra cleanups
and not really related to the series title "Introduce TargetInfo API
(for single binary)", which is fine to upstream by itself.
However, introducing target_info.h partially just to do this cleanup
first sounds a bit weird to me.
My complete thought was "This cleanup is ok, but please postpone it once
we have TargetInfo API upstream".
It's a remark I'll keep doing for TargetInfo, as the goal for v1 is to
have a minimal API, introducing the concept of Machine and CPU types,
and apply it to hw/arm, which was our initial need and why we talked
about this in the first place.
Once it's there upstream, we can all enhance it in parallel, with the
various needs we'll have for cleaning up other parts of the codebase.
My rationale is that it's easy to rebase our conflicting code against a
common file, but it's hard to do it if it doesn't exist, thus my
insistence on getting a minimal API first.
For instance, once it's upstream, we can easily add in different series
(and different people):
- target_current() -> enum Target
- target_aarch64() -> bool
and progress without having to first be blocked by the existence of
TargetInfo itself. We can as well cherry pick our mutual patches
touching TargetInfo without getting blocked by the upstream process
itself, and the first series to be pulled will make it available for
everyone.
> https://lore.kernel.org/qemu-devel/0b4376ee-504b-4096-a590-8a509ec7894d@linaro.org/
>
>>
>> Minimal requirements to have a complete series would be:
>> - Rename QMP TargetInfo struct to use that name
>> - Be able to query target cpu type (what this series does)
>> - Be able to query machine cpu type
>> - Modify generic functions listing machines/cpus to take this into account
>> - Tag labeled boards/cpu in hw/arm to prove this is working (without
>> doing any other cleanup to those files and *not* make them common)
>> - No other additional target information for the v1, let's keep that for
>> later.
>>
>> Note: target_cpu_type will not be TYPE_ARM_CPU, as it wrongly wraps
>> arm32 and aarch64 cpus, while it should correctly identify one or the
>> other. I suggested TYPE_TARGET_CPU_ARM, TYPE_TARGET_CPU_AARCH64, and
>> same for machines: TYPE_TARGET_MACHINE_ARM, TYPE_TARGET_MACHINE_AARCH64.
>> So we can reuse this naming convention with any other target we'll reuse
>> in the future.
>
> Got it.
>
>>
>> Pierrick
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type()
2025-04-17 16:54 [PATCH 0/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type() Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2025-04-17 18:28 ` [PATCH 0/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type() Pierrick Bouvier
@ 2025-04-18 17:42 ` Richard Henderson
8 siblings, 0 replies; 13+ messages in thread
From: Richard Henderson @ 2025-04-18 17:42 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Paolo Bonzini, Yanan Wang, Marc-André Lureau, Zhao Liu,
Marcel Apfelbaum, Daniel P. Berrangé, Eduardo Habkost
On 4/17/25 09:54, Philippe Mathieu-Daudé wrote:
> Philippe Mathieu-Daudé (7):
> qemu: Introduce target_cpu_type()
> cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type()
> cpus: Move target-agnostic methods out of cpu-target.c
> accel: Implement accel_init_ops_interfaces() for both system/user mode
> accel: Include missing 'qemu/accel.h' header in accel-internal.h
> accel: Make AccelCPUClass structure target-agnostic
> accel: Move target-agnostic code from accel-target.c -> accel-common.c
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2025-04-18 17:43 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-17 16:54 [PATCH 0/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type() Philippe Mathieu-Daudé
2025-04-17 16:54 ` [PATCH 1/7] qemu: Introduce target_cpu_type() Philippe Mathieu-Daudé
2025-04-17 16:54 ` [PATCH 2/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type() Philippe Mathieu-Daudé
2025-04-17 16:54 ` [PATCH 3/7] cpus: Move target-agnostic methods out of cpu-target.c Philippe Mathieu-Daudé
2025-04-17 16:54 ` [PATCH 4/7] accel: Implement accel_init_ops_interfaces() for both system/user mode Philippe Mathieu-Daudé
2025-04-17 16:54 ` [PATCH 5/7] accel: Include missing 'qemu/accel.h' header in accel-internal.h Philippe Mathieu-Daudé
2025-04-17 16:54 ` [PATCH 6/7] accel: Make AccelCPUClass structure target-agnostic Philippe Mathieu-Daudé
2025-04-17 16:54 ` [PATCH 7/7] accel: Move target-agnostic code from accel-target.c -> accel-common.c Philippe Mathieu-Daudé
2025-04-17 18:28 ` [PATCH 0/7] cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type() Pierrick Bouvier
2025-04-17 18:29 ` Pierrick Bouvier
2025-04-17 18:38 ` Philippe Mathieu-Daudé
2025-04-17 19:02 ` Pierrick Bouvier
2025-04-18 17:42 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).