target/i386: SEV: do not assume machine->cgs is SEV
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 5 Jun 2024 18:09:44 +0000 (20:09 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 17 Jun 2024 07:47:39 +0000 (09:47 +0200)
There can be other confidential computing classes that are not derived
from sev-common.  Avoid aborting when encountering them.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/sev.c

index c40562dce310c104403542f6a0fa4db8746f84c6..30b83f1d77dfe83aeec45b2eda9942f4248baa03 100644 (file)
@@ -1712,7 +1712,9 @@ void sev_es_set_reset_vector(CPUState *cpu)
 {
     X86CPU *x86;
     CPUX86State *env;
-    SevCommonState *sev_common = SEV_COMMON(MACHINE(qdev_get_machine())->cgs);
+    ConfidentialGuestSupport *cgs = MACHINE(qdev_get_machine())->cgs;
+    SevCommonState *sev_common = SEV_COMMON(
+        object_dynamic_cast(OBJECT(cgs), TYPE_SEV_COMMON));
 
     /* Only update if we have valid reset information */
     if (!sev_common || !sev_common->reset_data_valid) {