From: Jan Kiszka <jan.kiszka@web.de>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 5/5] linux-user: Fix h2g usage in page_find_alloc
Date: Sat, 16 Aug 2008 11:38:40 +0200 [thread overview]
Message-ID: <48A6A020.2070204@web.de> (raw)
In-Reply-To: <48A69B64.7050001@web.de>
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>
---
exec.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
Index: b/exec.c
===================================================================
--- a/exec.c
+++ b/exec.c
@@ -294,14 +294,13 @@ static inline PageDesc *page_find_alloc(
if (!p) {
/* allocate if not found */
#if defined(CONFIG_USER_ONLY)
- unsigned long addr;
size_t len = sizeof(PageDesc) * L2_SIZE;
/* Don't use qemu_malloc because it may recurse. */
p = mmap(0, len, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
*lp = p;
- addr = h2g(p);
- if (addr == (target_ulong)addr) {
+ if (h2g_valid(p)) {
+ unsigned long addr = h2g(p);
page_set_flags(addr & TARGET_PAGE_MASK,
TARGET_PAGE_ALIGN(addr + len),
PAGE_RESERVED);
next prev parent reply other threads:[~2008-08-16 9:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-16 9:28 [Qemu-devel] [PATCH 0/5] linux-user: Detect and fix 32-bit guest on 64-bit host issues - v2 Jan Kiszka
2008-08-16 9:24 ` [Qemu-devel] [PATCH 1/5] linux-user: Safety belt for h2g Jan Kiszka
2008-08-16 9:28 ` [Qemu-devel] [PATCH 2/5] linux-user: Introduce qemu_vmalloc_guest_safe Jan Kiszka
2008-08-16 9:30 ` [Qemu-devel] [PATCH 3/5] linux-user: Allocate guest-reachable descriptor tables Jan Kiszka
2008-08-16 9:38 ` Jan Kiszka [this message]
2008-08-16 9:39 ` [Qemu-devel] [PATCH 4/5] linux-user: Introduce h2g_valid Jan Kiszka
2008-08-21 19:41 ` [Qemu-devel] [PATCH 0/5] linux-user: Detect and fix 32-bit guest on 64-bit host issues - v2 Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48A6A020.2070204@web.de \
--to=jan.kiszka@web.de \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.