MCPcopy Create free account
hub / github.com/Bareflank/hypervisor / platform_alloc_contiguous

Function platform_alloc_contiguous

loader/linux/src/platform.c:123–140  ·  view source on GitHub ↗

* <!-- description --> * @brief This function allocates read/write virtual memory from the * kernel. This memory is physically contiguous. The resulting * pointer is at least 4k aligned, so use this function sparingly * as it will always allocate at least one page. Use * platform_free_contiguous() to release this memory. * * @note This function must zero the allocated me

Source from the content-addressed store, hash-verified

121 * Returns a nullptr on failure.
122 */
123NODISCARD void *
124platform_alloc_contiguous(uint64_t const size) NOEXCEPT
125{
126 void *mut_ret;
127
128 if (0 == size) {
129 bferror("invalid number of bytes (i.e., size)");
130 return NULLPTR;
131 }
132
133 mut_ret = kmalloc(size, GFP_KERNEL);
134 if (NULLPTR == mut_ret) {
135 bferror("kmalloc failed");
136 return NULLPTR;
137 }
138
139 return memset(mut_ret, 0, size);
140}
141
142/**
143 * <!-- description -->

Callers

nothing calls this directly

Calls 1

bferrorFunction · 0.50

Tested by

no test coverage detected