Hi Paolo,
On 4/1/2025 9:01 PM, Xiaoyao Li wrote:
...
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index add6430f7edd..5c69d1489365 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -36,6 +36,7 @@
#include "hw/qdev-properties.h"
#include "hw/i386/topology.h"
#ifndef CONFIG_USER_ONLY
+#include "confidential-guest.h"
#include "system/reset.h"
#include "qapi/qapi-commands-machine-target.h"
#include "exec/address-spaces.h"
@@ -8504,6 +8505,15 @@ static void x86_cpu_post_initfn(Object *obj)
}
accel_cpu_instance_init(CPU(obj));
+
+#ifndef CONFIG_USER_ONLY
+ MachineState *ms = MACHINE(object_dynamic_cast(qdev_get_machine(),
+ TYPE_MACHINE));
It leads to
qemu-system-x86_64: ../hw/core/qdev.c:824: qdev_get_machine:
Assertion `dev' failed.
Aborted (core dumped)
for the case of "-cpu help" due to the assert(dev) in qdev_get_machine().
How do you want to resolve it? I can think of two:
1. remove the assert() in qdev_get_machine(). or
2. drop the callback introduce by this patch. Instead just do
if (is_tdx_vm()) {
tdx_cpu_instance_init();
}
+ if (ms && ms->cgs) {
+
x86_confidential_guest_cpu_instance_init(X86_CONFIDENTIAL_GUEST(ms->cgs),
+ (CPU(obj)));
+ }
+#endif
}
static void x86_cpu_init_default_topo(X86CPU *cpu)