Re: [PATCH v4 5/7] x86/sev: Register the guest with the SVSM APIC protocol
From: Ard Biesheuvel
Date: Thu Oct 15 2026 - 02:05:04 EST
On Thu, 15 Oct 2026, at 05:56, Melody Wang wrote:
> Hi Ard,
>
> On 10/14/26 2:43 AM, Ard Biesheuvel wrote:
>> I'm struggling to follow the logic here: doesn't this attempt to locate
>> the protocol on non-SEV/SNP systems as well?
>
> Alternate Injection is only working for SEV-SNP guest.
>
>> Wouldn't it be sufficient to do
>>
>> if (!snp_vmpl ||
>> !(sev_get_status() & MSR_AMD64_SNP_ALTERNATE_INJ))
>> return 0;
>>
>> and leave the early_is_sevsnp_guest() check alone?
>>
>
> The thing is, snp_vmpl hasn't been initialized here yet. We read here a
> 0. So I need early_is_sevsnp_guest() to initialize it to U8_MAX so that
> I know that there's an SVSM present.
>
> Then I can enable AltInj.
>
OK.
But there are three conditions where there is no point in checking
whether the protocol exists:
- early_is_sevsnp_guest() -> false
- snp_vmpl == 0
- (sev_get_status() & MSR_AMD64_SNP_ALTERNATE_INJ) == 0
So this should be
>> if (!early_is_sevsnp_guest() || !snp_vmpl ||
>> !(sev_get_status() & MSR_AMD64_SNP_ALTERNATE_INJ))
>> return 0;
then?
Btw please don't use bare '1' and '2' as error codes, especially
since you don't actually check the value - just use a bool instead.