Contribute
Register

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

Joined
Sep 4, 2012
Messages
39
Motherboard
Lenovo IdeaPad Z50-70 59427655
CPU
i5-4210U
Graphics
Intel HD Graphics 4400
Mac
Classic Mac
Mobile Phone
I'm trying to install 10.11 on my haswell Laptop. Unibeast 6 /Clover.
I get an early reboot.

Anyone know, why?
 
Joined
Jan 23, 2016
Messages
2
Motherboard
Asus ROG G750JM
CPU
i4700HQ Haswell
Graphics
Nvidia GTX860M+Intel HD Graphics 4600
Mac
Classic Mac
Mobile Phone
Overview

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.tonymacx86.com/mavericks-laptop-support/114677-haswell-early-reboot-mavericks-locked-msrs-hp-envy-15-j063cl-i7-4700mq.html


How to patch the kernel

The vanilla kernel is located on your USB installer after running Unibeast. Here's how to patch it:

For Yosemite 10.10.x:
Code:
# 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\x00\x00\x00\x00|g' kernel
perl -pi -e 's|\xe2\x00\x00\x00\x4c\x00\x00\x00|\x00\x00\x00\x00\x00\x00\x00\x00|g' kernel
perl -pi -e 's|\xe2\x00\x00\x00\x90\x01\x00\x00|\x00\x00\x00\x00\x00\x00\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:

Code:
# 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:
Code:
md5 /Volumes/Installer/System/Library/Kernels/kernel
10.10/10.10.1 kernel
vanilla: 9f1768fddec369e545d938f0f4f76350
xcpm patched: 1938ebb0bd6cdc00930543025d3df887

10.10.2 kernel
vanilla: 8a985412c42c153601580fd1b8bc360e
xcpm patched: cc46457172315aea68d8e1f957d2746c

10.10.3 kernel
vanilla: fd9b0ed2a37a393d145033a2f0ce46b4
xcpm patched: d89759c11c5f434b4434b6fbf0464d6c

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.


Update 2015-01-26

For details see the blog article: https://racerrehabman.wordpress.com/2014/10/18/yosemitehaswell-kernel-patch-for-early-reboot/
Hi guys, i'm trying to install el capitan to asus rog g750jm laptop. i'm following the steps in guide but when i reach the step where i need to patch the kernel on the unibeast flash drive there is no kernel folder on the path specified. anyone can help me? plz
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
191,123
Motherboard
Intel DH67BL
CPU
Core i7-2600K
Graphics
Intel HD 3000
Mac
MacBook Air
Mobile Phone
iOS
Hi guys, i'm trying to install el capitan to asus rog g750jm laptop. i'm following the steps in guide but when i reach the step where i need to patch the kernel on the unibeast flash drive there is no kernel folder on the path specified. anyone can help me? plz
Follow the Clover guide linked from the FAQ.

http://www.tonymacx86.com/el-capitan-laptop-support/164990-faq-read-first-laptop-frequent-questions.html

The kernel is patched automatically by Clover with KernelPm=true (already set in guide plist files).
 
Joined
Mar 20, 2016
Messages
2
Motherboard
Asus a550L
CPU
i7 - 4510U
Graphics
820m
Mac
Classic Mac
Mobile Phone
iOS
It's too hard to understand instruction .
Do you have some like *Hackintosh for noobs and how to patch Haswell*.
I trying to patch 2 weeks and dont understand, which side i have to start.
i Readed F.A.Q 10 times and don't understand how to patch
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
191,123
Motherboard
Intel DH67BL
CPU
Core i7-2600K
Graphics
Intel HD 3000
Mac
MacBook Air
Mobile Phone
iOS
Joined
Sep 4, 2015
Messages
9
Motherboard
HP Compaq 15-s104tx
CPU
Intel i5-4210U (Haswell ULT)
Graphics
Intel HD Graphics Family(Intel HD 4400 Nvidia 820M 2GB) dedicated
Mobile Phone
Android
Hey @RehabMan since this patch is for Yosemite only, so will this work on Mac OS Sierra too. If not will this method be updated for sierra ?
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
191,123
Motherboard
Intel DH67BL
CPU
Core i7-2600K
Graphics
Intel HD 3000
Mac
MacBook Air
Mobile Phone
iOS
Hey @RehabMan since this patch is for Yosemite only, so will this work on Mac OS Sierra too. If not will this method be updated for sierra ?
No need to patch manually with Clover as my patch is built-in to Clover. Use config.plist/KernelAndKextPatches/KernelPm=true.
 
Joined
Sep 4, 2015
Messages
9
Motherboard
HP Compaq 15-s104tx
CPU
Intel i5-4210U (Haswell ULT)
Graphics
Intel HD Graphics Family(Intel HD 4400 Nvidia 820M 2GB) dedicated
Mobile Phone
Android
@RehabMan thanks for reply I will do that. one more question does that solve both errors "1. APIC error and 2. Early reboot error" or I have to use anything else.

Thank you
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
191,123
Motherboard
Intel DH67BL
CPU
Core i7-2600K
Graphics
Intel HD 3000
Mac
MacBook Air
Mobile Phone
iOS
Top