All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] exec: fix tlb_vaddr_to_host()
@ 2016-09-21 17:06 Laurent Vivier
  2016-09-22  6:57 ` Laurent Vivier
  2016-09-22  7:23 ` Aurelien Jarno
  0 siblings, 2 replies; 3+ messages in thread
From: Laurent Vivier @ 2016-09-21 17:06 UTC (permalink / raw)
  To: rth; +Cc: aurelien, afaerber, qemu-devel, 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 "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.

Fixes: "c9f82d0 ppc: Speed up dcbz"
Reported-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 include/exec/cpu_ldst.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
index b573df5..6eb5fe8 100644
--- a/include/exec/cpu_ldst.h
+++ b/include/exec/cpu_ldst.h
@@ -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];
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] exec: fix tlb_vaddr_to_host()
  2016-09-21 17:06 [Qemu-devel] [PATCH] exec: fix tlb_vaddr_to_host() Laurent Vivier
@ 2016-09-22  6:57 ` Laurent Vivier
  2016-09-22  7:23 ` Aurelien Jarno
  1 sibling, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2016-09-22  6:57 UTC (permalink / raw)
  To: rth; +Cc: aurelien, afaerber, qemu-devel, Benjamin Herrenschmidt

Already fixed by a Ben's non applied patch:

  http://patchwork.ozlabs.org/patch/655238/

Laurent

On 21/09/2016 19:06, Laurent Vivier wrote:
> 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.
> 
> Fixes: "c9f82d0 ppc: Speed up dcbz"
> Reported-by: Andreas Färber <afaerber@suse.de>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
>  include/exec/cpu_ldst.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
> index b573df5..6eb5fe8 100644
> --- a/include/exec/cpu_ldst.h
> +++ b/include/exec/cpu_ldst.h
> @@ -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];
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] exec: fix tlb_vaddr_to_host()
  2016-09-21 17:06 [Qemu-devel] [PATCH] exec: fix tlb_vaddr_to_host() Laurent Vivier
  2016-09-22  6:57 ` Laurent Vivier
@ 2016-09-22  7:23 ` Aurelien Jarno
  1 sibling, 0 replies; 3+ messages in thread
From: Aurelien Jarno @ 2016-09-22  7:23 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: rth, afaerber, qemu-devel

On 2016-09-21 19:06, Laurent Vivier wrote:
> 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.
> 
> Fixes: "c9f82d0 ppc: Speed up dcbz"
> Reported-by: Andreas Färber <afaerber@suse.de>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
>  include/exec/cpu_ldst.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
> index b573df5..6eb5fe8 100644
> --- a/include/exec/cpu_ldst.h
> +++ b/include/exec/cpu_ldst.h
> @@ -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.

Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                 http://www.aurel32.net

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-22  7:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-21 17:06 [Qemu-devel] [PATCH] exec: fix tlb_vaddr_to_host() Laurent Vivier
2016-09-22  6:57 ` Laurent Vivier
2016-09-22  7:23 ` Aurelien Jarno

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.