Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion WhateverGreen/kern_rad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ static const char *pathRadeonX4200[] { "/System/Library/Extensions/AMDRad
static const char *pathRadeonX4250[] { "/System/Library/Extensions/AMDRadeonX4250.kext/Contents/MacOS/AMDRadeonX4250" };
static const char *pathRadeonX5000[] { "/System/Library/Extensions/AMDRadeonX5000.kext/Contents/MacOS/AMDRadeonX5000" };
static const char *pathRadeonX6000[] { "/System/Library/Extensions/AMDRadeonX6000.kext/Contents/MacOS/AMDRadeonX6000" };
static const char *pathAMDRadeonServiceManager[] { "/System/Library/Extensions/AMDRadeonServiceManager.kext/Contents/MacOS/AMDRadeonServiceManager" };
static const char *patchPolarisController[] { "/System/Library/Extensions/AMD9500Controller.kext/Contents/MacOS/AMD9500Controller" };

static const char *idRadeonX3000New {"com.apple.kext.AMDRadeonX3000"};
Expand All @@ -51,6 +52,8 @@ static KernelPatcher::KextInfo kextRadeonLegacySupport
{ "com.apple.kext.AMDLegacySupport", pathLegacySupport, 1, {}, {}, KernelPatcher::KextInfo::Unloaded };
static KernelPatcher::KextInfo kextPolarisController
{ "com.apple.kext.AMD9500Controller", patchPolarisController, 1, {}, {}, KernelPatcher::KextInfo::Unloaded };
static KernelPatcher::KextInfo kextRadeonServiceManager
{ "com.apple.kext.AMDRadeonServiceManager", pathAMDRadeonServiceManager, 1, {}, {}, KernelPatcher::KextInfo::Unloaded };
static KernelPatcher::KextInfo kextRadeonX6000Framebuffer
{ "com.apple.kext.AMDRadeonX6000Framebuffer", pathRedeonX6000Framebuffer, arrsize(pathRedeonX6000Framebuffer), {}, {}, KernelPatcher::KextInfo::Unloaded };

Expand Down Expand Up @@ -125,6 +128,8 @@ void RAD::init(bool enableNavi10Bkl) {
lilu.onKextLoadForce(&kextRadeonLegacySupport);
else
lilu.onKextLoadForce(&kextPolarisController);
// Try loading RadeonServiceManager to save loadIndex status in memory.
lilu.onKextLoad(&kextRadeonServiceManager);

initHardwareKextMods();

Expand Down Expand Up @@ -302,6 +307,21 @@ IOReturn RAD::wrapAMDRadeonX6000AmdRadeonFramebufferGetAttribute(IOService *fram
return ret;
}

bool RAD::ifNeedOverrideConnector(KernelPatcher &patcher, size_t index, mach_vm_address_t address, size_t size) {
// No need to overwrite the connector when booting BaseSystem on macOS Tahoe.
// This step is unnecessary and will cause macOS Tahoe recovery mode to freeze when booting.
// Committed by laobamac
if (getKernelVersion() >= KernelVersion::Tahoe) {
if (kextRadeonServiceManager.loadIndex != index) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ifNeedOverrideConnector is only ever called when index == kextRadeonSupport.loadIndex. Does this not have the affect of removing all connector patches in all Tahoe versions?

return false;
}
else
return true;
}
else
return true;
}

bool RAD::processKext(KernelPatcher &patcher, size_t index, mach_vm_address_t address, size_t size) {
if (kextRadeonX6000Framebuffer.loadIndex == index) {
KernelPatcher::RouteRequest requests[] = {
Expand Down Expand Up @@ -333,7 +353,10 @@ bool RAD::processKext(KernelPatcher &patcher, size_t index, mach_vm_address_t ad
}

if (kextRadeonSupport.loadIndex == index) {
processConnectorOverrides(patcher, address, size, true);
// The abnormal start-up system does not cover the connector on Tahoe.
if (ifNeedOverrideConnector(patcher, index, address, size) != false) {
Copy link
Collaborator

@vit9696 vit9696 Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After we fix Lilu to correctly detect normal mode I believe the change here should look as follows:

if (getKernelVersion() < KernelVersion::Tahoe
  || checkKernelArgument("-radconnector")
  || lilu.getRunMode() == LiluAPI::RunningNormal) {
  processConnectorOverrides(patcher, address, size, true);
  DBGLOG("rad", "processing override connector");
} else {
  DBGLOG("rad", "skipping override connector");
}

No other changes should be necessary.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After we fix Lilu to correctly detect normal mode I believe the change here should look as follows:

if (getKernelVersion() < KernelVersion::Tahoe || checkKernelArgument("-radconnector") || lilu.getRunMode() == LiluAPI::RunningNormal) {
  processConnectorOverrides(patcher, address, size, true);
  DBGLOG("rad", "processing override connector");
} else {
  DBGLOG("rad", "skipping override connector");
}

No other changes should be necessary.

I understand, do you mean to put the method that recognizes BaseSystemKernelExtendes.kc into Lilu's getRunMode?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, we could go this way if no better is found. Please make sure we guard it with macOS 26, so that we definitely do not regress on older operating systems. Ideally we want a lighter approach.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, we could go this way if no better is found. Please make sure we guard it with macOS 26, so that we definitely do not regress on older operating systems. Ideally we want a lighter approach.

But when Lilu.kext checks the running status, the root file system may not have been loaded yet, and using vfs_lookup at this time will cause a panic.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case I think we should find some other approach. Do you have an ioreg dump? Ideally both IODeviceTree and IOService planes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case I think we should find some other approach. Do you have an ioreg dump? Ideally both IODeviceTree and IOService planes.

Unfortunately, ioreg only recorded BootKernelExtensions.kc. And there is no other obvious difference except BaseSystemKernelExtendes.kc.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, could you upload one for me to think about it as well? If it contains private data, you could also e-mail me to vit9696 at pm dot me ^^

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, could you upload one for me to think about it as well? If it contains private data, you could also e-mail me to vit9696 at pm dot me ^^

OK, Wait for me a moment, I will restart into Recovery and save one

processConnectorOverrides(patcher, address, size, true);
}

if (getKernelVersion() > KernelVersion::Mojave ||
(getKernelVersion() == KernelVersion::Mojave && getKernelMinorVersion() >= 5)) {
Expand Down
5 changes: 5 additions & 0 deletions WhateverGreen/kern_rad.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@ class RAD {
* Wrapped codec hw info method
*/
static void updateGetHWInfo(IOService *accelVideoCtx, void *hwInfo);

/**
* If need override connector
*/
bool ifNeedOverrideConnector(KernelPatcher &patcher, size_t index, mach_vm_address_t address, size_t size);
};

#endif /* kern_rad_hpp */