qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Zhao Liu <zhao1.liu@intel.com>, Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, pankaj.gupta@amd.com
Subject: Re: [PATCH] target/i386: SEV: do not assume machine->cgs is SEV
Date: Wed, 5 Jun 2024 20:52:37 -0700	[thread overview]
Message-ID: <b930a4ea-73a3-40a8-bbc1-def8aea72c5d@linaro.org> (raw)
In-Reply-To: <ZmEwvsAnh1lXNqhS@intel.com>

On 6/5/24 20:45, Zhao Liu wrote:
>> @@ -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)

You don't need the explicit cast either, since C auto-converts from void*.

   sev_common = object_dynamic_cast(OBJECT(cgs), TYPE_SEV_COMMON);


r~


  reply	other threads:[~2024-06-06  3:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-05 22:44 [PATCH] target/i386: SEV: do not assume machine->cgs is SEV Paolo Bonzini
2024-06-06  3:45 ` Zhao Liu
2024-06-06  3:52   ` Richard Henderson [this message]
2024-06-06  6:32     ` Paolo Bonzini
2024-06-06 16:06 ` Xiaoyao Li
2024-06-06 16:10   ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b930a4ea-73a3-40a8-bbc1-def8aea72c5d@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=pankaj.gupta@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zhao1.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).