mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Melody Wang" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Melody Wang <huibo.wang@amd.com>,
	"Borislav Petkov (AMD)" <bp@alien8.de>,
	Stefano Garzarella <sgarzare@redhat.com>,
	stable@vger.kernel.org, x86@kernel.org,
	linux-kernel@vger.kernel.org
Subject: [tip: x86/urgent] x86/sev: Make vTPM SVSM calls preemption-safe
Date: Tue, 22 Sep 2026 03:14:12 -0000	[thread overview]
Message-ID: <179004685258.2819794.12514099294540319299.tip-bot2@tip-bot2> (raw)
In-Reply-To: <a5bc0d4a2c462a0089109e145c21626b244b2ff0.1789345277.git.huibo.wang@amd.com>

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     6c43c72748fffd29dec15cd1f31e9a32949bc437
Gitweb:        https://git.kernel.org/tip/6c43c72748fffd29dec15cd1f31e9a32949bc437
Author:        Melody Wang <huibo.wang@amd.com>
AuthorDate:    Mon, 14 Sep 2026 00:57:17 
Committer:     Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Mon, 21 Sep 2026 19:59:25 -07:00

x86/sev: Make vTPM SVSM calls preemption-safe

Two functions in the SVSM vTPM guest implementation do not disable
preemption when fetching the SVSM Calling Area Address (CAA).

The SVSM CAA is a per-CPU structure. When a thread is preempted and migrated
to a different CPU after fetching the per-CPU CAA, the SVSM call will execute
on the new CPU with the original CPU's CAA. Which is wrong.

Move the CAA fetching operation inside svsm_perform_call_protocol() which
disables interrupts around the SVSM call and thus runs preemption-safe.

Fixes: 770de678bc28 ("x86/sev: Add SVSM vTPM probe/send_command functions")
Signed-off-by: Melody Wang <huibo.wang@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/a5bc0d4a2c462a0089109e145c21626b244b2ff0.1789345277.git.huibo.wang@amd.com
---
 arch/x86/coco/sev/svsm.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/x86/coco/sev/svsm.c b/arch/x86/coco/sev/svsm.c
index 916d62c..2d493d5 100644
--- a/arch/x86/coco/sev/svsm.c
+++ b/arch/x86/coco/sev/svsm.c
@@ -74,6 +74,14 @@ int svsm_perform_call_protocol(struct svsm_call *call)
 
 	flags = native_local_irq_save();
 
+	/*
+	 * 'caa' is a per-CPU variable. To avoid using a stale or incorrect
+	 * 'caa' if the task is preempted or migrated to another CPU after it
+	 * is fetched, always fetch 'caa' and then issue the SVSM call with
+	 * interrupts disabled. This ensures the correct 'caa' is used.
+	 */
+	call->caa = svsm_get_caa();
+
 	ghcb = __sev_get_ghcb(&state);
 
 	do {
@@ -321,7 +329,6 @@ int snp_svsm_vtpm_send_command(u8 *buffer)
 {
 	struct svsm_call call = {};
 
-	call.caa = svsm_get_caa();
 	call.rax = SVSM_VTPM_CALL(SVSM_VTPM_CMD);
 	call.rcx = __pa(buffer);
 
@@ -345,7 +352,6 @@ bool snp_svsm_vtpm_probe(void)
 	if (!snp_vmpl)
 		return false;
 
-	call.caa = svsm_get_caa();
 	call.rax = SVSM_VTPM_CALL(SVSM_VTPM_QUERY);
 
 	if (svsm_perform_call_protocol(&call))

  reply	other threads:[~2026-09-22  3:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14  0:57 [PATCH v2 0/8] Alternate Injection: Secure Interrupt Delivery for SEV-SNP Guests - Guest Support Melody Wang
2026-09-14  0:57 ` [PATCH v2 1/8] x86/sev: Make SVSM calls preemption-safe Melody Wang
2026-09-22  3:14   ` tip-bot2 for Melody Wang [this message]
2026-09-14  0:57 ` [PATCH v2 2/8] x86/sev: Add support for Alternate Injection Melody Wang
2026-09-14  0:57 ` [PATCH v2 3/8] x86/apic: Add an SVSM APIC driver Melody Wang
2026-09-14  0:57 ` [PATCH v2 4/8] x86/sev: Route unsupported APIC register accesses to the hypervisor APIC emulation Melody Wang
2026-09-14  0:57 ` [PATCH v2 5/8] x86/sev: Add a function to contain all SEV-specific setup operations Melody Wang
2026-09-14 20:04   ` Ard Biesheuvel
2026-09-14  0:57 ` [PATCH v2 6/8] x86/sev: Register the guest with the SVSM APIC protocol Melody Wang
2026-09-14 20:06   ` Ard Biesheuvel
2026-09-15  2:04     ` Melody Wang
2026-09-15  7:44       ` Ard Biesheuvel
2026-09-16 18:45         ` Melody Wang
2026-09-18  8:14           ` Ard Biesheuvel
2026-09-20 17:55             ` Melody Wang
2026-09-14  0:57 ` [PATCH v2 7/8] x86/sev: Allow the guest to configure interrupt vectors for the hypervisor Melody Wang
2026-09-14  0:57 ` [PATCH v2 8/8] x86/sev: Indicate that Alternate Injection is supported in the guest Melody Wang

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=179004685258.2819794.12514099294540319299.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=bp@alien8.de \
    --cc=huibo.wang@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=sgarzare@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=x86@kernel.org \
    /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

all inboxes | Powered by JetHome®