From 18c0d15c5b63fc2345c63a78f5586ff47eda706f Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 12 Aug 2023 18:57:09 +0200 Subject: simple lock: check that the non-_irq variants are not called from IRQ --- kern/lock.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'kern') diff --git a/kern/lock.h b/kern/lock.h index 2d493f87..885b60ba 100644 --- a/kern/lock.h +++ b/kern/lock.h @@ -49,6 +49,13 @@ * spl_t s = simple_lock_irq(&mylock); * [... critical section] * simple_unlock_irq(s, &mylock); + * + * To catch faulty code, when MACH_LDEBUG is set we check that non-_irq versions + * are not called while handling an interrupt. + * + * In the following, the _nocheck versions don't check anything, the _irq + * versions disable interrupts, and the pristine versions add a check when + * MACH_LDEBUG is set. */ #if NCPUS > 1 @@ -249,9 +256,8 @@ extern void lock_clear_recursive(lock_t); /* XXX: We don't keep track of readers, so this is an approximation. */ #define have_read_lock(l) ((l)->read_count > 0) #define have_write_lock(l) ((l)->writer == current_thread()) -// Disabled for now, until all places are fixed extern unsigned long in_interrupt[NCPUS]; -#define lock_check_no_interrupts() // assert(!in_interrupt[cpu_number()]) +#define lock_check_no_interrupts() assert(!in_interrupt[cpu_number()]) #endif /* MACH_LDEBUG */ #define have_lock(l) (have_read_lock(l) || have_write_lock(l)) -- cgit v1.2.3