- kmapoff_pgcnt = (early_random() & 0x1ff) + 1; /* 9 bits */
- if (vm_allocate_kernel(kernel_map, &kmapoff_kaddr,
- kmapoff_pgcnt * PAGE_SIZE_64, VM_FLAGS_ANYWHERE, VM_KERN_MEMORY_OSFMK) != KERN_SUCCESS) {
- panic("cannot vm_allocate %u kernel_map pages", kmapoff_pgcnt);
+ uint32_t kmapoff_pgcnt = (early_random() & 0x1ff) + 1; /* 9 bits */
+ if (kernel_memory_allocate(kernel_map, &kmapoff_kaddr,
+ ptoa(kmapoff_pgcnt), 0, KMA_KOBJECT | KMA_PERMANENT | KMA_VAONLY,
+ VM_KERN_MEMORY_OSFMK) != KERN_SUCCESS) {
+ panic("cannot kernel_memory_allocate %u pages", kmapoff_pgcnt);