KEXT 中的 task_policy_get 导致`绑定失败,因为找不到导出此符号的 kext`

问题描述

我试图从 KEXT 使用 task_policy_get 并收到以下错误

sudo /usr/bin/kmutil load -p myKext
Error Domain=KMErrorDomain Code=31 "Error occurred while building a collection: 
  1: One or more binaries has an error which prevented linking. See other errors.
  2: Could not use 'myKext' because: Failed to bind '_task_policy_get' in 'myKext' (at offset 0x320 in __DATA_CONST,__got) as Could not find a kext which exports this symbol"
    <key>OSBundleLibraries</key>
    <dict>
        <key>com.apple.kpi.bsd</key>
        <string>14.0.0</string>
        <key>com.apple.kpi.iokit</key>
        <string>14.0.0</string>
        <key>com.apple.kpi.libkern</key>
        <string>14.0.0</string>
        <key>com.apple.kpi.mach</key>
        <string>14.0.0</string>
        <key>com.apple.kpi.unsupported</key>
        <string>14.0.0</string>
    </dict>

我希望 task_policy_get一个可用的 KPI?有人能指出我正确的方向吗?

  • 11.3 测试版 (20E5210c)
  • Mac mini(M1,2020 年)

我真正想做的是暂时提高流程的服务质量 (qos) 值。也许有更好的方法来做到这一点?

解决方法

task_policy_get 是从用户空间调用的 MIG 接口。它没有列在 XNU 源代码树的任何 .exports 文件中,甚至没有列在 Private.exports 中,因此它不适合从 kext 调用。