Jump to content



Member Since 25 Jun 2012
Online Last Active 5 minutes ago

Topics I've Started

[GUIDE] Patching the kernel for Haswell CPUs, XCPM early reboot

05 November 2014 - 02:24 PM


The first version of OS X to support Haswell CPUs was Mountain Lion 10.8.5. At the same time, for certain CPUs including Haswell, Apple moved CPU power management from AppleIntelCPUPowerManagement.kext to the kernel. This technology is known as XCPM (Xnu CPU Power Management). This technology is enabled for Haswell CPUs automatically and can optionally be use with Ivy Bridge CPUs with the -xcpm kernel flag.

The problem is Apple's computers do not have a locked MSR 0xE2, yet most PC laptops do. When the kernel tries to write to this locked register, it causes a panic. And this panic happens so early in the process that it results in a reboot. Similar to how we must patch AppleIntelCPUPowerManagement.kext for locked CPU MSR 0xE2, the kernel must also be patched for CPUs using XCPM to avoid this reboot.

Background information can be found here: http://www.insanelym...063cl-i7-4700mq

How to patch the kernel

After creating your USB installer, you should have the "vanilla" kernel. Here's how to patch it:

For Yosemite 10.10 and 10.10.1 only:

# in Terminal, assuming your USB is called Installer
cp /Volumes/Installer/System/Library/Kernels/kernel ~/Desktop/kernel_backup
cp /Volumes/Installer/System/Library/Kernels/kernel ~/Desktop/kernel
cd ~/Desktop
# now patch the kernel at ~/Desktop/kernel
perl -pi -e 's|\xe2\x00\x00\x00\x02\x00\x00\x00|\x00\x00\x00\x00\x02\x00\x00\x00|g' kernel
perl -pi -e 's|\xe2\x00\x00\x00\x4c\x00\x00\x00|\x00\x00\x00\x00\x4c\x00\x00\x00|g' kernel
perl -pi -e 's|\xe2\x00\x00\x00\x90\x01\x00\x00|\x00\x00\x00\x00\x90\x01\x00\x00|g' kernel
# patched kernel is now at ~/Desktop/kernel
sudo cp kernel /Volumes/Installer/System/Library/Kernels/kernel
After you install OS X to your HDD, you will have vanilla 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 kernel with the patched version:
# in Terminal from the OS X installer, assuming your HDD volume is called "Macintosh HD"
cp /System/Library/Kernels/kernel "/Volumes/Macintosh HD/System/Library/Kernels/kernel"
After that, you can exit the installer, and boot into the installed partition to finish installation and reach the desktop.

MD5 sums for the kernel

Check your md5 sums with:
md5 /Volumes/Installer/System/Library/Kernels/kernel
10.10/10.10.1 kernel
vanilla: 9f1768fddec369e545d938f0f4f76350
xcpm patched: eb21ca4bd7aba97d5e7b080a481fc173

A note about Clover

The Clover bootloader has this patch built-in with the config.plist/KernelAndKextPatches/KernelPm option.

Keep in mind if you're not using Clover (and KernelPm), you will have to re-patch the (new) kernel after any OS X update. With Clover, it is automatic provided the code in Clover is updated (if necessary) to patch the (new) kernel.

Mac App Store access with NullEthernet.kext

23 January 2014 - 09:49 PM

If you don't have working "built-in" Ethernet (or your computer has no Ethernet at all) and do not have a supported PCIe WiFi card, then chances are you're using USB WiFi for internet access. The problem, of course, is that you have no access to the Mac App Store in that scenario.

On a whim, I created NullEthernet.kext to solve this problem. It is a "fake" Ethernet kext that will never actually work. That is, it will not ever provide network access, but it can be made to look "built-in" and solves the issue of Mac App Store access.

For Source/README/download, see here: https://github.com/R...X-Null-Ethernet

It is now confirmed working in at least two laptops where there is no Ethernet port, and the WiFi is unsupported (and not replaceable).

Update 2014-01-23

A new build is up. This version can be attached to a PCIe device as well as a fake ACPI device (as in the first version). This allows you to load the driver against an actual non-working PCIe device if that is your scenario. It also avoids a DSDT patch as all customization is done in an injector kext by modifying its Info.plist for your device. The injector/PCIe technique is not relevant in the scenario where you have no Ethernet device at all, for that case you must use the fake ACPI device. See the README.md for details.
© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy