Jump to content

Haswell early reboot, Mavericks, locked MSRs, and HP Envy 15-J063CL (i7-4700MQ)

mavericks kernel mach_kernel locked MSR reboot power management

  • Please log in to reply
454 replies to this topic

#441
RehabMan

RehabMan

    InsanelyMac Legend

  • Coders
  • 1,376 posts
  • Gender:Male
  • Location:Bellingham, WA
  • Interests:skiing, software, classic cars

Hm, dammit. Looks like I'm going to have to try Mountain Lion. I've spent the past 2-3 days trying everything. I've recreated by USB stick about 5 times, and had to redownload Mavericks twice. /me Sighs. Thanks again, I hope Mavericks supports Haswell someday.


Mavericks supports Haswell just fine. Just not the Haswell Pentium/Celeron chips (keep in mind Apple doesn't use those chips in their computers).

#442
HighMans

HighMans

    InsanelyMac Protégé

  • Members
  • Pip
  • 27 posts
  • Gender:Male

Mavericks supports Haswell just fine. Just not the Haswell Pentium/Celeron chips (keep in mind Apple doesn't use those chips in their computers).

That is a good point. Keeping my hopes up that someones finds a workaround for this issue. Thank again for helping me not spend another week trying to run a Haswell Pentium on Mavericks. :)



#443
RehabMan

RehabMan

    InsanelyMac Legend

  • Coders
  • 1,376 posts
  • Gender:Male
  • Location:Bellingham, WA
  • Interests:skiing, software, classic cars

That is a good point. Keeping my hopes up that someones finds a workaround for this issue. Thank again for helping me not spend another week trying to run a Haswell Pentium on Mavericks. :)


Maybe a patch could be created for the kernel, but it would require:
- someone motivated (eg. person has the hardware, and doesn't want to just swap the CPU for a compatible one)
- someone with the skills (x86 assembly language... a knack for binary patching)
- someone with the time (binary patches to the kernel can be time consuming)

#444
HighMans

HighMans

    InsanelyMac Protégé

  • Members
  • Pip
  • 27 posts
  • Gender:Male

Got it to work on 10.8.5. The only issues are that the ALC1150 Codec from ##### doesn't work with any of my headphone ports and E2205 LAN controller isn't supported. 



#445
Yung Raj

Yung Raj

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 233 posts
  • Gender:Male
  • Location:Houston, Texas

You could attempt using an AMD Kernel which works just as well. I did this temporarily when I moved from my AMD Setup to my new Intel Setup just recently, it works well, and I can also boot with caches..



#446
RehabMan

RehabMan

    InsanelyMac Legend

  • Coders
  • 1,376 posts
  • Gender:Male
  • Location:Bellingham, WA
  • Interests:skiing, software, classic cars

You could attempt using an AMD Kernel which works just as well. I did this temporarily when I moved from my AMD Setup to my new Intel Setup just recently, it works well, and I can also boot with caches..


The problem with any kind of mach_kernel built from sources, including one for AMD is you'll be unable to access Apple services (iCloud, FaceTime, Messages, etc.)


Plus there is no reason to do that if you have a supported Intel CPU.

#447
Yung Raj

Yung Raj

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 233 posts
  • Gender:Male
  • Location:Houston, Texas

Unless you are Bronya and can figure out a barebones patch to the kernel which can be implemented via Clover. He figured out  for Mountain Lion 10.8.5 and got the services working but still in progress :)

I know I'm a bit off topic here but that was just a suggestion if you can't get it working on vanilla kernel to say the least 

 

And plus I'm obviously on an Intel Kernel now hahah



#448
jsl

jsl

    InsanelyMac Sage

  • Members
  • PipPipPipPipPip
  • 310 posts

I wrote this "somewhere else" as well, but I thought this might be interesting here too...

Haswell/Mavericks Troubles

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. 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.

Update 2013-11-25

With some prodding by Pike's blog, I went back to my original patch that I had attempted a number of weeks ago, and I found the mistakes I had made with my patch (this was prior to building the kernel from sources). The details are on my blog here: http://racerrehabman...r-early-reboot/

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.

