Search code examples
macosusbmacos-catalinaiokitkernel-extension

Multiconfiguration USB Device - Problems in Catalina


The drivers for the interfaces of USB device with 2nd configuration are getting KIOServiceTerminated . The same drivers for similar interfaces in configuration 1 are loading and working properly. I get the following log for the interface that is geting loaded and immediately getting Terminate message after these messages. What is the problem?

default 16:42:40.813546+0530    kernel  IOUSBHostInterface: not registry member at registerService()
default 16:42:40.813560+0530    kernel  IOUSBHostInterface: bad busy count (0,-1)


Backtrace 0xffffff8000a125c6 0xffffff7f812f4731 0xffffff7f812f38a1 0xffffff7f81129388 0xffffff800037b625 0xffffff800037b151 0xffffff80002e013e

default 16:42:40.813561+0530    kernel        Kernel Extensions in backtrace:

default 16:42:40.813570+0530    kernel           com.apple.iokit.IOUSBHostFamily(1.2)[5E8D1616-2C4B-3E81-B199-59D3531E0759]@0xffffff7f8111a000->0xffffff7f81212fff

default 16:42:40.813577+0530    kernel              dependency: com.apple.driver.AppleBusPowerController(1.0)[5F8013C3-D135-3795-8C05-F5DDA387ADC4]@0xffffff7f81100000

default 16:42:40.813584+0530    kernel              dependency: com.apple.driver.usb.AppleUSBCommon(1.0)[98454AB6-B806-330F-98C6-FEA7F44D22BA]@0xffffff7f81108000

default 16:42:40.813590+0530    kernel              dependency: com.apple.driver.AppleUSBHostMergeProperties(1.2)[A7569701-C592-31CF-8740-439114078F9F]@0xffffff7f81116000

default 16:42:40.813597+0530    kernel           com.apple.iokit.IOUSBFamily(900.4.2)[3FCD6CD5-5077-374F-AD7A-6A0EA61E1FC5]@0xffffff7f812a2000->0xffffff7f8133bfff

default 16:42:40.813602+0530    kernel              dependency: com.apple.iokit.IOPCIFamily(2.9)[AA7C7A4F-9F5D-3533-9E78-177C3B6A72BF]@0xffffff7f810a2000

default 16:42:40.813608+0530    kernel              dependency: com.apple.iokit.IOUSBHostFamily(1.2)[5E8D1616-2C4B-3E81-B199-59D3531E0759]@0xffffff7f8111a000

default 16:42:40.813615+0530    kernel              dependency: com.apple.driver.usb.AppleUSBCommon(1.0)[98454AB6-B806-330F-98C6-FEA7F44D22BA]@0xffffff7f81108000

cdc usb device info-list

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundleExecutable</key>
    <string>xxandroid_usbbus</string>
    <key>CFBundleGetInfoString</key>
    <string>5.5, xx Mobile USB CDC driver for MAV</string>
    <key>CFBundleIdentifier</key>
    <string>com.xx.driver.xxAndroidusbbus</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>USB CDC driver</string>
    <key>CFBundlePackageType</key>
    <string>KEXT</string>
    <key>CFBundleShortVersionString</key>
    <string>5.5</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>5.5</string>
    <key>IOKitPersonalities</key>
    <dict>
        <key>AndroidUSBCDCDevice</key>
        <dict>
            <key>CFBundleIdentifier</key>
            <string>com.xx.driver.xxAndroidusbbus</string>
            <key>IOClass</key>
            <string>xxUSBCDC</string>
            <key>IOProbeScore</key>
            <integer>99999</integer>
            <key>IOProviderClass</key>
            <string>IOUSBDevice</string>
            <key>bDeviceClass</key>
            <integer>0</integer>
            <key>bDeviceProtocol</key>
            <integer>0</integer>
            <key>bDeviceSubClass</key>
            <integer>0</integer>
            <key>idProduct</key>
            <integer>1000</integer>
            <key>idVendor</key>
            <integer>1000</integer>
        </dict>
    </dict>
    <key>OSBundleLibraries</key>
    <dict>
        <key>com.apple.iokit.IOUSBFamily</key>
        <string>650.4.1</string>
        <key>com.apple.kpi.iokit</key>
        <string>13.0.0</string>
        <key>com.apple.kpi.libkern</key>
        <string>13.0.0</string>
        <key>com.apple.kpi.mach</key>
        <string>13.0.0</string>
        <key>com.apple.kpi.unsupported</key>
        <string>13.0.0</string>
    </dict>
</dict>
</plist>

