Skip to content

Commit

Permalink
Merge pull request #600 from msft-jlange/smp_tlb
Browse files Browse the repository at this point in the history
cpu: restrict IPI-based TLB flush to multi-proc environments
  • Loading branch information
joergroedel authored Jan 28, 2025
2 parents 389b3cb + c95720f commit b17a0e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 8 additions & 0 deletions kernel/src/cpu/smp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::cpu::idt::idt;
use crate::cpu::percpu::{this_cpu, this_cpu_shared, PerCpu};
use crate::cpu::shadow_stack::{is_cet_ss_supported, SCetFlags, MODE_64BIT, S_CET};
use crate::cpu::sse::sse_init;
use crate::cpu::tlb::set_tlb_flush_smp;
use crate::enable_shadow_stacks;
use crate::error::SvsmError;
use crate::hyperv;
Expand Down Expand Up @@ -44,6 +45,13 @@ pub fn start_secondary_cpus(platform: &dyn SvsmPlatform, cpus: &[ACPICPUInfo]) {
let mut count: usize = 0;
for c in cpus.iter().filter(|c| c.apic_id != 0 && c.enabled) {
log::info!("Launching AP with APIC-ID {}", c.apic_id);

// If this is the first AP being started, then advise the TLB package
// that future TLB flushes will have to be done with SMP scope.
if count == 0 {
set_tlb_flush_smp();
}

start_cpu(platform, c.apic_id).expect("Failed to bring CPU online");
count += 1;
}
Expand Down
5 changes: 0 additions & 5 deletions kernel/src/svsm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use svsm::cpu::shadow_stack::{
};
use svsm::cpu::smp::start_secondary_cpus;
use svsm::cpu::sse::sse_init;
use svsm::cpu::tlb::set_tlb_flush_smp;
use svsm::debug::gdbstub::svsm_gdbstub::{debug_break, gdbstub_start};
use svsm::debug::stacktrace::print_stack;
use svsm::enable_shadow_stacks;
Expand Down Expand Up @@ -308,10 +307,6 @@ pub extern "C" fn svsm_main() {

log::info!("{} CPU(s) present", nr_cpus);

// Advise the TLB package that future TLB flushes will have to be done with
// SMP scope.
set_tlb_flush_smp();

start_secondary_cpus(&**SVSM_PLATFORM, &cpus);

invalidate_early_boot_memory(&**SVSM_PLATFORM, &config, launch_info)
Expand Down

0 comments on commit b17a0e7

Please sign in to comment.