monitor: Prevent sign-extension of 32-bit addresses printed by info mem
PATCH 1/1 monitor: Prevent sign-extension of 32-bit addresses printed by info mem
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-
--- monitor.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
monitor.c +4 -2
@@ -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;
Signature · 1 line
1.7.5.4
Blue Swirl
AppliedQuoted 9 lines · Austin Clements
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-
Quoted 7 lines
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 <[email protected]>
Thanks, applied. I think 'info tlb' needs a similar fix.
Quoted 33 lines
---
monitor.c | 6 ++++--1 files changed, 4 insertions(+), 2 deletions(-)monitor.c +4
-3@@ -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
Quoth Blue Swirl on Aug 21 at 6:26 pm:
Quoted 12 lines · Austin Clements
Quoted 11 lines
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
Quoted 7 lines
Quoted 5 lines
00000000ef000000-00000000ef031000 0000000000031000 ur- 00000000ef7bc000-00000000ef7bd000 0000000000001000 urw 00000000ef7bd000-00000000ef7be000 0000000000001000 ur-
Signed-off-by Austin Clements <[email protected]>Thanks, applied. I think 'info tlb' needs a similar fix.
Quite right. I'll follow up with the info tlb patch.
PATCH 1/1 monitor: Prevent sign-extension of 32-bit addresses printed by info tlb
This is the same fix that was recently applied to info mem. Before this change, info tlb output looked like:
ffffffffffffc000: 000000000fffc000 --------Wffffffffffffd000: 000000000fffd000 --------Wffffffffffffe000: 000000000fffe000 --------Wfffffffffffff000: 000000000ffff000 --------W
With this change, it looks like
00000000ffffc000: 000000000fffc000 --------W00000000ffffd000: 000000000fffd000 --------W00000000ffffe000: 000000000fffe000 --------W00000000fffff000: 000000000ffff000 --------W
--- monitor.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
monitor.c +2 -2
@@ -2199,7 +2199,7 @@ static void print_pte(Monitor *mon, target_phys_addr_t addr,static void tlb_info_32 (Monitor *mon,CPUState *env) { -int l1, l2; +unsigned int l1, l2;uint32_t pgd, pde, pte; pgd = env->cr[3 ] & ~0xfff ;
@@ -2227,7 +2227,7 @@ static void tlb_info_32(Monitor *mon, CPUState *env)static void tlb_info_pae32 (Monitor *mon,CPUState *env) { -int l1, l2, l3; +unsigned int l1, l2, l3;uint64_t pdpe, pde, pte;uint64_t pdp_addr, pd_addr, pt_addr;
Signature · 1 line
1.7.5.4
Blue Swirl
AppliedRe: [Qemu-devel] [PATCH] monitor: Prevent sign-extension of 32-bit addresses printed by info tlb
Thanks, applied.
Quoted 47 lines · Austin Clements
This is the same fix that was recently applied to info mem. Before this change, info tlb output looked like:
ffffffffffffc000:000000000fffc000--------Wffffffffffffd000:000000000fffd000--------Wffffffffffffe000:000000000fffe000--------Wfffffffffffff000:000000000ffff000--------WWith this change, it looks like
00000000ffffc000:000000000fffc000--------W00000000ffffd000:000000000fffd000--------W00000000ffffe000:000000000fffe000--------W00000000fffff000:000000000ffff000--------WSigned-off-by Austin Clements <[email protected]>---
monitor.c | 4 ++--1 files changed, 2 insertions(+), 2 deletions(-)monitor.c +2
-3@@ -2199,7 +2199,7 @@ static void print_pte(Monitor *mon, target_phys_addr_t addr, static void tlb_info_32(Monitor *mon, CPUState *env) { - int l1, l2; + unsigned int l1, l2; uint32_t pgd, pde, pte; pgd = env->cr[3] & ~0xfff;@@ -2227,7 +2227,7 @@ static void tlb_info_32(Monitor *mon, CPUState *env) static void tlb_info_pae32(Monitor *mon, CPUState *env) { - int l1, l2, l3; + unsigned int l1, l2, l3; uint64_t pdpe, pde, pte; uint64_t pdp_addr, pd_addr, pt_addr; --1.7.5.4