acm cdc control interface plist info

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundleExecutable</key>
    <string>xxandroid_mdmcontrol</string>
    <key>CFBundleGetInfoString</key>
    <string>5.5, xx Mobile USB CDC ACM driver Control Interface for MAV</string>
    <key>CFBundleIdentifier</key>
    <string>com.xx.driver.xxAndroidmdmcontrol</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>xxUSBCDCACMControl</string>
    <key>CFBundlePackageType</key>
    <string>KEXT</string>
    <key>CFBundleShortVersionString</key>
    <string>5.5</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>5.5</string>
    <key>IOKitPersonalities</key>
    <dict>
        <key>AndroidUSBCDCACMControl </key>
        <dict>
            <key>CFBundleIdentifier</key>
            <string>com.xxxdriver.xxAndroidmdmcontrol</string>
            <key>IOClass</key>
            <string>xxUSBCDCACMControl</string>
            <key>IOProviderClass</key>
            <string>IOUSBInterface</string>
            <key>bConfigurationValue</key>
            <integer>2</integer>
            <key>bInterfaceNumber</key>
            <integer>1</integer>
            <key>IOProbeScore</key>
            <integer>99999</integer>
            <key>bInterfaceSubClass</key>
            <integer>2</integer>
            <key>bInterfaceProtocol</key>
            <integer>1</integer>
            <key>idProduct</key>
            <integer>1000</integer>
            <key>idVendor</key>
            <integer>1000</integer>
        </dict>
    </dict>
    <key>OSBundleLibraries</key>
    <dict>
        <key>com.apple.iokit.IOSerialFamily</key>
        <string>10.0.7</string>
        <key>com.apple.iokit.IOUSBFamily</key>
        <string>650.4.1</string>
        <key>com.apple.kpi.iokit</key>
        <string>13.0.0</string>
        <key>com.apple.kpi.libkern</key>
        <string>13.0.0</string>
        <key>com.apple.kpi.mach</key>
        <string>13.0.0</string>
        <key>com.apple.kpi.unsupported</key>
        <string>13.0.0</string>
    </dict>
</dict>
</plist>

acm data interface plist info

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundleExecutable</key>
    <string>xxandroid_mdmcontrol</string>
    <key>CFBundleGetInfoString</key>
    <string>5.5, xx Mobile USB CDC ACM driver Control Interface for MAV</string>
    <key>CFBundleIdentifier</key>
    <string>com.xx.driver.xxAndroidmdmcontrol</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>xxUSBCDCACMControl</string>
    <key>CFBundlePackageType</key>
    <string>KEXT</string>
    <key>CFBundleShortVersionString</key>
    <string>5.5</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>5.5</string>
    <key>IOKitPersonalities</key>
    <dict>
        <key>AndroidUSBCDCACMControl </key>
        <dict>
            <key>CFBundleIdentifier</key>
            <string>com.xxxdriver.xxAndroidmdmcontrol</string>
            <key>IOClass</key>
            <string>xxUSBCDCACMControl</string>
            <key>IOProviderClass</key>
            <string>IOUSBInterface</string>
            <key>bConfigurationValue</key>
            <integer>2</integer>
            <key>bInterfaceNumber</key>
            <integer>1</integer>
            <key>IOProbeScore</key>
            <integer>99999</integer>
            <key>bInterfaceSubClass</key>
            <integer>2</integer>
            <key>bInterfaceProtocol</key>
            <integer>1</integer>
            <key>idProduct</key>
            <integer>1000</integer>
            <key>idVendor</key>
            <integer>1000</integer>
        </dict>
    </dict>
    <key>OSBundleLibraries</key>
    <dict>
        <key>com.apple.iokit.IOSerialFamily</key>
        <string>10.0.7</string>
        <key>com.apple.iokit.IOUSBFamily</key>
        <string>650.4.1</string>
        <key>com.apple.kpi.iokit</key>
        <string>13.0.0</string>
        <key>com.apple.kpi.libkern</key>
        <string>13.0.0</string>
        <key>com.apple.kpi.mach</key>
        <string>13.0.0</string>
        <key>com.apple.kpi.unsupported</key>
        <string>13.0.0</string>
    </dict>
</dict>
</plist>

cdc serial interface plist info

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundleGetInfoString</key>
    <string>5.5, xx Mobile USB CDC DIAG driver Interface for MAV</string>
    <key>CFBundleExecutable</key>
    <string>xxandroid_serial</string>
    <key>CFBundleIdentifier</key>
    <string>com.xxx.driver.xxAndroidserial</string>
    <key>CFBundleName</key>
    <string>xxUSBCDCSerialData</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundlePackageType</key>
    <string>KEXT</string>
    <key>CFBundleShortVersionString</key>
    <string>5.5</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>5.5</string>
    <key>IOKitPersonalities</key>
    <dict>
        <key>AndroidUSBCDCSerail</key>
        <dict>
            <key>CFBundleIdentifier</key>
            <string>com.xx.driver.xxAndroidserial</string>
            <key>IOClass</key>
            <string>xxUSBCDCSerialData</string>
            <key>IOProviderClass</key>
            <string>IOUSBInterface</string>
            <key>InputBuffers</key>
            <integer>8</integer>
            <key>OutputBuffers</key>
            <integer>32</integer>
            <key>bConfigurationValue</key>
            <integer>2</integer>
            <key>bInterfaceNumber</key>
            <integer>3</integer>
            <key>idProduct</key>
            <integer>1000</integer>
            <key>idVendor</key>
            <integer>1000</integer>
        </dict>
    </dict>
    <key>OSBundleLibraries</key>
    <dict>
        <key>com.apple.iokit.IOSerialFamily</key>
        <string>10.0.7</string>
        <key>com.apple.iokit.IOUSBFamily</key>
        <string>650.4.1</string>
        <key>com.apple.kpi.bsd</key>
        <string>13.0.0</string>
        <key>com.apple.kpi.iokit</key>
        <string>13.0.0</string>
        <key>com.apple.kpi.libkern</key>
        <string>13.0.0</string>
        <key>com.apple.kpi.mach</key>
        <string>13.0.0</string>
        <key>com.apple.kpi.unsupported</key>
        <string>13.0.0</string>
    </dict>
