aboutsummaryrefslogtreecommitdiff
path: root/target/s390x/misc_helper.c
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2019-02-11 21:30:44 -0800
committerCornelia Huck <cohuck@redhat.com>2019-02-18 11:25:43 +0100
commit965018bea7ce79e1987b50ba9160cba957f015df (patch)
treea4e15366471490bf25b2e7e8d48d76ad1a8b57b0 /target/s390x/misc_helper.c
parent4037c39ba5d0507fa9e1ee302013b4b35e2526f5 (diff)
target/s390x: Implement STCK et al for CONFIG_USER_ONLY
This is a non-privileged instruction that was only implemented for system mode. However, the stck instruction is used by glibc, so this was causing SIGILL for programs run under debian stretch. Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: David Hildenbrand <david@redhat.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20190212053044.29015-3-richard.henderson@linaro.org> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Diffstat (limited to 'target/s390x/misc_helper.c')
-rw-r--r--target/s390x/misc_helper.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c
index 52262f62df..ee67c1fa0c 100644
--- a/target/s390x/misc_helper.c
+++ b/target/s390x/misc_helper.c
@@ -30,6 +30,7 @@
#include "exec/cpu_ldst.h"
#include "qapi/error.h"
#include "tcg_s390x.h"
+#include "s390-tod.h"
#if !defined(CONFIG_USER_ONLY)
#include "sysemu/cpus.h"
@@ -76,8 +77,28 @@ uint64_t HELPER(stpt)(CPUS390XState *env)
#endif
}
-#ifndef CONFIG_USER_ONLY
+/* Store Clock */
+uint64_t HELPER(stck)(CPUS390XState *env)
+{
+#ifdef CONFIG_USER_ONLY
+ struct timespec ts;
+ uint64_t ns;
+
+ clock_gettime(CLOCK_REALTIME, &ts);
+ ns = ts.tv_sec * NANOSECONDS_PER_SECOND + ts.tv_nsec;
+
+ return TOD_UNIX_EPOCH + time2tod(ns);
+#else
+ S390TODState *td = s390_get_todstate();
+ S390TODClass *tdc = S390_TOD_GET_CLASS(td);
+ S390TOD tod;
+ tdc->get(td, &tod, &error_abort);
+ return tod.low;
+#endif
+}
+
+#ifndef CONFIG_USER_ONLY
/* SCLP service call */
uint32_t HELPER(servc)(CPUS390XState *env, uint64_t r1, uint64_t r2)
{
@@ -138,17 +159,6 @@ void HELPER(spx)(CPUS390XState *env, uint64_t a1)
tlb_flush_page(cs, TARGET_PAGE_SIZE);
}
-/* Store Clock */
-uint64_t HELPER(stck)(CPUS390XState *env)
-{
- S390TODState *td = s390_get_todstate();
- S390TODClass *tdc = S390_TOD_GET_CLASS(td);
- S390TOD tod;
-
- tdc->get(td, &tod, &error_abort);
- return tod.low;
-}
-
static void update_ckc_timer(CPUS390XState *env)
{
S390TODState *td = s390_get_todstate();