Introduce (x86) CPU model deprecation API
PATCH v4 1/2 Introduce (x86) CPU model deprecation API
Complement versioned CPU model framework with the ability of marking some versions deprecated. When that CPU model is chosen, get some warning. The warning message is customized, e.g. telling in which future QEMU version will it be obsoleted.
The deprecation message will also appear by x86_cpu_list_entry(), e.g. '-cpu help'.
QMP 'query-cpu-definitions' will also return a bool value indicating the deprecation status.
---
Changelog
v4:
Move deprecation_note from X86CPUModel to X86CPUDefinition, to make it simple. Also, simplify 2 fields (deprecation_note and deprecated) into 1 (deprecation_note).
v3:
Make the deprecation implementation CPUClass generic.
v2:
Move deprecation check from parse_cpu_option() to machine_run_board_init(), so that it can cover implicit cpu_type assignment cases.
Add qapi new member documentation. Thanks Eric for comment and guidance on qapi.
--- hw/core/machine.c | 12 ++++++++++-- include/hw/core/cpu.h | 3 +++ qapi/machine-target.json | 7 ++++++- target/i386/cpu.c | 8 ++++++++ 4 files changed, 27 insertions(+), 3 deletions(-)
hw/core/machine.c +10 -2
@@ -1095,6 +1095,8 @@ MemoryRegion *machine_consume_memdev(MachineState *machine,void machine_run_board_init (MachineState *machine) {MachineClass *machine_class =MACHINE_GET_CLASS (machine); +ObjectClass *oc =object_class_by_name (machine->cpu_type); +CPUClass *cc;if (machine->ram_memdev_id) {Object *o;
@@ -1114,11 +1116,10 @@ void machine_run_board_init(MachineState *machine)* specified a CPU with -cpu check here that the user CPU is supported. */ if (machine_class->valid_cpu_types && machine->cpu_type) { -ObjectClass *class =object_class_by_name (machine->cpu_type);int i;for (i =0 ; machine_class->valid_cpu_types[i]; i++) { -if (object_class_dynamic_cast (class, +if (object_class_dynamic_cast (oc, machine_class->valid_cpu_types[i])) {/* The user specificed CPU is in the valid field, we are * good to go.
@@ -1141,6 +1142,13 @@ void machine_run_board_init(MachineState *machine) } } +/* Check if CPU type is deprecated and warn if so */ + cc =CPU_CLASS (oc); +if (cc->deprecation_note) { +warn_report ("CPU model %s is deprecated -- %s" , machine->cpu_type, + cc->deprecation_note); + } + machine_class->init (machine); }
include/hw/core/cpu.h +3 -0
@@ -155,6 +155,8 @@ struct TranslationBlock;* @disas_set_info: Setup architecture specific components of disassembly info * @adjust_watchpoint_address: Perform a target-specific adjustment to an * address before attempting to match it against watchpoints. +* @deprecation_note: If this CPUClass is deprecated, this field provides +* related information. * * Represents a CPU family or model. */
@@ -221,6 +223,7 @@ struct CPUClass {vaddr (*adjust_watchpoint_address)(CPUState *cpu,vaddr addr,int len);void (*tcg_initialize)(void ); +const char *deprecation_note;/* Keep non-pointer data at the end to minimize holes. */ int gdb_num_core_regs;bool gdb_stop_before_watchpoint;
qapi/machine-target.json +6 -1
@@ -286,6 +286,10 @@ # in the VM configuration, because aliases may stop being # migration-safe in the future (since 4.1) # +# @deprecated: If true, this CPU model is deprecated and may be removed in +# in some future version of QEMU according to the QEMU deprecation +# policy. (since 5.2) +# # @unavailable-features is a list of QOM property names that # represent CPU model attributes that prevent the CPU from running. # If the QOM property is read-only, that means there's no known
@@ -310,7 +314,8 @@ 'static': 'bool', '*unavailable-features': [ 'str' ], 'typename': 'str', - '*alias-of' : 'str' }, + '*alias-of' : 'str', + 'deprecated' : 'bool' }, 'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) || defined(TARGET_S390X) || defined(TARGET_MIPS)' } ##
target/i386/cpu.c +8 -0
@@ -1633,6 +1633,7 @@ typedef struct X86CPUDefinition {* If NULL, version 1 will be registered automatically. */ const X86CPUVersionDefinition *versions; +const char *deprecation_note; } X86CPUDefinition;/* Reference to a specific CPU model version */
@@ -4992,6 +4993,11 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data) info->migration_safe = cc->migration_safe; info->has_migration_safe = true; info->q_static = cc->static_model; +if (cc->model && cc->model->cpudef->deprecation_note) { + info->deprecated = true; + }else { + info->deprecated = false; + }/* * Old machine types won't report aliases, so that alias translation * doesn't break compatibility with previous QEMU versions.
@@ -5382,9 +5388,11 @@ static void x86_cpu_cpudef_class_init(ObjectClass *oc, void *data) {X86CPUModel *model = data;X86CPUClass *xcc =X86_CPU_CLASS (oc); +CPUClass *cc =CPU_CLASS (oc); xcc->model = model; xcc->migration_safe = true; + cc->deprecation_note = model->cpudef->deprecation_note; }static void x86_register_cpu_model_type (const char *name,X86CPUModel *model)
Signature · 1 line
1.8.3.1
PATCH v4 2/2 Mark Icelake-Client CPU models deprecated
Going to obsolete Icelake-Client CPU models in the future.
---
Change log
v4:
Deprecation note is general now. More detailed information is moved to docs/system/deprecated.rst.
v3:
Obsolete in v5.2 --> v5.3.
--- docs/system/deprecated.rst | 6 ++++++ target/i386/cpu.c | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-)
docs/system/deprecated.rst +6 -0
@@ -329,6 +329,12 @@ The ``compat`` property used to set backwards compatibility modes for the processor has been deprecated. The ``max-cpu-compat`` property of the ``pseries`` machine type should be used instead. +``Icelake-Client`` CPU Model (since 3.1) +'''''''''''''''''''''''''''''''''''''''' + +``Icelake-Client`` CPU Models are deprecated. Use ``Icelake-Server`` CPU +Models instead. + System emulator devices -----------------------
target/i386/cpu.c +7 -3
@@ -3358,10 +3358,13 @@ static X86CPUDefinition builtin_x86_defs[] = { .xlevel = 0x80000008, .model_id = "Intel Core Processor (Icelake)", .versions = (X86CPUVersionDefinition []) { - { .version =1 }, + { + .version =1 , + .note ="Deprecated" + }, { .version =2 , - .note ="no TSX" , + .note ="no TSX, Deprecated" , .alias ="Icelake-Client-noTSX" , .props = (PropValue []) { {"hle" ,"off" },
@@ -3370,7 +3373,8 @@ static X86CPUDefinition builtin_x86_defs[] = { }, }, {/* end of list */ } - } + }, + .deprecation_note = "Deprecated. Use Icelake-Server instead." }, { .name = "Icelake-Server",
Signature · 1 line
1.8.3.1
Re: [PATCH v4 2/2] Mark Icelake-Client CPU models deprecated
Quoted 55 lines · Robert Hoo
Going to obsolete Icelake-Client CPU models in the future.
Signed-off-by Robert Hoo <[email protected]>---
Change log
v4:
Deprecation note is general now. More detailed information is moved todocs/system/deprecated.rst.v3:
Obsolete in v5.2 --> v5.3.--- docs/system/deprecated.rst | 6 ++++++ target/i386/cpu.c | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-)docs/system/deprecated.rst +6
-0@@ -329,6 +329,12 @@ The ``compat`` property used to set backwards compatibility modes for the processor has been deprecated. The ``max-cpu-compat`` property of the ``pseries`` machine type should be used instead. +``Icelake-Client`` CPU Model (since 3.1) +'''''''''''''''''''''''''''''''''''''''' + +``Icelake-Client`` CPU Models are deprecated. Use ``Icelake-Server`` CPU +Models instead. + System emulator devices -----------------------target/i386/cpu.c +5
-2@@ -3358,10 +3358,13 @@ static X86CPUDefinition builtin_x86_defs[] = { .xlevel = 0x80000008, .model_id = "Intel Core Processor (Icelake)", .versions = (X86CPUVersionDefinition []) { - { .version =1 }, + { + .version =1 , + .note ="Deprecated" + }, { .version =2 , - .note ="no TSX" , + .note ="no TSX, Deprecated" , .alias ="Icelake-Client-noTSX" , .props = (PropValue []) { {"hle" ,"off" },
target/i386/cpu.c static X86CPUDefinition builtin_x86_defs[] = { · line 3377
Quoted 6 lines
target/i386/cpu.c +2
-1@@ -3370,7 +3373,8 @@ static X86CPUDefinition builtin_x86_defs[] = { }, }, {/* end of list */ } - } + }, + .deprecation_note = "Deprecated. Use Icelake-Server instead."
This results in the following message:
qemu-system-x86_64: warning: CPU model Icelake-Client-x86_64-cpu is deprecated -- Deprecated. Use Icelake-Server instead.
There's no need to say "deprecate" twice.
I'm changing it to "use Icelake-Server instead" and queueing on x86-next. Thanks!
Quoted 6 lines
target/i386/cpu.c +0
-0}, { .name = "Icelake-Server",Signature · 1 line
1.8.3.1
Signature · 1 line
Eduardo
Quoted 10 lines · Robert Hoo
Complement versioned CPU model framework with the ability of marking some versions deprecated. When that CPU model is chosen, get some warning. The warning message is customized, e.g. telling in which future QEMU version will it be obsoleted.
The deprecation message will also appear byx86_cpu_list_entry(), e.g. '-cpu help'.
QMP 'query-cpu-definitions' will also return a bool value indicating the deprecation status.Signed-off-by Robert Hoo <[email protected]>
Signature · 1 line
Eduardo
Quoted 37 lines · Robert Hoo
Complement versioned CPU model framework with the ability of marking some versions deprecated. When that CPU model is chosen, get some warning. The warning message is customized, e.g. telling in which future QEMU version will it be obsoleted.
The deprecation message will also appear byx86_cpu_list_entry(), e.g. '-cpu help'.
QMP 'query-cpu-definitions' will also return a bool value indicating the deprecation status.Signed-off-by Robert Hoo <[email protected]>---
Changelog
v4:
Movedeprecation_notefrom X86CPUModel to X86CPUDefinition, to make it simple. Also, simplify 2 fields (deprecation_noteand deprecated) into 1 (deprecation_note).v3:
Make the deprecation implementation CPUClass generic.v2:
Move deprecation check fromparse_cpu_option()tomachine_run_board_init(), so that it can cover implicitcpu_typeassignment cases.
Add qapi new member documentation. Thanks Eric for comment and guidance on qapi.--- hw/core/machine.c | 12 ++++++++++-- include/hw/core/cpu.h | 3 +++ qapi/machine-target.json | 7 ++++++- target/i386/cpu.c | 8 ++++++++ 4 files changed, 27 insertions(+), 3 deletions(-)hw/core/machine.c +0
-0
hw/core/machine.c MemoryRegion *machine_consume_memdev(MachineState *machine, · line 1098
Quoted 4 lines
hw/core/machine.c +1
-0@@ -1095,6 +1095,8 @@ MemoryRegion *machine_consume_memdev(MachineState *machine,void machine_run_board_init (MachineState *machine) {MachineClass *machine_class =MACHINE_GET_CLASS (machine); +ObjectClass *oc =object_class_by_name (machine->cpu_type);
machine->cpu_type can be NULL...
Quoted 18 lines
hw/core/machine.c +2
-2+CPUClass *cc;if (machine->ram_memdev_id) {Object *o;@@ -1114,11 +1116,10 @@ void machine_run_board_init(MachineState *machine)* specified a CPU with -cpu check here that the user CPU is supported. */ if (machine_class->valid_cpu_types && machine->cpu_type) { -ObjectClass *class =object_class_by_name (machine->cpu_type);int i;for (i =0 ; machine_class->valid_cpu_types[i]; i++) { -if (object_class_dynamic_cast (class, +if (object_class_dynamic_cast (oc, machine_class->valid_cpu_types[i])) {/* The user specificed CPU is in the valid field, we are * good to go.
hw/core/machine.c void machine_run_board_init(MachineState *machine) · line 1147
Quoted 6 lines
hw/core/machine.c +3
-0@@ -1141,6 +1142,13 @@ void machine_run_board_init(MachineState *machine) } } +/* Check if CPU type is deprecated and warn if so */ + cc =CPU_CLASS (oc); +if (cc->deprecation_note) {
...so this will crash.
I've changed this to "if (cc && cc->deprecation_note)".
Quoted 93 lines
hw/core/machine.c +4
-0+warn_report ("CPU model %s is deprecated -- %s" , machine->cpu_type, + cc->deprecation_note); + } + machine_class->init (machine); }include/hw/core/cpu.h +3
-0@@ -155,6 +155,8 @@ struct TranslationBlock;* @disas_set_info: Setup architecture specific components of disassembly info * @adjust_watchpoint_address: Perform a target-specific adjustment to an * address before attempting to match it against watchpoints. +* @deprecation_note: If this CPUClass is deprecated, this field provides +* related information. * * Represents a CPU family or model. */ @@ -221,6 +223,7 @@ struct CPUClass {vaddr (*adjust_watchpoint_address)(CPUState *cpu,vaddr addr,int len);void (*tcg_initialize)(void ); +const char *deprecation_note;/* Keep non-pointer data at the end to minimize holes. */ int gdb_num_core_regs;bool gdb_stop_before_watchpoint;qapi/machine-target.json +6
-1@@ -286,6 +286,10 @@ # in the VM configuration, because aliases may stop being # migration-safe in the future (since 4.1) # +# @deprecated: If true, this CPU model is deprecated and may be removed in +# in some future version of QEMU according to the QEMU deprecation +# policy. (since 5.2) +# # @unavailable-features is a list of QOM property names that # represent CPU model attributes that prevent the CPU from running. # If the QOM property is read-only, that means there's no known@@ -310,7 +314,8 @@ 'static': 'bool', '*unavailable-features': [ 'str' ], 'typename': 'str', - '*alias-of' : 'str' }, + '*alias-of' : 'str', + 'deprecated' : 'bool' }, 'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) || defined(TARGET_S390X) || defined(TARGET_MIPS)' } ##target/i386/cpu.c +8
-0@@ -1633,6 +1633,7 @@ typedef struct X86CPUDefinition {* If NULL, version 1 will be registered automatically. */ const X86CPUVersionDefinition *versions; +const char *deprecation_note; } X86CPUDefinition;/* Reference to a specific CPU model version */ @@ -4992,6 +4993,11 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data) info->migration_safe = cc->migration_safe; info->has_migration_safe = true; info->q_static = cc->static_model; +if (cc->model && cc->model->cpudef->deprecation_note) { + info->deprecated = true; + }else { + info->deprecated = false; + }/* * Old machine types won't report aliases, so that alias translation * doesn't break compatibility with previous QEMU versions. @@ -5382,9 +5388,11 @@ static void x86_cpu_cpudef_class_init(ObjectClass *oc, void *data) {X86CPUModel *model = data;X86CPUClass *xcc =X86_CPU_CLASS (oc); +CPUClass *cc =CPU_CLASS (oc); xcc->model = model; xcc->migration_safe = true; + cc->deprecation_note = model->cpudef->deprecation_note; }static void x86_register_cpu_model_type (const char *name,X86CPUModel *model)Signature · 1 line
1.8.3.1
Signature · 1 line
Eduardo
Quoted 82 lines · Eduardo Habkost
Quoted 46 lines · Robert Hoo
Complement versioned CPU model framework with the ability of marking some
versions deprecated. When that CPU model is chosen, get some warning. The
warning message is customized, e.g. telling in which future QEMU version will
it be obsoleted.
The deprecation message will also appear byx86_cpu_list_entry(), e.g. '-cpu
help'.
QMP 'query-cpu-definitions' will also return a bool value indicating the
deprecation status.Signed-off-by Robert Hoo <[email protected]>---
Changelog
v4:
Movedeprecation_notefrom X86CPUModel to X86CPUDefinition, to make it
simple. Also, simplify 2 fields (deprecation_noteand deprecated) into 1
(deprecation_note).v3:
Make the deprecation implementation CPUClass generic.v2:
Move deprecation check fromparse_cpu_option()tomachine_run_board_init(), so
that it can cover implicitcpu_typeassignment cases. Add qapi new member documentation. Thanks Eric for comment and guidance on qapi.--- hw/core/machine.c | 12 ++++++++++-- include/hw/core/cpu.h | 3 +++ qapi/machine-target.json | 7 ++++++- target/i386/cpu.c | 8 ++++++++ 4 files changed, 27 insertions(+), 3 deletions(-)hw/core/machine.c +0
-0hw/core/machine.c MemoryRegion · line 1099
Quoted 5 lines
hw/core/machine.c +1
-0@@ -1095,6 +1095,8 @@ MemoryRegion *machine_consume_memdev(MachineState *machine, void machine_run_board_init(MachineState *machine) { MachineClass *machine_class = MACHINE_GET_CLASS(machine); + ObjectClass *oc = object_class_by_name(machine->cpu_type);
machine->cpu_typecan be NULL...Quoted 27 lines
hw/core/machine.c +1
-0+CPUClass *cc;if (machine->ram_memdev_id) {Object *o;hw/core/machine.c +0
-0@@ -1114,11 +1116,10 @@ void machine_run_board_init(MachineState *machine) * specified a CPU with -cpu check here that the user CPU issupported.
*/ if (machine_class->valid_cpu_types && machine->cpu_type) {- ObjectClass *class = object_class_by_name(machine-
Quoted 1 line
cpu_type);int i; for (i = 0; machine_class->valid_cpu_types[i]; i++) {hw/core/machine.c +1
-1- if (object_class_dynamic_cast(class, + if (object_class_dynamic_cast(oc, machine_class-Quoted 1 line
valid_cpu_types[i])) {
/* The user specificed CPU is in the valid field,we are
* good to go.hw/core/machine.c +0
-0@@ -1141,6 +1142,13 @@ void machine_run_board_init(MachineState *machine) } }
Quoted 7 lines
hw/core/machine.c void machine_run_board_init(MachineState *machine) · line 1147
Quoted 3 lines
hw/core/machine.c +3
-0+/* Check if CPU type is deprecated and warn if so */ + cc =CPU_CLASS (oc); +if (cc->deprecation_note) {...so this will crash.
I've changed this to "if (cc &&
cc->deprecation_note)".
Thanks Eduardo.
Quoted 111 lines
Quoted 109 lines
hw/core/machine.c +4
-0+warn_report ("CPU model %s is deprecated -- %s" , machine- >cpu_type, + cc->deprecation_note); + } + machine_class->init (machine);}
include/hw/core/cpu.h +0
-0@@ -155,6 +155,8 @@ struct TranslationBlock;* @disas_set_info: Setup architecture specific components of disassembly info
* @adjust_watchpoint_address: Perform a target-specific
adjustment to an
* address before attempting to match it against watchpoints.
+ * @deprecation_note: If this CPUClass is deprecated, this field provides
+ * related information.
*
* Represents a CPU family or model.
*/include/hw/core/cpu.h +1
-0@@ -221,6 +223,7 @@ struct CPUClass {vaddr (*adjust_watchpoint_address)(CPUState *cpu,vaddr addr,int len);void (*tcg_initialize)(void ); +const char *deprecation_note;/* Keep non-pointer data at the end to minimize holes. */ int gdb_num_core_regs;bool gdb_stop_before_watchpoint;qapi/machine-target.json +0
-0@@ -286,6 +286,10 @@ # in the VM configuration, because aliases may stopbeing
# migration-safe in the future (since 4.1)
#
+# @deprecated: If true, this CPU model is deprecated and may be removed in
+# in some future version of QEMU according to the
QEMU deprecationqapi/machine-target.json +2
-0+# policy. (since 5.2) +# # @unavailable-features is a list of QOM property names that # represent CPU model attributes that prevent the CPU fromrunning.
# If the QOM property is read-only, that means there's no knownqapi/machine-target.json +2
-1@@ -310,7 +314,8 @@ 'static': 'bool', '*unavailable-features': [ 'str' ], 'typename': 'str', - '*alias-of' : 'str' }, + '*alias-of' : 'str', + 'deprecated' : 'bool' }, 'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) ||
defined(TARGET_I386)||defined(TARGET_S390X)||defined(TARGET_MIPS)' }##
target/i386/cpu.c +6
-0@@ -1633,6 +1633,7 @@ typedef struct X86CPUDefinition {* If NULL, version 1 will be registered automatically. */ const X86CPUVersionDefinition *versions; +const char *deprecation_note; } X86CPUDefinition;/* Reference to a specific CPU model version */ @@ -4992,6 +4993,11 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data) info->migration_safe = cc->migration_safe; info->has_migration_safe = true; info->q_static = cc->static_model; +if (cc->model && cc->model->cpudef->deprecation_note) { + info->deprecated = true; + }else { + info->deprecated = false; + }/* * Old machine types won't report aliases, so that alias translation
* doesn't break compatibility with previous QEMU versions.target/i386/cpu.c +2
-0@@ -5382,9 +5388,11 @@ static void x86_cpu_cpudef_class_init(ObjectClass *oc, void *data) {X86CPUModel *model = data;X86CPUClass *xcc =X86_CPU_CLASS (oc); +CPUClass *cc =CPU_CLASS (oc); xcc->model = model; xcc->migration_safe = true; + cc->deprecation_note = model->cpudef->deprecation_note; }static void x86_register_cpu_model_type(const char *name,
X86CPUModel *model)Signature · 1 line
1.8.3.1