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

login
register
mail settings
Submitter Marcel Apfelbaum
Date Nov. 7, 2013, 10:41 a.m.
Message ID <1383820884-29596-5-git-send-email-marcel.a@redhat.com>
Download mbox | patch
Permalink /patch/289281/
State New
Headers show

Comments

Marcel Apfelbaum - Nov. 7, 2013, 10:41 a.m.
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(+)

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];