On 7/10/2025 11:55 AM, Zhenzhong Duan wrote:
Gpa is defined in QAPI but never reported to monitor because has_gpa is
never set to ture.
Fix it by setting has_gpa to ture when TDX_REPORT_FATAL_ERROR_GPA_VALID
is set in error_code.
Hi Zhenzhong,
I would like to understand what the problem is without
panic_info->u.tdx.has_gpa being set?
Fixes: 6e250463b08b ("i386/tdx: Wire TDX_REPORT_FATAL_ERROR with GuestPanic
facility")
Signed-off-by: Zhenzhong Duan <[email protected]>
---
target/i386/kvm/tdx.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c
index e809e4b2df..370a9b6e65 100644
--- a/target/i386/kvm/tdx.c
+++ b/target/i386/kvm/tdx.c
@@ -1269,7 +1269,8 @@ void tdx_handle_get_tdvmcall_info(X86CPU *cpu, struct
kvm_run *run)
}
static void tdx_panicked_on_fatal_error(X86CPU *cpu, uint64_t error_code,
- char *message, uint64_t gpa)
+ char *message, bool has_gpa,
+ uint64_t gpa)
{
GuestPanicInformation *panic_info;
@@ -1278,6 +1279,7 @@ static void tdx_panicked_on_fatal_error(X86CPU *cpu, uint64_t error_code,
panic_info->u.tdx.error_code = (uint32_t) error_code;
panic_info->u.tdx.message = message;
panic_info->u.tdx.gpa = gpa;
+ panic_info->u.tdx.has_gpa = has_gpa;
qemu_system_guest_panicked(panic_info);
}
@@ -1297,6 +1299,7 @@ int tdx_handle_report_fatal_error(X86CPU *cpu, struct
kvm_run *run)
char *message = NULL;
uint64_t *tmp;
uint64_t gpa = -1ull;
+ bool has_gpa = false;
if (error_code & 0xffff) {
error_report("TDX: REPORT_FATAL_ERROR: invalid error code: 0x%"PRIx64,
@@ -1329,9 +1332,10 @@ int tdx_handle_report_fatal_error(X86CPU *cpu, struct
kvm_run *run)
if (error_code & TDX_REPORT_FATAL_ERROR_GPA_VALID) {
gpa = run->system_event.data[R_R13];
+ has_gpa = true;
}
- tdx_panicked_on_fatal_error(cpu, error_code, message, gpa);
+ tdx_panicked_on_fatal_error(cpu, error_code, message, has_gpa, gpa);
return -1;
}