Contribute
Register

[Guide] Using Clover to "hotpatch" ACPI

the-braveknight

Moderator
Joined
Nov 24, 2015
Messages
1,241
Motherboard
Lenovo Legion Y520 (Clover)
CPU
i7-7700HQ
Graphics
HD 630 (1920x1080) + Nvidia GTX 1060
Mac
MacBook Air
Mobile Phone
iOS
That was my other motivation. Clover Configurator used to just remove these entries. And no matter how many times you state it (bold face, etc), people will still use Clover Configurator when you told them not to.
If only we could create separate plist files for different config.plist sections (only possible with smbios so far)... at least we would make sure config.plist/ACPI section remains untouched when messing up with config.plist...
 
Joined
Oct 5, 2016
Messages
59
Motherboard
Asus Zenbook Pro UX501VW Intel Chipset HM170
CPU
Skylake i7-6700HQ
Graphics
Nvidia GTX 960M - Intel HD Graphics 530
Mobile Phone
iOS
Great guide as always, I need to read it again more carefully to understand all of it. I have only one question for now: Is it possible to use hotpatching for all the patching needed for a laptop? I'll try to explain myself better: Right now I think I employed static patching via MaciAsl for my DSDT and all SSDTs and therefore I use DropOEM=true to let Clover load the files in ACPI/patched folder.
If I want to use only hotpatching and start from the beginning, I would:
1. remove my patched files from ACPI/patched
2. Set DropOEM=false
3. Edit config.plist with appropriate renames and find and replace
4. Put the corresponding SSDTs in the repo in Clover/ACPI/Patched folder
Is this the correct way to go to implement only hotpatching from the beginning? (I don't want to confuse myself with a combination of hotpatching and static patching.)
Thanks in advance Rehabman for the answer!
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
191,716
Motherboard
Intel DH67BL
CPU
Core i7-2600K
Graphics
Intel HD 3000
Mac
MacBook Air
Mobile Phone
iOS
Great guide as always, I need to read it again more carefully to understand all of it. I have only one question for now: Is it possible to use hotpatching for all the patching needed for a laptop?
Yes. I've done it on the ProBook/EliteBook/Zbook, u430, Y50, and HP Envy J/K/Q/N series.

I'll try to explain myself better: Right now I think I employed static patching via MaciAsl for my DSDT and all SSDTs and therefore I use DropOEM=true to let Clover load the files in ACPI/patched folder.
If I want to use only hotpatching and start from the beginning, I would:
1. remove my patched files from ACPI/patched
2. Set DropOEM=false
3. Edit config.plist with appropriate renames and find and replace
4. Put the corresponding SSDTs in the repo in Clover/ACPI/Patched folder
Is this the correct way to go to implement only hotpatching from the beginning? (I don't want to confuse myself with a combination of hotpatching and static patching.)
Thanks in advance Rehabman for the answer!
Yes.
 
Joined
Nov 4, 2016
Messages
12
Motherboard
Dell XPS 9550
CPU
i7-6700HQ
Mobile Phone
iOS
Hi, Rehabman, if you are not busy, please have a look on my problem, I have no idea about my situation. And, I feel sorry about my bad English, I'll try my best.


My laptop is Dell XPS 15 9550 1080P, i7, 8G, 256 NVME(Toshiba).

I know how to apply static patching, after lots of patching, it almost working great, but sometimes it stuck on the apple logo (with progress bar) scene, just the progress increase, but nothing happen, never shows the login window.

I try verbose mode, it shows lots of log, but I can’t get the point.

When it stuck, I shutdown the laptop by hold on power button at 6 secs, and turn it on again, then it maybe get into “normal boot”, after glitch 8 apples logo, it shows the login window, also it maybe stuck again…then I reboot again,until it get into normal boot.

So, when I saw your hot patching tutorial, I want to try this way.

Now, I’m trying to fix the backlight keys, but it’s not working.
I rename the DSDT’s BRT6 method to BRTX(see my config.plist), and I make an add-on “SSDT-BRT6.aml”:
Code:
DefinitionBlock("", "SSDT", 2, "hack", "BRT6", 0)
{ 
    External(_SB.PCI0.LPCB.PS2K, MethodObj)
    External(_SB.PCI0.IGPU, DeviceObj)
    External(_SB.PCI0.IGPU.LCD, DeviceObj)
 
    Scope(_SB.PCI0.IGPU)
    {
        Method (BRT6, 2, NotSerialized)
        {
            If (LEqual (Arg0, One))
            {
                Notify (LCD, 0x86)
                Notify (^^LPCB.PS2K, 0x10)
                Notify (^^LPCB.PS2K, 0x0206)
                Notify (^^LPCB.PS2K, 0x0286)
            }

            If (And (Arg0, 0x02))
            {
                Notify (LCD, 0x87)
                Notify (^^LPCB.PS2K, 0x20)
                Notify (^^LPCB.PS2K, 0x0205)
                Notify (^^LPCB.PS2K, 0x0285)
            }
        }
    }
}
I follow your tutorial to Install the ACPIDebug.kext, and add the debug print code, finally when I press Fn + PrtScr, the LCD brightness up, system.log shows _Q66 is entered, but I can’t find the brightness down button(native button is F11/F12 to down/up), I don’t know how to fix the problem…

By the way, I’m using ApplePS2SmartTouchPad.kext, maybe it’s relate.

uh…in short, talk is cheap, just post the log and files… :)

Please take a glance on my problem, if you are free.
 

Attachments

RehabMan

Moderator
Joined
May 3, 2012
Messages
191,716
Motherboard
Intel DH67BL
CPU
Core i7-2600K
Graphics
Intel HD 3000
Mac
MacBook Air
Mobile Phone
iOS
Hi, Rehabman, if you are not busy, please have a look on my problem, I have no idea about my situation. And, I feel sorry about my bad English, I'll try my best.


My laptop is Dell XPS 15 9550 1080P, i7, 8G, 256 NVME(Toshiba).

I know how to apply static patching, after lots of patching, it almost working great, but sometimes it stuck on the apple logo (with progress bar) scene, just the progress increase, but nothing happen, never shows the login window.

I try verbose mode, it shows lots of log, but I can’t get the point.

When it stuck, I shutdown the laptop by hold on power button at 6 secs, and turn it on again, then it maybe get into “normal boot”, after glitch 8 apples logo, it shows the login window, also it maybe stuck again…then I reboot again,until it get into normal boot.

So, when I saw your hot patching tutorial, I want to try this way.

Now, I’m trying to fix the backlight keys, but it’s not working.
I rename the DSDT’s BRT6 method to BRTX(see my config.plist), and I make an add-on “SSDT-BRT6.aml”:
Code:
DefinitionBlock("", "SSDT", 2, "hack", "BRT6", 0)
{
    External(_SB.PCI0.LPCB.PS2K, MethodObj)
    External(_SB.PCI0.IGPU, DeviceObj)
    External(_SB.PCI0.IGPU.LCD, DeviceObj)
 
    Scope(_SB.PCI0.IGPU)
    {
        Method (BRT6, 2, NotSerialized)
        {
            If (LEqual (Arg0, One))
            {
                Notify (LCD, 0x86)
                Notify (^^LPCB.PS2K, 0x10)
                Notify (^^LPCB.PS2K, 0x0206)
                Notify (^^LPCB.PS2K, 0x0286)
            }

            If (And (Arg0, 0x02))
            {
                Notify (LCD, 0x87)
                Notify (^^LPCB.PS2K, 0x20)
                Notify (^^LPCB.PS2K, 0x0205)
                Notify (^^LPCB.PS2K, 0x0285)
            }
        }
    }
}
I follow your tutorial to Install the ACPIDebug.kext, and add the debug print code, finally when I press Fn + PrtScr, the LCD brightness up, system.log shows _Q66 is entered, but I can’t find the brightness down button(native button is F11/F12 to down/up), I don’t know how to fix the problem…

By the way, I’m using ApplePS2SmartTouchPad.kext, maybe it’s relate.

uh…in short, talk is cheap, just post the log and files… :)

