Many people with Haswell laptops (and some desktops) have been running into a new problem Apple has thrown at us. The new Mavericks kernel has power management moved down into the kernel. For this reason, my MacBookAir6,2 running Mavericks does not load AppleIntelCPUPowerManagement. In the past, we patched AppleIntelCPUPowerManagement to avoid the kernel writing to locked CPU MSRs (machine specific registers, credit RevoGirl). Some BIOSes lock some of these registers (the common one is 0xE2, I don't know if others can be locked as well). The problem is that touching these registers when they are locked causes an unexpected fault and you get a KP. It seems this KP is so early, that the kernel is unprepared to handle it, and the computer reboots.

Some people have found that if they use a kernel modified for AMD systems, they are able to boot (see here: http://www.tonymacx86.com/mountain-lion-laptop-support/110981-asus-g750jx-4.html#post697066). I tried this and it indeed works. But other things break... I was able to install (using that kernel), but I couldn't boot with caches (always had to use "-f"). Booting with caches caused a KP. In addition, there was no power management. CPU was running at x24 always.

But...

I decided to see what I could do by building my own kernel. My main thought was to make some changes, see if I could avoid touching locked MSRs with modifications to the source code with the idea to fold the changes into a patch. So, I downloaded the kernel source from opensource.apple.com, found out how to build it (thanks google!), and tried to use it. On first try, I didn't make any changes... and I was surprised that I was able to start the installer with the newly built kernel! No changes and it just works. WTF?

Turns out the sources for the kernel do not include the parts for xnu power management. Since it isn't there, it doesn't cause the problem. But of course, AppleIntelCPUPowerManagement expects for PM to be provided by the kernel, so it doesn't work. It doesn't crash, but still no power management. Since 10.8.5 does not have this change, I decided to try the (patched) AppleIntelCPUPowerManagement from 10.8.5 (v214). And that actually works.

I don't really like doing rollbacks like that, but it is probably a workable solution until something better comes along. I still think it might be possible to patch the kernel to avoid the MSR writing problem. See updates below on patches.

As a result, I'm now running a patched mach_kernel (not built from source, but patched from retail), MacBookPro11,2 smbios.plist, AppleIntelCPUPowerManagement.kext, ssdt.aml generated with Pike's script (plugin-type=1). Of course, AppleIntelCPUPowerManagement does not load, as all CPU power management is handled by the kernel (xcpm). In other words, it is running just as a real Haswell MacBookPro would as far as power management. The only "problem" that I can see, is that I'm not getting pstates between x8 and x24, much like the results with iMac14,2. I wonder if something is missing (taking the place of X86PlatformPlugin plists?) that the bootloader/DSDT/SSDT should be injecting to inform the kernel's xcpm behavior? More investigation is needed. I will investigate by watching the behavior of my real MacBookAir6,2 and perhaps a friend's real MacBookPro11,x.

I will update this post should I find more information.

Just for ease of reference here is the currently recommended patches...

Update 2014-10-18

I updated my blog and this post with the patches for the recently released Yosemite 10.10.

After you install OS X to your HDD, you will have vanilla mach_kernel on the HDD, leading to the same instant reboot problem. So, you must re-enter the OS X installer, and go into Terminal (using Utilities -> Terminal) and replace the mach_kernel with the patched version:

I don't need to put -f in my boot arguments I boot with default ones. Basically I'm not getting kernel panic like you do with that HP but you are right that powermanagement doesn't work. I can't sleep .. I thought I can but I can't.

So if everything works for ASUS, do you suggest I still use your kernel, OR to use the 10.8.5 power management kext you suggested. If I understand correctly you are saying that this should fix the sleep issue?

Also, one problem I noticed is that hardware acceleration doesn't work if smbios is set as macbook pro (or anything else but Mac Pro 5.1). However in this case I lose touchpad because mac pro 5.1 doesn't obviously load the laptop stuff like touchpad.

Any suggestions about that? I'm thinking in modifying Apple GraphicsPowerManagement and see what's set under MacPro5,1 and replicate that to MBP10.1 or any latest MBP available in order to try to solve this hardware acceleration issue.

I don't need to put -f in my boot arguments I boot with default ones. Basically I'm not getting kernel panic like you do with that HP but you are right that powermanagement doesn't work. I can't sleep .. I thought I can but I can't.

So if everything works for ASUS, do you suggest I still use your kernel, OR to use the 10.8.5 power management kext you suggested. If I understand correctly you are saying that this should fix the sleep issue?

Also, one problem I noticed is that hardware acceleration doesn't work if smbios is set as macbook pro (or anything else but Mac Pro 5.1). However in this case I lose touchpad because mac pro 5.1 doesn't obviously load the laptop stuff like touchpad.

Any suggestions about that? I'm thinking in modifying Apple GraphicsPowerManagement and see what's set under MacPro5,1 and replicate that to MBP10.1 or any latest MBP available in order to try to solve this hardware acceleration issue.

I've got full power management and sleep working... So yeah, you probably want this kernel over the AMD one.

Hardware accel (graphics) depends on injecting the correct properties for graphics (and probably compatible smbios). I use a DSDT patch to inject ig-platform=0a260006 (in my case the graphics stuff was actually in an SSDT). Also I rename GFX0 -> IGPU for better power management.

PM works with iMac13,2 and "Ivy style" SSDT or with MacBookPro8,3 and "Sandy style" SSDT.

Hmmmm....
here i was and thought i had bought uncompatible hardware!
searching high and low for ACPI that was missing...

Then you brew a new Kernel and the MF works ....im impressed.
Good job.

So i made the usb installer form Unibeast, copied your mach_kernel to the usb and it worked.
and to be able to boot the HD i had to copy over the mach_kernel as well.

Kext installs though, its giving me troubles.- HD4600 graphics (this computer uses eDP) i only get 1024x768(dont think it proberly installed)- USB3 (before sleep)- trackpad/keyboard (Synaptics) do you have a kext for this?- backlit keyboard on/off (must be hardwired)- Camera (kind of grainy, but could be poor lighting) works great out of the box....

Moderator

Hmmmm....
here i was and thought i had bought uncompatible hardware!
searching high and low for ACPI that was missing...

Then you brew a new Kernel and the MF works ....im impressed.
Good job.

So i made the usb installer form Unibeast, copied your mach_kernel to the usb and it worked.
and to be able to boot the HD i had to copy over the mach_kernel as well.

Kext installs though, its giving me troubles.- HD4600 graphics (this computer uses eDP) i only get 1024x768(dont think it proberly installed)- USB3 (before sleep)- trackpad/keyboard (Synaptics) do you have a kext for this?- backlit keyboard on/off (must be hardwired)- Camera (kind of grainy, but could be poor lighting) works great out of the box....

But use iMac14,2 (SSDT from ProBook Installer) or MacBookPro8,3 (generate with MaciASL).

Your USB3 may be configured differently, but there are DSDT patches for USB in the patch repo above (to be used with AppleUSBXHCI) or you can use GenericUSBXHCI without DSDT patches (currently what I'm using).

Note: The point of this post was really about the kernel, not about this specific laptop, so please do not turn it into a thread about troubleshooting your install. Thanks. I will write a more complete guide for this laptop when/if I get done with it.