Fix bsd-user qemu_vmalloc() host page protection code

Just do the same as linux-user does.

Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
Juergen Lock 2010-03-25 22:11:17 +01:00 committed by Blue Swirl
parent d1839d7367
commit b035ffd118

View File

@ -77,16 +77,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_ANON, -1, 0); MAP_PRIVATE | MAP_ANON, -1, 0);
addr = (unsigned long)p; if (h2g_valid(p)) {
if (addr == (target_ulong) addr) {
/* Allocated region overlaps guest address space. /* Allocated region overlaps guest address space.
This may recurse. */ This may recurse. */
abi_ulong addr = h2g(p);
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);
} }