Please take a glance on my problem, if you are free.
No files in ACPI/origin. Impossible to verify your patch for BRT6.
Make sure your _OSI calls are correctly patched.
Use ACPIDebug.kext to debug your DSDT and patches.

Please note that your patchmatic output cannot be disassembled...
Code:
...
ACPI Error: [RMP2] Namespace lookup failure, AE_ALREADY_EXISTS (20160930/dswload-462)
ACPI Exception: AE_ALREADY_EXISTS, During name lookup/catalog (20160930/psobject-310)
Could not parse external ACPI tables, AE_ALREADY_EXISTS
Note: It is because SSDT-LPC.aml is listed twice in SortedOrder. When using hotpatch, you generally do not need SortedOrder.
 
Last edited:
Joined
Nov 4, 2016
Messages
12
Motherboard
Dell XPS 9550
CPU
i7-6700HQ
Mobile Phone
iOS
No files in ACPI/origin. Impossible to verify your patch for BRT6.
Make sure your _OSI calls are correctly patched.
Use ACPIDebug.kext to debug your DSDT and patches.

Please note that your patchmatic output cannot be disassembled...
Code:
...
ACPI Error: [RMP2] Namespace lookup failure, AE_ALREADY_EXISTS (20160930/dswload-462)
ACPI Exception: AE_ALREADY_EXISTS, During name lookup/catalog (20160930/psobject-310)
Could not parse external ACPI tables, AE_ALREADY_EXISTS
Note: It is because SSDT-LPC.aml is listed twice in SortedOrder. When using hotpatch, you generally do not need SortedOrder.
Thank you! I'll remove the SortedOrder node and try again.
The origin folder is uploaded, please take a look.
 

