i386: do not call cpudef-only models functions for max, host, base
PATCH 1/1 i386: do not call cpudef-only models functions for max, host, base
properties set by function x86_cpu_apply_props, including kvm_default_props, tcg_default_props,
and the "vendor" property for KVM and HVF,
are actually to be set only for cpu models in builtin_x86_defs, registered with x86_register_cpu_model_type, and not for cpu models "base", "max", and the subclass "host".
This has been detected as a bug with Nested on AMD with cpu "host", as svm was not turned on by default, due to the wrongful setting of kvm_default_props via x86_cpu_apply_props.
Rectify the bug introduced in commit "i386: split cpu accelerators" and document the functions that are builtin_x86_defs-only.
--- target/i386/cpu.c | 19 ++++++- target/i386/host-cpu.c | 13 +++-- target/i386/kvm/kvm-cpu.c | 105 ++++++++++++++++++++------------------ target/i386/tcg/tcg-cpu.c | 11 ++-- 4 files changed, 89 insertions(+), 59 deletions(-)
target/i386/cpu.c +17 -2
@@ -4919,6 +4919,9 @@ static uint64_t x86_cpu_get_supported_feature_word(FeatureWord w,return r; } +/* +* Only for builtin_x86_defs models initialized with x86_register_cpudef_types. +*/ void x86_cpu_apply_props (X86CPU *cpu,PropValue *props) {PropValue *pv;
@@ -4931,7 +4934,11 @@ void x86_cpu_apply_props(X86CPU *cpu, PropValue *props) } } -/* Apply properties for the CPU model version specified in model */ +/* +* Apply properties for the CPU model version specified in model. +* Only for builtin_x86_defs models initialized with x86_register_cpudef_types. +*/ +static void x86_cpu_apply_version_props (X86CPU *cpu,X86CPUModel *model) {const X86CPUVersionDefinition *vdef;
@@ -4960,7 +4967,9 @@ static void x86_cpu_apply_version_props(X86CPU *cpu, X86CPUModel *model)assert (vdef->version == version); } -/* Load data from X86CPUDefinition into a X86CPU object +/* +* Load data from X86CPUDefinition into a X86CPU object. +* Only for builtin_x86_defs models initialized with x86_register_cpudef_types. */ static void x86_cpu_load_model (X86CPU *cpu,X86CPUModel *model) {
@@ -5051,6 +5060,12 @@ static void x86_register_cpu_model_type(const char *name, X86CPUModel *model)type_register (&ti); } + +/* +* register builtin_x86_defs; +* "max", "base" and subclasses ("host") are not registered here. +* See x86_cpu_register_types for all model registrations. +*/ static void x86_register_cpudef_types (const X86CPUDefinition *def) {X86CPUModel *m;
target/i386/host-cpu.c +8 -5
@@ -150,13 +150,16 @@ void host_cpu_vendor_fms(char *vendor, int *family, int *model, int *stepping)void host_cpu_instance_init (X86CPU *cpu) { -uint32_t ebx =0 , ecx =0 , edx =0 ; -char vendor[CPUID_VENDOR_SZ +1 ]; +X86CPUClass *xcc =X86_CPU_GET_CLASS (cpu); -host_cpuid (0 ,0 ,NULL , &ebx, &ecx, &edx); -x86_cpu_vendor_words2str (vendor, ebx, edx, ecx); +if (xcc->model) { +uint32_t ebx =0 , ecx =0 , edx =0 ; +char vendor[CPUID_VENDOR_SZ +1 ]; -object_property_set_str (OBJECT (cpu),"vendor" , vendor, &error_abort); +host_cpuid (0 ,0 ,NULL , &ebx, &ecx, &edx); +x86_cpu_vendor_words2str (vendor, ebx, edx, ecx); +object_property_set_str (OBJECT (cpu),"vendor" , vendor, &error_abort); + } }void host_cpu_max_instance_init (X86CPU *cpu)
target/i386/kvm/kvm-cpu.c +56 -49
124 lines not on this page · raw message
target/i386/tcg/tcg-cpu.c +8 -3
@@ -99,7 +99,8 @@ static void tcg_cpu_xsave_init(void) }/* -* TCG-specific defaults that override all CPU models when using TCG +* TCG-specific defaults that override cpudef models when using TCG. +* Only for builtin_x86_defs models initialized with x86_register_cpudef_types. */ static PropValue tcg_default_props[] = { {"vme" ,"off" },
@@ -109,8 +110,12 @@ static PropValue tcg_default_props[] = {static void tcg_cpu_instance_init (CPUState *cs) {X86CPU *cpu =X86_CPU (cs); -/* Special cases not set in the X86CPUDefinition structs: */ -x86_cpu_apply_props (cpu, tcg_default_props); +X86CPUClass *xcc =X86_CPU_GET_CLASS (cpu); + +if (xcc->model) { +/* Special cases not set in the X86CPUDefinition structs: */ +x86_cpu_apply_props (cpu, tcg_default_props); + }tcg_cpu_xsave_init (); }
Signature · 1 line
2.26.2
On 7/22/21 10:38 AM, Claudio Fontana wrote:
It seems the subject got dropped and the first line used as subject... But I'm not sure you want to start the description with it.
Quoted 4 lines
properties set by function
x86_cpu_apply_props, includingkvm_default_props,tcg_default_props,
and the "vendor" property for KVM and HVF,
This newline is what confuses me.
Quoted 8 lines
are actually to be set only for cpu models in
builtin_x86_defs, registered withx86_register_cpu_model_type, and not for cpu models "base", "max", and the subclass "host".This has been detected as a bug with Nested on AMD with cpu "host", as svm was not turned on by default, due to the wrongful setting of
kvm_default_propsviax86_cpu_apply_props.
Quoted 7 lines
Rectify the bug introduced in commit "i386: split cpu accelerators" and document the functions that are builtin_x86_defs-only.
Signed-off-by Claudio Fontana <[email protected]>Tested-by Alexander Bulekov <[email protected]>Fixes f5cc5a5c ("i386: split cpu accelerators from cpu.c,"...)
If you want to have gitlab closes the issue once merged, you'd need to use Resolves:/Fixes: tag instead, see
https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#default-closing-pattern
Quoted 6 lines
--- target/i386/cpu.c | 19 ++++++- target/i386/host-cpu.c | 13 +++-- target/i386/kvm/kvm-cpu.c | 105 ++++++++++++++++++++------------------ target/i386/tcg/tcg-cpu.c | 11 ++-- 4 files changed, 89 insertions(+), 59 deletions(-)
Quoted 5 lines · Philippe Mathieu-Daudé
On 7/22/21 10:38 AM, Claudio Fontana wrote:
It seems the subject got dropped and the first line used as subject... But I'm not sure you want to start the description with it.
hmm the subject got dropped from where? I see it in the mail subject..
Quoted 7 lines
Quoted 5 lines
properties set by function
x86_cpu_apply_props, includingkvm_default_props,tcg_default_props,
and the "vendor" property for KVM and HVF,This newline is what confuses me.
hmm maybe better:
"
Some cpu properties have to be set only for cpu models in builtin_x86_defs, registered with x86_register_cpu_model_type, and not for
cpu models "base", "max", and the subclass "host".
These properties are the ones set by function x86_cpu_apply_props, (also including kvm_default_props, tcg_default_props), and the "vendor" property for the KVM and HVF accelerators.
After recent refactoring of cpu, which also affected these properties, they were instead set unconditionally for all x86 cpus.
Quoted 3 lines
Quoted 3 lines
This has been detected as a bug with Nested on AMD with cpu "host", as svm was not turned on by default, due to the wrongful setting of
kvm_default_propsviax86_cpu_apply_props.
.. which set svm to "off".
Quoted 11 lines
Quoted 7 lines
Rectify the bug introduced in commit "i386: split cpu accelerators" and document the functions that are builtin_x86_defs-only.
Signed-off-by Claudio Fontana <[email protected]>Tested-by Alexander Bulekov <[email protected]>Fixes f5cc5a5c ("i386: split cpu accelerators from cpu.c,"...)If you want to have gitlab closes the issue once merged, you'd need to use Resolves:/Fixes: tag instead, see
https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#default-closing-pattern
I'll try Resolves: to avoid collision with Fixes: used to mark the commit that introduced the regression.
Wdyt about the new text?
Thanks,
Claudio
Quoted 8 lines
Quoted 7 lines
--- target/i386/cpu.c | 19 ++++++- target/i386/host-cpu.c | 13 +++-- target/i386/kvm/kvm-cpu.c | 105 ++++++++++++++++++++------------------ target/i386/tcg/tcg-cpu.c | 11 ++-- 4 files changed, 89 insertions(+), 59 deletions(-)
Quoted 44 lines · Claudio Fontana
Quoted 5 lines · Philippe Mathieu-Daudé
On 7/22/21 10:38 AM, Claudio Fontana wrote:
It seems the subject got dropped and the first line used as subject... But I'm not sure you want to start the description with it.
hmm the subject got dropped from where? I see it in the mail subject..
Quoted 7 lines
Quoted 5 lines
properties set by function
x86_cpu_apply_props, includingkvm_default_props,tcg_default_props,
and the "vendor" property for KVM and HVF,This newline is what confuses me.
hmm maybe better:
"
Some cpu properties have to be set only for cpu models inbuiltin_x86_defs, registered withx86_register_cpu_model_type, and not for
cpu models "base", "max", and the subclass "host".These properties are the ones set by function
x86_cpu_apply_props, (also includingkvm_default_props,tcg_default_props), and the "vendor" property for the KVM and HVF accelerators.After recent refactoring of cpu, which also affected these properties, they were instead set unconditionally for all x86 cpus.
Quoted 3 lines
Quoted 3 lines
This has been detected as a bug with Nested on AMD with cpu "host", as svm was not turned on by default, due to the wrongful setting of
kvm_default_propsviax86_cpu_apply_props... which set svm to "off".
Quoted 8 lines
Quoted 7 lines
Rectify the bug introduced in commit "i386: split cpu accelerators" and document the functions that are builtin_x86_defs-only.
Signed-off-by Claudio Fontana <[email protected]>Tested-by Alexander Bulekov <[email protected]>Fixes f5cc5a5c ("i386: split cpu accelerators from cpu.c,"...)
Quoted 7 lines
Quoted 3 lines
If you want to have gitlab closes the issue once merged, you'd need to use Resolves:/Fixes: tag instead, see
https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#default-closing-patternI'll try Resolves: to avoid collision with Fixes: used to mark the commit that introduced the regression.
Wdyt about the new text?
Clearer, thanks!