From 098cdd60678ce6f84f974967cbe3eae286790a16 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Tue, 27 Feb 2024 10:46:32 +0100 Subject: [PATCH] Fix flusher, currently only with -smp 1 --- src/arch/x86_64/interrupt/exception.rs | 3 ++- src/arch/x86_shared/ipi.rs | 15 --------------- src/context/memory.rs | 8 +++++++- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/arch/x86_64/interrupt/exception.rs b/src/arch/x86_64/interrupt/exception.rs index 2e8d3f363e..5270c6fcde 100644 --- a/src/arch/x86_64/interrupt/exception.rs +++ b/src/arch/x86_64/interrupt/exception.rs @@ -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::::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(); } diff --git a/src/arch/x86_shared/ipi.rs b/src/arch/x86_shared/ipi.rs index b453c0b695..d5b11df906 100644 --- a/src/arch/x86_shared/ipi.rs +++ b/src/arch/x86_shared/ipi.rs @@ -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) }; -} diff --git a/src/context/memory.rs b/src/context/memory.rs index 8f0bf75cd0..61c3da4357 100644 --- a/src/context/memory.rs +++ b/src/context/memory.rs @@ -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::::new().flush(); + } + while self.state.ackword.load(Ordering::Relaxed) < affected_cpu_count { core::hint::spin_loop(); }