mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Melody Wang <huibo.wang@amd.com>
To: Ard Biesheuvel <ardb@kernel.org>, x86@kernel.org
Cc: LKML <linux-kernel@vger.kernel.org>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	Jon Lange <jlange@microsoft.com>
Subject: Re: [PATCH v3 0/8] Alternate Injection: Secure Interrupt Delivery for SEV-SNP Guests - Guest Support
Date: Mon, 28 Sep 2026 12:34:02 -0700	[thread overview]
Message-ID: <922b5501-2e3e-4286-8709-3c6f0c2ce9b1@amd.com> (raw)
In-Reply-To: <335670cd-db18-4442-a3a9-5c99daa7d262@app.fastmail.com>

Hi Ard,

On 9/28/26 12:14 AM, Ard Biesheuvel wrote:
>> + * When the guest is running at VMPL2 with Alternate Injection enabled,
>> + * register Alternate Injection before ExitBootServices().
>> + */
>> +static int svsm_register_alt_inj(void)
>> +{
>> +       efi_guid_t alt_inj_proto = OVMF_SEV_ALT_INJ_REGISTER_PROTOCOL_GUID;
>> +       sev_alt_inj_register_protocol_t *proto;
>> +       efi_status_t status;
>> +
>> +       if (early_is_sevsnp_guest() && snp_vmpl) {
>> +               if (!(sev_get_status() & MSR_AMD64_SNP_ALTERNATE_INJ))
>> +                       return 0;
>> +       }
>> +
> 
> No need to test this - the protocol should deal with this.

I think we need to test this because the guest kernel should not try to 
register Alternate Injection if it is not a sev-snp guest, and running 
at VMPL0, and Alternate Injection is not supported.

Only if the three are satisfied, then it should try to register 
Alternate Injection.

This way, when the registration failed for whatever reason, such as the 
protocol is not supported by OVMF, etc, the guest should terminate. This 
way, the registration decision is still controlled by the guest.

All in all, it is the guest's decision whether to enable Alternate 
Injection or not and that check is done here. OVMF should not be 
responsible for checking that for the guest - it should simply do what 
it has been requested to do.

I hope this makes sense.

>> +       status = efi_bs_call(locate_protocol, &alt_inj_proto, NULL,
>> (void **)&proto);
>> +       if (status != EFI_SUCCESS) {
>> +               efi_err("Alternate Injection registration protocol not
>> exist\n");
>> +               return 1;
>> +       }
>> +
> 
> Just ignore the error

I think I need to check this error, as mentioned above, so the guest 
will terminate, that means the OVMF must support the protocol, when 
Alternate Injection is supported, and the guest kernel is trying to 
register it.

>
>> +       status = efi_call_proto(proto, sev_register_alt_inj);
>> +       if (status != EFI_SUCCESS) {
>> +               efi_err("Alternate Injection registration protocol
>> failed\n");
>> +               return 2;
>> +       }
>> +
> 
> Distinguish here between EFI_UNSUPPORTED (which can be ignored) and
> other errors.
> 
> Only question is whether EFI stub and OVMF are guaranteed to be in sync
> wrt snp_vmpl versus AmdSvsmIsSvsmPresent(), but I guess things would
> not work at all if that is not the case?
> 

yes if a SVSM is present, that means the SVSM is running at VMPL0, OVMF 
and the guest kernel will run at the lower priority level.

-- 
Thanks,
Melody


      reply	other threads:[~2026-09-28 19:34 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-20 18:12 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
2026-09-23 20:31   ` Borislav Petkov
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-23 20:46   ` 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-23 20:46   ` Melody Wang
2026-09-20 18:17 ` [PATCH v3 8/8] x86/sev: Indicate that Alternate Injection is supported in the guest Melody Wang
2026-09-23 20:56 ` [PATCH v3 0/8] Alternate Injection: Secure Interrupt Delivery for SEV-SNP Guests - Guest Support Ard Biesheuvel
2026-09-24 18:34   ` Melody Wang
2026-09-24 19:06     ` Ard Biesheuvel
2026-09-25  4:47       ` Borislav Petkov
2026-09-25  5:44         ` Ard Biesheuvel
2026-09-25  5:47           ` Borislav Petkov
2026-09-28  2:55       ` Melody Wang
2026-09-28  7:14         ` Ard Biesheuvel
2026-09-28 19:34           ` Melody Wang [this message]

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=922b5501-2e3e-4286-8709-3c6f0c2ce9b1@amd.com \
    --to=huibo.wang@amd.com \
    --cc=ardb@kernel.org \
    --cc=jlange@microsoft.com \
    --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®