diff options
author | Dale Rahn <drahn@cvs.openbsd.org> | 2007-05-31 23:50:26 +0000 |
---|---|---|
committer | Dale Rahn <drahn@cvs.openbsd.org> | 2007-05-31 23:50:26 +0000 |
commit | c7e7fcb7339a8e20c2b652ca1396f83a432d18ea (patch) | |
tree | 2c197c7874d8e315ade97986aca0001d451ae039 /sys/arch/powerpc | |
parent | dfb977538340fb5e6bd87d8e08766eea5874a6d2 (diff) |
panic if mtx_leave is called on an unlocked mutex. ok kettenis@
Diffstat (limited to 'sys/arch/powerpc')
-rw-r--r-- | sys/arch/powerpc/powerpc/mutex.S | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/sys/arch/powerpc/powerpc/mutex.S b/sys/arch/powerpc/powerpc/mutex.S index 0b5bfab1e6b..34185e4f3be 100644 --- a/sys/arch/powerpc/powerpc/mutex.S +++ b/sys/arch/powerpc/powerpc/mutex.S @@ -1,4 +1,4 @@ -/* $OpenBSD: mutex.S,v 1.2 2007/05/29 20:22:10 drahn Exp $ */ +/* $OpenBSD: mutex.S,v 1.3 2007/05/31 23:50:25 drahn Exp $ */ /* * Copyright (c) 2007 Dale Rahn @@ -75,15 +75,21 @@ ENTRY(mtx_enter) #ifdef DIAGNOSTIC .L_mutex_selflocked: mr %r5, %r3 - lis %r3,.L_panicstr@ha - la %r3,.L_panicstr@l(%r3) + lis %r3,.L_paniclocked@ha + la %r3,.L_paniclocked@l(%r3) bl panic -.L_panicstr: +.L_paniclocked: .string "mtx_enter: recursed %x %x\n" #endif ENTRY(mtx_leave) +#ifdef DIAGNOSTIC + lwz %r6,MTX_OWNER(%r3) + cmpwi 0,%r6,0 # test owner == 0 + + beq- .L_mutex_notlocked +#endif li %r4,0 lwz %r5,MTX_OLDCPL(%r3) stw %r4,MTX_OLDCPL(%r3) @@ -96,3 +102,14 @@ ENTRY(mtx_leave) b _C_LABEL(lcsplx) 1: blr + +#ifdef DIAGNOSTIC +.L_mutex_notlocked: + GET_CPUINFO(%r4) + mr %r5, %r3 + lis %r3,.L_panicnotlocked@ha + la %r3,.L_panicnotlocked@l(%r3) + bl panic +.L_panicnotlocked: + .string "mtx_leave: not locked %x %x\n" +#endif |