[PATCH] i386/tdx: Remove task->watch only when it's valid

Xiaoyao Li posted 1 patch 4 months, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250625035505.2770580-1-xiaoyao.li@intel.com
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
target/i386/kvm/tdx-quote-generator.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH] i386/tdx: Remove task->watch only when it's valid
Posted by Xiaoyao Li 4 months, 3 weeks ago
In some case (e.g., failed to connect to QGS socket),
tdx_generate_quote_cleanup() is called with task->watch invalid. It
triggers assertion of

  qemu-system-x86_64: GLib: g_source_remove: assertion 'tag > 0' failed

Fix it by checking task->watch.

Fixes: 40da501d8989 ("i386/tdx: handle TDG.VP.VMCALL<GetQuote>")
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
 target/i386/kvm/tdx-quote-generator.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/target/i386/kvm/tdx-quote-generator.c b/target/i386/kvm/tdx-quote-generator.c
index f59715f61751..dee8334b27ac 100644
--- a/target/i386/kvm/tdx-quote-generator.c
+++ b/target/i386/kvm/tdx-quote-generator.c
@@ -75,7 +75,9 @@ static void tdx_generate_quote_cleanup(TdxGenerateQuoteTask *task)
 {
     timer_del(&task->timer);
 
-    g_source_remove(task->watch);
+    if (task->watch) {
+        g_source_remove(task->watch);
+    }
     qio_channel_close(QIO_CHANNEL(task->sioc), NULL);
     object_unref(OBJECT(task->sioc));
 
-- 
2.43.0
Re: [PATCH] i386/tdx: Remove task->watch only when it's valid
Posted by Paolo Bonzini 4 months, 1 week ago
Queued, thanks.

Paolo
Re: [PATCH] i386/tdx: Remove task->watch only when it's valid
Posted by Zhao Liu 4 months, 3 weeks ago
On Wed, Jun 25, 2025 at 11:55:05AM +0800, Xiaoyao Li wrote:
> Date: Wed, 25 Jun 2025 11:55:05 +0800
> From: Xiaoyao Li <xiaoyao.li@intel.com>
> Subject: [PATCH] i386/tdx: Remove task->watch only when it's valid
> X-Mailer: git-send-email 2.43.0
> 
> In some case (e.g., failed to connect to QGS socket),
> tdx_generate_quote_cleanup() is called with task->watch invalid. It
> triggers assertion of
> 
>   qemu-system-x86_64: GLib: g_source_remove: assertion 'tag > 0' failed
> 
> Fix it by checking task->watch.
> 
> Fixes: 40da501d8989 ("i386/tdx: handle TDG.VP.VMCALL<GetQuote>")
> Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
> ---
>  target/i386/kvm/tdx-quote-generator.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>