Skip to contentSkip to conversation

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

PATCH In review Xiaoyao Li 3 participants 4 messages Jul 10, 2025 – Sep 12, 2025 x86 trust domain extensions (TDX)

lore
Share & tools
lore

Xiaoyao Li

author
#0 lore raw

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

There is actually the .has_gpa field when translating the QAPI data type GuestPanicInformationTdx to C structure.

Stop using the magic number -1 as the indicator for no valid gpa. Instead just use .has_gpa field.

---
 system/runstate.c     | 2 +-
 target/i386/kvm/tdx.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
system/runstate.c +1 -1
index 38900c935a35..87cdcab4f388 100644
@@ -690,7 +690,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);
target/i386/kvm/tdx.c +1 -1
index 370a9b6e656c..14704eb523c5 100644
@@ -1298,7 +1298,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) {
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Xiaoyao Li

There is actually the .has_gpa field when translating the QAPI data type GuestPanicInformationTdx to C structure.

Stop using the magic number -1 as the indicator for no valid gpa. Instead just use .has_gpa field.

---
 system/runstate.c     | 2 +-
 target/i386/kvm/tdx.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
Reviewed-by on v1 1/1
#2 lore raw
In reply to Xiaoyao Li
Quoted 6 lines

-----Original Message-----
From: Li, Xiaoyao <[email protected]>
Subject: [PATCH] i386/tdx: Use .has_gpa field to check if the gpa is valid

Quoted 7 lines

There is actually the .has_gpa field when translating the QAPI data type GuestPanicInformationTdx to C structure.

Stop using the magic number -1 as the indicator for no valid gpa. Instead just use .has_gpa field.

Good catch.

Thanks
Zhenzhong

author
#3 lore raw
In reply to Xiaoyao Li

Gentle ping.

Quoted 38 lines · Xiaoyao Li

There is actually the .has_gpa field when translating the QAPI data type GuestPanicInformationTdx to C structure.

Stop using the magic number -1 as the indicator for no valid gpa. Instead just use .has_gpa field.

---
  system/runstate.c     | 2 +-
  target/i386/kvm/tdx.c | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
system/runstate.c +1 -1
index 38900c935a35..87cdcab4f388 100644
@@ -690,7 +690,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);
target/i386/kvm/tdx.c +1 -1
index 370a9b6e656c..14704eb523c5 100644
@@ -1298,7 +1298,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) {