svn commit: r217855 - in stable/8/sys: amd64/amd64 arm/arm
i386/i386 ia64/ia64 mips/mips pc98/pc98 powerpc/aim
powerpc/booke sparc64/sparc64 sun4v/sun4v
John Baldwin
jhb at FreeBSD.org
Tue Jan 25 22:08:22 UTC 2011
Author: jhb
Date: Tue Jan 25 22:08:22 2011
New Revision: 217855
URL: http://svn.freebsd.org/changeset/base/217855
Log:
MFC 214835:
Adjust the order of operations in spinlock_enter() and spinlock_exit() to
work properly with single-stepping in a kernel debugger.
Modified:
stable/8/sys/amd64/amd64/machdep.c
stable/8/sys/arm/arm/machdep.c
stable/8/sys/i386/i386/machdep.c
stable/8/sys/ia64/ia64/machdep.c
stable/8/sys/mips/mips/machdep.c
stable/8/sys/pc98/pc98/machdep.c
stable/8/sys/powerpc/aim/machdep.c
stable/8/sys/powerpc/booke/machdep.c
stable/8/sys/sparc64/sparc64/machdep.c
stable/8/sys/sun4v/sun4v/machdep.c
Directory Properties:
stable/8/sys/ (props changed)
stable/8/sys/amd64/include/xen/ (props changed)
stable/8/sys/cddl/contrib/opensolaris/ (props changed)
stable/8/sys/contrib/dev/acpica/ (props changed)
stable/8/sys/contrib/pf/ (props changed)
Modified: stable/8/sys/amd64/amd64/machdep.c
==============================================================================
--- stable/8/sys/amd64/amd64/machdep.c Tue Jan 25 21:51:32 2011 (r217854)
+++ stable/8/sys/amd64/amd64/machdep.c Tue Jan 25 22:08:22 2011 (r217855)
@@ -1757,11 +1757,15 @@ void
spinlock_enter(void)
{
struct thread *td;
+ register_t flags;
td = curthread;
- if (td->td_md.md_spinlock_count == 0)
- td->td_md.md_saved_flags = intr_disable();
- td->td_md.md_spinlock_count++;
+ if (td->td_md.md_spinlock_count == 0) {
+ flags = intr_disable();
+ td->td_md.md_spinlock_count = 1;
+ td->td_md.md_saved_flags = flags;
+ } else
+ td->td_md.md_spinlock_count++;
critical_enter();
}
@@ -1769,12 +1773,14 @@ void
spinlock_exit(void)
{
struct thread *td;
+ register_t flags;
td = curthread;
critical_exit();
+ flags = td->td_md.md_saved_flags;
td->td_md.md_spinlock_count--;
if (td->td_md.md_spinlock_count == 0)
- intr_restore(td->td_md.md_saved_flags);
+ intr_restore(flags);
}
/*
Modified: stable/8/sys/arm/arm/machdep.c
==============================================================================
--- stable/8/sys/arm/arm/machdep.c Tue Jan 25 21:51:32 2011 (r217854)
+++ stable/8/sys/arm/arm/machdep.c Tue Jan 25 22:08:22 2011 (r217855)
@@ -493,11 +493,15 @@ void
spinlock_enter(void)
{
struct thread *td;
+ register_t cspr;
td = curthread;
- if (td->td_md.md_spinlock_count == 0)
- td->td_md.md_saved_cspr = disable_interrupts(I32_bit | F32_bit);
- td->td_md.md_spinlock_count++;
+ if (td->td_md.md_spinlock_count == 0) {
+ cspr = disable_interrupts(I32_bit | F32_bit);
+ td->td_md.md_spinlock_count = 1;
+ td->td_md.md_saved_cspr = cspr;
+ } else
+ td->td_md.md_spinlock_count++;
critical_enter();
}
@@ -505,12 +509,14 @@ void
spinlock_exit(void)
{
struct thread *td;
+ register_t cspr;
td = curthread;
critical_exit();
+ cspr = td->td_md.md_saved_cspr;
td->td_md.md_spinlock_count--;
if (td->td_md.md_spinlock_count == 0)
- restore_interrupts(td->td_md.md_saved_cspr);
+ restore_interrupts(cspr);
}
/*
Modified: stable/8/sys/i386/i386/machdep.c
==============================================================================
--- stable/8/sys/i386/i386/machdep.c Tue Jan 25 21:51:32 2011 (r217854)
+++ stable/8/sys/i386/i386/machdep.c Tue Jan 25 22:08:22 2011 (r217855)
@@ -2981,11 +2981,15 @@ void
spinlock_enter(void)
{
struct thread *td;
+ register_t flags;
td = curthread;
- if (td->td_md.md_spinlock_count == 0)
- td->td_md.md_saved_flags = intr_disable();
- td->td_md.md_spinlock_count++;
+ if (td->td_md.md_spinlock_count == 0) {
+ flags = intr_disable();
+ td->td_md.md_spinlock_count = 1;
+ td->td_md.md_saved_flags = flags;
+ } else
+ td->td_md.md_spinlock_count++;
critical_enter();
}
@@ -2993,12 +2997,14 @@ void
spinlock_exit(void)
{
struct thread *td;
+ register_t flags;
td = curthread;
critical_exit();
+ flags = td->td_md.md_saved_flags;
td->td_md.md_spinlock_count--;
if (td->td_md.md_spinlock_count == 0)
- intr_restore(td->td_md.md_saved_flags);
+ intr_restore(flags);
}
#if defined(I586_CPU) && !defined(NO_F00F_HACK)
Modified: stable/8/sys/ia64/ia64/machdep.c
==============================================================================
--- stable/8/sys/ia64/ia64/machdep.c Tue Jan 25 21:51:32 2011 (r217854)
+++ stable/8/sys/ia64/ia64/machdep.c Tue Jan 25 22:08:22 2011 (r217855)
@@ -512,11 +512,15 @@ void
spinlock_enter(void)
{
struct thread *td;
+ int intr;
td = curthread;
- if (td->td_md.md_spinlock_count == 0)
- td->td_md.md_saved_intr = intr_disable();
- td->td_md.md_spinlock_count++;
+ if (td->td_md.md_spinlock_count == 0) {
+ intr = intr_disable();
+ td->td_md.md_spinlock_count = 1;
+ td->td_md.md_saved_intr = intr;
+ } else
+ td->td_md.md_spinlock_count++;
critical_enter();
}
@@ -524,12 +528,14 @@ void
spinlock_exit(void)
{
struct thread *td;
+ int intr;
td = curthread;
critical_exit();
+ intr = td->td_md.md_saved_intr;
td->td_md.md_spinlock_count--;
if (td->td_md.md_spinlock_count == 0)
- intr_restore(td->td_md.md_saved_intr);
+ intr_restore(intr);
}
void
Modified: stable/8/sys/mips/mips/machdep.c
==============================================================================
--- stable/8/sys/mips/mips/machdep.c Tue Jan 25 21:51:32 2011 (r217854)
+++ stable/8/sys/mips/mips/machdep.c Tue Jan 25 22:08:22 2011 (r217855)
@@ -449,11 +449,15 @@ void
spinlock_enter(void)
{
struct thread *td;
+ register_t intr;
td = curthread;
- if (td->td_md.md_spinlock_count == 0)
- td->td_md.md_saved_intr = intr_disable();
- td->td_md.md_spinlock_count++;
+ if (td->td_md.md_spinlock_count == 0) {
+ intr = intr_disable();
+ td->td_md.md_spinlock_count = 1;
+ td->td_md.md_saved_intr = intr;
+ } else
+ td->td_md.md_spinlock_count++;
critical_enter();
}
@@ -461,12 +465,14 @@ void
spinlock_exit(void)
{
struct thread *td;
+ register_t intr;
td = curthread;
critical_exit();
+ intr = td->td_md.md_saved_intr;
td->td_md.md_spinlock_count--;
if (td->td_md.md_spinlock_count == 0)
- intr_restore(td->td_md.md_saved_intr);
+ intr_restore(intr);
}
/*
Modified: stable/8/sys/pc98/pc98/machdep.c
==============================================================================
--- stable/8/sys/pc98/pc98/machdep.c Tue Jan 25 21:51:32 2011 (r217854)
+++ stable/8/sys/pc98/pc98/machdep.c Tue Jan 25 22:08:22 2011 (r217855)
@@ -2312,11 +2312,15 @@ void
spinlock_enter(void)
{
struct thread *td;
+ register_t flags;
td = curthread;
- if (td->td_md.md_spinlock_count == 0)
- td->td_md.md_saved_flags = intr_disable();
- td->td_md.md_spinlock_count++;
+ if (td->td_md.md_spinlock_count == 0) {
+ flags = intr_disable();
+ td->td_md.md_spinlock_count = 1;
+ td->td_md.md_saved_flags = flags;
+ } else
+ td->td_md.md_spinlock_count++;
critical_enter();
}
@@ -2324,12 +2328,14 @@ void
spinlock_exit(void)
{
struct thread *td;
+ register_t flags;
td = curthread;
critical_exit();
+ flags = td->td_md.md_saved_flags;
td->td_md.md_spinlock_count--;
if (td->td_md.md_spinlock_count == 0)
- intr_restore(td->td_md.md_saved_flags);
+ intr_restore(flags);
}
#if defined(I586_CPU) && !defined(NO_F00F_HACK)
Modified: stable/8/sys/powerpc/aim/machdep.c
==============================================================================
--- stable/8/sys/powerpc/aim/machdep.c Tue Jan 25 21:51:32 2011 (r217854)
+++ stable/8/sys/powerpc/aim/machdep.c Tue Jan 25 22:08:22 2011 (r217855)
@@ -704,11 +704,15 @@ void
spinlock_enter(void)
{
struct thread *td;
+ register_t msr;
td = curthread;
- if (td->td_md.md_spinlock_count == 0)
- td->td_md.md_saved_msr = intr_disable();
- td->td_md.md_spinlock_count++;
+ if (td->td_md.md_spinlock_count == 0) {
+ msr = intr_disable();
+ td->td_md.md_spinlock_count = 1;
+ td->td_md.md_saved_msr = msr;
+ } else
+ td->td_md.md_spinlock_count++;
critical_enter();
}
@@ -716,12 +720,14 @@ void
spinlock_exit(void)
{
struct thread *td;
+ register_t msr;
td = curthread;
critical_exit();
+ msr = td->td_md.md_saved_msr;
td->td_md.md_spinlock_count--;
if (td->td_md.md_spinlock_count == 0)
- intr_restore(td->td_md.md_saved_msr);
+ intr_restore(msr);
}
/*
Modified: stable/8/sys/powerpc/booke/machdep.c
==============================================================================
--- stable/8/sys/powerpc/booke/machdep.c Tue Jan 25 21:51:32 2011 (r217854)
+++ stable/8/sys/powerpc/booke/machdep.c Tue Jan 25 22:08:22 2011 (r217855)
@@ -553,11 +553,15 @@ void
spinlock_enter(void)
{
struct thread *td;
+ register_t msr;
td = curthread;
- if (td->td_md.md_spinlock_count == 0)
- td->td_md.md_saved_msr = intr_disable();
- td->td_md.md_spinlock_count++;
+ if (td->td_md.md_spinlock_count == 0) {
+ msr = intr_disable();
+ td->td_md.md_spinlock_count = 1;
+ td->td_md.md_saved_msr = msr;
+ } else
+ td->td_md.md_spinlock_count++;
critical_enter();
}
@@ -565,12 +569,14 @@ void
spinlock_exit(void)
{
struct thread *td;
+ register_t msr;
td = curthread;
critical_exit();
+ msr = td->td_md.md_saved_msr;
td->td_md.md_spinlock_count--;
if (td->td_md.md_spinlock_count == 0)
- intr_restore(td->td_md.md_saved_msr);
+ intr_restore(msr);
}
/* Shutdown the CPU as much as possible. */
Modified: stable/8/sys/sparc64/sparc64/machdep.c
==============================================================================
--- stable/8/sys/sparc64/sparc64/machdep.c Tue Jan 25 21:51:32 2011 (r217854)
+++ stable/8/sys/sparc64/sparc64/machdep.c Tue Jan 25 22:08:22 2011 (r217855)
@@ -223,9 +223,10 @@ spinlock_enter(void)
if (td->td_md.md_spinlock_count == 0) {
pil = rdpr(pil);
wrpr(pil, 0, PIL_TICK);
+ td->td_md.md_spinlock_count = 1;
td->td_md.md_saved_pil = pil;
- }
- td->td_md.md_spinlock_count++;
+ } else
+ td->td_md.md_spinlock_count++;
critical_enter();
}
@@ -233,12 +234,14 @@ void
spinlock_exit(void)
{
struct thread *td;
+ register_t pil;
td = curthread;
critical_exit();
+ pil = td->td_md.md_saved_pil;
td->td_md.md_spinlock_count--;
if (td->td_md.md_spinlock_count == 0)
- wrpr(pil, td->td_md.md_saved_pil, 0);
+ wrpr(pil, pil, 0);
}
static phandle_t
Modified: stable/8/sys/sun4v/sun4v/machdep.c
==============================================================================
--- stable/8/sys/sun4v/sun4v/machdep.c Tue Jan 25 21:51:32 2011 (r217854)
+++ stable/8/sys/sun4v/sun4v/machdep.c Tue Jan 25 22:08:22 2011 (r217855)
@@ -268,9 +268,10 @@ spinlock_enter(void)
td = curthread;
if (td->td_md.md_spinlock_count == 0) {
pil = intr_disable();
+ td->td_md.md_spinlock_count = 1;
td->td_md.md_saved_pil = pil;
- }
- td->td_md.md_spinlock_count++;
+ } else
+ td->td_md.md_spinlock_count++;
critical_enter();
}
@@ -278,14 +279,14 @@ void
spinlock_exit(void)
{
struct thread *td;
+ register_t pil;
td = curthread;
critical_exit();
+ pil = td->td_md.md_saved_pil;
td->td_md.md_spinlock_count--;
- if (td->td_md.md_spinlock_count == 0) {
- intr_restore(td->td_md.md_saved_pil);
- }
-
+ if (td->td_md.md_spinlock_count == 0)
+ intr_restore(pil);
}
unsigned
More information about the svn-src-stable-8
mailing list