HOW OS X open the gate for TRIM on 3rd party SSD

For many years (since 10.6.8 maybe), the IOAHCIBlockStorage.kext driver in the OS X only allows TRIM to be enabled on Apple SSD. Such behavior blocks all 3rd party SSD to enable this essential technology while running OS X. Although it was possible to patch the IOAHCIBlockStorage binary to force enable TRIM on any SSD, begin with OS X 10.10, any modification on the protected kexts would cause the kext signature validation failure and the modified kexts would be denied to load without adding “kext-dev-mode=1” to boot-args explicitly. Furthermore, in the newest dev build of OS X 10.11, the kext signing become a part of the newly introduced System Integrity Protection (SIP) technology, along with the filesystem and runtime protection. In order to modify the protected kexts, SIP must be partially turned off. This kind of trade-off could be a great impact on the whole system security mechanism.

The good news is, starting with OS X 10.10.4, and also in the current 10.11 build, Apple finally open the gate for all 3rd party SSD for the TRIM support. By running this command in the Terminal, the TRIM would be enabled on all SSD attached after the system reboot:

$ sudo trimforce enable

So how this little tiny tool do to enable TRIM? What does this tool do to the system?

The secret is:

After executing the command above, an Apple signed codeless kext, AppleDataSetManagement.kext, would be installed to the /System/Library/Extensions/. The Info.plist inside this special kext contains the property needed for the IOAHCIBlockStorage driver to enable TRIM without checking the SSD brand. As it shows below:

TRIM

Compare it to the Info.plist in the IOAHCIBlockStorage.kext, a boolean property “Force Data Set Management = True” is set. While the IOProbeScore is set to 5000 is to ensure that this plist got the first change to load.

That’s how it is done on a Mac computer.

For Hackintosh user, disable SIP to turn off the kext signing might be unavoidable in order to get unsigned kext loaded. And actually this property can be added to any Info.plist such as FakeSMC.kext or just create a codeless kext by your own. In this case, with the help of Kext injection function by Clover, TRIM can always be enabled even in Recovery or OS X Install environment and there is no need to deal with the original IOAHCIBlockStorage and the “trimforce” tool any more since an equivalent injection could been made easily.

Update 1: After the TRIM is enabled, the kernel log shall have such records below during the system boot:

PM kernel[0]: *IOAHCIBlockStorageDriver::DetermineDeviceFeatures – !!!!! WARNING !!!!! – Force Data Set Management is set

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.