cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type()
cover cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type()
(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.cSignature · 1 line
2.47.1
PATCH 1/7 qemu: Introduce target_cpu_type()
Introduce the target_cpu_type() helper to access the CPU_RESOLVING_TYPE target-specific definition from target-agnostic code.
--- 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
MAINTAINERS +2 -0
@@ -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
meson.build +2 -0
@@ -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')
include/qemu/target_info.h new file +19 -0
@@ -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
target_info-defs.c new file +16 -0
@@ -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 ; +}
Signature · 1 line
2.47.1
PATCH 2/7 cpus: Replace CPU_RESOLVING_TYPE -> target_cpu_type()
In reply to Philippe Mathieu-Daudé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.
--- accel/accel-target.c | 6 ++++-- accel/tcg/tcg-all.c | 5 +++-- cpu-target.c | 7 ++++--- 3 files changed, 11 insertions(+), 7 deletions(-)
accel/accel-target.c +4 -2
@@ -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); } }
accel/tcg/tcg-all.c +3 -2
@@ -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) {
cpu-target.c +4 -3
@@ -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 ();
Signature · 1 line
2.47.1
PATCH 3/7 cpus: Move target-agnostic methods out of cpu-target.c
In reply to Philippe Mathieu-Daudé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.
--- cpu-target.c | 77 +------------------------------------------- hw/core/cpu-common.c | 74 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 76 deletions(-)
cpu-target.c +1 -76
@@ -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)
hw/core/cpu-common.c +74 -0
95 lines not on this page · raw message
Signature · 1 line
2.47.1
PATCH 4/7 accel: Implement accel_init_ops_interfaces() for both system/user mode
In reply to Philippe Mathieu-Daudé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.
---
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%)MAINTAINERS +1 -1
@@ -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
accel/accel-internal.h renamed from accel/accel-system.h +4 -4
@@ -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 */
accel/accel-system.c +2 -2
@@ -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;
accel/accel-target.c +2 -8
@@ -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); }
accel/accel-user.c +6 -0
@@ -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 ) {
Signature · 1 line
2.47.1
PATCH 5/7 accel: Include missing 'qemu/accel.h' header in accel-internal.h
In reply to Philippe Mathieu-Daudé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);
| ^--- accel/accel-internal.h | 2 ++ 1 file changed, 2 insertions(+)
accel/accel-internal.h +2 -0
@@ -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 */
Signature · 1 line
2.47.1
PATCH 6/7 accel: Make AccelCPUClass structure target-agnostic
In reply to Philippe Mathieu-Daudé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);
| ^--- 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
include/accel/accel-cpu-target.h +1 -11
@@ -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 */
include/accel/accel-cpu.h new file +23 -0
@@ -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 */
accel/accel-target.c +0 -1
@@ -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"
Signature · 1 line
2.47.1
PATCH 7/7 accel: Move target-agnostic code from accel-target.c -> accel-common.c
In reply to Philippe Mathieu-Daudé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.
--- 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
accel/accel-common.c new file +142 -0
@@ -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)
accel/accel-target.c +0 -129
142 lines not on this page · raw message
accel/meson.build +1 -0
@@ -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'))
Signature · 1 line
2.47.1
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
Quoted 41 lines · Philippe Mathieu-Daudé
(Series fully reviewed, I plan to queue it via my tree)
This series replace the target-specific
CPU_RESOLVING_TYPEby calls to the target-agnostictarget_cpu_type()method.Since RFCv1:
- Split from bigger/unrelated TargetInfo series (Pierrick)
- Added Pierrick R-b tags
- Added commit descriptionsPhilippe Mathieu-Daudé (7):
qemu: Introducetarget_cpu_type()
cpus: ReplaceCPU_RESOLVING_TYPE->target_cpu_type()
cpus: Move target-agnostic methods out ofcpu-target.c
accel: Implementaccel_init_ops_interfaces()for both system/user mode
accel: Include missing 'qemu/accel.h' header inaccel-internal.h
accel: Make AccelCPUClass structure target-agnostic
accel: Move target-agnostic code fromaccel-target.c->accel-common.cMAINTAINERS | 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 100644include/accel/accel-cpu.hcreate mode 100644include/qemu/target_info.hcreate mode 100644accel/accel-common.c
create mode 100644target_info-defs.c
Quoted 8 lines · Pierrick Bouvier
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
Quoted 1 line · Pierrick Bouvier
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/[email protected]/
Quoted 11 lines
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.
Quoted 2 lines
Note:
target_cpu_typewill not beTYPE_ARM_CPU, as it wrongly wraps arm32 and aarch64 cpus, while it should correctly identify one or the other. I suggestedTYPE_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.
Quoted 2 lines
Pierrick
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 3 lines · Pierrick Bouvier
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.
Quoted 24 lines
https://lore.kernel.org/qemu-devel/[email protected]/
Quoted 11 lines
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.Quoted 6 lines
Note:
target_cpu_typewill not beTYPE_ARM_CPU, as it wrongly wraps arm32 and aarch64 cpus, while it should correctly identify one or the other. I suggestedTYPE_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.
Quoted 2 lines
Pierrick
Quoted 8 lines · Philippe Mathieu-Daudé
Philippe Mathieu-Daudé (7):
qemu: Introducetarget_cpu_type()
cpus: ReplaceCPU_RESOLVING_TYPE->target_cpu_type()
cpus: Move target-agnostic methods out ofcpu-target.c
accel: Implementaccel_init_ops_interfaces()for both system/user mode
accel: Include missing 'qemu/accel.h' header inaccel-internal.h
accel: Make AccelCPUClass structure target-agnostic
accel: Move target-agnostic code fromaccel-target.c->accel-common.c
r~