kmem_alloc for ARM64

I've been working hard trying to get rid of all the kernel functions that we aren't allowed to call, and now have only a handful left. Loads fine on Intel, but not on arm64e.

Code Block
2: Could not use 'net.lundman.zfs' because: Failed to bind '_cpu_number' in 'net.lundman.zfs' (at offset 0x3c0 in __DATA_CONST, __got) as could not find a kext which exports this symbol
For arm64e:
6 symbols not found in any library kext:
_vnop_getnamedstream_desc
_vnop_removenamedstream_desc
_kmem_alloc
_vnop_makenamedstream_desc
_kmem_free
_cpu_number


The documentation suggest I should use kmem_alloc(), and it is certainly in the t8101 kernel.

I suppose it is in com.apple.kpi.unsupported - does that mean I'm not allowed to call them, or I should use some other method to allocate memory?

The dependency list is:
Code Block
<key>OSBundleLibraries</key>
<dict>
<key>com.apple.iokit.IOStorageFamily</key>
<string>1.6</string>
<key>com.apple.iokit.IOAVFamily</key>
<string>1.0.0</string>
<key>com.apple.kpi.bsd</key>
<string>8.0.0</string>
<key>com.apple.kpi.iokit</key>
<string>8.0.0</string>
<key>com.apple.kpi.libkern</key>
<string>10.0</string>
<key>com.apple.kpi.mach</key>
<string>8.0.0</string>
<key>com.apple.kpi.unsupported</key>
<string>8.0.0</string>
</dict>


(I think for namedstream issues, perhaps that has been removed on arm, so can just go without). cpu_number() I can probably live without, mostly used to spread out used locks semi-randomly. But I gotsa get me some memory!

Lund


IIRC kmem_alloc was never a KPI. The standard KPI allocator is <Kernel/OSMalloc.h>.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Oh I was reading: https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/vm/vm.html
the section with "Allocating Memory In the Kernel Itself". But it is probably old news.

Looks like I can call OSMalloc, with our own-allocator with quantum set over kalloc_kernmap_size. I will try that first.

While I have your attention (do I though?) - it would be nice if we could use xnu's kalloc.zones, but we struggled with it for quite a long time. The issue was always that the machine would simply panic, if it ran out of a zone. (say, zone.64)
Surely there is a way to be told/warned/event that a zone is getting full, or under pressure? Would really like to avoid panic, even if it means stalling an allocation long enough for it to reap. We never found a memory-pressure system we were allowed to call, (or it was calling us After it spun looking for memory and calling panic).

kmem_alloc for ARM64
 
 
Q