From 866828924cdd5870fd05cf8748dd06f411ac81fc Mon Sep 17 00:00:00 2001 From: "John Hodge (sonata)" Date: Fri, 30 Nov 2012 00:19:13 +0800 Subject: [PATCH] Kernel/x86 - Added owner field to SHORTLOCK to catch doublelocks --- KernelLand/Kernel/arch/x86/include/arch.h | 1 + KernelLand/Kernel/arch/x86/lib.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/KernelLand/Kernel/arch/x86/include/arch.h b/KernelLand/Kernel/arch/x86/include/arch.h index 8a987058..040e18bb 100644 --- a/KernelLand/Kernel/arch/x86/include/arch.h +++ b/KernelLand/Kernel/arch/x86/include/arch.h @@ -45,6 +45,7 @@ struct sShortSpinlock { #if LOCK_DISABLE_INTS int IF; //!< Interrupt state on call to SHORTLOCK #endif + void *LockedBy; }; // === MACROS === diff --git a/KernelLand/Kernel/arch/x86/lib.c b/KernelLand/Kernel/arch/x86/lib.c index 1b1a0c3f..b732f75f 100644 --- a/KernelLand/Kernel/arch/x86/lib.c +++ b/KernelLand/Kernel/arch/x86/lib.c @@ -85,7 +85,11 @@ void SHORTLOCK(struct sShortSpinlock *Lock) __ASM__ ("pushf;\n\tpop %0" : "=r"(IF)); IF &= 0x200; // AND out all but the interrupt flag - ASSERT( !CPU_HAS_LOCK(Lock) ); + if( CPU_HAS_LOCK(Lock) ) + { + Panic("Double lock of %p, %p req, %p has", Lock, __builtin_return_address(0), Lock->LockedBy); + for(;;); + } #if TRACE_LOCKS if( TRACE_LOCK_COND ) @@ -100,6 +104,7 @@ void SHORTLOCK(struct sShortSpinlock *Lock) // Wait for another CPU to release __AtomicTestSetLoop( (Uint*)&Lock->Lock, cpu ); Lock->IF = IF; + Lock->LockedBy = __builtin_return_address(0); #if TRACE_LOCKS if( TRACE_LOCK_COND ) -- 2.20.1