Skip to content

Commit

Permalink
platform/snp: enable alternate injection only if requested
Browse files Browse the repository at this point in the history
The current logic for enabling alternate injection is broken, as it
will enable it always. This is causing a crash during boot when
running under a hypervisor that does not support the feature:

    [SVSM] ERROR: Panic: CPU[0] panicked at kernel/src/svsm.rs:449:36:
    Failed to setup guest VMSA/CAA: Ghcb(VmgexitError(2, 6))
    [SVSM] ---BACKTRACE---:
    [SVSM]   [0xffffff8000128445]
    [SVSM]   Invalid frame
    [SVSM] ---END---

Fix this by checking upfront if the feature was requested.

Fixes: 978aef5 ("protocols/apic: update the registration-based APIC protocol")
Signed-off-by: Carlos López <[email protected]>
  • Loading branch information
00xc committed Jul 4, 2024
1 parent af0697e commit 6946a54
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions kernel/src/platform/snp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,13 @@ impl SvsmPlatform for SnpPlatform {
}

fn configure_alternate_injection(&mut self, alt_inj_requested: bool) -> Result<(), SvsmError> {
if !alt_inj_requested {
return Ok(());
}

// If alternate injection was requested, then it must be supported by
// the hypervisor.
if alt_inj_requested
&& !hypervisor_ghcb_features().contains(GHCBHvFeatures::SEV_SNP_EXT_INTERRUPTS)
{
if !hypervisor_ghcb_features().contains(GHCBHvFeatures::SEV_SNP_EXT_INTERRUPTS) {
return Err(SvsmError::NotSupported);
}

Expand Down

0 comments on commit 6946a54

Please sign in to comment.