From: Melody Wang <huibo.wang@amd.com>
To: x86@kernel.org
Cc: LKML <linux-kernel@vger.kernel.org>,
Tom Lendacky <thomas.lendacky@amd.com>,
ardb@kernel.org
Subject: Re: [PATCH v3 3/8] x86/apic: Add an SVSM APIC driver
Date: Mon, 21 Sep 2026 18:31:40 -0700 [thread overview]
Message-ID: <b6b5e5a5-567f-470a-a0ba-3fbad9314811@amd.com> (raw)
In-Reply-To: <69bd40ce677aeac56cf53b10910c602d60604393.1789927246.git.huibo.wang@amd.com>
Hi all,
On 9/20/26 11:16 AM, Melody Wang wrote:
> +
> +static u32 __svsm_apic_msr_rw(u32 reg, u32 v, bool write)
> +{
> + u32 msr = APIC_BASE_MSR + (reg >> 4);
> + struct svsm_call call = {};
> + const char *call_reg_str;
> + unsigned int call_reg;
> + int ret;
> +
> + call_reg = write ? SVSM_APIC_WRITE_REGISTER
> + : SVSM_APIC_READ_REGISTER;
> +
> + call_reg_str = write ? "SVSM_APIC_WRITE_REGISTER"
> + : "SVSM_APIC_READ_REGISTER";
> +
> + switch (reg) {
> + case APIC_ID:
> + case APIC_TASKPRI:
> + case APIC_PROCPRI:
> + case APIC_EOI:
> + case APIC_ISR ... APIC_ISR + 0x70:
> + case APIC_TMR ... APIC_TMR + 0x70:
> + case APIC_IRR ... APIC_IRR + 0x70:
> + case APIC_ICR:
> + case APIC_SELF_IPI:
> + call.rax = SVSM_APIC_CALL(call_reg);
> + call.rcx = msr;
> + call.rdx = v;
> +
> + ret = svsm_perform_call_protocol(&call);
Sashiko said this:
"Can this SVSM APIC call be interrupted by an NMI, causing CAA page
corruption and guest termination?
If a normal thread or IRQ handler executes an SVSM APIC operation and an
NMI fires exactly between setting call_pending to 1 and the vmmcall
instruction inside svsm_issue_call(), the NMI handler might execute another
APIC operation.
The nested SVSM call from the NMI would use the exact same per-CPU Calling
Area Address (CAA) page, clearing call_pending to 0. When the interrupted
call resumes, svsm_process_result_codes() would misinterpret the unmodified
input registers as an error code because call_pending is 0.
Does this result in ret being non-zero and triggering sev_es_terminate()
fatally crashing the guest?"
This will happen when there is APIC operation happening in the NMI
handler, there is no such case so I would keep the code as it is for now
unless there is some use case that needs us to do an APIC operation in
the NMI handler in the future.
Thanks,
Melody
next prev parent reply other threads:[~2026-09-22 1:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-20 18:12 [PATCH v3 0/8] Alternate Injection: Secure Interrupt Delivery for SEV-SNP Guests - Guest Support Melody Wang
2026-09-20 18:12 ` [PATCH v3 1/8] x86/sev: Make SVSM calls preemption-safe Melody Wang
2026-09-20 18:16 ` Melody Wang
2026-09-20 18:12 ` [PATCH v3 2/8] x86/sev: Add support for Alternate Injection Melody Wang
2026-09-20 18:16 ` Melody Wang
2026-09-20 18:16 ` [PATCH v3 0/8] Alternate Injection: Secure Interrupt Delivery for SEV-SNP Guests - Guest Support Melody Wang
2026-09-20 18:16 ` [PATCH v3 3/8] x86/apic: Add an SVSM APIC driver Melody Wang
2026-09-22 1:31 ` Melody Wang [this message]
2026-09-20 18:16 ` [PATCH v3 4/8] x86/sev: Route unsupported APIC register accesses to the hypervisor APIC emulation Melody Wang
2026-09-20 18:16 ` [PATCH v3 5/8] x86/sev: Add a function to contain all SEV-specific setup operations Melody Wang
2026-09-20 18:16 ` [PATCH v3 6/8] x86/sev: Register the guest with the SVSM APIC protocol Melody Wang
2026-09-20 18:16 ` [PATCH v3 7/8] x86/sev: Allow the guest to configure interrupt vectors for the hypervisor Melody Wang
2026-09-20 18:17 ` [PATCH v3 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=b6b5e5a5-567f-470a-a0ba-3fbad9314811@amd.com \
--to=huibo.wang@amd.com \
--cc=ardb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=thomas.lendacky@amd.com \
--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®