Bug 191693

Summary: [amd64] [patch] Macboook 4,1 kernel panic on boot - with workaround and fix
Product: Base System Reporter: walker.aj325
Component: kernAssignee: Pedro F. Giffuni <pfg>
Status: Closed FIXED    
Severity: Affects Some People CC: emaste, pfg
Priority: ---    
Version: 10.0-RELEASE   
Hardware: amd64   
OS: Any   
Attachments:
Description Flags
diff of proposed change
none
Updated patch for 1386 and amd64
none
Add in Macbookpro4,1 none

Description walker.aj325 2014-07-07 12:14:10 UTC
My macbook 4.1 panics on boot when SMP enabled. Setting the following in loader.conf fixes the problem: " smbios.system.product="MacBook3,1" ". This is an ugly work-around.

There is a high probability the following change to machdep.c will fix the problem permanently:

	/*
	 * On MacBooks, we need to disallow the legacy USB circuit to
	 * generate an SMI# because this can cause several problems,
	 * namely: incorrect CPU frequency detection and failure to
	 * start the APs.
	 * We do this by disabling a bit in the SMI_EN (SMI Control and
	 * Enable register) of the Intel ICH LPC Interface Bridge. 
	 */
	sysenv = getenv("smbios.system.product");
	if (sysenv != NULL) {
		if (strncmp(sysenv, "MacBook1,1", 10) == 0 ||
		    strncmp(sysenv, "MacBook3,1", 10) == 0 ||
>		    strncmp(sysenv, "MacBook4,1", 10) == 0 ||
		    strncmp(sysenv, "MacBookPro1,1", 13) == 0 ||
		    strncmp(sysenv, "MacBookPro1,2", 13) == 0 ||
		    strncmp(sysenv, "MacBookPro3,1", 13) == 0 ||
		    strncmp(sysenv, "Macmini1,1", 10) == 0) {
			if (bootverbose)
				printf("Disabling LEGACY_USB_EN bit on "
				    "Intel ICH.\n");
			outl(ICH_SMI_EN, inl(ICH_SMI_EN) & ~0x8);
		}
		freeenv(sysenv);
	}

Right now the loader.conf change is serving me just fine, but there may be a few other potential users affected by this bug.
Comment 1 walker.aj325 2014-07-07 16:59:28 UTC
Created attachment 144494 [details]
diff of proposed change
Comment 2 walker.aj325 2014-07-13 07:47:44 UTC
I have now been using the above fix for about a week. It appears to have resolved the problem. Is there any additional information or testing required?
Comment 3 Pedro F. Giffuni freebsd_committer freebsd_triage 2014-08-23 16:29:00 UTC
Created attachment 146184 [details]
Updated patch for 1386 and amd64

You didn't include path information in your patch, which is sort of lucky because there are actually 2 machdep.c files that have to be updated.

This makes me wonder if we should be adding MacBookPro4,1 to the list.
Comment 4 Pedro F. Giffuni freebsd_committer freebsd_triage 2014-09-03 20:35:09 UTC
Created attachment 146748 [details]
Add in Macbookpro4,1
Comment 5 Pedro F. Giffuni freebsd_committer freebsd_triage 2014-09-03 20:37:34 UTC
I think the patch is ready, but I would like someone to confirm (perhaps Ed)?
Comment 6 Ed Maste freebsd_committer freebsd_triage 2014-09-04 21:38:16 UTC
The patch looks fine to me.
Comment 7 commit-hook freebsd_committer freebsd_triage 2014-09-05 01:06:55 UTC
A commit references this bug:

Author: pfg
Date: Fri Sep  5 01:06:45 UTC 2014
New revision: 271149
URL: http://svnweb.freebsd.org/changeset/base/271149

Log:
  Apply known workarounds for modern MacBooks.

  The legacy USB circuit tends to give trouble on MacBook.
  While the original report covered MacBook, extend the fix
  preemptively for the newer MacBookPro too.

  PR:		191693
  Reviewed by:	emaste
  MFC after:	5 days

Changes:
  head/sys/amd64/amd64/machdep.c
  head/sys/i386/i386/machdep.c
Comment 8 commit-hook freebsd_committer freebsd_triage 2014-09-13 18:28:12 UTC
A commit references this bug:

Author: pfg
Date: Sat Sep 13 18:27:47 UTC 2014
New revision: 271541
URL: http://svnweb.freebsd.org/changeset/base/271541

Log:
  MFC	r271149:
  Apply known workarounds for less modern MacBooks.

  The legacy USB circuit tends to give trouble on older MacBooks.
  While the original report covered MacBook4, extend the fix
  preemptively for the newer MacBookPro4 too.

  PR:		191693
  Reviewed by:	emaste
  Approved by:	re

Changes:
_U  stable/10/
  stable/10/sys/amd64/amd64/machdep.c
  stable/10/sys/i386/i386/machdep.c
Comment 9 commit-hook freebsd_committer freebsd_triage 2014-09-13 18:35:15 UTC
A commit references this bug:

Author: pfg
Date: Sat Sep 13 18:34:57 UTC 2014
New revision: 271542
URL: http://svnweb.freebsd.org/changeset/base/271542

Log:
  MFC	r271149:
  Apply known workarounds for less modern MacBooks.

  The legacy USB circuit tends to give trouble on older MacBooks.
  While the original report covered MacBook4, extend the fix
  preemptively for the newer MacBookPro4 too.

  PR:		191693
  Reviewed by:	emaste

Changes:
_U  stable/9/sys/
  stable/9/sys/amd64/amd64/machdep.c
  stable/9/sys/i386/i386/machdep.c
Comment 10 Pedro F. Giffuni freebsd_committer freebsd_triage 2014-09-13 18:37:16 UTC
Committed and merged back to stable/9.
Change will be in 10.1 Release.

Thank you for your report and contribution!