diff mbox

[7/7] Assert arguments in range for guest address space.

Message ID 34db9eeee1243a0a73f3e3bf15d179bee3299b3b.1266267595.git.rth@twiddle.net
State New
Headers show

Commit Message

Richard Henderson Feb. 15, 2010, 7:58 p.m. UTC
We don't expect host addresses within page_set_flags or
page_check_range.
---
 exec.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/exec.c b/exec.c
index bb712ec..10673fc 100644
--- a/exec.c
+++ b/exec.c
@@ -2327,6 +2327,14 @@  void page_set_flags(target_ulong start, target_ulong end, int flags)
 {
     target_ulong addr, len;
 
+    /* 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 HOST_LONG_BITS > TARGET_VIRT_ADDR_SPACE_BITS
+    assert(end < (1ul << TARGET_VIRT_ADDR_SPACE_BITS));
+#endif
+    assert(start < end);
+
     start = start & TARGET_PAGE_MASK;
     end = TARGET_PAGE_ALIGN(end);
 
@@ -2356,6 +2364,13 @@  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 HOST_LONG_BITS > TARGET_VIRT_ADDR_SPACE_BITS
+    assert(start < (1ul << TARGET_VIRT_ADDR_SPACE_BITS));
+#endif
+
     if (start + len - 1 < start) {
         /* We've wrapped around.  */
         return -1;