diff options
Diffstat (limited to 'sys/arch/i386')
-rw-r--r-- | sys/arch/i386/i386/genassym.cf | 5 | ||||
-rw-r--r-- | sys/arch/i386/i386/mutex.S | 22 | ||||
-rw-r--r-- | sys/arch/i386/include/cpu.h | 6 |
3 files changed, 29 insertions, 4 deletions
diff --git a/sys/arch/i386/i386/genassym.cf b/sys/arch/i386/i386/genassym.cf index 1f95c15ad01..2b87e13ec17 100644 --- a/sys/arch/i386/i386/genassym.cf +++ b/sys/arch/i386/i386/genassym.cf @@ -1,4 +1,4 @@ -# $OpenBSD: genassym.cf,v 1.31 2010/07/03 04:54:32 kettenis Exp $ +# $OpenBSD: genassym.cf,v 1.32 2010/09/24 13:21:30 matthew Exp $ # # Copyright (c) 1982, 1990 The Regents of the University of California. # All rights reserved. @@ -207,6 +207,9 @@ define CPU_INFO_IUNMASK offsetof(struct cpu_info, ci_iunmask) define CPU_INFO_ILEVEL offsetof(struct cpu_info, ci_ilevel) define CPU_INFO_IDEPTH offsetof(struct cpu_info, ci_idepth) define CPU_INFO_ISOURCES offsetof(struct cpu_info, ci_isources) +ifdef DIAGNOSTIC +define CPU_INFO_MUTEX_LEVEL offsetof(struct cpu_info, ci_mutex_level) +endif define CPU_INFO_CURPMAP offsetof(struct cpu_info, ci_curpmap) struct pmap diff --git a/sys/arch/i386/i386/mutex.S b/sys/arch/i386/i386/mutex.S index b82363e1779..313da9eb01a 100644 --- a/sys/arch/i386/i386/mutex.S +++ b/sys/arch/i386/i386/mutex.S @@ -1,4 +1,4 @@ -/* $OpenBSD: mutex.S,v 1.7 2009/08/13 13:24:55 weingart Exp $ */ +/* $OpenBSD: mutex.S,v 1.8 2010/09/24 13:21:30 matthew Exp $ */ /* * Copyright (c) 2004 Artur Grabowski <art@openbsd.org> @@ -63,6 +63,9 @@ ENTRY(mtx_enter) testl %eax, %eax # if (already held) jnz 3f movl CPUVAR(SELF), %eax +#ifdef DIAGNOSTIC + incl CPU_INFO_MUTEX_LEVEL(%eax) +#endif movl %eax, MTX_OWNER(%ecx) movl %edx, MTX_OLDIPL(%ecx) leave @@ -107,6 +110,9 @@ ENTRY(mtx_enter_try) testl %eax, %eax # if (already held) jnz 3f movl CPUVAR(SELF), %eax +#ifdef DIAGNOSTIC + incl CPU_INFO_MUTEX_LEVEL(%eax) +#endif movl %eax, MTX_OWNER(%ecx) movl %edx, MTX_OLDIPL(%ecx) movl $1, %eax @@ -130,7 +136,7 @@ ENTRY(mtx_enter_try) #ifdef DIAGNOSTIC 4: pushl $5f call _C_LABEL(panic) -5: .asciz "mtx_enter: locking against myself" +5: .asciz "mtx_enter_try: locking against myself" #endif @@ -138,6 +144,12 @@ ENTRY(mtx_leave) pushl %ebp movl %esp, %ebp movl SOFF(%ebp), %ecx +#ifdef DIAGNOSTIC + movl CPUVAR(SELF), %eax + cmpl %eax, MTX_OWNER(%ecx) + jne 1f + decl CPU_INFO_MUTEX_LEVEL(%eax) +#endif xorl %eax, %eax movl %eax, MTX_OWNER(%ecx) pushl MTX_OLDIPL(%ecx) @@ -146,3 +158,9 @@ ENTRY(mtx_leave) call _C_LABEL(splx) leave ret + +#ifdef DIAGNOSTIC +1: pushl $2f + call _C_LABEL(panic) +2: .asciz "mtx_leave: lock not held" +#endif diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h index 5896c7230b4..5fafaa0618a 100644 --- a/sys/arch/i386/include/cpu.h +++ b/sys/arch/i386/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.114 2010/08/11 21:22:44 kettenis Exp $ */ +/* $OpenBSD: cpu.h,v 1.115 2010/09/24 13:21:30 matthew Exp $ */ /* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */ /*- @@ -106,6 +106,10 @@ struct cpu_info { int ci_idepth; u_int32_t ci_imask[NIPL]; u_int32_t ci_iunmask[NIPL]; +#ifdef DIAGNOSTIC + int ci_mutex_level; +#define __HAVE_CPU_MUTEX_LEVEL +#endif paddr_t ci_idle_pcb_paddr; /* PA of idle PCB */ u_long ci_flags; /* flags; see below */ |