From: "Rémi Denis-Courmont" <remi@remlab.net>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] tcg: assert last byte is in guest space
Date: Fri, 8 Feb 2019 18:37:27 +0200 [thread overview]
Message-ID: <20190208163727.13733-1-remi@remlab.net> (raw)
Rather than assert that the first byte of a checked range is within the
guest address space, assert that the last byte is. The assertion is
moved past the overflow check to ensure that the last byte is actually
the one with the highest address.
Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
---
accel/tcg/translate-all.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 8f593b926f..ea0c96af71 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -2515,13 +2515,6 @@ int page_check_range(target_ulong start, target_ulong len, int flags)
target_ulong end;
target_ulong addr;
- /* This function should never be called with addresses outside the
- guest address space. If this assert fires, it probably indicates
- a missing call to h2g_valid. */
-#if TARGET_ABI_BITS > L1_MAP_ADDR_SPACE_BITS
- assert(start < ((target_ulong)1 << L1_MAP_ADDR_SPACE_BITS));
-#endif
-
if (len == 0) {
return 0;
}
@@ -2530,6 +2523,13 @@ int page_check_range(target_ulong start, target_ulong len, int flags)
return -1;
}
+ /* This function should never be called with addresses outside the
+ guest address space. If this assert fires, it probably indicates
+ a missing call to h2g_valid. */
+#if TARGET_ABI_BITS > L1_MAP_ADDR_SPACE_BITS
+ assert((start + len - 1) < ((target_ulong)1 << L1_MAP_ADDR_SPACE_BITS));
+#endif
+
/* must do before we loose bits in the next step */
end = TARGET_PAGE_ALIGN(start + len);
start = start & TARGET_PAGE_MASK;
--
2.20.1
next reply other threads:[~2019-02-08 16:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-08 16:37 Rémi Denis-Courmont [this message]
2019-02-08 18:12 ` [Qemu-devel] [PATCH] tcg: assert last byte is in guest space Richard Henderson
2019-02-08 18:32 ` Rémi Denis-Courmont
2019-02-08 20:27 ` Richard Henderson
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=20190208163727.13733-1-remi@remlab.net \
--to=remi@remlab.net \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).