Post

Replies

Boosts

Views

Activity

mp_rendezvous & scheduling on particular cpus
I'm trying to gain some understanding of how mp_rendezvous works on x86, and I have a few questions: There are two variants, mp_rendezvous_no_intrs and mp_rendezvous. The first states that it disables interrupts during the execution of the requested function. However both boil down to mp_cpus_call1, which seems to disable interrupts for reasons not related to whether the "no_intrs" variant of mp_rendezvous was called (from osfmk/i386/mp.c), if the function is being called on cpus other than the master cpu: topo_lock = (cpus != cpu_to_cpumask(master_cpu)); if (topo_lock) { ml_set_interrupts_enabled(FALSE); (void) mp_safe_spin_lock(&x86_topo_lock); } Additionally interrupts seem to be disabled for the execution on the current CPU, as well: /* Call locally if mode not SYNC */ if (mode != SYNC && call_self) { KERNEL_DEBUG_CONSTANT( TRACE_MP_CPUS_CALL_LOCAL, VM_KERNEL_UNSLIDE(action_func), VM_KERNEL_UNSLIDE_OR_PERM(arg0), VM_KERNEL_UNSLIDE_OR_PERM(arg1), 0, 0); if (action_func != NULL) { ml_set_interrupts_enabled(FALSE); action_func(arg0, arg1); ml_set_interrupts_enabled(intrs_enabled); } } Finally, I noticed that if I have a function that is being called via mp_rendezvous, and trace it using DTrace, only the execution on the CPU that mp_rendezvous is called on hits the Dtrace probe. Is that because the other CPU's are executing the function on an interrupt thread when handling the IPI? Thank you, Neal
0
0
674
Sep ’22
Dtrace preprocessor functionality
I'm wondering if anyone has done any work to make using Kernel headers inside Dtrace scripts possible when using its functionality to run the preprocessor over a D script. AFAICT, D's compiler won't compile clang built-ins, inline functions or extern "C" declarations, C++ constructs, etc. Thanks in advance.
0
0
1.3k
Sep ’22
MusicKit compatibility with macOS
I'm trying to build a small toy MusicKit app on macOS Ventura (beta 4), and am running into something I think is probably an easy issue. I've started with the single-view application template, and have added a button, the target of which calls MusicKit methods: @IBAction func buttonPushed(_ sender: Any) {     Task {       let status = await MusicAuthorization.request()       switch status {       case .authorized:         print("auth")       case .restricted:         print("restricted")       case .notDetermined:         print("not determined")       case .denied:         print("denied")       @unknown default:         print("default")       }       print(MusicAuthorization.currentStatus)     } } I have added the NSAppleMusicUsageDescription key to the application's Info.plist However, I am always seeing that MusicAuthorization.request() returns denied with no prompt to the user for access. Thank you in advance.
4
0
943
Aug ’22
USBDriverKit driver not dispatching events
I have a driver that is not much more than the sample code for a USB mouse. I am able to get the driver to match with my device (Logitech G600 mouse), and I can see logging inside my handleReport() function, but dispatchRelativePointerEvent does not seem to cause any effect, although it returns KERN_SUCCESS. I've tried it with both SUPERDISPATCH and without (it isn't clear to me if the superclass method needs to be called in the kernel or not in this case), and by subclassing both IOUserHIDEventService and IOUserHIDEventDriver. Below is my handleReport function. Thanks in advance for any assistance, and this is on macOS Ventura Beta 2 void G600Driver::handleReport(uint64_t timestamp,                               uint8_t *report,                               uint32_t reportLength,                               IOHIDReportType type,                               uint32_t reportID) {   kern_return_t kr = dispatchRelativePointerEvent(timestamp, -10, -10, 0, 0, SUPERDISPATCH);   DRLOG("ret: %d", kr); }```
4
0
1.8k
Jul ’22
Kernel DriverKit log subsystem
I'm debugging a USB DriverKit driver, and noticed the os_log messages during the kernel verification checks do not have a subsystem (not my driver's logging): { "traceID" : 44303244788367364, "eventMessage" : "DK: G600Driver-0x1002dd073: family entitlements check failed", "eventType" : "logEvent", "source" : null, "formatString" : "DK: %s-0x%qx: family entitlements check failed\n", "activityIdentifier" : 0, "subsystem" : "", "category" : "", "threadID" : 2655768, "senderImageUUID" : "198748B0-2858-345A-957A-45C9ACB4C2F2", "backtrace" : { "frames" : [ { "imageOffset" : 9007231, "imageUUID" : "198748B0-2858-345A-957A-45C9ACB4C2F2" } ] }, "bootUUID" : "", "processImagePath" : "\/kernel", "timestamp" : "2022-06-14 01:57:51.171906-0700", "senderImagePath" : "\/kernel", "machTimestamp" : 281599031530198, "messageType" : "Default", "processImageUUID" : "198748B0-2858-345A-957A-45C9ACB4C2F2", "processID" : 0, "senderProgramCounter" : 9007231, "parentActivityIdentifier" : 0, "timezoneName" : "" } Is there a recommended way (other than substring matching on the driver name) to create a predicate for filtering the log to messages relevant to my driver? Thanks.
2
0
1.2k
Jun ’22
Kernel debugging with T2 SecureBoot
Hello,I recently purchased a Mac Mini (my first Mac with T2) and wanted to see what was the right way to debug the kernel with a debug/development kernel that I may have missed. I disabled Secure Boot from Recovery Mode, but still found my debug/development kernel was not being picked up with the kcsuffix boot arg after I copied it into /System/Library/Kernels and invalidated the kext cache.What did work was to overwrite the immutablekernel file in the PrelnkKernels directory wih my debug/development kernel (I assumed that after I disabled Secure Boot it would not check the certificates or verify the integrity of the binar); is this the only way? Is kcsuffix no longer supported with Secure Boot?Thanks,Neal
0
0
681
Dec ’19