Skip to content

Commit

Permalink
platform: restrict SVSM request loop to SNP platforms
Browse files Browse the repository at this point in the history
The SVSM request loop is not meaningful on non-SNP platforms, so it
should not be invoked on non-SNP platforms.

Signed-off-by: Jon Lange <jlange@microsoft.com>
  • Loading branch information
msft-jlange committed Feb 14, 2025
1 parent 675e101 commit d62f63d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
19 changes: 11 additions & 8 deletions kernel/src/cpu/percpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1365,14 +1365,17 @@ pub fn current_task() -> TaskPointer {

#[no_mangle]
pub extern "C" fn cpu_idle_loop() {
// Start request processing on this CPU.
let apic_id = this_cpu().get_apic_id();
let processing_name = format!("request-processing on CPU {}", apic_id);
start_kernel_task(request_processing_main, processing_name)
.expect("Failed to launch request processing task");
let loop_name = format!("request-loop on CPU {}", apic_id);
start_kernel_task(request_loop_main, loop_name)
.expect("Failed to launch request loop task");
// Start request processing on this CPU if required.
if SVSM_PLATFORM.start_svsm_request_loop() {
// Start request processing on this CPU.
let apic_id = this_cpu().get_apic_id();
let processing_name = format!("request-processing on CPU {}", apic_id);
start_kernel_task(request_processing_main, processing_name)
.expect("Failed to launch request processing task");
let loop_name = format!("request-loop on CPU {}", apic_id);
start_kernel_task(request_loop_main, loop_name)
.expect("Failed to launch request loop task");
}

loop {
// Go idle
Expand Down
5 changes: 5 additions & 0 deletions kernel/src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ pub trait SvsmPlatform {
cpu: &PerCpu,
context: &hyperv::HvInitialVpContext,
) -> Result<(), SvsmError>;

/// Indicates whether this platform should invoke the SVSM request loop.
fn start_svsm_request_loop(&self) -> bool {
false
}
}

//FIXME - remove Copy trait
Expand Down
4 changes: 4 additions & 0 deletions kernel/src/platform/snp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ impl SvsmPlatform for SnpPlatform {

current_ghcb().ap_create(vmsa_pa, cpu.get_apic_id().into(), 0, sev_features)
}

fn start_svsm_request_loop(&self) -> bool {
true
}
}

#[derive(Clone, Copy, Debug, Default)]
Expand Down

0 comments on commit d62f63d

Please sign in to comment.