On 7/10/2025 10:11 PM, Daniel P. Berrangé wrote:
On Thu, Jul 10, 2025 at 10:06:10PM +0800, Xiaoyao Li wrote:
On 7/10/2025 7:40 PM, Xiaoyao Li wrote:
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?

Never mind, I figure it out.

qapi_event_send_guest_panicked() in qemu_system_guest_panicked will send the
event and data. Libvirt tries to parse the data, but find the .has_data
field is not set correctly.

Close, but not quite.

The "has_" fields are only present in the QEMU internal data structures,
never on the wire in the JSON messages that libvirt receives.

The problem is with QEMU's struct -> JSON serialization - if the 'has_gpa'
field is not set to 'true', then QEMU will *never* emit the 'gpa' field
in the JSON it sends to the client app.

So what libvirt receives is this:

  {"timestamp": {"seconds": 1752156518, "microseconds": 809325},
   "event": "GUEST_PANICKED",
   "data": {"action": "pause", "info": {
       "error-code": 0,
       "message": "TD misconfiguration: SEPT #VE has to be disabled",
       "type": "tdx"}}}

which has no 'gpa' present.

Thanks for the explanation! It's much clear to me now!

My original patch used (gpa == -1) as the indicator for whether gpa is
valid, this needs to be cleaned up. I will send the cleanup patch.

The value you assign to 'gpa' doesn't matter when 'has_gpa' is false,
as it'll never get into the JSON event, so having it be '-1' is not
significantly different from leaving it on 0.

I meant cleanup the QEMU internal logic in qemu_system_guest_panicked()

--- a/system/runstate.c
+++ b/system/runstate.c
@@ -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);


With regards,
Daniel


Reply via email to