Develop kernel-resident device drivers and kernel extensions using Kernel.

Kernel Documentation

Pinned Posts

Posts under Kernel tag

47 Posts
Sort by:
Post not yet marked as solved
12 Replies
4.1k Views
"kmutil load" will fail to load a 3rd party kernel extension when booted into an OS on an external drive. The same kernel extension will load fine when booting from the internal "Macintosh HD" . "kmutil inspect" also fails with the same error message when booted using an external drive, but works fine when booting with the internal "Macintosh HD". Both errors indicate the "kernelcache" file cannot be found: sh-3.2/usr/bin/kmutil load -p /Library/Extensions/XXXX.kext Error Domain=KMErrorDomain Code=71 "Could not find: Unable to get contents of boot kernel collection collection at /System/Volumes/Preboot/3B670FAA-F124-41AB-98A8-7C3940B5ECAC/boot/16FE8A65862647F7F8752DA7C4EF320E4CADEB250FCF438FB84A55F822BEB4A98108829E21658BB08B1E314BBC85169A/System/Library/Caches/com.apple.kernelcaches/kernelcache" UserInfo={NSLocalizedDescription=Could not find: Unable to get contents of boot kernel collection collection at /System/Volumes/Preboot/3B670FAA-F124-41AB-98A8-7C3940B5ECAC/boot/16FE8A65862647F7F8752DA7C4EF320E4CADEB250FCF438FB84A55F822BEB4A98108829E21658BB08B1E314BBC85169A/System/Library/Caches/com.apple.kernelcaches/kernelcache} sh-3.2/usr/bin/kmutil inspect No variant specified, falling back to release Error Domain=KMErrorDomain Code=71 "Invalid argument: Unable to read contents of file at /System/Volumes/Preboot/3B670FAA-F124-41AB-98A8-7C3940B5ECAC/boot/904DF99E6EB1281F8E510B3FFB953383F530F313CCFB30A9C1F98231A81B02BDA5E6E0D2BF26FC5D4EB3D2E226B8BC1C/System/Library/Caches/com.apple.kernelcaches/kernelcache" UserInfo={NSLocalizedDescription=Invalid argument: Unable to read contents of file at /System/Volumes/Preboot/3B670FAA-F124-41AB-98A8-7C3940B5ECAC/boot/904DF99E6EB1281F8E510B3FFB953383F530F313CCFB30A9C1F98231A81B02BDA5E6E0D2BF26FC5D4EB3D2E226B8BC1C/System/Library/Caches/com.apple.kernelcaches/kernelcache} The "kernelcache" file path does not exist. In fact, there is no "904DF..." directory under "boot". There is no "kernelcache" file in the entire "/System/Volumes/Preboot" mount. sh-3.2find /System/Volumes/Preboot -name kernelcache find: /System/Volumes/Preboot/.Trashes: Operation not permitted This is on an M1 MacBook Air running 11.3. Is there a special way to load kernel extensions when booting from an external drive? Thanks.
Posted
by Cardano.
Last updated
.
Post not yet marked as solved
1 Replies
762 Views
FB9108925 FB10408005 Since Apple Silicon we've seen a lot of WebDAV instability in macOS 11.x, 12.x and now 13.x that isn't found on x86 Macs. Some were fixed in earlier minor OS upgrades (e.g. webdavfs-387.100.1 that added a missing mutex init), but it's still highly unreliable. The purpose of this post is to put more focus on the bug, see if there is something else we can do to help solve this, as well as hear about potential workarounds from other people experiencing the same problems. I've got a reproducible case described below that triggers a deadlock in VFS every time, requiring a hard reboot to fully recover. Before reboot I've captured this stack trace showing the WebDAV/VFS/UBC/VM layers getting tangled up (macOS 13.2 Build 22D49 running on Macmini9,1): Thread 0x16358 1001 samples (1-1001) priority 46 (base 31) 1001 thread_start + 8 (libsystem_pthread.dylib + 7724) [0x18d2e0e2c] 1001 _pthread_start + 148 (libsystem_pthread.dylib + 28780) [0x18d2e606c] 1001 ??? (diskarbitrationd + 99400) [0x100d5c448] 1001 unmount + 8 (libsystem_kernel.dylib + 55056) [0x18d2b2710] *1001 ??? (kernel.release.t8103 + 30712) [0xfffffe00083437f8] *1001 ??? (kernel.release.t8103 + 1775524) [0xfffffe00084ed7a4] *1001 ??? (kernel.release.t8103 + 7081508) [0xfffffe00089fce24] *1001 ??? (kernel.release.t8103 + 2522264) [0xfffffe00085a3c98] *1001 ??? (kernel.release.t8103 + 2523168) [0xfffffe00085a4020] *1001 vnode_iterate + 728 (kernel.release.t8103 + 2410988) [0xfffffe00085889ec] *1001 ??? (kernel.release.t8103 + 6095404) [0xfffffe000890c22c] *1001 ??? (kernel.release.t8103 + 1097172) [0xfffffe0008447dd4] *1001 ??? (kernel.release.t8103 + 1100852) [0xfffffe0008448c34] *1001 ??? (kernel.release.t8103 + 1024804) [0xfffffe0008436324] *1001 ??? (kernel.release.t8103 + 1025092) [0xfffffe0008436444] *1001 ??? (kernel.release.t8103 + 6497736) [0xfffffe000896e5c8] *1001 ??? (kernel.release.t8103 + 2705840) [0xfffffe00085d09b0] *1001 webdav_vnop_pageout + 432 (com.apple.filesystems.webdav + 16920) [0xfffffe000b2db7b8] *1001 webdav_vnop_close + 64 (com.apple.filesystems.webdav + 9492) [0xfffffe000b2d9ab4] *1001 webdav_vnop_close_locked + 96 (com.apple.filesystems.webdav + 19708) [0xfffffe000b2dc29c] *1001 webdav_close_mnomap + 264 (com.apple.filesystems.webdav + 20004) [0xfffffe000b2dc3c4] *1001 webdav_fsync + 404 (com.apple.filesystems.webdav + 20484) [0xfffffe000b2dc5a4] *1001 ubc_msync + 184 (kernel.release.t8103 + 6096856) [0xfffffe000890c7d8] *1001 ??? (kernel.release.t8103 + 1097172) [0xfffffe0008447dd4] *1001 ??? (kernel.release.t8103 + 1100728) [0xfffffe0008448bb8] *1001 lck_rw_sleep + 136 (kernel.release.t8103 + 505804) [0xfffffe00083b77cc] *1001 ??? (kernel.release.t8103 + 607656) [0xfffffe00083d05a8] *1001 ??? (kernel.release.t8103 + 613952) [0xfffffe00083d1e40] I've spent countless hours reading the xnu-8792.81.2 and webdavfs-392 sources trying to understand what happens. Symbols mapped back to the source code tell me it's trying to flush a dirty mmap'ed file back to the WebDAV host when the volume is about to get unmounted, but I suspect the pageout request is triggered recursively, perhaps because the mmap'ed file has shrunk and pages need to be released? The test case: Use Finder to connect to a WebDAV volume which holds a fairly large image (200 MB Photoshop file in my case). Navigate to this file in column mode so Finder renders a preview (using a QuickLook process). I believe this mmap's the file, but that alone isn't sufficient, so I think the Finder tries to write an updated thumbnail back to the volume as well. Click the Eject icon in the Finder to unmount the volume, which now deadlocks that file system. In the end something remains unreleased in the filesystem since the unmount request never completes, so whether that's a VNode lock or just open file refcount or something else I don't know. Now, why this deadlock is only seen on Apple Silicon is a mystery. Is Finder/QuickLook executing different code paths for generating or storing the thumbnail? Or is there yet more cases of uninitialized mutexes/locks that happen to be accidentally functional on x86 but expose a problem on AS? I've been through a lot of kernel source code trying to find any but have come up short. But since the above is easily reproduced I'm hoping someone with filesystem/kernel debug capability can succeed in pinpointing the bug. It's at least positive that the overall architecture works on x86 so I'm hoping it is a simple fix in the end. The reason I'm debugging this is we've got a lot of customers running WebDAV on M1/M2 and they find Finder file copying highly unreliable (i.e. writing many files to the WebDAV server, possibly overwriting existing files; some users have reported a need to reboot 20 times a day). I'm really looking for a bug that's common to all of these tasks, not just the mmap + unmount problem which is a minimal test case that I've cooked up in the lab. The few spindumps I've seen from end users have also included the combination of webdav_vnop_pageout + webdav_fsync + ubc_msync + lck_rw_sleep even if unmounting wasn't the initial op that forced the deadlock. This problem has been reproduced with different WebDAV server vendors, and there is a test account on a server running Apache provided in FB10408005 (though please select the PSD file, not just the tiny JPG). Thanks in advance!
Posted Last updated
.
Post not yet marked as solved
6 Replies
11k Views
Our user reported lately that their devices were rebooted automatically after using our app for more than 2 hours , at the beginnig I cannot , I never seen an app will make the iOS system get rebooted, until our user send me a video prove it what they said is true.And after that I asked them for the panic-full logs in their devices which indicate the device was rebooted unusually, the log shows that it's exactly our app's process leads to the reboot, OMG, I got shocked...Our app is a live broadcasting app, most of our users encountered the reboot problem are when they finished broadcasting a live for a long time (maybe more than 2 hours) and close the room button, another infomation is that we add WebRTC.framework to our app lately, Our user's devices and system version vary, so maybe there is no relation with these factors.I reproduce this problem once on my iPhone 7P (I boradcasted for 2 hours, my phone rebooted exactly after I clicked the close button of my live room), and the panic log in my phone is very similar with logs from our users. Here is part of my log, I put the full on pastebin: https://pastebin.com/Hh9TqZgh{ "build":"iPhone OS 12.3.1 (16F203)", "product":"iPhone9,2", "kernel":"Darwin Kernel Version 18.6.0: Thu Apr 25 22:14:06 PDT 2019; root:xnu-4903.262.2~2/RELEASE_ARM64_T8010", "incident":"82BE9C5C-B6C3-40B4-98C7-B467ACEEF879", "crashReporterKey":"7800f8ead4380bbeae183732c167c3a212d0b0fe", "date":"2019-10-09 14:03:49.04 +0800", "panicString":"panic(cpu 0 caller 0xfffffff021e53bd0): Kernel data abort. (saved state: 0xffffffe050fbaf80) x0: 0x0000000000000000 x1: 0x000f076700041104 x2: 0xfffffffffffffffb x3: 0xffffffe04a4be81b x4: 0x0000000000000000 x5: 0x0000000000000020 x6: 0x0000000000000000 x7: 0xfffffff0221fc940 x8: 0x139a6525663e0012 x9: 0x139a6525663e0012 x10: 0x0000000000000000 x11: 0x0200000010000860 x12: 0x0000000000000000 x13: 0x3a3a79726f6d654d x14: 0x656e72654b746567 x15: 0x002928617461446c x16: 0xfffffff021cb2df7 x17: 0x0000000000000020 x18: 0xfffffff021d31000 x19: 0xffffffe006609000 x20: 0xffffffe007192880 x21: 0x0000000281f9e760 x22: 0x0000000008600000 x23: 0x0000000000000006 x24: 0x000000000000000c x25: 0xffffffe0070b4600 x26: 0x0000000085020080 x27: 0x0000000000000018 x28: 0x0000000000000000 fp: 0xffffffe050fbb350 lr: 0xfffffff020f9ed74 sp: 0xffffffe050fbb2d0 pc: 0xfffffff020f9ed74 cpsr: 0x60400304 esr: 0x96000006 far: 0x0000000000000000 Debugger message: panic Memory ID: 0x1 OS version: 16F203 Kernel version: Darwin Kernel Version 18.6.0: Thu Apr 25 22:14:06 PDT 2019; root:xnu-4903.262.2~2/RELEASE_ARM64_T8010 KernelCache UUID: 2AEBFD081F36C4C81402573F19F4DEE7 Kernel UUID: 897227C4-A9D9-3E80-AA04-C1C2029A8430 iBoot version: iBoot-4513.260.81 secure boot?: YES Paniclog version: 12 Kernel slide: 0x000000001ac54000 Kernel text base: 0xfffffff021c58000 Epoch Time: sec usec Boot : 0x5d9c64c8 0x000468bc Sleep : 0x5d9d3a6c 0x000d0471 Wake : 0x5d9d3aa5 0x00014f47 Calendar: 0x5d9d7819 0x0007c4af Panicked task 0xffffffe00634f2a0: 43873 pages, 21 threads: pid 339: EXXXLXXX Panicked thread: 0xffffffe001324000, backtrace: 0xffffffe050fba710, tid: 121839 lr: 0xfffffff021d661c4 fp: 0xffffffe050fba7a0 lr: 0xfffffff021e54538 fp: 0xffffffe050fba8e0 lr: 0xfffffff021d31610 fp: 0xffffffe050fba8f0 lr: 0xfffffff021d65768 fp: 0xffffffe050fbac60 lr: 0xfffffff021d65ae0 fp: 0xffffffe050fbaca0 lr: 0xfffffff021d65934 fp: 0xffffffe050fbacc0 lr: 0xfffffff021e53bd0 fp: 0xffffffe050fbae20 lr: 0xfffffff021e54c5c fp: 0xffffffe050fbaf60 lr: 0xfffffff021d31610 fp: 0xffffffe050fbaf70 lr: 0xfffffff020f9ed74 fp: 0xffffffe050fbb350 lr: 0xfffffff020f9d590 fp: 0xffffffe050fbb3a0 lr: 0xfffffff020f9d39c fp: 0xffffffe050fbb410 lr: 0xfffffff020f9c5f0 fp: 0xffffffe050fbb470 lr: 0xfffffff022217ee0 fp: 0xffffffe050fbb580 lr: 0xfffffff02221f8d4 fp: 0xffffffe050fbb710 lr: 0xfffffff021e2b128 fp: 0xffffffe050fbb820 lr: 0xfffffff021d49c90 fp: 0xffffffe050fbb9b0 lr: 0xfffffff021d5c17c fp: 0xffffffe050fbbb40 lr: 0xfffffff021e54d28 fp: 0xffffffe050fbbc80 lr: 0xfffffff021d31610 fp: 0xffffffe050fbbc90 lr: 0x00000001a343b0f4 fp: 0x0000000000000000 ", "panicFlags":"0x2", "otherString":" ** Stackshot Succeeded ** Bytes Traced 357072 ** ", "memoryStatus":{ "compressorSize":8413, "compressions":50291, "decompressions":21892, "busyBufferCount":0, "pageSize":16384, "memoryPressure":false, "memoryPages":{ "active":68032, "throttled":0, "fileBacked":61496, "wired":24379, "purgeable":2883, "inactive":40858, "free":11191, "speculative":27437 } } ........ }I have no idea about what to do next to resolve this problem, any suggestions will help, thanks!
Posted
by JoeyBlue_.
Last updated
.
Post not yet marked as solved
0 Replies
634 Views
Hello, I use https://juce.com to develop an audio app for macOS. With previous macOSes on Intel, I used THREAD_TIME_CONSTRAINT_POLICY as described in https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/scheduler/scheduler.html to set real time priority for the audio processing thread, according to CPU usage values. Juce has an API to get the CPU frequency so I was able to set usage values. With macOS Monterey on Apple Silicon, the Juce API is unable to give the CPU frequency (the getCpuSpeedInMegahertz API just returns 0). Is THREAD_TIME_CONSTRAINT_POLICY still valid on latest macOS on Apple Silicon? If so, what CPU frequency value should be used - ie how can we determine it? If not, how should the real time priority be set? Thanks! -Mathieu Fyi Juce code to get CPU (SystemStats::getCpuSpeedInMegahertz) can be found at https://github.com/juce-framework/JUCE/blob/master/modules/juce_core/native/juce_mac_SystemStats.mm
Posted
by mathieu51.
Last updated
.
Post not yet marked as solved
0 Replies
560 Views
After installing Xcode Command Line Tools, the System Settings App now asks me, to reboot my machine into recoveryOS and change the systems security to allow kernel extensions/ system extensions. It's not prominently mentioned, but just there and I never, ever had this. Must be a new dialog. Well, if you click on it... My Question is: Why? Kernel Extensions have been deprecated long ago (I thought) and the dialog mentions nothing specific.
Posted Last updated
.
Post marked as solved
1 Replies
657 Views
Developing a program that needs maximum cores. My previous Intel Mac mini used all 6 cores, according to Activity Monitor. It showed 600% cpu usage. I assumed the M2 would use twelve, but only shows 400% cpu usage in Activity Monitor, ergo, two less! I don't recall setting a core usage parameter in Xcode. Any ideas? Ventura 13.3 and Xcode 14.3 up to date as of this post.
Posted Last updated
.