From c313fa7a789e9565bb0b6c7d259d55e6aa98fb9e Mon Sep 17 00:00:00 2001 From: Jon Lange Date: Thu, 24 Oct 2024 10:10:38 -0700 Subject: [PATCH] irq: assume the availablity of interrupts on all systems Now that SNP requires the use of restricted injection, it is safe to assume that all all platforms support the use of SVSM interrupts, and all abstractions can be removed. Signed-off-by: Jon Lange --- kernel/src/cpu/percpu.rs | 17 +++++++---------- kernel/src/platform/mod.rs | 3 --- kernel/src/platform/native.rs | 4 ---- kernel/src/platform/snp.rs | 22 +++------------------- kernel/src/platform/tdp.rs | 4 ---- kernel/src/sev/status.rs | 4 ---- 6 files changed, 10 insertions(+), 44 deletions(-) diff --git a/kernel/src/cpu/percpu.rs b/kernel/src/cpu/percpu.rs index 35510f58f..f8f59bcf5 100644 --- a/kernel/src/cpu/percpu.rs +++ b/kernel/src/cpu/percpu.rs @@ -825,16 +825,13 @@ impl PerCpu { } pub fn schedule_init(&self) -> TaskPointer { - // If the platform permits the use of interrupts, then ensure that - // interrupts will be enabled on the current CPU when leaving the - // scheduler environment. This is done after disabling interrupts - // for scheduler initialization so that the first interrupt that can - // be received will always observe that there is a current task and - // not the boot thread. - if SVSM_PLATFORM.as_dyn_ref().use_interrupts() { - unsafe { - self.irq_state.set_restore_state(true); - } + // Ensure that interrupts will be enabled on the current CPU when + // leaving the scheduler environment. This is done after disabling + // interrupts for scheduler initialization so that the first interrupt + // that can be received will always observe that there is a current + // task and not the boot thread. + unsafe { + self.irq_state.set_restore_state(true); } let task = self.runqueue.lock_write().schedule_init(); self.current_stack.set(task.stack_bounds()); diff --git a/kernel/src/platform/mod.rs b/kernel/src/platform/mod.rs index 0d7eaad81..4ceb23b59 100644 --- a/kernel/src/platform/mod.rs +++ b/kernel/src/platform/mod.rs @@ -115,9 +115,6 @@ pub trait SvsmPlatform { /// Queries the state of APIC registration on this system. fn query_apic_registration_state(&self) -> bool; - /// Determines whether the platform supports interrupts to the SVSM. - fn use_interrupts(&self) -> bool; - /// Signal an IRQ on one or more CPUs. fn post_irq(&self, icr: u64) -> Result<(), SvsmError>; diff --git a/kernel/src/platform/native.rs b/kernel/src/platform/native.rs index 17f3d4421..6a1f10561 100644 --- a/kernel/src/platform/native.rs +++ b/kernel/src/platform/native.rs @@ -128,10 +128,6 @@ impl SvsmPlatform for NativePlatform { false } - fn use_interrupts(&self) -> bool { - true - } - fn post_irq(&self, icr: u64) -> Result<(), SvsmError> { write_msr(APIC_MSR_ICR, icr); Ok(()) diff --git a/kernel/src/platform/snp.rs b/kernel/src/platform/snp.rs index 79863690c..c2611671c 100644 --- a/kernel/src/platform/snp.rs +++ b/kernel/src/platform/snp.rs @@ -19,7 +19,7 @@ use crate::sev::hv_doorbell::current_hv_doorbell; use crate::sev::msr_protocol::{ hypervisor_ghcb_features, request_termination_msr, verify_ghcb_version, GHCBHvFeatures, }; -use crate::sev::status::{sev_restricted_injection, vtom_enabled}; +use crate::sev::status::vtom_enabled; use crate::sev::{ init_hypervisor_ghcb_features, pvalidate_range, sev_status_init, sev_status_verify, PvalidateOp, }; @@ -71,15 +71,11 @@ impl From for PvalidateOp { } #[derive(Clone, Copy, Debug)] -pub struct SnpPlatform { - can_use_interrupts: bool, -} +pub struct SnpPlatform {} impl SnpPlatform { pub fn new() -> Self { - Self { - can_use_interrupts: false, - } + Self {} } } @@ -93,14 +89,6 @@ impl SvsmPlatform for SnpPlatform { fn env_setup(&mut self, _debug_serial_port: u16, vtom: usize) -> Result<(), SvsmError> { sev_status_init(); VTOM.init(&vtom).map_err(|_| SvsmError::PlatformInit)?; - - // Now that SEV status is initialized, determine whether this platform - // supports the use of SVSM interrupts. SVSM interrupts are supported - // if this system uses restricted injection. - if sev_restricted_injection() { - self.can_use_interrupts = true; - } - Ok(()) } @@ -278,10 +266,6 @@ impl SvsmPlatform for SnpPlatform { APIC_EMULATION_REG_COUNT.load(Ordering::Relaxed) > 0 } - fn use_interrupts(&self) -> bool { - self.can_use_interrupts - } - fn post_irq(&self, icr: u64) -> Result<(), SvsmError> { current_ghcb().hv_ipi(icr)?; Ok(()) diff --git a/kernel/src/platform/tdp.rs b/kernel/src/platform/tdp.rs index d0e9c0873..8955c3f5a 100644 --- a/kernel/src/platform/tdp.rs +++ b/kernel/src/platform/tdp.rs @@ -144,10 +144,6 @@ impl SvsmPlatform for TdpPlatform { false } - fn use_interrupts(&self) -> bool { - true - } - fn post_irq(&self, _icr: u64) -> Result<(), SvsmError> { Err(SvsmError::Tdx) } diff --git a/kernel/src/sev/status.rs b/kernel/src/sev/status.rs index 939132c11..819ead30a 100644 --- a/kernel/src/sev/status.rs +++ b/kernel/src/sev/status.rs @@ -158,10 +158,6 @@ pub fn vtom_enabled() -> bool { sev_flags().contains(SEVStatusFlags::VTOM) } -pub fn sev_restricted_injection() -> bool { - sev_flags().contains(SEVStatusFlags::REST_INJ) -} - pub fn sev_status_verify() { let required = SEVStatusFlags::SEV | SEVStatusFlags::SEV_ES