diff mbox series

[4/5] target/i386: SEV: store pointer to decoded id_auth in SevSnpGuest

Message ID 20240627145357.1038664-5-pbonzini@redhat.com (mailing list archive)
State New, archived
Headers show
Series target/i386: SEV: fix compiler warnings on 32-bit hosts | expand

Commit Message

Paolo Bonzini June 27, 2024, 2:53 p.m. UTC
Do not rely on finish->id_auth_uaddr, so that there are no casts from
pointer to uint64_t.  They break on 32-bit hosts.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/sev.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Richard Henderson June 27, 2024, 4:37 p.m. UTC | #1
On 6/27/24 07:53, Paolo Bonzini wrote:
> Do not rely on finish->id_auth_uaddr, so that there are no casts from
> pointer to uint64_t.  They break on 32-bit hosts.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   target/i386/sev.c | 13 ++++++++-----
>   1 file changed, 8 insertions(+), 5 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
diff mbox series

Patch

diff --git a/target/i386/sev.c b/target/i386/sev.c
index a6b063b762c..28d6bd3adfa 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -155,6 +155,7 @@  struct SevSnpGuestState {
     char *id_block_base64;
     uint8_t *id_block;
     char *id_auth_base64;
+    uint8_t *id_auth;
     char *host_data;
 
     struct kvm_sev_snp_launch_start kvm_start_conf;
@@ -2208,16 +2209,16 @@  sev_snp_guest_set_id_auth(Object *obj, const char *value, Error **errp)
     struct kvm_sev_snp_launch_finish *finish = &sev_snp_guest->kvm_finish_conf;
     gsize len;
 
+    finish->id_auth_uaddr = 0;
+    g_free(sev_snp_guest->id_auth);
     g_free(sev_snp_guest->id_auth_base64);
-    g_free((guchar *)finish->id_auth_uaddr);
 
     /* store the base64 str so we don't need to re-encode in getter */
     sev_snp_guest->id_auth_base64 = g_strdup(value);
+    sev_snp_guest->id_auth =
+        qbase64_decode(sev_snp_guest->id_auth_base64, -1, &len, errp);
 
-    finish->id_auth_uaddr =
-        (uint64_t)qbase64_decode(sev_snp_guest->id_auth_base64, -1, &len, errp);
-
-    if (!finish->id_auth_uaddr) {
+    if (!sev_snp_guest->id_auth) {
         return;
     }
 
@@ -2226,6 +2227,8 @@  sev_snp_guest_set_id_auth(Object *obj, const char *value, Error **errp)
                    len, KVM_SEV_SNP_ID_AUTH_SIZE);
         return;
     }
+
+    finish->id_auth_uaddr = (uintptr_t)sev_snp_guest->id_auth;
 }
 
 static bool