diff mbox

[for-1.7,v2,4/8] exec: don't ignore high address bits on lookup

Message ID 1383820884-29596-5-git-send-email-marcel.a@redhat.com
State New
Headers show

Commit Message

Marcel Apfelbaum Nov. 7, 2013, 10:41 a.m. UTC
From: "Michael S. Tsirkin" <mst@redhat.com>

Lookup of address > target address space should
return an unassigned section, instead of silently
ignoring high bits.

Reported-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
---
 exec.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox

Patch

diff --git a/exec.c b/exec.c
index 79610ce..aeeaf00 100644
--- a/exec.c
+++ b/exec.c
@@ -197,6 +197,9 @@  static void phys_page_set_level(PhysPageEntry *lp, hwaddr *index,
     }
 }
 
+#define TARGET_PHYS_MAX_ADDR  \
+        (0x1ULL << (TARGET_PHYS_ADDR_SPACE_BITS - TARGET_PAGE_BITS))
+
 static void phys_page_set(AddressSpaceDispatch *d,
                           hwaddr index, hwaddr nb,
                           uint16_t leaf)
@@ -213,6 +216,10 @@  static MemoryRegionSection *phys_page_find(PhysPageEntry lp, hwaddr index,
     PhysPageEntry *p;
     int i;
 
+    if (index >= TARGET_PHYS_MAX_ADDR) {
+        return &sections[PHYS_SECTION_UNASSIGNED];
+    }
+
     for (i = P_L2_LEVELS - 1; i >= 0 && !lp.is_leaf; i--) {
         if (lp.ptr == PHYS_MAP_NODE_NIL) {
             return &sections[PHYS_SECTION_UNASSIGNED];