summaryrefslogtreecommitdiffstats
path: root/target/i386/tcg
diff options
context:
space:
mode:
authorClaudio Fontana2021-07-23 13:29:21 +0200
committerPaolo Bonzini2021-07-23 15:47:13 +0200
commit5b8978d8042660de35b2c67c62ffeb6b42ff441e (patch)
tree6e1205da9c17e198c66fec9230d2b82d9183500c /target/i386/tcg
parenttarget/i386: Added consistency checks for CR3 (diff)
downloadqemu-5b8978d8042660de35b2c67c62ffeb6b42ff441e.tar.gz
qemu-5b8978d8042660de35b2c67c62ffeb6b42ff441e.tar.xz
qemu-5b8978d8042660de35b2c67c62ffeb6b42ff441e.zip
i386: do not call cpudef-only models functions for max, host, base
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. 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, which set svm to "off". 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 <cfontana@suse.de> Tested-by: Alexander Bulekov <alxndr@bu.edu> Fixes: f5cc5a5c ("i386: split cpu accelerators from cpu.c,"...) Resolves: https://gitlab.com/qemu-project/qemu/-/issues/477 Message-Id: <20210723112921.12637-1-cfontana@suse.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'target/i386/tcg')
-rw-r--r--target/i386/tcg/tcg-cpu.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c
index 238e3a9395..93a79a5741 100644
--- a/target/i386/tcg/tcg-cpu.c
+++ b/target/i386/tcg/tcg-cpu.c
@@ -111,7 +111,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" },
@@ -121,8 +122,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();
}