Update 2013-11-26

It appears that having a jump in pstates from idle to nominal (in this case x8 to x24) is by design. It appears to be intentional. I loaded AppleIntelCPUPowerManagementInfo.kext on my MacBookAir6,2 and it too jumps from idle (x8) to nominal (x17) with no states in between.
 
Update 2013-12-30
 
By borrowing some files from a real Mavericks 10.9.1 install on a real MacBookPro11,2, I was able to achieve states in between idle and nominal:
 
AICPUPMI: CPU P-States [ 8 (17) 24 26 29 30 31 32 33 34 ] GPU P-States [ 17 ]
 
Note new state 17.  This was booting via Clover with MacBookPro11,2 smbios and custom SSDT using ssdtPRgen.sh.
 
In order to do this, I borrowed from the Mac:
/System/Library/CoreServices/PlatformSupport.plist
/System/Library/Extensions/IOPlatformPluginFamily.kext
/mach_kernel (version 13.0.2, patched for xcpm)
 
I'm not sure the kernel replacement was necessary, but I did it anyway.  I think this means that when a future version of OS X arrives that has true support for MacBookPro11,2, things will work a bit better.  I find it interesting that an owner of a a real MacBookPro11,2 cannot do a fresh install of 10.9.1 from the App Store and expect their machine to work as it should.
 
