mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
linux-user: Use h2g_valid in qemu_vmalloc.
Signed-off-by: Richard Henderson <rth@twiddle.net>
This commit is contained in:
parent
b9f83121a1
commit
7bc7b099df
1 changed files with 4 additions and 5 deletions
|
@ -80,16 +80,15 @@ void mmap_unlock(void)
|
||||||
void *qemu_vmalloc(size_t size)
|
void *qemu_vmalloc(size_t size)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
unsigned long addr;
|
|
||||||
mmap_lock();
|
mmap_lock();
|
||||||
/* Use map and mark the pages as used. */
|
/* Use map and mark the pages as used. */
|
||||||
p = mmap(NULL, size, PROT_READ | PROT_WRITE,
|
p = mmap(NULL, size, PROT_READ | PROT_WRITE,
|
||||||
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||||
|
|
||||||
addr = (unsigned long)p;
|
if (h2g_valid(p)) {
|
||||||
if (addr == (target_ulong) addr) {
|
/* Allocated region overlaps guest address space. This may recurse. */
|
||||||
/* Allocated region overlaps guest address space.
|
unsigned long addr = h2g(p);
|
||||||
This may recurse. */
|
|
||||||
page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + size),
|
page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + size),
|
||||||
PAGE_RESERVED);
|
PAGE_RESERVED);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue