qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH for-1.7 v2 6/8] exec: don't ignore high address bits


From: Marcel Apfelbaum
Subject: [Qemu-devel] [PATCH for-1.7 v2 6/8] exec: don't ignore high address bits on set
Date: Thu, 7 Nov 2013 12:41:22 +0200

From: "Michael S. Tsirkin" <address@hidden>

We should never add pages outside target address space,
we had such bugs in the past so add debug message to catch
that quickly if we do, otherwise at least don't corrupt
the page tables.

Signed-off-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Marcel Apfelbaum <address@hidden>
---
 exec.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/exec.c b/exec.c
index aeeaf00..6c3196f 100644
--- a/exec.c
+++ b/exec.c
@@ -52,6 +52,7 @@
 #include "exec/memory-internal.h"
 
 //#define DEBUG_SUBPAGE
+/* #define DEBUG_PHYS_PAGE_SET */
 
 #if !defined(CONFIG_USER_ONLY)
 static int in_migration;
@@ -204,6 +205,16 @@ static void phys_page_set(AddressSpaceDispatch *d,
                           hwaddr index, hwaddr nb,
                           uint16_t leaf)
 {
+    if (nb && (index + nb - 1) >= TARGET_PHYS_MAX_ADDR) {
+#ifdef DEBUG_PHYS_PAGE_SET
+        printf("%s: page table corruption: page address " TARGET_FMT_plx
+               " > max supported address %llx\n", __func__, (index + nb - 1),
+               TARGET_PHYS_MAX_ADDR);
+#endif
+        /* at least don't corrupt the page tables */
+        return;
+    }
+
     /* Wildly overreserve - it doesn't matter much. */
     phys_map_node_reserve(3 * P_L2_LEVELS);
 
-- 
1.8.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]