IOPCIMatch

I'm writing a PCI driver based on the AppleSamplePCI reference design. I'm trying to determine why the system dies when I add the IOPCIMatch and IOPCIMatchPrimary keys to the IOKitPersonalities in order for the driver to talk to this specific board.

Any help would be much appreciated.


Brian

How does the system "die"? Is that at boot time? Or when you load the driver? Debugging boot time problems can be tricky but if you're just having problems at load time the process is pretty straightforward: start with an empty shell of a driver, get that working, then build on things from there.


Share and Enjoy

--

Quinn "The Eskimo!"

Apple Developer Relations, Developer Technical Support, Core OS/Hardware

I don't add the driver to System/Library/Extensions. Its immediately upon loading the kext.


sudo kextload -verbose 6 AppleSamplePCI.kext


The debug boot-args are being utilized in leui of a kext-signing credential.

After the driver is built, it is copied with root permissions to /tmp :


sudo cp -R AppleSamplePCI.kext /tmp


And utilizing...


sudo kextutil -verbose 6 AppleSamplePCI.kext


...provides the diagnostic information, and immidiately recreates the same crashing condition of the driver load. The stdout from this command doesn't reflect any dependency issues or errors with the kext file.


Basically, we're trying to set this reference driver, which *should* be a tested and validated starting point to talk to a PCI signal and data acquisition device connected via Thunderbolt to an Atikio enclosure.

We remove the matching components from the info.plist that the driver comes with, and instead assign:

IOPCIPrimaryMatch

to the vid/pid of the target device. We also add:

IOPCITunnelCompatible=true

and:

IOKitDebug=65535


It seems

IOPCIPrimaryMatch

to be the cause of the black screen of death.


We've tried it both with the hardware connected (where it should match) and disconnected (where at the worst, it should provide an error message - not a system crash).


I can provide the trace from the sudo dmesg after the system returns as well as the plist if you have any pointers.


Thanks!

Trace Follows:


Anonymous UUID:      0A2A4A75-1866-A4AD-2B2C-E694BCFF5139


Thu Jun 18 10:28:21 2015


*** Panic Report ***
panic(cpu 0 caller 0xffffff800ce17cc2): Kernel trap at 0xffffff800d311a93, type 14=page fault, registers:
CR0: 0x000000008001003b, CR2: 0x0000000000270027, CR3: 0x000000016070f0bc, CR4: 0x00000000001627e0
RAX: 0xffffff7f8f2ef1a0, RBX: 0xffffff8018036f01, RCX: 0x0000000000800003, RDX: 0x0000000000270028
RSP: 0xffffff801430b968, RBP: 0xffffff801430b990, RSI: 0xffffff801430b9b0, RDI: 0x0000000000270027
R8:  0x0000000000000010, R9:  0xffffff801789c240, R10: 0x0000000000270028, R11: 0x0000000000000002
R12: 0x0000000000270027, R13: 0x0000000000000000, R14: 0x0000000000000000, R15: 0xffffff8018036f00
RFL: 0x0000000000010246, RIP: 0xffffff800d311a93, CS:  0x0000000000000008, SS:  0x0000000000000010
Fault CR2: 0x0000000000270027, Error code: 0x0000000000000000, Fault CPU: 0x0


Backtrace (CPU 0), Frame : Return Address
0xffffff801430b610 : 0xffffff800cd2bda1
0xffffff801430b690 : 0xffffff800ce17cc2
0xffffff801430b850 : 0xffffff800ce34b73
0xffffff801430b870 : 0xffffff800d311a93
0xffffff801430b990 : 0xffffff7f8d52c471
0xffffff801430b9e0 : 0xffffff7f8d52c556
0xffffff801430ba30 : 0xffffff7f8d52c5ba
0xffffff801430ba60 : 0xffffff800d2b3a07
0xffffff801430bac0 : 0xffffff800d2ae9be
0xffffff801430bb20 : 0xffffff800d2ae675
0xffffff801430bb60 : 0xffffff800d2cf28b
0xffffff801430bbc0 : 0xffffff800d273b89
0xffffff801430bc30 : 0xffffff800d269cac
0xffffff801430bc90 : 0xffffff800d267a42
0xffffff801430bce0 : 0xffffff800d267840
0xffffff801430bd40 : 0xffffff800d281301
0xffffff801430bdc0 : 0xffffff800cd7338d
0xffffff801430be10 : 0xffffff800cd3000c
0xffffff801430be40 : 0xffffff800cd149f3
0xffffff801430be90 : 0xffffff800cd2531d
0xffffff801430bf10 : 0xffffff800ce031ea
0xffffff801430bfb0 : 0xffffff800ce35396
      Kernel Extensions in backtrace:
        com.apple.iokit.IOPCIFamily(2.9)[52E715FC-521D-3869-B2EA-5228FA4BEA34]@0xffffff7f8d524000->0xffffff7f8d552fff


