aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhao Liu <zhao1.liu@intel.com>2025-07-17 10:39:33 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2025-07-17 15:51:29 +0200
commite52af92e9e6f8fc00f2ae6b63214b3d6213b3cec (patch)
tree2ad75c8997dc5f7ec7f02e97d4ebbf08dd1c49c9
parentd3a24134e37d57abd3e7445842cda2717f49e96d (diff)
downloadqemu-e52af92e9e6f8fc00f2ae6b63214b3d6213b3cec.zip
qemu-e52af92e9e6f8fc00f2ae6b63214b3d6213b3cec.tar.gz
qemu-e52af92e9e6f8fc00f2ae6b63214b3d6213b3cec.tar.bz2
i386/cpu: Move x86_ext_save_areas[] initialization to .instance_init
In x86_cpu_post_initfn(), the initialization of x86_ext_save_areas[] marks the unsupported xsave areas based on Host support. This step must be done before accel_cpu_instance_init(), otherwise, KVM's assertion on host xsave support would fail: qemu-system-x86_64: ../target/i386/kvm/kvm-cpu.c:149: kvm_cpu_xsave_init: Assertion `esa->size == eax' failed. (on AMD EPYC 7302 16-Core Processor) Move x86_ext_save_areas[] initialization to .instance_init and place it before accel_cpu_instance_init(). Fixes: commit 5f158abef44c ("target/i386: move accel_cpu_instance_init to .instance_init") Reported-by: Paolo Abeni <pabeni@redhat.com> Tested-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20250717023933.2502109-1-zhao1.liu@intel.com Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--target/i386/cpu.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index da7d8dc..251d576 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -9620,6 +9620,16 @@ static void x86_cpu_register_feature_bit_props(X86CPUClass *xcc,
static void x86_cpu_post_initfn(Object *obj)
{
+#ifndef CONFIG_USER_ONLY
+ if (current_machine && current_machine->cgs) {
+ x86_confidential_guest_cpu_instance_init(
+ X86_CONFIDENTIAL_GUEST(current_machine->cgs), (CPU(obj)));
+ }
+#endif
+}
+
+static void x86_cpu_init_xsave(void)
+{
static bool first = true;
uint64_t supported_xcr0;
int i;
@@ -9639,13 +9649,6 @@ static void x86_cpu_post_initfn(Object *obj)
}
}
}
-
-#ifndef CONFIG_USER_ONLY
- if (current_machine && current_machine->cgs) {
- x86_confidential_guest_cpu_instance_init(
- X86_CONFIDENTIAL_GUEST(current_machine->cgs), (CPU(obj)));
- }
-#endif
}
static void x86_cpu_init_default_topo(X86CPU *cpu)
@@ -9715,6 +9718,11 @@ static void x86_cpu_initfn(Object *obj)
x86_cpu_load_model(cpu, xcc->model);
}
+ /*
+ * accel's cpu_instance_init may have the xsave check,
+ * so x86_ext_save_areas[] must be initialized before this.
+ */
+ x86_cpu_init_xsave();
accel_cpu_instance_init(CPU(obj));
}