</dict>
</plist>

ioreg -lirc IOUSBHostInterface

-o MTP@0  <class IORegistryEntry:IOService:IOUSBNub:IOUSBInterface, id 0x100002520, registered, matched, active, busy 0 (16 ms), retain 6>
    {
      "USBSpeed" = 3
      "iInterface" = 5
      "IOServiceLegacyMatchingRegistryID" = 4294976802
      "bInterfaceProtocol" = 0
      "bAlternateSetting" = 0
      "idProduct" = 1000
      "bcdDevice" = 1028
      "USB Interface Name" = "MTP"
      "USB Product Name" = “xxx”
      "locationID" = 336592896
      "bInterfaceClass" = 255
      "bInterfaceSubClass" = 255
      "IOCFPlugInTypes" = {"2d9786c6-9ef3-11d4-ad51-000a27052861"="IOUSBHostFamily.kext/Contents/PlugIns/IOUSBLib.bundle"}
      "USBPortType" = 0
      "kUSBString" = "MTP"
      "bInterfaceNumber" = 0
      "bConfigurationValue" = 1
      "USB Vendor Name" = “xxx”
      "idVendor" = 1000
      "IOServiceDEXTEntitlements" = (("com.apple.developer.driverkit.transport.usb"))
      "bNumEndpoints" = 3
      "USB Serial Number" = “xxxxx”
      "IOGeneralInterest" = "IOCommand is not serializable"
      "IOClassNameOverride" = "IOUSBInterface"
    }


+-o ADB Interface@1  <class IORegistryEntry:IOService:IOUSBNub:IOUSBInterface, id 0x100002521, registered, matched, active, busy 0 (16 ms), retain 6>
    {
      "USBSpeed" = 3
      "iInterface" = 6
      "IOServiceLegacyMatchingRegistryID" = 4294976805
      "bInterfaceProtocol" = 1
      "bAlternateSetting" = 0
      "idProduct" = 1000
      "bcdDevice" = 1028
      "USB Interface Name" = "ADB Interface"
      "USB Product Name" = “xxxx”
      "locationID" = 336592896
      "bInterfaceClass" = 255
      "bInterfaceSubClass" = 66
      "IOCFPlugInTypes" = {"2d9786c6-9ef3-11d4-ad51-000a27052861"="IOUSBHostFamily.kext/Contents/PlugIns/IOUSBLib.bundle"}
      "USBPortType" = 0
      "kUSBString" = "ADB Interface"
      "bInterfaceNumber" = 1
      "bConfigurationValue" = 1
      "USB Vendor Name" = “xxx”
      "idVendor" = 1000
      "IOServiceDEXTEntitlements" = (("com.apple.developer.driverkit.transport.usb"))
      "bNumEndpoints" = 2
      "USB Serial Number" = “xxxx”
      "IOGeneralInterest" = "IOCommand is not serializable"
      "IOClassNameOverride" = "IOUSBInterface"
    }

Solution

  • I don't fully understand what you are trying to do at this point yet (you have provided very little hard information), so I'd ideally need some more information to be certain - kext info.plist, the API calls that are triggering the error, etc.

    However, considering you list "IOProviderClass(IOUSBInterface)" in your comments and com.apple.iokit.IOUSBFamily shows up in the backtrace you quoted, my suspicion is that you are running into bugs in the increasingly badly maintained IOUSBFamily legacy compatibility layer you seem to be using in your kext. I have found various problems with this layer in Mojave and even more so in Catalina, some of them hardware-dependent (e.g. some problems only occur on some Mac models).

    You can try reporting the bugs to Apple, but I suspect you will get the same advice I am about to give you: you should port your driver to the newer IOUSBHostFamily API. If possible, using DriverKit or as a regular user space daemon, otherwise as a kernel extension. If it must be a kernel extension, the IOUSBHost*.h header files from the macOS SDK contain porting instructions in the comments at the top of each file.