monitor: Prevent sign-extension of 32-bit addresses printed by info mem
authorAustin Clements <amdragon@MIT.EDU>
Mon, 15 Aug 2011 03:19:21 +0000 (23:19 -0400)
committerBlue Swirl <blauwirbel@gmail.com>
Sun, 21 Aug 2011 16:42:31 +0000 (16:42 +0000)
Previously, on 32-bit i386, info mem used signed 32-bit int's to store
the page table indexes.  As a result, address calculation was done in
32 bits and then incorrectly sign-extended to 64 bits, yielding output
like

ffffffffef000000-ffffffffef031000 0000000000031000 ur-
ffffffffef7bc000-ffffffffef7bd000 0000000000001000 urw
ffffffffef7bd000-ffffffffef7be000 0000000000001000 ur-

This makes these indexes unsigned, which yields correct output

00000000ef000000-00000000ef031000 0000000000031000 ur-
00000000ef7bc000-00000000ef7bd000 0000000000001000 urw
00000000ef7bd000-00000000ef7be000 0000000000001000 ur-

Signed-off-by: Austin Clements <amdragon@mit.edu>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
monitor.c

index 68553f1f3843f3a6f44bd1a086e93a57a15bf804..d0499233e5e9b3455bb4e69db4a9fe51e78a4a7c 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -2226,7 +2226,8 @@ static void mem_print(Monitor *mon, target_phys_addr_t *pstart,
 
 static void mem_info_32(Monitor *mon, CPUState *env)
 {
-    int l1, l2, prot, last_prot;
+    unsigned int l1, l2;
+    int prot, last_prot;
     uint32_t pgd, pde, pte;
     target_phys_addr_t start, end;
 
@@ -2263,7 +2264,8 @@ static void mem_info_32(Monitor *mon, CPUState *env)
 
 static void mem_info_pae32(Monitor *mon, CPUState *env)
 {
-    int l1, l2, l3, prot, last_prot;
+    unsigned int l1, l2, l3;
+    int prot, last_prot;
     uint64_t pdpe, pde, pte;
     uint64_t pdp_addr, pd_addr, pt_addr;
     target_phys_addr_t start, end;