From 5d971d4895921fd55c28bc08c2b0bd87e91be568 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Thu, 14 Apr 2005 18:30:10 +0000 Subject: [PATCH] Close a race I introduced in the spinlock_* changes. We need to finish disabling interrupts before updating the saved pil in the thread. If we save the value first then it can be clobbered if an interrupt comes in and the interrupt handler tries to acquire a spin lock. Submitted by: marius --- sys/sparc64/sparc64/machdep.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/sparc64/sparc64/machdep.c b/sys/sparc64/sparc64/machdep.c index ccad87809bc5..a91f8093156d 100644 --- a/sys/sparc64/sparc64/machdep.c +++ b/sys/sparc64/sparc64/machdep.c @@ -236,11 +236,13 @@ void spinlock_enter(void) { struct thread *td; + register_t pil; td = curthread; if (td->td_md.md_spinlock_count == 0) { - td->td_md.md_saved_pil = rdpr(pil); + pil = rdpr(pil); wrpr(pil, 0, 14); + td->td_md.md_saved_pil = pil; } td->td_md.md_spinlock_count++; critical_enter();