All of lore.kernel.org
 help / color / mirror / Atom feed
* kernel_thread creation bug?
@ 2004-10-22  8:07 Atsushi Nemoto
  2004-10-22 12:16 ` Ralf Baechle
  0 siblings, 1 reply; 6+ messages in thread
From: Atsushi Nemoto @ 2004-10-22  8:07 UTC (permalink / raw)
  To: linux-mips; +Cc: ralf

I'm encountering strange kernel lockup recently.  I noticed that
sometimes an interrupt happend in middle of RESTORE_SOME code.

RESTORE_SOME restores CP0_STATUS from stack.  But the value in the
stack did not contains EXL bit when the problem happens.

With recent change in kernel_thread(), initial cp0_status value comes
from current C0_STATUS (which does not include EXL bit).  Is this
correct?  The initial value should contain EXL bit to start the thread
up safely, shouldn't it?

Now I'm testing this patch and it seems to fix the problem.

diff -u linux-mips/arch/mips/kernel/process.c linux/arch/mips/kernel/
--- linux-mips/arch/mips/kernel/process.c	Wed Sep 22 13:27:59 2004
+++ linux/arch/mips/kernel/process.c	Fri Oct 22 16:49:39 2004
@@ -171,6 +171,9 @@
 	regs.regs[5] = (unsigned long) fn;
 	regs.cp0_epc = (unsigned long) kernel_thread_helper;
 	regs.cp0_status = read_c0_status();
+#if !(defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX))
+	regs.cp0_status |= ST0_EXL;
+#endif
 
 	/* Ok, create the new process.. */
 	return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs, 0, NULL, NULL);

---
Atsushi Nemoto

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: kernel_thread creation bug?
  2004-10-22  8:07 kernel_thread creation bug? Atsushi Nemoto
@ 2004-10-22 12:16 ` Ralf Baechle
  2004-10-22 12:25   ` Atsushi Nemoto
  0 siblings, 1 reply; 6+ messages in thread
From: Ralf Baechle @ 2004-10-22 12:16 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: linux-mips

On Fri, Oct 22, 2004 at 05:07:58PM +0900, Atsushi Nemoto wrote:

> With recent change in kernel_thread(), initial cp0_status value comes
> from current C0_STATUS (which does not include EXL bit).  Is this
> correct?  The initial value should contain EXL bit to start the thread
> up safely, shouldn't it?

Yes ...

  Ralf

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: kernel_thread creation bug?
  2004-10-22 12:16 ` Ralf Baechle
@ 2004-10-22 12:25   ` Atsushi Nemoto
  2004-10-23  4:08     ` Maciej W. Rozycki
  0 siblings, 1 reply; 6+ messages in thread
From: Atsushi Nemoto @ 2004-10-22 12:25 UTC (permalink / raw)
  To: ralf; +Cc: linux-mips

>>>>> On Fri, 22 Oct 2004 14:16:48 +0200, Ralf Baechle <ralf@linux-mips.org> said:
>> With recent change in kernel_thread(), initial cp0_status value
>> comes from current C0_STATUS (which does not include EXL bit).  Is
>> this correct?  The initial value should contain EXL bit to start
>> the thread up safely, shouldn't it?

ralf> Yes ...

I see the fix in CVS.  Thank you.

