Jump to content
Welcome to InsanelyMac.com - No more ads! And some exciting news... Read more... ×
miliuco

[GUIDE] Unlocking CFG with OpenCore and CFGLock.efi

2 posts in this topic

Recommended Posts

What is CFG Lock and MSR 0xE2?

 

CFG Lock is a BIOS setting that allows writing to a specific register, in this case MSR E2 (MSR = Model Specific Register). An MSR consists of one or more registers in blocks of instructions used to do certain tasks on a CPU. MTRs are also used to control CPU's access to memory ranges. Commands capable of reading and writing to MSR work with elevated privileges (the operating system, primarily).

Many motherboards come from factory with MSR E2 region locked (read but not write) and quite a few of them even hide this option in BIOS user interface. In those that do show the option to block or unblock this variable, it is usually called CFG Lock. CFG Lock is a bit with 2 values, 0x1 or 0x0. When it is 0x1, macOS cannot write into this region and kernel patches are required.

macOS wants to write this registry, both the Kernel and AppleIntelPowerManagement. It defines the C-states of the CPU, which is why it is essential for macOS. Without the ability to write to MSR E2, all or most of the CPU power management is lost and the system does not boot.

In Clover 2 patches have been used: KernelPM (for AppleIntelPowerManagement.kext) and KernelXCPM (for the kernel). In OpenCore 2 others have been used: AppleCpuPmCfgLock (for AppleIntelPowerManagement.kext) and AppleXcpmCfgLock (for the kernel). These patches fix the problem but the registry is still read-only. To ensure native CPU power management, CFG Lock bit must be set to 0x0.

To achieve this, the firmware must be modified to support writing to MSR E2. This method is preferred over Clover and OC patches, it generates greater system stability and the CPU power management more closely resembles that of a real Mac. The methods that are usually proposed for this task are too complex for most users who do not have a high level of knowledge, requiring specialized tools and even modified Grub.

Below I comment on an alternative method that is much simpler and that, at least in my case, seems to have been successful. Like any of the methods that modify this bit, it has the risk of not working or even damaging the BIOS, so if you try it it is under your entire responsibility.

CFGLock.efi

User @Brumbaer has a tool called CFGLock.efi (see post). It is an EFI application, it has to be installed in OC Tools folder (Misc - Tools in config.plist) and in this way it is available in the OC menu next to Reset NVRAM. It should be accompanied by another tool included in the OC package called VerifyMsrE2.efi that reports current status of CFG Lock (locked / unlocked).

When CFGLock.efi runs, it displays information (CFG variable found, varstore in which it resides, current reading and requests user intervention to make the change from 0x1 to 0x0 or vice versa). Then you have to restart. With VerifyMsrE2.efi we can check if the change has been successful.

Both EFI applications can be run by selecting them directly in the OC menu but it is also possible, by installing OpenShell.efi tool, to run this shell and running them from there. Information for handling OpenShell.efi is available in OC and elsewhere.

 

oc-menu.thumb.png.cb62e720820f5aad2297381290e7e8c7.png

 

After CFGLock.efi


I have tried CFGLock.efi and apparently it has worked well.
 

  1. macOS boots up and works fine with the OC patches AppleCpuPmCfgLock and AppleXcpmCfgLock disabled.
     
  2. VerifyMsrE2.efi reports "This firmware has UNLOCKED MSR 0XE2 register!".
     
  3. Hackintool in Utilities - Get AppleIntelInfo displays this text:
    AppleIntelInfo.kext v3.0 Copyright © 2012-2017 Pike R. Alpha. All rights reserved.
    IA32_MISC_ENABLES................(0x1A0) : 0x850089
    ------------------------------------------
    - CFG Lock............................. : 0 (MSR not locked)
    Note: Hackintool current version (3.4.6) doesn't show text after Get AppleIntelInfo in Big Sur beta 10. It's got from Catalina.
     
  4. Intel Power Gadget - Frequency graph shows variations between maximum and minimum suggestive of CPUPM.

 

cpupm.png.f7f36d99fd17e900e5d73cee2bdcd6cf.png

Edited by miliuco

Share this post