BSD process name corresponding to current thread: kextutil
Boot args: kext-dev-mode=1


Mac OS version:
14D136


Kernel version:
Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64
Kernel UUID: 4B3A11F4-77AA-3D27-A22D-81A1BC5B504D
Kernel slide:    0x000000000ca00000
Kernel text base: 0xffffff800cc00000
__HIB  text base: 0xffffff800cb00000
System model name: Macmini7,1 (Mac-35C5E08120C7EEAF)


System uptime in nanoseconds: 6181324071636
last loaded kext at 6181323897035: com.example.apple-samplecode.driver.SamplePCI 2.2.0 (addr 0xffffff7f8f37e000, size 36864)
last unloaded kext at 111555286311: com.apple.driver.AppleIntelLpssI2C 2.0.56 (addr 0xffffff7f8ed5a000, size 36864)
loaded kexts:
com.example.apple-samplecode.driver.SamplePCI 2.2.0
com.apple.filesystems.smbfs 3.0.1
com.apple.driver.AudioAUUC 1.70
com.apple.driver.AGPM 110.19.5
com.apple.driver.ApplePlatformEnabler 2.2.0d4
com.apple.driver.X86PlatformShim 1.0.0
com.apple.filesystems.autofs 3.0
com.apple.iokit.IOBluetoothSerialManager 4.3.4f4
com.apple.driver.AppleOSXWatchdog 1
com.apple.driver.AppleUpstreamUserClient 3.6.1
com.apple.driver.AppleGraphicsDevicePolicy 3.7.7
com.apple.driver.AppleHDA 272.18
com.apple.driver.AppleMCCSControl 1.2.11
com.apple.iokit.IOUserEthernet 1.0.1
com.apple.Dont_Steal_Mac_OS_X 7.0.0
com.apple.driver.AppleHWAccess 1
com.apple.driver.AppleHV 1
com.apple.driver.AppleLPC 1.7.3
com.apple.driver.AppleIntelSlowAdaptiveClocking 4.0.0
com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport 4.3.4f4
com.apple.driver.AppleIntelHD5000Graphics 10.0.6
com.apple.driver.AppleIntelFramebufferAzul 10.0.6
com.apple.driver.AppleThunderboltIP 2.0.2
com.apple.driver.AppleIRController 327.5
com.apple.AppleFSCompression.AppleFSCompressionTypeDataless 1.0.0d1
com.apple.AppleFSCompression.AppleFSCompressionTypeZlib 1.0.0d1
com.apple.BootCache 36
com.apple.driver.AppleUSBHub 705.4.2
com.apple.driver.XsanFilter 404
com.apple.iokit.IOAHCIBlockStorage 2.7.1
com.apple.driver.AppleSDXC 1.6.5
com.apple.iokit.AppleBCM5701Ethernet 10.1.3
com.apple.driver.AirPort.Brcm4360 930.37.3
com.apple.driver.AppleAHCIPort 3.1.2
com.apple.driver.AppleUSBXHCI 710.4.11
com.apple.driver.AppleACPIButtons 3.1
com.apple.driver.AppleRTC 2.0
com.apple.driver.AppleHPET 1.8
com.apple.driver.AppleSMBIOS 2.1
com.apple.driver.AppleACPIEC 3.1
com.apple.driver.AppleAPIC 1.7
com.apple.nke.applicationfirewall 161
com.apple.security.quarantine 3
com.apple.security.TMSafetyNet 8
com.apple.kext.triggers 1.0
com.apple.driver.AppleGraphicsControl 3.10.22
com.apple.driver.DspFuncLib 272.18
com.apple.kext.OSvKernDSPLib 1.15
com.apple.driver.AppleSMBusController 1.0.13d1
com.apple.driver.AppleHDAController 272.18
com.apple.iokit.IOHDAFamily 272.18
com.apple.iokit.IOAudioFamily 203.3
com.apple.vecLib.kext 1.2.0
com.apple.iokit.IOUSBUserClient 705.4.0
com.apple.driver.X86PlatformPlugin 1.0.0
com.apple.driver.AppleSMC 3.1.9
com.apple.driver.IOPlatformPluginFamily 5.9.1d7
com.apple.iokit.IOSlowAdaptiveClockingFamily 1.0.0
com.apple.iokit.IOBluetoothHostControllerUSBTransport 4.3.4f4
com.apple.iokit.IOBluetoothFamily 4.3.4f4
com.apple.iokit.IOSerialFamily 11
com.apple.iokit.IOSurface 97.4
com.apple.iokit.IONDRVSupport 2.4.1
com.apple.AppleGraphicsDeviceControl 3.10.22
com.apple.iokit.IOAcceleratorFamily2 156.14
com.apple.iokit.IOGraphicsFamily 2.4.1
com.apple.iokit.IOSCSIArchitectureModelFamily 3.7.5
com.apple.driver.AppleUSBMergeNub 705.4.0
com.apple.iokit.IOUSBHIDDriver 705.4.0
com.apple.driver.AppleUSBComposite 705.4.9
com.apple.driver.CoreStorage 471.20.7
com.apple.driver.AppleThunderboltDPInAdapter 4.0.6
com.apple.driver.AppleThunderboltDPAdapterFamily 4.0.6
com.apple.driver.AppleThunderboltPCIDownAdapter 2.0.2
com.apple.driver.AppleThunderboltNHI 3.1.7
com.apple.iokit.IOThunderboltFamily 4.2.2
com.apple.iokit.IOEthernetAVBController 1.0.3b3
com.apple.iokit.IO80211Family 730.60
com.apple.driver.mDNSOffloadUserClient 1.0.1b8
com.apple.iokit.IONetworkingFamily 3.2
com.apple.iokit.IOAHCIFamily 2.7.5
com.apple.iokit.IOUSBFamily 720.4.4
com.apple.driver.AppleEFINVRAM 2.0
com.apple.driver.AppleEFIRuntime 2.0
com.apple.iokit.IOHIDFamily 2.0.0
com.apple.iokit.IOSMBusFamily 1.1
com.apple.security.sandbox 300.0
com.apple.kext.AppleMatch 1.0.0d1
com.apple.driver.AppleKeyStore 2
com.apple.driver.AppleMobileFileIntegrity 1.0.5
com.apple.driver.AppleCredentialManager 1.0
com.apple.driver.DiskImages 396
com.apple.iokit.IOStorageFamily 2.0
com.apple.iokit.IOReportFamily 31
com.apple.driver.AppleFDEKeyStore 28.30
com.apple.driver.AppleACPIPlatform 3.1
com.apple.iokit.IOPCIFamily 2.9
com.apple.iokit.IOACPIFamily 1.4
com.apple.kec.Libm 1
com.apple.kec.pthread 1
com.apple.kec.corecrypto 1.0

