From 6946a5496c2132d4610fc34c71caad159b413f3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20L=C3=B3pez?= Date: Thu, 4 Jul 2024 14:34:13 +0200 Subject: [PATCH] platform/snp: enable alternate injection only if requested MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: 978aef5a9d75 ("protocols/apic: update the registration-based APIC protocol") Signed-off-by: Carlos López --- kernel/src/platform/snp.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kernel/src/platform/snp.rs b/kernel/src/platform/snp.rs index 9eee77cf1..5594f380d 100644 --- a/kernel/src/platform/snp.rs +++ b/kernel/src/platform/snp.rs @@ -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); }