All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] linux-user, ppc: mftbl can be used by user application
       [not found] <55925E00.4090308@suse.de>
@ 2015-06-30  9:49 ` Laurent Vivier
  2015-06-30  9:52   ` Alexander Graf
  0 siblings, 1 reply; 2+ messages in thread
From: Laurent Vivier @ 2015-06-30  9:49 UTC (permalink / raw)
  To: Alexander Graf, Riku Voipio; +Cc: qemu-ppc, qemu-devel, Laurent Vivier

In qemu-linux-user, when calling gethostbyname2(),
it was hanging in .__res_nmkquery.

(gdb) bt
0 in .__res_nmkquery () from /lib64/libresolv.so.2
1 in .__libc_res_nquery () from /lib64/libresolv.so.2
2 in .__libc_res_nsearch () from /lib64/libresolv.so.2
3 in ._nss_dns_gethostbyname3_r () from /lib64/libnss_dns.so.2
4 in ._nss_dns_gethostbyname2_r () from /lib64/libnss_dns.so.2
5 in .gethostbyname2_r () from /lib64/libc.so.6
6 in .gethostbyname2 () from /lib64/libc.so.6

.__res_nmkquery() is:

...
do { RANDOM_BITS (randombits); } while ((randombits & 0xffff) == 0);
...

<.__res_nmkquery+112>:	mftbl   r11
<.__res_nmkquery+116>:	clrlwi  r10,r11,16
<.__res_nmkquery+120>:	cmpwi   cr7,r10,0
<.__res_nmkquery+124>:	beq     cr7,<.__res_nmkquery+112>

but as mftbl (Move From Time Base Lower) is not implemented,
r11 is always 0, so we have an infinite loop.

This patch fills the Time Base register with cpu_get_real_ticks().

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/linux-user/main.c b/linux-user/main.c
index 47ab017..9879370 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -1424,8 +1424,7 @@ void cpu_loop (CPUSPARCState *env)
 #ifdef TARGET_PPC
 static inline uint64_t cpu_ppc_get_tb(CPUPPCState *env)
 {
-    /* TO FIX */
-    return 0;
+    return cpu_get_real_ticks();
 }
 
 uint64_t cpu_ppc_load_tbl(CPUPPCState *env)
-- 
2.4.3

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

* Re: [Qemu-devel] [PATCH] linux-user, ppc: mftbl can be used by user application
  2015-06-30  9:49 ` [Qemu-devel] [PATCH] linux-user, ppc: mftbl can be used by user application Laurent Vivier
@ 2015-06-30  9:52   ` Alexander Graf
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Graf @ 2015-06-30  9:52 UTC (permalink / raw)
  To: Laurent Vivier, Riku Voipio; +Cc: qemu-ppc, qemu-devel

On 06/30/15 11:49, Laurent Vivier wrote:
> In qemu-linux-user, when calling gethostbyname2(),
> it was hanging in .__res_nmkquery.
>
> (gdb) bt
> 0 in .__res_nmkquery () from /lib64/libresolv.so.2
> 1 in .__libc_res_nquery () from /lib64/libresolv.so.2
> 2 in .__libc_res_nsearch () from /lib64/libresolv.so.2
> 3 in ._nss_dns_gethostbyname3_r () from /lib64/libnss_dns.so.2
> 4 in ._nss_dns_gethostbyname2_r () from /lib64/libnss_dns.so.2
> 5 in .gethostbyname2_r () from /lib64/libc.so.6
> 6 in .gethostbyname2 () from /lib64/libc.so.6
>
> .__res_nmkquery() is:
>
> ...
> do { RANDOM_BITS (randombits); } while ((randombits & 0xffff) == 0);
> ...
>
> <.__res_nmkquery+112>:	mftbl   r11
> <.__res_nmkquery+116>:	clrlwi  r10,r11,16
> <.__res_nmkquery+120>:	cmpwi   cr7,r10,0
> <.__res_nmkquery+124>:	beq     cr7,<.__res_nmkquery+112>
>
> but as mftbl (Move From Time Base Lower) is not implemented,
> r11 is always 0, so we have an infinite loop.
>
> This patch fills the Time Base register with cpu_get_real_ticks().
>
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>

Thanks, applied to ppc-next. Riku, if you want to veto, feel free to :).


Alex

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

end of thread, other threads:[~2015-06-30  9:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <55925E00.4090308@suse.de>
2015-06-30  9:49 ` [Qemu-devel] [PATCH] linux-user, ppc: mftbl can be used by user application Laurent Vivier
2015-06-30  9:52   ` Alexander Graf

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.