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

Posts under Kernel tag

200 Posts

Post

Replies

Boosts

Views

Activity

In macOS 13.1, how to communicate with USB billboard device
In macOS 13.1 environment, all IOUSBDevice devices in the current system can be found via the IOServiceAddMatchingNotification function. In the registered callback function, properties such as idVendor, idProduct, and locationID of the device can be read. However, when calling the IOCreatePlugInInterfaceForService function, for USB HID and USB HID devices, a successful status of 0x00000000(kIOReturnSuccess) is returned, but for usb billboard device(type-c ,only have control pipe), an error of 0xe00002be(kIOReturnNoResources) is always returned. Thanks a lot !
1
0
1.6k
Apr ’23
kextload failed "Authenticating extension failed: Bad code signature."
I get this error when loading kext. "Authenticating extension failed: Bad code signature." The MacBook system status is as follows. There are a few points to illustrate. This kext file works fine with SIP turned off in MacBook 2018 (MacOS 10.14.6). This kext will not be released, it will only be used for debugging within our own group. This kext has been compiled into the arm64 version. The SIP option has been turned off in recovery mode and the option to reduce security has been checked for kext testing. I want to use this kext (and not distribute) if I have to use the Apple Developer program for authentication and signing and authentication. What should I do if I don't need to? Or is it not caused by certified signatures?
0
1
1.2k
Mar ’23
macOS: Audio Workgroup threads not running on P-Cores
We have noticed that in our application that creates worker threads for audio processing, these threads (time-constrained priority) in some cases do not run on the P-Cores (on Apple Silicon Macs). It was my understanding that once we use audio workgroups, the scheduler will always schedule our threads on the P-Cores. This works okay as long as the CoreAudio buffer size used is 256 samples or less (@ 48K). But if the buffer size is 512 or above, the threads are run on E-Cores (checked using System Trace). Is this expected behavior? Can I find any documentation for this (short of analyzing the scheduler source in kernel)? Thanks. Devendra.
1
0
1.1k
Mar ’23
Do we need to release the reference count on host port
Hi, I am using the below code to compute the free memory in iOS. uint64_t memAvailable() { mach_port_t host_port = mach_host_self(); if(host_port == MACH_PORT_NULL) { return 0; } vm_size_t pagesize; host_page_size(host_port, &pagesize); vm_statistics_data_t vm_stat; mach_msg_type_number_t host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t); if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS) { tdlog(LOG_LEVEL_DEBUG, @"Failed to fetch vm statistics"); return 0; } /* Stats in bytes */ return vm_stat.free_count * pagesize; } My qs is do we need to call mach_port_deallocate() to release the reference count on host_port?? Please advise.
1
0
852
Mar ’23
On Free Memory
Apple platforms have APIs, inherited from Mach, that return low-level memory statistics [1]. Some third-party tools report those statistics as if they were relevant to app developers. In most cases they are not. Specifically, any report on the amount of free memory is unlikely to be useful. This number is the size of the kernel’s free memory pool. Most VM-based OSes attempt to keep a certain amount of free memory available to avoid running out of memory in critical circumstances (for example, when trying to allocate memory on the page out path). But the size of that pool has very little to do with the amount of memory pressure on the system. Remember that the kernel’s goal is to keep the pool at a certain size, so it lets memory go to ‘waste’ until critical thresholds are crossed, as which point it starts cleaning up. As a concrete example of this, consider an iPhone running Safari. When you press the Home button, you return to the home screen but the system leaves Safari loaded in memory. At this point the free memory is X, where X is slightly higher than the threshold where the system would remove Safari from memory. Now apply some memory pressure to the system. It responds by removing Safari from memory, whereupon the free memory jumps up to Y, where Y is much larger than X. So putting memory pressure on the system has resulted in a larger free memory value. If you were using this free memory value as a proxy for memory pressure, you’d end up drawing exactly the wrong conclusion. Apple platforms have various standard techniques for handling memory pressure — memory warnings, NSCache, purgeable memory, DISPATCH_SOURCE_TYPE_MEMORYPRESSURE, and so on — and you should use those techniques rather than any sort of free memory value. Finally: If you want to get a summary of how much memory your app is using, you should look at its footprint. If you’re building an automated test suite, you can get this value programmatically. See this post for details. If you want to find out how much memory headroom you have, check out the os_proc_available_memory function. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com" [1] Specifically, the host_statistics API and the various structures defined in <mach/vm_statistics.h>. Revision History 2023-03-03 Added a reference to os_proc_available_memory. 2021-02-27 Fixed a broken link. Made other minor editorial changes. 2019-06-27 First posted.
0
0
2.7k
Mar ’23
Missing Debug Kernels 16G2136 and 20G1120
Hi,  I've been looking for the following Debug Kernels from the download section of this site but there are not available for download.  Is it possible to get these elsewhere? If not, what do others do when these files are not available? Debug Kit 10.12.6 Build 16G2136 Debug Kit 11.7.4 Build 20G1120 Many Thanks,
0
0
501
Feb ’23
What Condition Can Cause System Reboot?
My log: {"bug_type":"210","timestamp":"2022-01-20 19:00:59.00 +0700","os_version":"iPhone OS 15.2.1 (19C63)","incident_id":"3AB7979E-9CC4-44FF-A37B-10C4C3382C5A"} { "build" : "iPhone OS 15.2.1 (19C63)", "product" : "iPhone14,3", "kernel" : "Darwin Kernel Version 21.2.0: Sun Nov 28 20:43:39 PST 2021; root:xnu-8019.62.2~1/RELEASE_ARM64_T8110", "incident" : "3AB7979E-9CC4-44FF-A37B-10C4C3382C5A", "crashReporterKey" : "5fb1098457e4e82a638cdf4335f0309c4323ce88", "date" : "2022-01-20 19:00:59.82 +0700", "panicString" : "panic(cpu 2 caller 0xfffffff02ba9d6ac): mbuf_watchdog: 1 waiters stuck for 11 secs\n3418/3424 mbufs in use:\n\t3418 mbufs allocated to data\n\t6 mbufs allocated to caches\n760/760 mbuf 2KB clusters in use\n591/592 mbuf 4KB clusters in use\n2048/2048 mbuf 16KB clusters in use What I want to ask is, what is the condition that can trigger system rebooting?
3
0
3.4k
Feb ’23
How to write kernel driver for USB on macOS ?
I am creating a macOS app that will send commands to a USB device when it is plugged into a Mac. There are only two steps to accomplish this: send request commands to the USB and receive response messages from it. The USB has an attached SCSI, but I am unsure of how to send SCSI commands to macOS. Research has indicated that a kernel driver must be written for the USB to function on macOS. I have a .cpp file that can be converted into a .dll file to work on the Windows side. Is it possible to reuse this .cpp file and convert it into a .so file that can run on the macOS side? Is there someone interested in this project? I am looking to outsource it.
0
0
1.2k
Feb ’23
Does MDM Profile Support the Kernel Extension Update above Mac OS 11
From https://support.apple.com/en-us/HT211860 said: To install a new or updated kernel extension in macOS Big Sur, you can do either one of the following: Instruct the user to follow the prompts within Security &amp; Privacy preferences to allow the extension, then restart their Mac. You can permit users who are not administrators to allow the extension using the AllowNonAdminUserApprovals key in the Kernel Extension Policy MDM payload. Send the RestartDevice MDM command and set the RebuildKernelCachekey to True. Is There a way that user dont need to click "Allow" in Security &amp; Privacy preferences ? The udpated kernel extension can be loaded after the user restart the computer?
1
0
763
Feb ’23
Lots of kmutil executions
I am seeing kmutil being executed a *lot* on my iMac with Big Sur. Apple's documentation says kmutil is used for loading and unloading kexts (and some other things). Should I be concerned with this much kmutil activity?
Replies
7
Boosts
0
Views
5.7k
Activity
Apr ’23
In macOS 13.1, how to communicate with USB billboard device
In macOS 13.1 environment, all IOUSBDevice devices in the current system can be found via the IOServiceAddMatchingNotification function. In the registered callback function, properties such as idVendor, idProduct, and locationID of the device can be read. However, when calling the IOCreatePlugInInterfaceForService function, for USB HID and USB HID devices, a successful status of 0x00000000(kIOReturnSuccess) is returned, but for usb billboard device(type-c ,only have control pipe), an error of 0xe00002be(kIOReturnNoResources) is always returned. Thanks a lot !
Replies
1
Boosts
0
Views
1.6k
Activity
Apr ’23
Docker native support on OSX
I know there are some know issues about the extensive usage of the clone system call from docker. At the moment there is an issue #9 on github without solution...Is there a plan to support natively docker on OSX kernel?
Replies
13
Boosts
10
Views
11k
Activity
Apr ’23
Temperature/Humidity/Pressure API
Hi! Is it possible to get iPhone's Temperature/Humidity/Pressure/Battery_Voltage/Acceleration_Values using API calls? I want to make an app that displays these values from iPhone internal sensors. Is it possible? Thank you
Replies
2
Boosts
0
Views
3.1k
Activity
Apr ’23
How to get taskinfo to report kernel threads in BigSur
Hi, Just discovered that taskinfo on BigSur no longer shows details of kernel task threads. Is there a way to get around this limitation? Thanks. Devendra.
Replies
5
Boosts
0
Views
2.4k
Activity
Mar ’23
Replacing kernel with KDK kernel in general
So, M2 came with 22D68 on it, and closest KDK is 22D49. In the Intel days, I would just copy the KDK 22D49 to the system and reboot into it. Can we still achieve this on arm? Recovery boot, disable authenticated-root, something-something snapshot.. ? Anyone figured it out already?
Replies
1
Boosts
0
Views
869
Activity
Mar ’23
Has anyone found a way to get cpu_number() on aarch64 ?
Since it is Private exported, can't use it directly.
Replies
2
Boosts
0
Views
1.2k
Activity
Mar ’23
kextload failed "Authenticating extension failed: Bad code signature."
I get this error when loading kext. "Authenticating extension failed: Bad code signature." The MacBook system status is as follows. There are a few points to illustrate. This kext file works fine with SIP turned off in MacBook 2018 (MacOS 10.14.6). This kext will not be released, it will only be used for debugging within our own group. This kext has been compiled into the arm64 version. The SIP option has been turned off in recovery mode and the option to reduce security has been checked for kext testing. I want to use this kext (and not distribute) if I have to use the Apple Developer program for authentication and signing and authentication. What should I do if I don't need to? Or is it not caused by certified signatures?
Replies
0
Boosts
1
Views
1.2k
Activity
Mar ’23
How to sign and notarize a kext
How to sign and notarize a kext? Any body could help me to finish it? I already wrote a apply to enable my develop account kext sign ability,but i dose not recieve any response. Help!
Replies
4
Boosts
0
Views
953
Activity
Mar ’23
macOS: Audio Workgroup threads not running on P-Cores
We have noticed that in our application that creates worker threads for audio processing, these threads (time-constrained priority) in some cases do not run on the P-Cores (on Apple Silicon Macs). It was my understanding that once we use audio workgroups, the scheduler will always schedule our threads on the P-Cores. This works okay as long as the CoreAudio buffer size used is 256 samples or less (@ 48K). But if the buffer size is 512 or above, the threads are run on E-Cores (checked using System Trace). Is this expected behavior? Can I find any documentation for this (short of analyzing the scheduler source in kernel)? Thanks. Devendra.
Replies
1
Boosts
0
Views
1.1k
Activity
Mar ’23
Do we need to release the reference count on host port
Hi, I am using the below code to compute the free memory in iOS. uint64_t memAvailable() { mach_port_t host_port = mach_host_self(); if(host_port == MACH_PORT_NULL) { return 0; } vm_size_t pagesize; host_page_size(host_port, &amp;pagesize); vm_statistics_data_t vm_stat; mach_msg_type_number_t host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t); if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&amp;vm_stat, &amp;host_size) != KERN_SUCCESS) { tdlog(LOG_LEVEL_DEBUG, @"Failed to fetch vm statistics"); return 0; } /* Stats in bytes */ return vm_stat.free_count * pagesize; } My qs is do we need to call mach_port_deallocate() to release the reference count on host_port?? Please advise.
Replies
1
Boosts
0
Views
852
Activity
Mar ’23
On Free Memory
Apple platforms have APIs, inherited from Mach, that return low-level memory statistics [1]. Some third-party tools report those statistics as if they were relevant to app developers. In most cases they are not. Specifically, any report on the amount of free memory is unlikely to be useful. This number is the size of the kernel’s free memory pool. Most VM-based OSes attempt to keep a certain amount of free memory available to avoid running out of memory in critical circumstances (for example, when trying to allocate memory on the page out path). But the size of that pool has very little to do with the amount of memory pressure on the system. Remember that the kernel’s goal is to keep the pool at a certain size, so it lets memory go to ‘waste’ until critical thresholds are crossed, as which point it starts cleaning up. As a concrete example of this, consider an iPhone running Safari. When you press the Home button, you return to the home screen but the system leaves Safari loaded in memory. At this point the free memory is X, where X is slightly higher than the threshold where the system would remove Safari from memory. Now apply some memory pressure to the system. It responds by removing Safari from memory, whereupon the free memory jumps up to Y, where Y is much larger than X. So putting memory pressure on the system has resulted in a larger free memory value. If you were using this free memory value as a proxy for memory pressure, you’d end up drawing exactly the wrong conclusion. Apple platforms have various standard techniques for handling memory pressure — memory warnings, NSCache, purgeable memory, DISPATCH_SOURCE_TYPE_MEMORYPRESSURE, and so on — and you should use those techniques rather than any sort of free memory value. Finally: If you want to get a summary of how much memory your app is using, you should look at its footprint. If you’re building an automated test suite, you can get this value programmatically. See this post for details. If you want to find out how much memory headroom you have, check out the os_proc_available_memory function. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com" [1] Specifically, the host_statistics API and the various structures defined in <mach/vm_statistics.h>. Revision History 2023-03-03 Added a reference to os_proc_available_memory. 2021-02-27 Fixed a broken link. Made other minor editorial changes. 2019-06-27 First posted.
Replies
0
Boosts
0
Views
2.7k
Activity
Mar ’23
Missing Debug Kernels 16G2136 and 20G1120
Hi,  I've been looking for the following Debug Kernels from the download section of this site but there are not available for download.  Is it possible to get these elsewhere? If not, what do others do when these files are not available? Debug Kit 10.12.6 Build 16G2136 Debug Kit 11.7.4 Build 20G1120 Many Thanks,
Replies
0
Boosts
0
Views
501
Activity
Feb ’23
Can Apple reopen the OpenDarwin project?
Can Apple reopen the OpenDarwin project? It's time for OpenDarwin to reappear.Now, the situation is much different than before, and instead of harming Apple's interests, reopening the OpenDarwin project could help improve the quality of Apple's operating systems.
Replies
1
Boosts
0
Views
752
Activity
Feb ’23
What Condition Can Cause System Reboot?
My log: {"bug_type":"210","timestamp":"2022-01-20 19:00:59.00 +0700","os_version":"iPhone OS 15.2.1 (19C63)","incident_id":"3AB7979E-9CC4-44FF-A37B-10C4C3382C5A"} { "build" : "iPhone OS 15.2.1 (19C63)", "product" : "iPhone14,3", "kernel" : "Darwin Kernel Version 21.2.0: Sun Nov 28 20:43:39 PST 2021; root:xnu-8019.62.2~1/RELEASE_ARM64_T8110", "incident" : "3AB7979E-9CC4-44FF-A37B-10C4C3382C5A", "crashReporterKey" : "5fb1098457e4e82a638cdf4335f0309c4323ce88", "date" : "2022-01-20 19:00:59.82 +0700", "panicString" : "panic(cpu 2 caller 0xfffffff02ba9d6ac): mbuf_watchdog: 1 waiters stuck for 11 secs\n3418/3424 mbufs in use:\n\t3418 mbufs allocated to data\n\t6 mbufs allocated to caches\n760/760 mbuf 2KB clusters in use\n591/592 mbuf 4KB clusters in use\n2048/2048 mbuf 16KB clusters in use What I want to ask is, what is the condition that can trigger system rebooting?
Replies
3
Boosts
0
Views
3.4k
Activity
Feb ’23
How to write kernel driver for USB on macOS ?
I am creating a macOS app that will send commands to a USB device when it is plugged into a Mac. There are only two steps to accomplish this: send request commands to the USB and receive response messages from it. The USB has an attached SCSI, but I am unsure of how to send SCSI commands to macOS. Research has indicated that a kernel driver must be written for the USB to function on macOS. I have a .cpp file that can be converted into a .dll file to work on the Windows side. Is it possible to reuse this .cpp file and convert it into a .so file that can run on the macOS side? Is there someone interested in this project? I am looking to outsource it.
Replies
0
Boosts
0
Views
1.2k
Activity
Feb ’23
When "/tmp" and $TMPDIR directory are cleaned up in macOS?
When "/tmp" and $TMPDIR directory are cleaned up in macOS?I know about removing files and directories in /tmp directory in boot time. Is it right?In addition, are there other times in trying to clean up the directory?
Replies
7
Boosts
0
Views
13k
Activity
Feb ’23
Does MDM Profile Support the Kernel Extension Update above Mac OS 11
From https://support.apple.com/en-us/HT211860 said: To install a new or updated kernel extension in macOS Big Sur, you can do either one of the following: Instruct the user to follow the prompts within Security &amp; Privacy preferences to allow the extension, then restart their Mac. You can permit users who are not administrators to allow the extension using the AllowNonAdminUserApprovals key in the Kernel Extension Policy MDM payload. Send the RestartDevice MDM command and set the RebuildKernelCachekey to True. Is There a way that user dont need to click "Allow" in Security &amp; Privacy preferences ? The udpated kernel extension can be loaded after the user restart the computer?
Replies
1
Boosts
0
Views
763
Activity
Feb ’23
Programatically get free and used RAM in ios
Hi, I need to programatically compute the free and used RAM in ios using objective C. Most of the samples I have seen uses host_statistics API, although that works but that API is macOS specific and not iOS. I am looking for API which is compliant with iOS.
Replies
3
Boosts
1
Views
2.0k
Activity
Jan ’23
macOS 12.6.2 and 11.7.2 kernel debug kits missing
Although the Ventura 13.1 kernel debug kit was posted, there doesn't appear to be a kdk for macOS 12.6.2 21G320 or 11.7.2 20G1020 available in developer downloads. The Ventura 13.0 kdk is also still missing. Thanks. FB11885071
Replies
1
Boosts
1
Views
1.1k
Activity
Dec ’22