/*
* Allocate 'size' bytes of memory in host kernel address space (size
* is a multiple of 4 KB) and return the address or NULL if error.
* The allocated memory must be marked as executable by the host kernel
* and must be page aligned. On i386 with PAE (but not on x86_64),
* it must be allocated in the first 4 GB of physical memory.
*/
void * CDECL
kqemu_vmalloc(unsigned int size)
{
caddr_t kaddr;
int r;
r = i_ddi_mem_alloc(NULL, &kqemu_mem_attr, P2ROUNDUP(size, X86_PGSZ),
1, 0, NULL, &kaddr, NULL, NULL);
if (r != DDI_SUCCESS) {
kqemu_log("kqemu_vmalloc: alloc failed");
return (NULL);
}
bzero(kaddr, P2ROUNDUP(size, X86_PGSZ));
if (kaddr)
addtag(kaddr, size);
return (kaddr);
}