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>
Xiaoyao Li committed
May 12, 2026 at 16:21 UTC
a5b14a8e38f25b7adfda1164da83bdceeb10a9ae
2 files changed
+2
-2
system/runstate.c
+1
-1
@@ -706,7 +706,7 @@ void qemu_system_guest_panicked(GuestPanicInformation *info)
706
" error code: 0x%" PRIx32 " error message:\"%s\"\n",
707
info->u.tdx.error_code, message);
708
g_free(message);
709
- if (info->u.tdx.gpa != -1ull) {
709
+ if (info->u.tdx.has_gpa) {
710
qemu_log_mask(LOG_GUEST_ERROR, "Additional error information "
711
"can be found at gpa page: 0x%" PRIx64 "\n",
712
info->u.tdx.gpa);
target/i386/kvm/tdx.c
+1
-1
@@ -1403,7 +1403,7 @@ int tdx_handle_report_fatal_error(X86CPU *cpu, struct kvm_run *run)
1403
uint64_t reg_mask = run->system_event.data[R_ECX];
1404
char *message = NULL;
1405
uint64_t *tmp;
1406
- uint64_t gpa = -1ull;
1406
+ uint64_t gpa = 0;
1407
bool has_gpa = false;
1408
1409
if (error_code & 0xffff) {