exec: fix tlb_vaddr_to_host()
PATCH 1/1 exec: fix tlb_vaddr_to_host()
When used in linux-user mode, tlb_vaddr_to_host(..., addr, ...)) should return "g2h(addr)", but instead it returns "g2h(vaddr)". As "vaddr" is "typedef uint64_t", the result of "g2h(vaddr)" is "((void *)((unsigned long)(target_ulong)(uint64_t) + guest_base))".
This bug has been found trying to run "ls" with qemu-ppc.
--- include/exec/cpu_ldst.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/exec/cpu_ldst.h +1 -1
@@ -401,7 +401,7 @@ static inline void *tlb_vaddr_to_host(CPUArchState *env, target_ulong addr, int access_type, int mmu_idx) {#if defined(CONFIG_USER_ONLY ) -return g2h (vaddr); +return g2h (addr);#else int index = (addr >>TARGET_PAGE_BITS ) & (CPU_TLB_SIZE -1 );CPUTLBEntry *tlbentry = &env->tlb_table[mmu_idx][index];
Signature · 1 line
2.5.5
Already fixed by a Ben's non applied patch:
http://patchwork.ozlabs.org/patch/655238/
Laurent
Quoted 28 lines · Laurent Vivier
When used in linux-user mode,
tlb_vaddr_to_host(..., addr, ...)) should return "g2h(addr)", but instead it returns "g2h(vaddr)". As "vaddr" is "typedefuint64_t", the result of "g2h(vaddr)" is "((void *)((unsigned long)(target_ulong)(uint64_t) +guest_base))".This bug has been found trying to run "ls" with qemu-ppc.
Fixes "c9f82d0 ppc: Speed up dcbz"Reported-by Andreas Färber <[email protected]>Signed-off-by Laurent Vivier <[email protected]>--- include/exec/cpu_ldst.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/exec/cpu_ldst.h +1
-1@@ -401,7 +401,7 @@ static inline void *tlb_vaddr_to_host(CPUArchState *env, target_ulong addr, int access_type, int mmu_idx) {#if defined(CONFIG_USER_ONLY ) -return g2h (vaddr); +return g2h (addr);#else int index = (addr >>TARGET_PAGE_BITS ) & (CPU_TLB_SIZE -1 );CPUTLBEntry *tlbentry = &env->tlb_table[mmu_idx][index];
Quoted 19 lines · Laurent Vivier
When used in linux-user mode,
tlb_vaddr_to_host(..., addr, ...)) should return "g2h(addr)", but instead it returns "g2h(vaddr)". As "vaddr" is "typedefuint64_t", the result of "g2h(vaddr)" is "((void *)((unsigned long)(target_ulong)(uint64_t) +guest_base))".This bug has been found trying to run "ls" with qemu-ppc.
Fixes "c9f82d0 ppc: Speed up dcbz"Reported-by Andreas Färber <[email protected]>Signed-off-by Laurent Vivier <[email protected]>--- include/exec/cpu_ldst.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/exec/cpu_ldst.h +0
-0
include/exec/cpu_ldst.h static inline void *tlb_vaddr_to_host(CPUArchState *env, target_ulong addr, · line 407
Quoted 8 lines
include/exec/cpu_ldst.h +1
-1@@ -401,7 +401,7 @@ static inline void *tlb_vaddr_to_host(CPUArchState *env, target_ulong addr, int access_type, int mmu_idx) {#if defined(CONFIG_USER_ONLY ) -return g2h (vaddr); +return g2h (addr);#else int index = (addr >>TARGET_PAGE_BITS ) & (CPU_TLB_SIZE -1 );CPUTLBEntry *tlbentry = &env->tlb_table[mmu_idx][index];
That looks fine to me, sorry for the typo.
Signature · 2 lines
Aurelien Jarno GPG: 4096R/1DDD8C9B [email protected] http://www.aurel32.net