Skip to contentSkip to conversation

linux-user: SPARC "rd %tick" can be used by user application

PATCH In review Laurent Vivier 2 participants 2 messages May 28, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: SPARC "rd %tick" can be used by user application

we have the same problem decribed in 7d6b1daedd ("linux-user, ppc: mftbl can be used by user application") for ppc in the case of sparc.

When we use an application trying to resolve a name, it hangs in

    0x00000000ff5dd40c:  rd  %tick, %o5
    0x00000000ff5dd410:  srlx  %o5, 0x20, %o4
    0x00000000ff5dd414:  btst  %o5, %g4
    0x00000000ff5dd418:  be  %icc, 0xff5dd40c

because %tick is staying at 0.

As QEMU_CLOCK_VIRTUAL is not available in linux-user mode, simply use cpu_get_host_ticks() instead.

---
 target/sparc/helper.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
target/sparc/helper.c +3 -1
index 1d854890b4..46232788c8 100644
@@ -67,7 +67,9 @@ uint64_t helper_tick_get_count(CPUSPARCState *env, void *opaque, int mem_idx)
 
     return cpu_tick_get_count(timer);
 #else
-    return 0;
+    /* In user-mode, QEMU_CLOCK_VIRTUAL doesn't exist.
+       Just pass through the host cpu clock ticks.  */
+    return cpu_get_host_ticks();
 #endif
 }
 
Signature · 1 line
2.14.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Laurent Vivier

we have the same problem decribed in 7d6b1daedd ("linux-user, ppc: mftbl can be used by user application") for ppc in the case of sparc.

When we use an application trying to resolve a name, it hangs in

    0x00000000ff5dd40c:  rd  %tick, %o5
    0x00000000ff5dd410:  srlx  %o5, 0x20, %o4
    0x00000000ff5dd414:  btst  %o5, %g4
    0x00000000ff5dd418:  be  %icc, 0xff5dd40c
Quoted 6 lines

because %tick is staying at 0.

As QEMU_CLOCK_VIRTUAL is not available in linux-user mode, simply use cpu_get_host_ticks() instead.

Quoted 20 lines
---
 target/sparc/helper.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
target/sparc/helper.c +3 -1
index 1d854890b4..46232788c8 100644
@@ -67,7 +67,9 @@ uint64_t helper_tick_get_count(CPUSPARCState *env, void *opaque, int mem_idx)
 
     return cpu_tick_get_count(timer);
 #else
-    return 0;
+    /* In user-mode, QEMU_CLOCK_VIRTUAL doesn't exist.
+       Just pass through the host cpu clock ticks.  */
+    return cpu_get_host_ticks();
 #endif
 }