I'm not 100% sure what's going on here but it looks like you have a problem with the matching dictionary in your KEXT that's causing the kernel's PCI bridge matching code to crash.


Here's a semi-symbolicated section of the top of the stack during the crash.


1 mach_kernel                    0xffffff800cd2bda1
2 mach_kernel                    0xffffff800ce17cc2
3 mach_kernel                    0xffffff800ce34b73
4 mach_kernel                    0xffffff800d311a93
5 com.apple.iokit.IOPCIFamily    0xffffff7f8d52c471 IOPCIBridge::matchKeys(...)
6 com.apple.iokit.IOPCIFamily    0xffffff7f8d52c556 IOPCIBridge::pciMatchNub(...)
7 com.apple.iokit.IOPCIFamily    0xffffff7f8d52c5ba IOPCIBridge::matchNubWithPropertyTable(...)
...


Frame 5 is the critical one. This looks like the first call to strtoul in IOPCIBridge::matchKeys in the following file.


<http://www.opensource.apple.com/source/IOPCIFamily/IOPCIFamily-239.1.2/IOPCIBridge.cpp>


btw You might want to look at TN2063 "Understanding and Debugging Kernel Panics".


<https://developer.apple.com/library/mac/technotes/tn2063/_index.html#//apple_ref/doc/uid/DTS10003091>


and also set up two-machine kernel debugging with the Kernel Debug Kit.


<https://developer.apple.com/downloads/>


Share and Enjoy

--

Quinn "The Eskimo!"

Apple Developer Relations, Developer Technical Support, Core OS/Hardware

IOPCIMatch
 
 
Q