Qonfused / ASUS-ZenBook-Duo-14-UX481-Hackintosh

OpenCore configuration for the ASUS ZenBook Duo 14" (UX481FA/FL)
https://github.com/Qonfused/ASUS-ZenBook-Duo-14-UX481-Hackintosh
BSD 3-Clause "New" or "Revised" License
31 stars 1 forks source link

[BIOS/UEFI] Disable CFGLock with `ControlMsrE2.efi` tool #44

Closed Qonfused closed 1 year ago

Qonfused commented 1 year ago

A good breakdown of how this driver works is explained in an InsanelyMac Forum post by @miliuco; the driver scans the BIOS's HiiDatabase for CFG Lock registers, and can set their bits to 0x00 to unlock them.

This is primarily needed for power management (required by the kernel and AppleCPUPowerManagement) as it's needed to define the CPU's C-states or idle states.

Requires:

Disable:

Qonfused commented 1 year ago

RU.efi alternative: https://github.com/dreamwhite/bios-extraction-guide/blob/master/ru.efi.md

Qonfused commented 1 year ago

Requires testing on UX581/UX582 firmwares.

shiecldk commented 1 month ago

@Qonfused I can test this. How is this different from using modGRUBShell.efi to modify the hidden BIOS settings for CFGLock or using the AppleCpuPmCfgLock and AppleXcpmCfgLock under Kernel -> Quirks in OpenCore config.plist?

Qonfused commented 1 month ago

There's two different approaches here, though in short it isn't functionally different from the modGRUBShell.efi approach but is significantly easier for the end-user.

For proper CPU power management, macOS needs to be able to write the E2 MSR (PKG_CST_CONFIG_CONTROL) to define the C-states (or power-saving states) of the CPU. Otherwise this will cause a kernel panic since XNU expects to be able to write there. By default, ASUS locks writes to the whole MSR E2 region, though this can be unlocked with CFG Lock in the BIOS (or using modGRUBShell.efi / ControlMsrE2.efi).

The alternative approach is to forfeit power management and patch out XNU's writes to this MSR region with AppleCpuPmCfgLock and AppleXcpmCfgLock. It's best used as a last-resort for when no CFG Lock setting is provided in firmware since it otherwise needlessly borks native power management. You can also no longer do this on macOS 13+ as the CPU PM kext was dropped (unless you load and patch a legacy version).

shiecldk commented 1 month ago

I see. So the best option would be using ControlMsrE2.efi and CFGLock.efi? I see the insanelymac post says that they are already included in OpenCore?

Qonfused commented 1 month ago

ControlMsrE2 is what it's named in the OpenCore release package. They're the easiest (automated) approach, though the fallback would still be to use the GRUB shell. If compatible, it should be the preferred approach.