Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Oct 2010 16:12:49 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 185089 for review
Message-ID:  <201010251612.o9PGCnQ8052338@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@185089?ac=10

Change 185089 by jhb@jhb_jhbbsd on 2010/10/25 16:12:41

	Don't try to use the saved register flag in td_md after spinlock
	count drops to zero since a single stepping trap may clobber it.
	I think we also need to follow a similar rule in spinlock_enter()
	as well.

Affected files ...

.. //depot/projects/smpng/sys/amd64/amd64/machdep.c#96 edit
.. //depot/projects/smpng/sys/arm/arm/machdep.c#31 edit
.. //depot/projects/smpng/sys/i386/i386/machdep.c#161 edit
.. //depot/projects/smpng/sys/ia64/ia64/machdep.c#125 edit
.. //depot/projects/smpng/sys/mips/mips/machdep.c#16 edit
.. //depot/projects/smpng/sys/pc98/pc98/machdep.c#42 edit
.. //depot/projects/smpng/sys/powerpc/aim/machdep.c#21 edit
.. //depot/projects/smpng/sys/powerpc/booke/machdep.c#18 edit
.. //depot/projects/smpng/sys/sparc64/sparc64/machdep.c#104 edit
.. //depot/projects/smpng/sys/sun4v/sun4v/machdep.c#15 edit

Differences ...

==== //depot/projects/smpng/sys/amd64/amd64/machdep.c#96 (text+ko) ====

@@ -1773,12 +1773,14 @@
 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);
 }
 
 /*

==== //depot/projects/smpng/sys/arm/arm/machdep.c#31 (text+ko) ====

@@ -505,12 +505,14 @@
 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);
 }
 
 /*

==== //depot/projects/smpng/sys/i386/i386/machdep.c#161 (text+ko) ====

@@ -3008,12 +3008,14 @@
 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)

==== //depot/projects/smpng/sys/ia64/ia64/machdep.c#125 (text+ko) ====

@@ -525,12 +525,14 @@
 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

==== //depot/projects/smpng/sys/mips/mips/machdep.c#16 (text+ko) ====

@@ -462,12 +462,14 @@
 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);
 }
 
 /*

==== //depot/projects/smpng/sys/pc98/pc98/machdep.c#42 (text+ko) ====

@@ -2340,12 +2340,14 @@
 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)

==== //depot/projects/smpng/sys/powerpc/aim/machdep.c#21 (text+ko) ====

@@ -763,12 +763,14 @@
 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);
 }
 
 /*

==== //depot/projects/smpng/sys/powerpc/booke/machdep.c#18 (text+ko) ====

@@ -528,12 +528,14 @@
 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. */

==== //depot/projects/smpng/sys/sparc64/sparc64/machdep.c#104 (text+ko) ====

@@ -234,12 +234,14 @@
 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

==== //depot/projects/smpng/sys/sun4v/sun4v/machdep.c#15 (text+ko) ====

@@ -279,14 +279,15 @@
 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);
+		intr_restore(pil);
 	}
-
 }
 
 unsigned



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201010251612.o9PGCnQ8052338>