Computer Specifics
HP Envy 15-J063CL (Costco)
i7-4700MQ @2.4Ghz, 12GB RAM
HM87 chipset
HD4600 graphics (1080p panel),
BCM4352 ac WiFi (works with only injection)
RTL8111/8168/8411 (works with RealtekRTL8111)
(I am not certain that I'm keeping this laptop...)

Working:
- power management (see pstate results below)
- booting with caches
- HD4600 graphics (this computer uses eDP) (ig-platform-id=0x0a260006)
- HDMI
- USB3 (before *and* after sleep)
- trackpad/keyboard (Synaptics)
- sleep
- sleep triggered by lid
- shutdown/restart
- backlit keyboard on/off (must be hardwired)
- Camera (kind of grainy, but could be poor lighting)
- display brightness (works after display sleep with PNLF DSDT patch)
- works with patched AppleHDA (volume seems low)

Not Working/Not Started/In progress

Not Tested
- Bluetooth

Notes:
- Fixed USB3 after sleep by switching from native AppleUSBXHCI to GenericUSBXHCI with -gux_defer_usb2 flag.
- To avoid strange flicker/flash of display upon boot, make sure to use "Graphics Mode"=1920x1080x32
 
PStates:
 
iMac14,2 (X86PlatformPlugin)
DPCIManager PStates: 8,24,25,26,27,28,29,30,31,32
 
MacBookPro8,3 (ACPI_SMC_PlatformPlugin)
DPCIManager PStates: 8,12,16,20,24,26,28,30,31,32

MacBookPro11,2 (xcpm, patched mach_kernel)
DPCIManager PStates: 8,24,25,26,27,29,30,32,33
 
MacBookPro11,2 (xcpm, parts borrowed from real MacBookPro11,2 install):
DPCIManager PStates: 8, 17, 24, 25, 26, 28, 29, 30, 31, 32


See my blog for perl patch for mach_kernel.

For ease of use, I'm providing the patches from my blog here. Please note these patches are only for applying to vanilla mach_kernel, not the "xcpm free" kernel for 10.9 provided as the attachment. The two techniques are mutually exclusive. Either you use "xcpm free" and old school PM, or you use patched kernel and new school (xcpm) PM.

For 10.9.x:

perl -pi -e 's|\x74\x6c(\x48\x83\xc7\x28\x90\x8b\x05..\x5e\x00\x85\x47\xdc)\x74\x54(\x8b\x4f\xd8\x45\x85\xc0\x74\x08\x44\x39\xc1\x44\x89\xc1)\x75\x44(\x0f\x32\x89\xc0\x48\xc1\xe2\x20\x48\x09\xc2\x48\x89\x57\xf8\x48\x8b\x47\xe8\x48\x85\xc0\x74\x06\x48\xf7\xd0\x48\x21\xc2\x48\x0b\x57\xf0\x49\x89\xd1\x49\xc1\xe9\x20\x89\xd0\x8b\x4f\xd8\x4c\x89\xca)(\x0f\x30\x8b\x4f\xd8\x0f\x32\x89\xc0\x48\xc1\xe2\x20\x48\x09\xc2\x48\x89\x17\x48\x83\xc7\x30\xff\xce)\x75\x99(\x5d\xc3)\x90{7}|\x74\x73${1}\x74\x5b${2}\x75\x4b${3}\x66\x81\xf9\xe2\x00\x74\x02${4}\x75\x92${5}|g' mach_kernel
For 10.8.5:
perl -pi -e 's|\x74\x69(\x48\x83\xc7\x28\x90\x8b\x05\xfe\xce\x5f\x00\x85\x47\xdc)\x74\x51(\x8b\x4f\xd8\x45\x85\xc0\x74\x05\x44\x39\xc1)\x75\x44(\x0f\x32\x89\xc0\x48\xc1\xe2\x20\x48\x09\xc2\x48\x89\x57\xf8\x48\x8b\x47\xe8\x48\x85\xc0\x74\x06\x48\xf7\xd0\x48\x21\xc2\x48\x0b\x57\xf0\x49\x89\xd1\x49\xc1\xe9\x20\x89\xd0\x8b\x4f\xd8\x4c\x89\xca)(\x0f\x30\x8b\x4f\xd8\x0f\x32\x89\xc0\x48\xc1\xe2\x20\x48\x09\xc2\x48\x89\x17\x48\x83\xc7\x30\xff\xce)\x75\x9c(\x5d\xc3)\x90{7}(\x90{3})|\x74\x70${1}\x74\x58${2}\x75\x4b${3}\x66\x81\xf9\xe2\x00\x74\x02${4}\x75\x95${5}${6}|g' mach_kernel
How to patch your kernel

The vanilla mach_kernel is located on your USB installer after creating your USB (with whatever tool you like :-). Here's how to patch it:





# in Terminal, assuming your USB is called Installer
cp /Volumes/Installer/mach_kernel ~/Desktop/mach_kernel_backup
cp /Volumes/Installer/mach_kernel ~/Desktop/mach_kernel
cd ~/Desktop
# now copy/paste one or more of the perl patches from above into Terminal
perl ...[from above]... mach_kernel
perl ...[from above]... mach_kernel
# patched mach_kernel is now at ~/Desktop/mach_kernel
sudo cp mach_kernel /Volumes/Installer/mach_kernel
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:
# in Terminal from the OS X installer, assuming your HDD volume is called "Macintosh HD"
cp /mach_kernel "/Volumes/Macintosh HD/mach_kernel"
After that, you can exit the installer, and boot into the installed partition to finish installation and reach the desktop.

MD5 sums for mach_kernel

Check your md5 sums with:
md5 mach_kernel
10.9.4 mach_kernel
vanilla: 3d0ad5a7a8ef3b1d4e6ea33e92e4d3b5
xpcm patched: 921c850e3062e750730b0e99f5eaa381

10.9.3 mach_kernel
vanilla: 5ba55b0d446094f82e48e8a413ddfaec
xcpm patched: 6848b1904426d5e270a2db6fada67fb0

10.9.2 mach_kernel
vanilla: 15ce54d9b6edc47e282fdf038f71738c
xcpm patched: aeb9203dc754afac23bf9696833032fe

10.9 mach_kernel
vanilla: 06b687fa00945c97e06ad1919625793c
xcpm patched: 88bf62a7955b9e20cdb19906bdda6b43

10.8.5 mach_kernel
vanilla: e835be83eb956af0b63d28f69bfb22b3
xcpm patched: 539c3a1e2fef063384b44543765b8a39


DSDT Patches:

I have published my DSDT patch project on github. It relies heavily on my generic laptop DSDT patch repo. Read the README.md and setup carefully in order to use.

https://github.com/R...Envy-DSDT-Patch
 
 
10.9 kernel (xcpm free) built from Apple's sources is provided below. Note: DO NOT apply the patches to this attached kernel... they will have no effect. The patches are for vanilla mach_kernel.
 
Update 2014-02-13
Attached mach_kernel built from Apple's sources removed. There is no reason to use it. Use the provided patches to create a mach_kernel that works with machines with locked MSR 0xE2.

 

Does this patch work for 10.9.5 ?



#449
RehabMan

RehabMan

    InsanelyMac Legend

  • Coders
  • 1,376 posts
  • Gender:Male
  • Location:Bellingham, WA
  • Interests:skiing, software, classic cars

Does this patch work for 10.9.5 ?


10.9.5 is not released.

#450
jsl

jsl

    InsanelyMac Sage

  • Members
  • PipPipPipPipPip
  • 310 posts

10.9.5 is not released.

Thanks and this patch seems working for my Asus G750 Laptop with 10.9.5 now.



#451
lazzy

lazzy

    InsanelyMac Protégé

  • Members
  • PipPip
  • 70 posts
  • Location:paris

Hi Jsl

are you using yosemite beta public 2. I try to install 10.10 on my G750js it doesn't work. i create usb boot clover by this topic http://www.insanelym...emite-beta-1-2/  

But i can't boot right now i think I miss some Boot argument 



#452
jsl

jsl

    InsanelyMac Sage

  • Members
  • PipPipPipPipPip
  • 310 posts

Hi Jsl

are you using yosemite beta public 2. I try to install 10.10 on my G750js it doesn't work. i create usb boot clover by this topic http://www.insanelym...emite-beta-1-2/

But i can't boot right now i think I miss some Boot argument 

Use my config.plist please.

Attached Files



#453
lazzy

lazzy

    InsanelyMac Protégé

  • Members
  • PipPip
  • 70 posts
  • Location:paris

Your config doesn't for me. 

Finally i found config works for installer ( dart=0 kext-dev-mode=1 nv_disable=1  )

after install it 's only need dart=0 it works very well (active wifi native)

but hd4600 doesn't work very lag. I flow another topic 

but can you share your dsdt ssdt and all your kext for 10.10

thanks

Attached Files



#454
ip4368

ip4368

    InsanelyMac Protégé

  • Members
  • Pip
  • 1 posts

10.9.5 is not released

10.9.5 is just released a couple hours ago, i update from 10.9 to 10.9.5, after i used your patch, it still goes into early boot, i can't even boot with -x or -f or -s with original kernel/patched kernel, i patch it with the terminal in my installer, but as no one patch the mach_kernel and list the md5, i can't verify mine. Might anyone send me a patched kernel that's works? thanks a lot


Thanks and this patch seems working for my Asus G750 Laptop with 10.9.5 now.

hi jsl, might you send me your 10.9.5 patched kernel? thanks a lot.

 

edit: i found that i cannot successfully patch it, as their md5 is the same. is there any method to patch it on windows? or anyone can help me to patch this? i uploaded the vanilla kernel of 10.9.5, thanks guys.

 

edit2: Thanks to @Onixs for helping me to patch my kernel, it was patched successfully, and i want to provide more info for everyone.

the md5 of vanilla mach_kernel is: 8f9adba4ca2f55907b8ec8d4bbf4c555 and that of patched is 0563c5d1fd99db17198d53ad60c9d9ba

Attached Files



#455
RehabMan

RehabMan

    InsanelyMac Legend

  • Coders
  • 1,376 posts
  • Gender:Male
  • Location:Bellingham, WA
  • Interests:skiing, software, classic cars
Note: Updated post #1 with md5 information for 10.9.5. Seems likely the same patch will continue to work for 10.9.5.





Also tagged with one or more of these keywords: mavericks, kernel, mach_kernel, locked MSR, reboot, power management


2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users

© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy