Contribute
Register

[Guide] Using Clover to "hotpatch" ACPI

RehabMan

Moderator
Joined
May 2, 2012
Messages
183,805
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
wanna trick us to clear the cache aye? Nope, never!

Huh?
kextcache output shows the unsigned/patched kexts you have installed (and whether they are installed correctly).
It is an important diagnosis tool.
Hint: You should have already done it before asking for help.

Note: This guide is for advanced users that know what they are doing.
 
Joined
May 24, 2015
Messages
166
Motherboard
ThinkPad X1c 2015
Mac
Classic Mac
Mobile Phone
People working on hotpatching may find my utilities useful. https://github.com/gfoury/clover-config-plist-tools

check-dsdt-patches.py checks how many times a patch applies (zero is bad). It also can produce the results of hot-patching DSDT.aml, so you can examine them in iASL or in a hex editor. Run this to just check the current DSDT and config.plist:

Code:
$ check-dsdt-patches.py DSDT.aml

check-kext-patches.py does the same thing, except checking Clover config.plist kext patches against the current /System/Library and /Library. (This is a little tricky because of plugins.)

makebinpatch.py generates patch stanzas.
Code:
$ makebinpatch.py 'ABC\x00' '\x80EF\xFf' 'change ABC to EF'
               <dict>
                   <key>Comment</key>
                   <string>Change ABC to EF</string>
                   <key>Find</key>
                   <data>
                   QUJDAA==
                   </data>
                   <key>Replace</key>
                   <data>
                   gEVG/w==
                   </data>
               </dict>
$

diffplist.py compares two plist files. Normally, you'd use the -n flag to normalize them; this sorts their keys before comparing.
Code:
$ diffplist -n -U10 config1.plist config2.plist

Finally, catplist.py does what it sounds like: read a plist, and write it out in normal, indented form. It can also sort dictionary keys for fully normalized mode.

Just for RehabMan, these utilities have a "short data" mode, where elements are placed on the same line:

Code:
                   <key>Find</key>
                   <data>QUJDAA==</data>
 

RehabMan

Moderator
Joined
May 2, 2012
Messages
183,805
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
People working on hotpatching may find my utilities useful. https://github.com/gfoury/clover-config-plist-tools

check-dsdt-patches.py checks how many times a patch applies (zero is bad). It also can produce the results of hot-patching DSDT.aml, so you can examine them in iASL or in a hex editor. Run this to just check the current DSDT and config.plist:

Code:
$ check-dsdt-patches.py DSDT.aml

I have a similar script I use myself, although it actually applies all config.plist/DSDT/ACPI/Patches to an entire set of DSDT.aml+SSDT*.aml (intended to be used on ACPI/origin). That way you can disassemble the result (iasl -da -dl DSDT.aml SSDT*.aml) to verify the result of the hotpatch disassembles cleanly (no duplicates).

Note that zero patch matches are sometimes expected (config.plist files that are used on multiple models, such as my Probook github).

check-kext-patches.py does the same thing, except checking Clover config.plist kext patches against the current /System/Library and /Library. (This is a little tricky because of plugins.)

Does it deal with MatchOS?

Just for RehabMan, these utilities have a "short data" mode, where elements are placed on the same line:

Code:
                   <key>Find</key>
                   <data>QUJDAA==</data>

For Xcode users really... compatible with how Xcode writes plists.
 
Joined
May 24, 2015
Messages
166
Motherboard
ThinkPad X1c 2015
Mac
Classic Mac
Mobile Phone
I have a similar script I use myself, although it actually applies all config.plist/DSDT/ACPI/Patches to an entire set of DSDT.aml+SSDT*.aml (intended to be used on ACPI/origin). That way you can disassemble the result (iasl -da -dl DSDT.aml SSDT*.aml) to verify the result of the hotpatch disassembles cleanly (no duplicates).
Yeah, you can specify multiple .aml files to check-dsdt-patches.py, and it dumps them all separately to a destination directory if the directory is given.

Note that zero patch matches are sometimes expected (config.plist files that are used on multiple models, such as my Probook github).

Agreed. I still think people who are building config.plists for multiple machines are probably focusing on one machine at a time; I was. So I included Expect:1 clauses in that process. If I had another ASUS UX30xXX machine around, I'd probably comment out the Expects for a universal patch.

Does it deal with MatchOS?

...no...after its time. Will fix.

For Xcode users really... compatible with how Xcode writes plists.

Grr. I mean, I think it's superior, but it's not the canonical form as spit out by plutil -convert xml1 -o - config.plist. Sometimes the documentation is stricter, such as the Configurator certificate payload:
Code:
PayloadContent:  Data
Mandatory. The base64 representation of the payload with a line length of 52.

I haven't checked if mobileconfig clients accept the Xcode style.
 

RehabMan

Moderator
Joined
May 2, 2012
Messages
183,805
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
I haven't checked if mobileconfig clients accept the Xcode style.

Any decent XML parser should ignore whitespace outside tags.
 
Joined
Jun 5, 2017
Messages
102
Motherboard
Asus Notebook Y583LD(Clover EFI)
CPU
i3-4030U/HM86
Graphics
HD4400,1366x768
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
Introduction

Patching ACPI is always necessary to enable (near) full functionality when installing OS X on non-Apple hardware.

There is a complete guide here: http://www.tonymacx86.com/threads/guide-patching-laptop-dsdt-ssdts.152573/

[/ QUOTE]
Excuse me if you might not recommend fixing SSDTs? Keep DropOEM = False, so how to balance rename? Add a custom configuration set SSDT file to match DSDT? If you use DropOEM = ture, SSDT-Plugintype1 when using SSDT-CpuPM and SSDT-Cpu0Ist lost is not included in CLOVER \ ACPI \ patched? To keep the original loading order to place SSDT-Plugintype1.aml in that position? If it is the use of ssdtPRGen.sh generated SSDT.aml where the loading position and where is correct?
Patchmatic validation repair can be properly dismantled, compiled. Can go to the clover boot -V mode can see the error!

Please help me look at how to repair Thank you
 

Attachments

  • CLOVER.zip
    1.3 MB · Views: 72
  • MacBook Air.ioreg
    6.3 MB · Views: 97
  • extract.zip
    48.5 KB · Views: 69
  • reboot.jpg
    reboot.jpg
    266.9 KB · Views: 120
  • system.log.zip
    86.2 KB · Views: 68
Joined
Jun 5, 2017
Messages
102
Motherboard
Asus Notebook Y583LD(Clover EFI)
CPU
i3-4030U/HM86
Graphics
HD4400,1366x768
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
If DropOEM = true, load CLOVER \ ACPI's AML. If you discard only CpuPM, Cpu0lst, custom *.aml, and what is the difference between loading sequence and priority execution?
patchmatic -extract There is no error in extracting the compilation validation

localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> Method parse/execution failed
2017-08-28 10:06:07.203704+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> Method parse/execution failed
2017-08-28 10:06:07.203706+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> [\_SB_.PCI0.BAT0._BIF] (Node ffffff801685ef90)
2017-08-28 10:06:07.203707+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> [\_SB_.PCI0.BAT0._BIF] (Node ffffff801685ef90)
2017-08-28 10:06:07.203718+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> , AE_BAD_PARAMETER
2017-08-28 10:06:07.203718+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> , AE_BAD_PARAMETER
2017-08-28 10:06:07.203720+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> (20140828/psparse-270)
2017-08-28 10:06:07.203721+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> (20140828/psparse-270)
2017-08-28 10:06:07.203724+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> ACPI Error:
2017-08-28 10:06:07.203725+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> ACPI Error:
2017-08-28 10:06:07.203726+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> Method parse/execution failed
2017-08-28 10:06:07.203727+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> Method parse/execution failed
2017-08-28 10:06:07.203729+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> [\_SB_.PCI0.BAT0._BIX] (Node ffffff801685f750)
2017-08-28 10:06:07.203731+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> [\_SB_.PCI0.BAT0._BIX] (Node ffffff801685f750)
2017-08-28 10:06:07.203732+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> , AE_BAD_PARAMETER
2017-08-28 10:06:07.203733+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> , AE_BAD_PARAMETER
2017-08-28 10:06:07.203735+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> (20140828/psparse-270)
2017-08-28 10:06:07.203736+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> (20140828/psparse-270)
2017-08-28 10:06:08.207029+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> ACPI Exception: AE_BAD_PARAMETER,
2017-08-28 10:06:08.207032+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> ACPI Exception: AE_BAD_PARAMETER,
2017-08-28 10:06:08.207035+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> Returned by Handler for [EmbeddedControl]
2017-08-28 10:06:08.207037+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> Returned by Handler for [EmbeddedControl]
2017-08-28 10:06:08.207041+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> (20140828/evregion-170)
2017-08-28 10:06:08.207042+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> (20140828/evregion-170)
2017-08-28 10:06:08.207047+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> ACPI Error:
2017-08-28 10:06:08.207048+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> ACPI Error:
2017-08-28 10:06:08.207052+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> Method parse/execution failed
2017-08-28 10:06:08.207054+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> Method parse/execution failed
2017-08-28 10:06:08.207057+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> [\_SB_.PCI0.LPCB.EC__.SMBR] (Node ffffff8016866b50)
2017-08-28 10:06:08.207060+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> [\_SB_.PCI0.LPCB.EC__.SMBR] (Node ffffff8016866b50)
2017-08-28 10:06:08.207062+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> , AE_BAD_PARAMETER
2017-08-28 10:06:08.207064+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> , AE_BAD_PARAMETER
2017-08-28 10:06:08.207066+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> (20140828/psparse-270)
2017-08-28 10:06:08.207068+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> (20140828/psparse-270)
2017-08-28 10:06:08.207076+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> ACPI Error:
2017-08-28 10:06:08.207078+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> ACPI Error:
2017-08-28 10:06:08.207080+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> Method parse/execution failed
2017-08-28 10:06:08.207082+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> Method parse/execution failed
2017-08-28 10:06:08.207086+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> [\_SB_.PCI0.LPCB.EC__.BIF9] (Node ffffff801685f850)
2017-08-28 10:06:08.207088+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> [\_SB_.PCI0.LPCB.EC__.BIF9] (Node ffffff801685f850)
2017-08-28 10:06:08.207090+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> , AE_BAD_PARAMETER
2017-08-28 10:06:08.207091+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> , AE_BAD_PARAMETER
2017-08-28 10:06:08.207094+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> (20140828/psparse-270)
2017-08-28 10:06:08.207096+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> (20140828/psparse-270)
2017-08-28 10:06:08.207101+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> ACPI Error:
2017-08-28 10:06:08.207102+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> ACPI Error:
2017-08-28 10:06:08.207105+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> Method parse/execution failed
2017-08-28 10:06:08.207106+0800 localhost kernel[0]: (AppleACPIPlatform) <AppleACPIPlatform`AcpiOsVprintf> Method parse/execution failed
 

RehabMan

Moderator
Joined
May 2, 2012
Messages
183,805
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
If DropOEM = true, load CLOVER \ ACPI's AML. If you discard only CpuPM, Cpu0lst, custom *.aml, and what is the difference between loading sequence and priority execution?
patchmatic -extract There is no error in extracting the compilation validation

For the hardware in your profile you should not drop any SSDTs, CPU related or otherwise.
If you use DropOem=true (because you need to patch SSDTs statically), you should include all of them in ACPI/patched.

Of course, this guide is the hotpatch guide, so really your question is off-topic. With hotpatch, we patch everything with config.plist, therefore there are no SSDTs in ACPI/patched (and no DSDT.aml either), therefore DropOem is always false for hotpatch scenarios.
 
Joined
Dec 10, 2016
Messages
145
Motherboard
Dell Inspiron 7559-1.0.1-Clover
CPU
i5-6300HQ
Graphics
HD 530 GTX 960M,1920x1080
Mac
  1. MacBook Pro
Mobile Phone
  1. iOS
Tips for complex Rename and Replace
General procedure:
- start with native ACPI
....

- for the EC fields, create another EC OperationRegion (use a name that is different from the original) and Field definition as a sort of "overlay" which contains only the EC fields you need to patch
- to create the EC overlay, you can use the patched Field/OperationRegion in the patched DSDT, then eliminate unpatched fields
- use External to allow the replacement methods in the SSDT to access the fields defined elsewhere in the ACPI set (usually DSDT)
- let the compiler point out where you need to use External
- watch out for symbols with duplicate names in different scopes

Let's look at an example.... <todo: left off here: later, use u430 example>
Hi,I try to patch battery "hotpatch" into the ssdt-battery.dsl,I find out the EC fields and patched them.but stop when doing "create the EC overlay/use External to allow the replacement methods in the SSDT".if I paste relate method into dsl file, MACiASL show "syntax error, unexpected PARSEOP_METHOD, expecting $end and premature End-Of-File."unexpected PARSEOP_METHOD mate cause by missing relate External,but I can't find out what cause expecting $end and premature End-Of-File.this patch for Laptop: Dell 7559 i5.
 

Attachments

  • origin.zip
    56 KB · Views: 71
  • relate_methon.zip
    1.8 KB · Views: 59
  • ssdt-battery.dsl.zip
    2.1 KB · Views: 74
  • patched_DSDT.aml
    102.6 KB · Views: 68
Top