acidanthera / bugtracker

Acidanthera Bugtracker
383 stars 44 forks source link

[WhateverGreen] Backlight Registers Alternative Fix (BLT) not working on CFL since macOS 13.5.x and 13.6 #2333

Closed lrlopez closed 1 year ago

lrlopez commented 1 year ago

On WhateverGreen 1.6.5, @0xFireWolf introduced a new submodule called Backlight Registers Alternative Fix (BLT) which reverted some inline compiler optimizations introduced by macOS 13.4 in backlight related functions on CFL platforms. Version 1.6.6, extended the fix to KBL too.

In some minor macOS update 13.5.x the reversion mechanism stopped to work in my CFL system. The problem still appears on macOS 13.6. So, since then, screen gets black for 3 minutes when macOS boots up.

(Sometimes, it works after a reboot but not always.)

I'm dumping here the relevant debug messages: (if you need other messages, just ask for them)

BLT: [COMM] Will set up the fix for the CFL platform.
BLT: [CFL ] Analyzing the function at 0xffffff7f9d1d5f04 to probe the offset of each required member field.
BLT: [CFL ] Found the instruction movl: Register %r14 now stores the new brightness level.
BLT: [CFL ] Found the instruction movq: Register %rbx now stores the controller instance.
BLT: [CFL ] Found the instruction divl: The frequency divider is stored at offset 0x2d00.
BLT: [CFL ] Found the instruction movl: The brightness level is stored at offset 0x2d00.
BLT: [CFL ] Analyzing AppleIntelFramebufferController:LightUpEDP() at 0xffffff7f9d1e0f10 to identify the position of the inlined invocation of hwSetBacklight().

Now is when things go wrong: this code fragment fails as steps 1 and 3 are not triggered by the code parser. Due to this, an incomplete context (misses both "start" and "end" addresses) is returned that breaks the patching process.

BLT: [COMM] Error: Unable to find the position of the inlined invocation of hwSetBacklight() in AppleIntelFramebufferController:LightUpEDP().

And then the black screen stays for around 3 minutes.

I would decompile the AppleIntelFramebufferController:LightUpEDP() function myself , but I don't have enough macOS dev background nor tools to do it, sorry.

If I can be of any further help, please just say it.

Thanks in advance for your time!

0xFireWolf commented 1 year ago

In the PR that introduces this new fix, I mentioned that macOS 13.5 was not affected by the optimization. I just upgraded to macOS 13.6 and could confirm that the new release was not affected neither. So, you can enable both BLR and BLT to satisfy your needs.

lrlopez commented 1 year ago

Thanks! Reverting to BLR worked flawlessly. It may be a good idea to state that information in the docs. I'm closing the issue.