qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Xiaoyao Li <xiaoyao.li@intel.com>
Subject: [PULL 4/6] target/i386: tdx: fix locking for interrupt injection
Date: Thu, 17 Jul 2025 17:23:14 +0200	[thread overview]
Message-ID: <20250717152316.353049-5-pbonzini@redhat.com> (raw)
In-Reply-To: <20250717152316.353049-1-pbonzini@redhat.com>

Take tdx_guest->lock when injecting the event notification interrupt into
the guest.

Fixes CID 1612364.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Cc: Xiaoyao Li <xiaoyao.li@intel.com>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/kvm/tdx.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c
index 7d69d6d7b06..1574e7d76fe 100644
--- a/target/i386/kvm/tdx.c
+++ b/target/i386/kvm/tdx.c
@@ -1126,10 +1126,15 @@ int tdx_parse_tdvf(void *flash_ptr, int size)
     return tdvf_parse_metadata(&tdx_guest->tdvf, flash_ptr, size);
 }
 
-static void tdx_inject_interrupt(uint32_t apicid, uint32_t vector)
+static void tdx_inject_interrupt(TdxGuest *tdx)
 {
     int ret;
+    uint32_t apicid, vector;
 
+    qemu_mutex_lock(&tdx->lock);
+    vector = tdx->event_notify_vector;
+    apicid = tdx->event_notify_apicid;
+    qemu_mutex_unlock(&tdx->lock);
     if (vector < 32 || vector > 255) {
         return;
     }
@@ -1179,8 +1184,7 @@ static void tdx_get_quote_completion(TdxGenerateQuoteTask *task)
         error_report("TDX: get-quote: failed to update GetQuote header.");
     }
 
-    tdx_inject_interrupt(tdx_guest->event_notify_apicid,
-                         tdx_guest->event_notify_vector);
+    tdx_inject_interrupt(tdx);
 
     g_free(task->send_data);
     g_free(task->receive_buf);
-- 
2.50.1



  parent reply	other threads:[~2025-07-17 18:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-17 15:23 [PULL 0/6] Mostly target/i386 patches for QEMU 10.1 hard freeze Paolo Bonzini
2025-07-17 15:23 ` [PULL 1/6] target/i386: do not expose ARCH_CAPABILITIES on AMD CPU Paolo Bonzini
2025-07-18  7:21   ` Michael Tokarev
2025-07-18  8:09     ` Paolo Bonzini
2025-07-17 15:23 ` [PULL 2/6] i386/cpu: Move x86_ext_save_areas[] initialization to .instance_init Paolo Bonzini
2025-07-17 15:23 ` [PULL 3/6] meson: re-generate scripts/meson-buildoptions.sh to fix IGVM entry Paolo Bonzini
2025-07-17 15:23 ` Paolo Bonzini [this message]
2025-07-17 15:23 ` [PULL 5/6] i386/cpu: Cleanup host_cpu_max_instance_init() Paolo Bonzini
2025-07-17 15:23 ` [PULL 6/6] i386/tdx: Remove the redundant qemu_mutex_init(&tdx->lock) Paolo Bonzini
  -- strict thread matches above, loose matches on Subject: below --
2025-07-17 16:06 [PULL 0/6] Mostly target/i386 patches for QEMU 10.1 hard freeze Paolo Bonzini
2025-07-17 16:06 ` [PULL 4/6] target/i386: tdx: fix locking for interrupt injection Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250717152316.353049-5-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=xiaoyao.li@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).