---
Atsushi Nemoto

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: kernel_thread creation bug?
  2004-10-22 12:25   ` Atsushi Nemoto
@ 2004-10-23  4:08     ` Maciej W. Rozycki
  2004-10-23  5:15       ` Maciej W. Rozycki
  0 siblings, 1 reply; 6+ messages in thread
From: Maciej W. Rozycki @ 2004-10-23  4:08 UTC (permalink / raw)
  To: Atsushi Nemoto, Ralf Baechle; +Cc: linux-mips

On Fri, 22 Oct 2004, Atsushi Nemoto wrote:

> >>>>> On Fri, 22 Oct 2004 14:16:48 +0200, Ralf Baechle <ralf@linux-mips.org> said:
> >> With recent change in kernel_thread(), initial cp0_status value
> >> comes from current C0_STATUS (which does not include EXL bit).  Is
> >> this correct?  The initial value should contain EXL bit to start
> >> the thread up safely, shouldn't it?
> 
> ralf> Yes ...
> 
> I see the fix in CVS.  Thank you.

 Thanks for tracking down this problem -- I think we want the following
fix on top of yours to handle the R3k style of exception handling.  I
don't have a way to test it ATM (I'd appreciate feedback if anyone could
do that for me), but it should be obvious.

 Ralf, do you agree?

  Maciej

patch-mips-2.6.9-20041023-kernel_thread-r3k-0
diff -up --recursive --new-file linux-mips-2.6.9-20041023.macro/arch/mips/kernel/process.c linux-mips-2.6.9-20041023/arch/mips/kernel/process.c
--- linux-mips-2.6.9-20041023.macro/arch/mips/kernel/process.c	Sat Oct 23 03:30:46 2004
+++ linux-mips-2.6.9-20041023/arch/mips/kernel/process.c	Sat Oct 23 03:43:16 2004
@@ -175,7 +175,10 @@ long kernel_thread(int (*fn)(void *), vo
 	regs.regs[5] = (unsigned long) fn;
 	regs.cp0_epc = (unsigned long) kernel_thread_helper;
 	regs.cp0_status = read_c0_status();
-#if !(defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX))
+#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
+	regs.cp0_status &= ~ST0_KUP;
+	regs.cp0_status |= ST0_IEP;
+#else
 	regs.cp0_status |= ST0_EXL;
 #endif
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: kernel_thread creation bug?
  2004-10-23  4:08     ` Maciej W. Rozycki
@ 2004-10-23  5:15       ` Maciej W. Rozycki
  2004-10-23 11:28         ` Ralf Baechle
  0 siblings, 1 reply; 6+ messages in thread
From: Maciej W. Rozycki @ 2004-10-23  5:15 UTC (permalink / raw)
  To: Atsushi Nemoto, Ralf Baechle; +Cc: linux-mips

On Sat, 23 Oct 2004, Maciej W. Rozycki wrote:

>  Thanks for tracking down this problem -- I think we want the following
> fix on top of yours to handle the R3k style of exception handling.  I
> don't have a way to test it ATM (I'd appreciate feedback if anyone could
> do that for me), but it should be obvious.
> 
>  Ralf, do you agree?

 We want interrupts to be disabled until rfe, of course.  Here's an
update.  Hopefully no more bugs here...

  Maciej

patch-mips-2.6.9-20041023-kernel_thread-r3k-1
diff -up --recursive --new-file linux-mips-2.6.9-20041023.macro/arch/mips/kernel/process.c linux-mips-2.6.9-20041023/arch/mips/kernel/process.c
--- linux-mips-2.6.9-20041023.macro/arch/mips/kernel/process.c	Sat Oct 23 03:30:46 2004
+++ linux-mips-2.6.9-20041023/arch/mips/kernel/process.c	Sat Oct 23 05:07:59 2004
@@ -175,7 +175,10 @@ long kernel_thread(int (*fn)(void *), vo
 	regs.regs[5] = (unsigned long) fn;
 	regs.cp0_epc = (unsigned long) kernel_thread_helper;
 	regs.cp0_status = read_c0_status();
-#if !(defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX))
+#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
+	regs.cp0_status &= ~(ST0_KUP | ST0_IEC);
+	regs.cp0_status |= ST0_IEP;
+#else
 	regs.cp0_status |= ST0_EXL;
 #endif
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: kernel_thread creation bug?
  2004-10-23  5:15       ` Maciej W. Rozycki
@ 2004-10-23 11:28         ` Ralf Baechle
  0 siblings, 0 replies; 6+ messages in thread
From: Ralf Baechle @ 2004-10-23 11:28 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: Atsushi Nemoto, linux-mips

On Sat, Oct 23, 2004 at 06:15:25AM +0100, Maciej W. Rozycki wrote:

>  We want interrupts to be disabled until rfe, of course.  Here's an
> update.  Hopefully no more bugs here...

Go ahead ...

  Ralf

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-10-23 11:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-22  8:07 kernel_thread creation bug? Atsushi Nemoto
2004-10-22 12:16 ` Ralf Baechle
2004-10-22 12:25   ` Atsushi Nemoto
2004-10-23  4:08     ` Maciej W. Rozycki
2004-10-23  5:15       ` Maciej W. Rozycki
2004-10-23 11:28         ` Ralf Baechle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.