Attachments

RehabMan

Moderator
Joined
May 3, 2012
Messages
191,716
Motherboard
Intel DH67BL
CPU
Core i7-2600K
Graphics
Intel HD 3000
Mac
MacBook Air
Mobile Phone
iOS
Thank you! I'll remove the SortedOrder node and try again.
The origin folder is uploaded, please take a look.
Make sure your patchmatic output disassembles without error (with iasl -da -dl *.aml).
 
Joined
Nov 4, 2016
Messages
12
Motherboard
Dell XPS 9550
CPU
i7-6700HQ
Mobile Phone
iOS
Make sure your patchmatic output disassembles without error (with iasl -da -dl *.aml).
I forgot to add the GPRW method rename patch, that cause disassemble failed again...
And at your post, I found this, is that a typing mistake? <Find> is same as <Replace>.

Code:
My thought is that the beginning of the method body is less likely to be different than the total length of the method, so it helps to add a few extra bytes from the body of the method to the find/replace specification:

Find:      <47 50 52 57 02 70 68>
Replace: <47 50 52 57 02 70 68>
I just test "iasl -da -dl *.aml", now they should disassemble without errors, please see my attachment.
 

Attachments

Joined
Nov 4, 2016
Messages
12
Motherboard
Dell XPS 9550
CPU
i7-6700HQ
Mobile Phone
iOS
After reading your conversation with Wern at post :http://www.insanelymac.com/forum/topic/292800-dsdt-debuggingtracing-to-systemlog/page-2 , I learned how to debug ACPI error via ACPIDebug.kext and RMDT.PX function, that's a good idea to help people locate the problem.

I dig into the _Q66 method, and found it call

Code:
    Method (SMEE, 1, NotSerialized)
    {
        Store (Arg0, Local0)
        \rmdt.p3("SMEE enter. Arg0, Local0", Arg0, Local0) //4, 4
        Store (GENS (0x11, Zero, Zero), Local0)
        \rmdt.p2("OSID: ", \_SBX.OSID)
        If (LGreaterEqual (\_SBX.OSID, 0x20))
        {
            If (And (Local0, 0x04))
            {
                \rmdt.p1("goto EV5 4")
                EV5 (One, Zero)
            }

            If (And (Local0, 0x02))
            {
                \rmdt.p1("goto EV5 2")
                EV5 (0x02, Zero)
            }
        }

        If (And (Local0, 0x08))
        {
            Store (GENS (0x1D, Zero, Zero), Local0)
            \rmdt.p1("goto EV17")
            EV17 (Local0, Zero)
        }
       
        \rmdt.p2("GENS 1D ", GENS (0x1D, Zero, Zero))
        \rmdt.p2("GENS 11 ", GENS (0x1D, Zero, Zero))
        \rmdt.p1("SMEE exit")
    }

then, the definition of EV5 is:

Code:
    Method (EV5, 2, NotSerialized)
    {
        \_SB.PCI0.IGPU.BRT6 (Arg0, Arg1)
    }

But, why does the Console.app just print the log “SMEE enter. Arg0, Local0” and do nothing after that?

I finally found the problem, the next line contains this method “ \_SBX.OSID “ , there is no device names SBX, I realized that something makes side-effect …the _OSI to XOSI patch.


Then I compare to origin DSDT.dsl, the code is:
Code:
If (LGreaterEqual (\_SB.OSID (), 0x20))

OK, I think _SB.OSID will be full named as _SB_.OSID when it compiled as AML, then _OSI rename patch matchs the prefix…

So, I make a rename patch, find OSID replace to OSSD, attempt to avoid the similar name, but I still uncertain about the order of this two patchs…I put the OSID rename patch before the _OSI in config.plist, and then reboot.

Wow, my backlight key has been fixed!

The next step is to solve the random stuck problem, now take a rest...
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
191,716
Motherboard
Intel DH67BL
CPU
Core i7-2600K
Graphics
Intel HD 3000
Mac
MacBook Air
Mobile Phone
iOS
But, why does the Console.app just print the log “SMEE enter. Arg0, Local0” and do nothing after that?

I finally found the problem, the next line contains this method “ \_SBX.OSID “ , there is no device names SBX, I realized that something makes side-effect …the _OSI to XOSI patch.


Then I compare to origin DSDT.dsl, the code is:
Code:
If (LGreaterEqual (\_SB.OSID (), 0x20))

OK, I think _SB.OSID will be full named as _SB_.OSID when it compiled as AML, then _OSI rename patch matchs the prefix…
You can check in your patchmatic output...
A patch to rename OSID to something else might help (OSID -> XSID, for example). Make sure that patch is before the XOSI patch.
 
Top