[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] target/i386: SEV: do not assume machine->cgs is SEV
From: |
Zhao Liu |
Subject: |
Re: [PATCH] target/i386: SEV: do not assume machine->cgs is SEV |
Date: |
Thu, 6 Jun 2024 11:45:02 +0800 |
On Thu, Jun 06, 2024 at 12:44:09AM +0200, Paolo Bonzini wrote:
> Date: Thu, 6 Jun 2024 00:44:09 +0200
> From: Paolo Bonzini <pbonzini@redhat.com>
> Subject: [PATCH] target/i386: SEV: do not assume machine->cgs is SEV
> X-Mailer: git-send-email 2.45.1
>
> 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 | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/target/i386/sev.c b/target/i386/sev.c
> index 004c667ac14..97e15f8b7a9 100644
> --- a/target/i386/sev.c
> +++ b/target/i386/sev.c
> @@ -1710,7 +1710,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));
SEV_COMMON(object_dynamic_cast()) looks to be twice cast, we can just
force to do conversion with pointer type:
(SevCommonState *) object_dynamic_cast(OBJECT(cgs), TYPE_SEV_COMMON)
> /* Only update if we have valid reset information */
> if (!sev_common || !sev_common->reset_data_valid) {
> --
> 2.45.1
>
>