Fix flusher, currently only with -smp 1

This commit is contained in:
4lDO2
2024-02-27 10:46:32 +01:00
parent 79381249a2
commit 098cdd6067
3 changed files with 9 additions and 17 deletions
+2 -1
View File
@@ -49,7 +49,7 @@ interrupt_stack!(non_maskable, @paranoid, |stack| {
if let Some(reason) = reasons.iter().next() {
if reason == NmiReasons::TLB_SHOOTDOWN && let Some(addrsp) = percpu.current_addrspace.get().as_ref() {
core::arch::asm!("mov rax, cr3; mov cr3, rax", out("rax") _);
rmm::PageFlushAll::<crate::paging::RmmA>::new().flush();
addrsp.tlb_ack.fetch_add(1, Ordering::Relaxed);
}
@@ -60,6 +60,7 @@ interrupt_stack!(non_maskable, @paranoid, |stack| {
#[cfg(not(feature = "profiling"))]
{
// TODO: This will likely deadlock
println!("Non-maskable interrupt");
stack.dump();
}
-15
View File
@@ -37,18 +37,3 @@ pub fn ipi(kind: IpiKind, target: IpiTarget) {
let icr = (target as u64) << 18 | 1 << 14 | (kind as u64);
unsafe { LOCAL_APIC.set_icr(icr) };
}
#[cfg(feature = "multi_core")]
#[inline(always)]
pub fn ipi_single(kind: IpiKind, target: u32) {
use crate::device::local_apic::LOCAL_APIC;
#[cfg(feature = "profiling")]
if matches!(kind, IpiKind::Profile) {
let icr = (target as u64) << 18 | 1 << 14 | 0b100 << 8;
unsafe { LOCAL_APIC.set_icr(icr) };
return;
}
let icr = u64::from(target) << 18 | 1 << 14 | (kind as u64);
unsafe { LOCAL_APIC.set_icr(icr) };
}
+7 -1
View File
@@ -2520,8 +2520,10 @@ impl<'guard, 'addrsp> Flusher<'guard, 'addrsp> {
let mut affected_cpu_count = 0;
let current_cpu_id = crate::cpu_id();
for cpu_id in self.active_cpus.iter_mut() {
if cpu_id == crate::cpu_id() {
if cpu_id == current_cpu_id {
continue;
}
@@ -2529,6 +2531,10 @@ impl<'guard, 'addrsp> Flusher<'guard, 'addrsp> {
affected_cpu_count += 1;
}
if self.active_cpus.contains(current_cpu_id) {
rmm::PageFlushAll::<RmmA>::new().flush();
}
while self.state.ackword.load(Ordering::Relaxed) < affected_cpu_count {
core::hint::spin_loop();
}