From 1331f4103f4c59856061bf4e4833ba1f48d9a6e0 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sun, 18 Sep 2016 21:05:59 -0600 Subject: [PATCH] Unlock context switch lock without potentially screwing up switch_to function --- arch/x86_64/src/context.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/x86_64/src/context.rs b/arch/x86_64/src/context.rs index 004914d..09cca9c 100644 --- a/arch/x86_64/src/context.rs +++ b/arch/x86_64/src/context.rs @@ -52,6 +52,7 @@ impl Context { } /// Switch to the next context by restoring its stack and registers + #[cold] #[inline(never)] #[naked] pub unsafe fn switch_to(&mut self, next: &mut Context) { @@ -94,7 +95,12 @@ impl Context { asm!("mov $0, rbp" : "=r"(self.rbp) : : "memory" : "intel", "volatile"); asm!("mov rbp, $0" : : "r"(next.rbp) : "memory" : "intel", "volatile"); - // Unset global lock, set inside of kernel - CONTEXT_SWITCH_LOCK.store(false, Ordering::SeqCst); + asm!("call context_switch_unlock" : : : "memory" : "intel", "volatile"); } } + +/// Unset global lock, set inside of kernel +#[no_mangle] +extern fn context_switch_unlock(){ + CONTEXT_SWITCH_LOCK.store(false, Ordering::SeqCst); +}