Commit a5b14a8e38 for qemu.org

commit a5b14a8e38f25b7adfda1164da83bdceeb10a9ae
Author: Xiaoyao Li <xiaoyao.li@intel.com>
Date:   Tue May 12 16:21:06 2026 +0800

    i386/tdx: Use .has_gpa field to check if the gpa is valid

    When translating the QAPI type GuestPanicInformationTdx into its C
    struct, the generated code provides a .has_gpa boolean field to indicate
    whether the optional gpa field is present.

    Replace the magic sentinel value -1ULL, previously used to signal "no
    valid GPA", with the idiomatic .has_gpa field.  This removes the
    implicit sentinel coupling and makes the validity check self-documenting.

    Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
    Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
    Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
    Link: https://lore.kernel.org/r/20260512082108.621596-2-xiaoyao.li@intel.com
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

diff --git a/system/runstate.c b/system/runstate.c
index 0e1cb3b4e6..09be7c8d20 100644
--- a/system/runstate.c
+++ b/system/runstate.c
@@ -706,7 +706,7 @@ void qemu_system_guest_panicked(GuestPanicInformation *info)
                           " error code: 0x%" PRIx32 " error message:\"%s\"\n",
                           info->u.tdx.error_code, message);
             g_free(message);
-            if (info->u.tdx.gpa != -1ull) {
+            if (info->u.tdx.has_gpa) {
                 qemu_log_mask(LOG_GUEST_ERROR, "Additional error information "
                               "can be found at gpa page: 0x%" PRIx64 "\n",
                               info->u.tdx.gpa);
diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c
index df46fce769..da4478cb21 100644
--- a/target/i386/kvm/tdx.c
+++ b/target/i386/kvm/tdx.c
@@ -1403,7 +1403,7 @@ int tdx_handle_report_fatal_error(X86CPU *cpu, struct kvm_run *run)
     uint64_t reg_mask = run->system_event.data[R_ECX];
     char *message = NULL;
     uint64_t *tmp;
-    uint64_t gpa = -1ull;
+    uint64_t gpa = 0;
     bool has_gpa = false;

     if (error_code & 0xffff) {