diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-08-12 13:33:00 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-08-12 23:29:30 +0200 |
commit | 98a5b2d84e39d5cc8a92951589aa307fdbaff902 (patch) | |
tree | df3594e91ec62c2076bbe33837d20dacec54a0ac /kern | |
parent | 2a53e6afccb6a69f027badac73d0f2f36ac9e319 (diff) | |
download | gnumach-98a5b2d84e39d5cc8a92951589aa307fdbaff902.tar.gz gnumach-98a5b2d84e39d5cc8a92951589aa307fdbaff902.tar.bz2 gnumach-98a5b2d84e39d5cc8a92951589aa307fdbaff902.zip |
assert: fix concurrency against irqs
by using simple_lock_irq.
Diffstat (limited to 'kern')
-rw-r--r-- | kern/debug.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/kern/debug.c b/kern/debug.c index cd782361..b608d9ff 100644 --- a/kern/debug.c +++ b/kern/debug.c @@ -54,10 +54,10 @@ void Assert(const char *exp, const char *file, int line, const char *fun) { #if NCPUS > 1 - simple_lock(&Assert_print_lock); + spl_t s = simple_lock_irq(&Assert_print_lock); printf("{cpu%d} %s:%d: %s: Assertion `%s' failed.", cpu_number(), file, line, fun, exp); - simple_unlock(&Assert_print_lock); + simple_unlock_irq(s, &Assert_print_lock); #else printf("%s:%d: %s: Assertion `%s' failed.", file, line, fun, exp); @@ -112,7 +112,7 @@ void Debugger(const char *message) even before panic_init() gets called from the "normal" place in kern/startup.c. (panic_init() still needs to be called from there to make sure we get initialized before starting multiple processors.) */ -def_simple_lock_data(static, panic_lock) +def_simple_lock_irq_data(static, panic_lock) const char *panicstr; int paniccpu; @@ -131,13 +131,14 @@ void Panic(const char *file, int line, const char *fun, const char *s, ...) { va_list listp; + spl_t spl; panic_init(); - simple_lock(&panic_lock); + spl = simple_lock_irq(&panic_lock); if (panicstr) { if (cpu_number() != paniccpu) { - simple_unlock(&panic_lock); + simple_unlock_irq(spl, &panic_lock); halt_cpu(); /* NOTREACHED */ } @@ -146,7 +147,7 @@ Panic(const char *file, int line, const char *fun, const char *s, ...) panicstr = s; paniccpu = cpu_number(); } - simple_unlock(&panic_lock); + simple_unlock_irq(spl, &panic_lock); printf("panic "); #if NCPUS > 1 printf("{cpu%d} ", paniccpu); |