Commit fb1c2cd7d9a9955a98eb7c874a74122f1e964811
1 parent
14cc46b1
linux-user: Fix h2g usage in page_find_alloc
Paul's comment on my first approach to fix the h2g usage in page_find_alloc finally open my eyes about what the code is actually supposed to do: With the help of h2g_valid we can no cleanly check if a freshly allocate page (for host usage) is guest-reachable and, in case it is, mark it reserved in the guest's address range. Signed-off-by: Jan Kiszka <jan.kiszka@web.de> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name> Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5957 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
2 additions
and
3 deletions
exec.c
... | ... | @@ -305,14 +305,13 @@ static inline PageDesc *page_find_alloc(target_ulong index) |
305 | 305 | if (!p) { |
306 | 306 | /* allocate if not found */ |
307 | 307 | #if defined(CONFIG_USER_ONLY) |
308 | - unsigned long addr; | |
309 | 308 | size_t len = sizeof(PageDesc) * L2_SIZE; |
310 | 309 | /* Don't use qemu_malloc because it may recurse. */ |
311 | 310 | p = mmap(0, len, PROT_READ | PROT_WRITE, |
312 | 311 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
313 | 312 | *lp = p; |
314 | - addr = h2g(p); | |
315 | - if (addr == (target_ulong)addr) { | |
313 | + if (h2g_valid(p)) { | |
314 | + unsigned long addr = h2g(p); | |
316 | 315 | page_set_flags(addr & TARGET_PAGE_MASK, |
317 | 316 | TARGET_PAGE_ALIGN(addr + len), |
318 | 317 | PAGE_RESERVED); | ... | ... |