Re: Kernel panic at early boot time

2012-08-13 Thread John Baldwin
On Wednesday, August 08, 2012 8:26:56 pm mnln.l4 wrote:
 I finally have some time to take a closer look at this issue. Yes, it
 is caused by SMI#. DragonflyBSD has tried to fix the similar problem
 (see 
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/bb467734fc407e2c2de7f8314c63dd9f708f4df4)
 
 But Windows and Linux don't cause such problem on my machine.
 
 I compared MP initialization code between FreeBSD, Linux and NetBSD. I
 believe the problem is FreeBSD doesn't wait for 10ms between IPI_INIT
 assert and IPI_INIT deassert (though FreeBSD waits for 10ms after
 IPI_INIT deassert). After inserting 10ms wait time, the issue is
 solved. BTW, Intel's MP spec 1.4 doesn't explain very well either.

I think the confusion is that we have an extra IPI step (deassert INIT IPI)
that we did have the wait after.  Your patch is correct and I've committed
it (well, a variant, I put the DELAY() after the lapic_ipi_wait()).  I think
we should actually just remove the deassert INIT IPI entirely as I can find
no reference in either the MP spec or otherwise that says that it should be
used.  It is also ignored on all modern processors.

-- 
John Baldwin
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org


Re: Kernel panic at early boot time

2012-08-08 Thread mnln.l4
I finally have some time to take a closer look at this issue. Yes, it
is caused by SMI#. DragonflyBSD has tried to fix the similar problem
(see 
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/bb467734fc407e2c2de7f8314c63dd9f708f4df4)

But Windows and Linux don't cause such problem on my machine.

I compared MP initialization code between FreeBSD, Linux and NetBSD. I
believe the problem is FreeBSD doesn't wait for 10ms between IPI_INIT
assert and IPI_INIT deassert (though FreeBSD waits for 10ms after
IPI_INIT deassert). After inserting 10ms wait time, the issue is
solved. BTW, Intel's MP spec 1.4 doesn't explain very well either.

Patch for AMD64 (similar change for i386 as well)

Index: mp_machdep.c
===
--- mp_machdep.c(revision 239120)
+++ mp_machdep.c(working copy)
@@ -993,6 +993,8 @@
lapic_ipi_raw(APIC_DEST_DESTFLD | APIC_TRIGMOD_EDGE |
APIC_LEVEL_ASSERT | APIC_DESTMODE_PHY | APIC_DELMODE_INIT, apic_id);

+   DELAY(1); /* wait ~10mS */
+
/* wait for pending status end */
lapic_ipi_wait(-1);


For comparison,
1. FreeBSD's ap_start() method:
http://fxr.watson.org/fxr/source/amd64/amd64/mp_machdep.c?v=FREEBSD9#L977
2. Linux's wakeup_secondary_cpu_via_init() method:
http://lxr.linux.no/linux+v3.5/arch/x86/kernel/smpboot.c#L527
3. NetBSD's x86_ipi_init() method:
http://fxr.watson.org/fxr/source/arch/x86/x86/lapic.c?v=NETBSD5#L507,
http://fxr.watson.org/fxr/source/arch/xen/x86/cpu.c?v=NETBSD5;im=bigexcerpts#L858

Best,



On Fri, Jun 22, 2012 at 6:55 PM, mnln.l4 mnln...@gmail.com wrote:
 Thanks for explaining the cause!


 On Tue, Jun 19, 2012 at 4:54 AM, John Baldwin j...@freebsd.org wrote:

 On Sunday, June 17, 2012 2:35:14 pm mnln.l4 wrote:
  I get a kernel panic at early boot time on 9.0-stable (r237150),
  GENERIC,
  AMD64.
 
  Repro step:
  1. Boot, wait for welcome screen.
  2. Repeat pressing Enter key rapidly (so kernel is loading, don't stop
  pressing Enter key).
  3. See the following message at early boot

 So don't do that.  All your key presses are triggering SMI# events that
 are
 interfering with the AP's ability to respond to its startup IPI.  There is
 nothing we can do about this in the OS.

 --
 John Baldwin


___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org


Re: Kernel panic at early boot time

2012-06-22 Thread mnln.l4
Thanks for explaining the cause!

On Tue, Jun 19, 2012 at 4:54 AM, John Baldwin j...@freebsd.org wrote:

 On Sunday, June 17, 2012 2:35:14 pm mnln.l4 wrote:
  I get a kernel panic at early boot time on 9.0-stable (r237150), GENERIC,
  AMD64.
 
  Repro step:
  1. Boot, wait for welcome screen.
  2. Repeat pressing Enter key rapidly (so kernel is loading, don't stop
  pressing Enter key).
  3. See the following message at early boot

 So don't do that.  All your key presses are triggering SMI# events that are
 interfering with the AP's ability to respond to its startup IPI.  There is
 nothing we can do about this in the OS.

 --
 John Baldwin

___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org


Re: Kernel panic at early boot time

2012-06-19 Thread John Baldwin
On Sunday, June 17, 2012 2:35:14 pm mnln.l4 wrote:
 I get a kernel panic at early boot time on 9.0-stable (r237150), GENERIC,
 AMD64.
 
 Repro step:
 1. Boot, wait for welcome screen.
 2. Repeat pressing Enter key rapidly (so kernel is loading, don't stop
 pressing Enter key).
 3. See the following message at early boot

So don't do that.  All your key presses are triggering SMI# events that are
interfering with the AP's ability to respond to its startup IPI.  There is
nothing we can do about this in the OS.

-- 
John Baldwin
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org