X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/39236c6e673c41db228275375ab7fdb0f837b292..490019cf9519204c5fb36b2fba54ceb983bb6b72:/osfmk/kern/btlog.c diff --git a/osfmk/kern/btlog.c b/osfmk/kern/btlog.c index 50fc5991e..c39dd166d 100644 --- a/osfmk/kern/btlog.c +++ b/osfmk/kern/btlog.c @@ -31,6 +31,7 @@ #include #include #include +#include #include /* @@ -73,6 +74,7 @@ struct btlog { btlog_recordindex_t freelist; }; +extern boolean_t vm_kernel_ready; extern boolean_t kmem_alloc_ready; #define lookup_btrecord(btlog, index) \ @@ -92,7 +94,7 @@ btlog_create(size_t numrecords, kern_return_t ret; size_t btrecord_size; - if (!kmem_alloc_ready) + if (vm_kernel_ready && !kmem_alloc_ready) return NULL; if (numrecords > BTLOG_MAX_RECORDS) @@ -118,8 +120,13 @@ btlog_create(size_t numrecords, /* since rounding to a page size might hold more, recalculate */ numrecords = MIN(BTLOG_MAX_RECORDS, (buffersize_needed - sizeof(btlog_t))/btrecord_size); - - ret = kmem_alloc(kernel_map, &buffer, buffersize_needed); + + if (kmem_alloc_ready) { + ret = kmem_alloc(kernel_map, &buffer, buffersize_needed, VM_KERN_MEMORY_DIAG); + } else { + buffer = (vm_address_t)pmap_steal_memory(buffersize_needed); + ret = KERN_SUCCESS; + } if (ret != KERN_SUCCESS) return NULL;