Link to post
Share on other sites

Note: Gigabyte has published (09/16/2020) a new BIOS for my Z390 Aorus Elite board, it is the F10g version and the main novelty, at least in the graphical interface, is the presence of a new option to block or unblock CFG so this task is much easier from now on.

cfg0.jpg.5aca27cb6feb2179f61c0726b63e20f7.jpg

Share this post


Link to post
Share on other sites

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By jrbros1
      Hi there,
       
      So I have my Windows computer, used a USB with Clover setup to boot into Mojave OS that I installed on the SD card in the computer. The world was a great place and all was well!

      Then I did the steps to partition the pc system to now include the additional drive that I would put Clover on. Here's where I messed up: Instead of directly copying over the full Clover folder into the EFI folder of the new drive (which just had the Boot & Microsoft folders in it), I replaced the EFI's boot folder with Clover's boot folder. So the EFI folder now contains a Microsoft folder, a Clover folder, and Clover's Boot folder only.

      Now, I only can access the Clover boot up menu, the macOS, but no Windows at all. Even if I go into BIOS and pick Windows Boot Manager or Partition 1 for the start up, I get a black screen for both. I can still access the macOS as well as Shell, but I don't know what that does other than displaying all of the yellow text fly by..

      Is there a kind soul out there that can help me get Windows back to boot? Keep in mind I'm a bit of a newbie here so laying out the common-sense steps would be helpful!

      Thank you in advance!
    • By pink101
      Hello everyone, i just want to ask something. why is it that my radeon hd 7770 graphic card was detected as "Latte" gpu instead of verde when using radeon_bios_decode? is the card actually a Latte graphic card but someone flashed it so they can sold to me as radeon hd 7770? or is it actually a real radeon hd 7770 but the tool falsely detected it as latte cpu?

    • By dzontra
      Hi guys,
       
      I'm having a  problem with BIOS. I hope someone can help me to fix it.
      I was able to boot to Wins or Catalina with no issues with OC. When I tried to go to BIOS i got a black screen with white cursor, nothing else (you can see it on the video). I can move cursor until i click right/left button, it freeze.
      After reboot i would boot to Wins/Catalina, no issue. My first guess was to reset CMOS by removing a battery. So i did it. And that was bad idea. After that i wasn't able to boot to any OS. I get that black screen because CMOS got reset. Probably there should be a screen with option to set time, date, etc, before you boot to OS. But, I dont see it. I tried to reset CMOS several times, removing the battery ot using a jumper. Nothing helped. I get the same result. I've noticed that resolution is much lower on my 27" screen (2K). Cursor can move to half of the screen, horizontally and vertically. So I started troubleshoot with other components.
      1. I tried every RAM stick on each slot, same result. RAM works on another PC.
      2. I tried to remove GPU and use iGPU (HDMI and DVI), same result.
      3. I tried DP, HDMI, VGA  with GPU, same result. (GPU works fine on another PC)
      4. I tried to unplug everything, USB 2, USB 3, SSD's, same result. 
       
      The only thing i haven't tried yet is another power supply, just because i dont have one to test it.
      Not sure what was the trigger because so far i was able to get to BIOS with no issue. The only thing that it comes to my mind is that a week ago I came across a software, Gigabyte EasyTune and I played with it. Ususallu, if I want to OC my CPU I do it from BIOS, never used any software. EasyTune did work and OC'ed my CPU and i rebooted my PC many times since then but i never tried to access BIOS until yesterday.
       
      I hope you someone can give some tips of how to fix it. Not sure if BIOS got corrupted because of the software or not.
       
      Tnx
      Video.mov
    • By blackosx
      Do you want to quickly find your boot log, or ever wanted to know which version of bootloader is installed on your disk(s), had the need to dump your BIOS from OS X, just curious about your own system setup or been asked to provide your setup information to others when asking for assistance?
       
      DarwinDumper is a useful collection of readily available tools, and scripts wrapped in an application framework giving you a convenient method to quickly gather a system overview of your hack or Mac. And rest assured that enabling the privacy option will mask sensitive data like the IOPlatformSerialNumber, IOPlatformUUID, IOMACAddress(s), USB Serial Number(s), SystemSerialNumber, serial-number, fmm-mobileme-token-FMM, MLB and ROM efi vars and CustomUUID in the dumped files and report.

      Current Release Version: 3.1.1



      The system dumps are saved to a folder or your choice, but defaulting to the same directory as the main application. You can choose to setup a symlink to make it simple to run DarwinDumper from the Terminal.
       
      There is an option to create an html report showing a complete overview of the dumps. This report will mostly just contain the text dumps as you'll find in the main dump directory, but for some dumps there is extra processing to try to present the information in a better way. For example, the Disk Partitions and Unique ID's dump will show a visual map of the disk layout, and the DMI Tables (SMBIOS) dump will show the data split by table type.
       

       
      Note: The html report does not contain all files from a complete dump so if seeking assistance for a problem and you wish to send someone a DarwinDump then you will want to send the complete dump directory and not just the .html report file.
       
      The following can be read and dumped by DarwinDumper:
      - ACPI tables.
      - Audio codec and further info.
      - Boot loaders and configuration files.
      - CPU info.
      - Device-properties.
      - Disk partition structure / info.
      - Disk sectors (hex).
      - DMI (SMBIOS).
      - EDID.
      - I/O Kit Registry.
      - EFI Memory Map.
      - EFI vars (some).
      - Kernel information
      - Kexts - (list of currently loaded kexts).
      - Memory.
      - NVRAM (both Apple specific and UEFI firmware variables).
      - SMC Keys.
      - LSPCI (PCI vendor & device codes) dumps.
      - Power (Sleep/Hibernate) settings.
      - RTC.
      - System Profiler.
      - System BIOS.
      - System Log(s).
      - Video BIOS.
       
      License:
      DarwinDumper is licensed under GNU General Public License, version 3.0 (GPLv3).
       
      Tools included:
      AnalyseVBIOS
      Copyright: Not Known. License: Not known Source: http://www.insanelymac.com/forum/topic/211294-information-on-vesa-modes-in-atinvidia-bios/ Alt Link: https://www.dropbox.com/s/dnp903x2z9pqf8k/AnalyseVBIOS.zip?dl=0   AppleIntelInfo Copyright: © 2012-2017 Pike R. Alpha. All rights reserved. License: Creative Commons Attribution-NonCommercial Source: https://github.com/Piker-Alpha/AppleIntelInfo   atomdis Copyright: Michael Larabel @ Phoronix.com License: GPL Version 2 Source: http://www.phoronix.com/scan.php?page=article&item=amd_atombios_dumper   bgrep Copyright 2009 Felix Domke <[email protected]>. All rights reserved.   Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:      1. Redistributions of source code must retain the above copyright notice, this list of       conditions and the following disclaimer.      2. Redistributions in binary form must reproduce the above copyright notice, this list       of conditions and the following disclaimer in the documentation and/or other materials       provided with the distribution.   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.   The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of the copyright holder.   Source: https://github.com/tmbinc/bgrep   bdmesg Copyright 2010 by Islam M. Ahmed Zaid. All rights reserved. License: GPL Version 2 Source: http://forge.voodooprojects.org/p/chameleon/source/tree/HEAD/trunk/i386/util/bdmesg.c Alt Link: https://sourceforge.net/p/cloverefiboot/code/1905/tree/CloverPackage/utils/bdmesg/bdmesg.c   cmosDumperForOsx Created by rafirafi, revised extensively by STLVNUB License: Information not available Source: https://www.dropbox.com/s/bg1q0yho6g7u3xn/cmosDumperForOsxV0.1.zip?dl=0   csrstat Created by Piker-Alpha Copyright: © 2015-2017) by Pike R. Alpha License: Information not available Source: https://github.com/Piker-Alpha/csrstat   dmidecode Original nongnu.org
      License: GPL Version 2
      Now updated and hosted by acidanthera Source: https://github.com/acidanthera/dmidecode   dumpACPI Created by blackosx. Idea taken from PHPdev32's MacIASL. Source: https://bitbucket.org/blackosx/dumpacpi   edid-decode Created by Adam Jackson, revised by Andy Vandijck License: Information not available Original Source: http://cgit.freedesktop.org/xorg/app/edid-decode Revised Source: https://www.dropbox.com/s/l0htffnqzs9e1vg/edid-decode.zip?dl=0   fdisk440 Apple Computer, Inc. License: APSL v2.0 Original Source: http://www.opensource.apple.com/source/diskdev_cmds/diskdev_cmds-491/fdisk.tproj/mbr.h Modified by Zef Source: http://forge.voodooprojects.org/p/chameleonApplications/source/tree/HEAD/trunk/fdisk.tproj Alternate Link: https://www.dropbox.com/s/odl9kp38j3flla5/fdisk440.zip?dl=0   FirmwareMemoryMap script Amit Singh (showbootermemorymap) Further development by bcc9 and dmazar License: Information not available   flashrom http://flashrom.org/Flashrom License: GPL Version 2 Source: https://www.dropbox.com/s/gfmqx2t7lvofs1v/flashrom.zip?dl=0   getcodecid Copyright © 2012 AnV Software. All rights reserved. License: Information not available Source: https://github.com/Gengik84/getcodecid   getdump Created by fassl?, modifications by Slice and AutumnRain? License: Information not available Source: https://sourceforge.net/projects/voodoohda/files/   gfxutil Copyright 2008 mcmatrix. All rights reserved. License: Information not available Historic detail can be found at forum.netkas.org Source: https://github.com/acidanthera/gfxutil   iasl Copyright © 2000 – 2014 Intel Corporation. License: Information not available Source for v20200110: https://www.acpica.org/node/176   ioregwv Apple Computer, Inc. License: APSL v2.0 Original Source: https://opensource.apple.com/source/IOKitTools/IOKitTools-86/ Modified by blackosx Source: https://bitbucket.org/blackosx/ioregwv   lzma Copyright © 2013 Igor Pavlov. License: GNU Lesser General Public License Source: http://www.7-zip.org/sdk.html This build by Slice at insanelymac.com: https://www.insanelymac.com/forum/topic/311786-updated-lzma-utility-v1514/   lzvn Copyright: © 2014 Apple Computer, Inc. All rights reserved. License: APSL Credit: Piker-Alpha, Andy Vandijck, MinusZwei. https://github.com/Piker-Alpha/LZVN   MacGap2 Created by Tim Debo. All rights reserved. License: MIT Source: https://github.com/MacGapProject/MacGap2   Macpmem driver (Macpmem.kext) Copyright © 2007-2011 Volatile Systems. Copyright 2013-2014 Google Inc. All Rights Reserved. License: GPL Version 2 Source Code: https://github.com/google/rekall/tree/master/tools/osx/MacPmem]https://github.com/google/rekall/tree/master/tools/osx/MacPmem   nvram Apple Computer, Inc. License: APSL v2.0 Modified by blackosx Source: https://bitbucket.org/blackosx/nvram   oclinfo Copyright © 2009 cmf License: GPL Version 2 Source: http://www.insanelymac.com/forum/topic/170796-opencl-info/   pciutils driver (DirectHW.kext) DirectHW is Copyright © 2008-2010 coresystems GmbH License: GPL Version 2 Source: https://github.com/CloverHackyColor/directhw Kext: Pre-built (Signed) Kext   pciutils lspci Copyright © 1997--2008 Martin Mares License: GPL Version 2 Source Code: https://git.kernel.org/pub/scm/utils/pciutils/pciutils.git
      RadeonDump Created by Dong Luo. Copyright 2008. All rights reserved. Modified by Andy Vandijck License: Information not available Source: http://www.insanelymac.com/forum/topic/282794-darwindumper/page__st__120?do=findComment&comment=1920068 Alt Link: https://www.dropbox.com/s/5drpckxlmaot732/RadeonPCI.zip?dl=0   radeon_bios_decode Created by Dong Luo. Copyright 2008. All rights reserved. License: Information not available Source: http://www.insanelymac.com/forum/topic/282794-darwindumper/page__st__120?do=findComment&comment=1920068   SMC_util_FansOnly Copyright © 2006 devnull  License: GPL Version 2 Source: https://www.dropbox.com/s/ra9h6gbjj6yhgol/SMC_util_FansOnly.zip?dl=0   smcutil Copyright © 2006 devnull  License: GPL Version 2 Source: https://www.dropbox.com/s/0dgvexijx4oewfr/smcutil.zip?dl=0   VoodooHDA.kext Created by fassl?, modifications by Slice and AutumnRain? License: https://sourceforge.net/p/voodoohda/code/HEAD/tree/tranc/License.h]https://sourceforge.net/p/voodoohda/code/HEAD/tree/tranc/License.h Source: https://sourceforge.net/p/voodoohda/code/HEAD/tree/]https://sourceforge.net/p/voodoohda/code/HEAD/tree/   x86info Written to succeed CPUID by Phil Karn (KA9Q). Contributed to by various people. OS X compatability by Slice License: GPL Version 2 Original Source: https://github.com/kernelslacker/x86info Revised Source: https://github.com/CloverHackyColor/x86info  
       
      Running DarwinDumper from the command line:
      From Terminal, you can initiate DarwinDumper by running the following script directly.
      /DarwinDumper.app/Contents/Resources/public/bash/script.sh To help with this, the UI has a Symlink option which you can click to create a symbolic link which points to the above script. DarwinDumper can then be subsequently run from the command-line by loading a new Terminal window and typing darwindumper followed by return.
      $ darwindumper usage: [-a zip,lzma,none] [-d acpi,appleintelinfo,audio,biosSystem,biosVideo,codecid,cpuinfo,devprop,diskLoaderConfigs,bootLoaderBootSectors,diskPartitionInfo,dmi,edid,bootlogF,bootlogK,firmmemmap,memory,ioreg,kernelinfo,kexts,lspci,rcscripts,nvram,opencl,power,rtc,sip,smc,sysprof] [-h] [-l] [-o html,private] [-p 1,2,3,4,5,6,7,8] [-v] Example:
      $ darwindumper -l Will re-run the last dump used options.

      Credits (in alphabetical order):
      acidanthera team, Adam Jackson, Amit Singh, Andy Vandijck, Apple Inc., arsradu, bcc9, blackosx, cmf, DieBuche, dmazar, Dong Luo, droplets, ErmaC, Felix Domke, Google Inc., Intel Corporation, InsanelyDeepak, JrCs, Kabyl, Kynnder, Martin Mareš, mcmatrix, Michael Larabel, Mickey1979, phcoder, Phil Karn, Piker-Alpha, rafirafi, гык-sse2, Slice ,sonotone, STLVNUB, THe KiNG, Trauma, Volatile Systems, xsmile, !Xabbu.
       
      DarwinDumper was originally inspired as an open project by Trauma, it has remained an open project and please keep it an open project, so if you make any changes or additions to it then please share your work here.
       
      Please report any feedback, requests or bugs.
       
      Known issues: v3.1.0
      1 - When SIP File Protection is enabled, dumping disk partition info of non-APFS containers and disks which are not APFS physical stores may fail when running from DarwinDumper via the graphical interface. However, it's been known to succeed when using DarwinDumper from the command line. Something to do with osascript.
      2 - lzma archive option has been known to fail on macOS 10.15 when running dumps requiring root privileges.
       
      macOS Version support:
      - v2.9.9.2 is for older macOS versions
      - v3.0.4 requires OS X 10.9 and newer to run in the Finder, though it should work from the command line okay on older OS versions.
      - v3.1.0 was updated for newer macOS versions and has been tested on 10.13 and 10.15.

      DarwinDumper Download
    • By Majed DH
      Hi everyone. 
      I have HP 15-da0xxx series laptop. i got macos mojave installed on it. but I was trying to get my intel graphics working but i couldn't change dmvt preallocation. 
      So I updated the bios (unfortunately). And since then i could not boot any version of clover. 
      I tried two versions that were working and even an installer that worked before is not working:
       
      I searched alot about the error and found nothing relared to macos or hackintosh..  would it be solved by patching the dsdt? 

      Any suggestions people ? 
×