From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:43065) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QsoHP-00030E-Cb for qemu-devel@nongnu.org; Sun, 14 Aug 2011 23:56:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QsoHO-0002Rg-BV for qemu-devel@nongnu.org; Sun, 14 Aug 2011 23:55:59 -0400 Received: from dmz-mailsec-scanner-4.mit.edu ([18.9.25.15]:65219) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QsoHO-0002QQ-9W for qemu-devel@nongnu.org; Sun, 14 Aug 2011 23:55:58 -0400 From: Austin Clements Date: Sun, 14 Aug 2011 23:19:21 -0400 Message-Id: <1313378361-15610-1-git-send-email-amdragon@mit.edu> Subject: [Qemu-devel] [PATCH] monitor: Prevent sign-extension of 32-bit addresses printed by info mem List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Austin Clements , Markus Armbruster , Luiz Capitulino 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 --- monitor.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/monitor.c b/monitor.c index 718935b..6a4f8c2 100644 --- a/monitor.c +++ b/monitor.c @@ -2224,7 +2224,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; @@ -2261,7 +2262,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; -- 1.7.5.4