[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 17/18] memory: info mtree check mr range overflow
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 17/18] memory: info mtree check mr range overflow |
Date: |
Tue, 14 Mar 2017 17:18:19 +0100 |
From: Peter Xu <address@hidden>
The address of memory regions might overflow when something wrong
happened, like reported in:
https://lists.gnu.org/archive/html/qemu-devel/2017-03/msg02043.html
For easier debugging, let's try to detect it.
Reported-by: Mark Cave-Ayland <address@hidden>
Signed-off-by: Peter Xu <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
memory.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/memory.c b/memory.c
index 284894b..64b0a60 100644
--- a/memory.c
+++ b/memory.c
@@ -2494,6 +2494,7 @@ static void mtree_print_mr(fprintf_function mon_printf,
void *f,
MemoryRegionListHead submr_print_queue;
const MemoryRegion *submr;
unsigned int i;
+ hwaddr cur_start, cur_end;
if (!mr) {
return;
@@ -2503,6 +2504,18 @@ static void mtree_print_mr(fprintf_function mon_printf,
void *f,
mon_printf(f, MTREE_INDENT);
}
+ cur_start = base + mr->addr;
+ cur_end = cur_start + MR_SIZE(mr->size);
+
+ /*
+ * Try to detect overflow of memory region. This should never
+ * happen normally. When it happens, we dump something to warn the
+ * user who is observing this.
+ */
+ if (cur_start < base || cur_end < cur_start) {
+ mon_printf(f, "[DETECTED OVERFLOW!] ");
+ }
+
if (mr->alias) {
MemoryRegionList *ml;
bool found = false;
@@ -2522,8 +2535,7 @@ static void mtree_print_mr(fprintf_function mon_printf,
void *f,
mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx
" (prio %d, %s): alias %s @%s " TARGET_FMT_plx
"-" TARGET_FMT_plx "%s\n",
- base + mr->addr,
- base + mr->addr + MR_SIZE(mr->size),
+ cur_start, cur_end,
mr->priority,
memory_region_type((MemoryRegion *)mr),
memory_region_name(mr),
@@ -2534,8 +2546,7 @@ static void mtree_print_mr(fprintf_function mon_printf,
void *f,
} else {
mon_printf(f,
TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %s): %s%s\n",
- base + mr->addr,
- base + mr->addr + MR_SIZE(mr->size),
+ cur_start, cur_end,
mr->priority,
memory_region_type((MemoryRegion *)mr),
memory_region_name(mr),
@@ -2562,7 +2573,7 @@ static void mtree_print_mr(fprintf_function mon_printf,
void *f,
}
QTAILQ_FOREACH(ml, &submr_print_queue, queue) {
- mtree_print_mr(mon_printf, f, ml->mr, level + 1, base + mr->addr,
+ mtree_print_mr(mon_printf, f, ml->mr, level + 1, cur_start,
alias_print_queue);
}
--
1.8.3.1
- [Qemu-devel] [PULL 07/18] scripts/dump-guest-memory.py: fix int128_get64 on recent gcc, (continued)
- [Qemu-devel] [PULL 07/18] scripts/dump-guest-memory.py: fix int128_get64 on recent gcc, Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 09/18] util: Removed unneeded header from path.c, Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 12/18] qemu-timer: fix off-by-one, Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 13/18] qemu-timer: do not include sysemu/cpus.h from util/qemu-timer.h, Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 14/18] cpus: define QEMUTimerListNotifyCB for QEMU system emulation, Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 16/18] icount: process QEMU_CLOCK_VIRTUAL timers in vCPU thread, Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 18/18] nbd/client: fix drop_sync [CVE-2017-2630], Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 11/18] target/nios2: take BQL around interrupt check, Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 10/18] scsi: mptsas: fix the wrong reading size in fetch request, Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 17/18] memory: info mtree check mr range overflow,
Paolo Bonzini <=
- [Qemu-devel] [PULL 15/18] main-loop: remove now unnecessary optimization, Paolo Bonzini, 2017/03/14
- Re: [Qemu-devel] [PULL 00/18] Misc patches for QEMU 2.9 hard freeze, Peter Maydell, 2017/03/14