Help. My NVMe shows up as External…

Some people (see comments) are having issues with M.2 devices sitting behind a PCI bridge (IOName is pci-bridge) and then IONVMeFamily.kext fails to read the built-in property.

Update: Blog article updated for macOS Sierra DP4 !

The solution so far was to use a (tiny) SSDT (snippet) or add it to any other SSDT and to set the missing built-in property from a _DSM method, but we can also patch a few more bytes in the binary:

AppleNVMeController::InitializePCI()

test       rax, rax
je         0xa711
or         byte [ds:rbx+0x108], 0x10

Let’s just nop the first five bytes so that it looks like this:

nop
nop
nop
nop
nop
or         byte [ds:rbx+0x108], 0x10

In other words. You need Clover to search for the output of:

echo -n '4885c07407808b0801000010'|xxd -r -p|base64

And replace it with the output of:

echo -n '9090909090808b0801000010'|xxd -r -p|base64

Then you take the result and morph it into this:

    <dict>
        <key>Comment</key>
        <string>IONVMeFamily Pike R. Alpha Patch#External</string>
        <key>Disabled</key>
        <false/>
        <key>Name</key>
        <string>IONVMeFamily</string>
        <key>Find</key>
        <data>SIXAdAeAiwgBAAAQ</data>
        <key>Replace</key>
        <data>kJCQkJCAiwgBAAAQ</data>
    </dict>

Add the above lines to KextsToPatch in your Clover config.plist and that should fix it for you.

Edit: Confirmed working on a Gigabyte GA-Z87MX-D3H where a PCIe X4 card with a M.2 is installed in the PCIEX8 slot (Device _SB.PCI0.PEG1@1,1 in the DSDT).

Edit-2: I have since updated the tiny SSDT for this motherboard. Just rename PEG1 to the device that you are using. Like NPE7 for certain hardware 😉

Edit-3: ACPI code from said link (above) added.

        External(_SB.PCI0.PEG1, DeviceObj)

        /* PEG1 is used for my PCIe card with M.2, installed in slot 'PCIEX8' */

        Scope (\_SB.PCI0.PEG1)
        {
            /* Here we inject a new device (SSD0) for the PCIe card with M.2 */

            Device (SSD0)
            {
                Name (_ADR, Zero)  // _ADR: Address
                Name (NVME, One)
                Method (_DSM, 4, NotSerialized)  // _DSM: Device-Specific Method
                {
                    If (LEqual (Arg2, Zero))
                    {
                        Return (Buffer (One)
                        {
                             0x03
                        })
                    }

                    If (LEqual (NVME, One))
                    {
                        Return (Package (0x04)
                        {
                            "use-msi", 
                            One, 
                            "nvme-LPSR-during-S3-S4", 
                            One
                        })
                    }
                    Else
                    {
                        Return (Package (0x06)
                        {
                            "use-msi", 
                            One, 
                            "sata-express-power-off", 
                            One, 
                            "ssd-off-in-S4", 
                            One
                        })
                    }
                }

                Device (PRT0)
                {
                    Name (_ADR, 0xFFFF)  // _ADR: Address
                    Method (_DSM, 4, NotSerialized)  // _DSM: Device-Specific Method
                    {
                        If (LEqual (Arg2, Zero))
                        {
                            Return (Buffer (One)
                            {
                                 0x03
                            })
                        }

                        Return (Package (0x02)
                        {
                            "io-device-location", 
                            Buffer (0x04)
                            {
                                "SSD"
                            }
                        })
                    }
                }
            }
        }

15 thoughts on “Help. My NVMe shows up as External…

  1. Pingback: IONVMeFamily.kext changes in Sierra DP4 (build 16A270f) – Pike's Universum

  2. hi Pikeralpha, sorry it didn’t work for me (adding the lines above) KextsToPatch in my Clover config.plist

    this is what my iojones output looks like for my NVME disk, thanks if you can help, and thank you for all the hard work, i’ve been using numerous patches of yours and slowly learning this thing

  3. success! thanks for the work Pikeralpha, i’m testing Sierra PB7 at the moment and your NMVE IONVMeFamily.kext bin patch data and external drive patch work a treat.

    Just to let you know yes i was using El Capitan before 🙂

    Many thanks

  4. Hi Pike this appear to be working for El Capitan, only one byte change from Sierra
    // El Capitan external icon fix
    UInt8 Find[] = {0x48, 0x85, 0xC0, 0x74, 0x07, 0x80, 0x8B, 0x00, 0x01, 0x00, 0x00, 0x10};
    UInt8 Replace[] = {0x90, 0x90, 0x90, 0x90, 0x90, 0x80, 0x8B, 0x00, 0x01, 0x00, 0x00, 0x10};

    cheers

  5. Pike, I was able to successfully apply this patch, thank you.

    I’d also like to patch my AHCI kext so that my other PCIe SSDs show up as internal.

    The trouble is– I don’t really understand how to replicate the process you went through to figure this out. I’m really trying to learn how to edit kexts.

    I understand I can open the binary up with Hexfriend and other Hex editors but I don’t know what I should/can replace. I’m also not quite sure how to track down the kext responsible for this. I’m relatively its either in the IOAHCIFamily.kext or AppleAHCIPort.kext but I’m just guessing.

    Do you think you could help me walk through this? Teach a man to fish…

    Thank you so much!

    • Download/install Hopper v4 and “Menu File/Read Executable To Disassemble…” the binary of said kext. Switch to “Strings” and go hunting for text like: internal, built-in and ESB2 AHCI. That should help.

      Note: The demo version of Hopper won’t let you save your changes. Use the HEX editor of your choice to change the locations that you need to change.

      • Thanks Pike,

        I downloaded used the Hopper app to find ESB2 within AppleAHCIPort binary. But now I’m not sure what to do.

        Could you help me understand why you had me search for ESB2?

        Thank you for your help!

        Nick

      • Click on the green link at the right, which will show you the actual disassembled code.

        And in the past, motherboards with the ICH9/10 had some issues (Google it, like I just did) where people injected a device-id of the ESB2 to get rid of the yellow drive icon(s). You should also check the hot-plug setting(s) in your BIOS. Disabling may also help.

        Note that I have no time to look into this, so you are on your own here. All free time that I have left right now is used for Kaby Lake research – macOS Sierra is booting up just fine, but with some issues that I need to fix.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s