* [Qemu-devel] [PATCH v3 0/2] target/s390x: Implement STCK et al for CONFIG_USER_ONLY
@ 2019-02-12 5:30 Richard Henderson
2019-02-12 5:30 ` [Qemu-devel] [PATCH v3 1/2] target/s390x: Split out s390-tod.h Richard Henderson
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Richard Henderson @ 2019-02-12 5:30 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-s390x, cohuck
Changes since v2:
* Fix botched subject line, include r-b tags.
Changes since v1:
* Move more of hw/s390x/tod.h to a new header.
* Use time2tod.
r~
Richard Henderson (2):
target/s390x: Split out s390-tod.h
target/s390x: Implement STCK et al for CONFIG_USER_ONLY
include/hw/s390x/tod.h | 16 +---------------
target/s390x/helper.h | 2 +-
target/s390x/s390-tod.h | 29 +++++++++++++++++++++++++++++
target/s390x/misc_helper.c | 34 ++++++++++++++++++++++------------
target/s390x/translate.c | 2 ++
target/s390x/insn-data.def | 11 ++++++-----
6 files changed, 61 insertions(+), 33 deletions(-)
create mode 100644 target/s390x/s390-tod.h
--
2.17.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH v3 1/2] target/s390x: Split out s390-tod.h
2019-02-12 5:30 [Qemu-devel] [PATCH v3 0/2] target/s390x: Implement STCK et al for CONFIG_USER_ONLY Richard Henderson
@ 2019-02-12 5:30 ` Richard Henderson
2019-02-12 5:30 ` [Qemu-devel] [PATCH v3 2/2] target/s390x: Implement STCK et al for CONFIG_USER_ONLY Richard Henderson
2019-02-12 9:11 ` [Qemu-devel] [PATCH v3 0/2] " Cornelia Huck
2 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2019-02-12 5:30 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-s390x, cohuck
We will need these from CONFIG_USER_ONLY as well,
which cannot access include/hw/.
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/hw/s390x/tod.h | 16 +---------------
target/s390x/s390-tod.h | 29 +++++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 15 deletions(-)
create mode 100644 target/s390x/s390-tod.h
diff --git a/include/hw/s390x/tod.h b/include/hw/s390x/tod.h
index 47ef9de869..9c4a6000c3 100644
--- a/include/hw/s390x/tod.h
+++ b/include/hw/s390x/tod.h
@@ -12,6 +12,7 @@
#define HW_S390_TOD_H
#include "hw/qdev.h"
+#include "s390-tod.h"
typedef struct S390TOD {
uint8_t high;
@@ -50,21 +51,6 @@ typedef struct S390TODClass {
void (*set)(S390TODState *td, const S390TOD *tod, Error **errp);
} S390TODClass;
-/* The value of the TOD clock for 1.1.1970. */
-#define TOD_UNIX_EPOCH 0x7d91048bca000000ULL
-
-/* Converts ns to s390's clock format */
-static inline uint64_t time2tod(uint64_t ns)
-{
- return (ns << 9) / 125 + (((ns & 0xff80000000000000ull) / 125) << 9);
-}
-
-/* Converts s390's clock format to ns */
-static inline uint64_t tod2time(uint64_t t)
-{
- return ((t >> 9) * 125) + (((t & 0x1ff) * 125) >> 9);
-}
-
void s390_init_tod(void);
S390TODState *s390_get_todstate(void);
diff --git a/target/s390x/s390-tod.h b/target/s390x/s390-tod.h
new file mode 100644
index 0000000000..8b74d6a6d8
--- /dev/null
+++ b/target/s390x/s390-tod.h
@@ -0,0 +1,29 @@
+/*
+ * TOD (Time Of Day) clock
+ *
+ * Copyright 2018 Red Hat, Inc.
+ * Author(s): David Hildenbrand <david@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef TARGET_S390_TOD_H
+#define TARGET_S390_TOD_H
+
+/* The value of the TOD clock for 1.1.1970. */
+#define TOD_UNIX_EPOCH 0x7d91048bca000000ULL
+
+/* Converts ns to s390's clock format */
+static inline uint64_t time2tod(uint64_t ns)
+{
+ return (ns << 9) / 125 + (((ns & 0xff80000000000000ull) / 125) << 9);
+}
+
+/* Converts s390's clock format to ns */
+static inline uint64_t tod2time(uint64_t t)
+{
+ return ((t >> 9) * 125) + (((t & 0x1ff) * 125) >> 9);
+}
+
+#endif
--
2.17.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH v3 2/2] target/s390x: Implement STCK et al for CONFIG_USER_ONLY
2019-02-12 5:30 [Qemu-devel] [PATCH v3 0/2] target/s390x: Implement STCK et al for CONFIG_USER_ONLY Richard Henderson
2019-02-12 5:30 ` [Qemu-devel] [PATCH v3 1/2] target/s390x: Split out s390-tod.h Richard Henderson
@ 2019-02-12 5:30 ` Richard Henderson
2019-02-12 9:11 ` [Qemu-devel] [PATCH v3 0/2] " Cornelia Huck
2 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2019-02-12 5:30 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-s390x, cohuck
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>
---
target/s390x/helper.h | 2 +-
target/s390x/misc_helper.c | 34 ++++++++++++++++++++++------------
target/s390x/translate.c | 2 ++
target/s390x/insn-data.def | 11 ++++++-----
4 files changed, 31 insertions(+), 18 deletions(-)
diff --git a/target/s390x/helper.h b/target/s390x/helper.h
index 018e9dd414..6260b50496 100644
--- a/target/s390x/helper.h
+++ b/target/s390x/helper.h
@@ -121,13 +121,13 @@ DEF_HELPER_4(cu41, i32, env, i32, i32, i32)
DEF_HELPER_4(cu42, i32, env, i32, i32, i32)
DEF_HELPER_5(msa, i32, env, i32, i32, i32, i32)
DEF_HELPER_FLAGS_1(stpt, TCG_CALL_NO_RWG, i64, env)
+DEF_HELPER_FLAGS_1(stck, TCG_CALL_NO_RWG_SE, i64, env)
#ifndef CONFIG_USER_ONLY
DEF_HELPER_3(servc, i32, env, i64, i64)
DEF_HELPER_4(diag, void, env, i32, i32, i32)
DEF_HELPER_3(load_psw, noreturn, env, i64, i64)
DEF_HELPER_FLAGS_2(spx, TCG_CALL_NO_RWG, void, env, i64)
-DEF_HELPER_FLAGS_1(stck, TCG_CALL_NO_RWG_SE, i64, env)
DEF_HELPER_FLAGS_2(sck, TCG_CALL_NO_RWG, i32, env, i64)
DEF_HELPER_FLAGS_2(sckc, TCG_CALL_NO_RWG, void, env, i64)
DEF_HELPER_FLAGS_2(sckpf, TCG_CALL_NO_RWG, void, env, i64)
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();
diff --git a/target/s390x/translate.c b/target/s390x/translate.c
index 639084af07..19072efec6 100644
--- a/target/s390x/translate.c
+++ b/target/s390x/translate.c
@@ -4060,6 +4060,7 @@ static DisasJumpType op_stap(DisasContext *s, DisasOps *o)
tcg_gen_ld32u_i64(o->out, cpu_env, offsetof(CPUS390XState, core_id));
return DISAS_NEXT;
}
+#endif
static DisasJumpType op_stck(DisasContext *s, DisasOps *o)
{
@@ -4096,6 +4097,7 @@ static DisasJumpType op_stcke(DisasContext *s, DisasOps *o)
return DISAS_NEXT;
}
+#ifndef CONFIG_USER_ONLY
static DisasJumpType op_sck(DisasContext *s, DisasOps *o)
{
tcg_gen_qemu_ld_i64(o->in1, o->addr1, get_mem_index(s), MO_TEQ | MO_ALIGN);
diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def
index dab805fd90..61582372ab 100644
--- a/target/s390x/insn-data.def
+++ b/target/s390x/insn-data.def
@@ -837,6 +837,12 @@
C(0xe33e, STRV, RXY_a, Z, la2, r1_32u, new, m1_32, rev32, 0)
C(0xe32f, STRVG, RXY_a, Z, la2, r1_o, new, m1_64, rev64, 0)
+/* STORE CLOCK */
+ C(0xb205, STCK, S, Z, la2, 0, new, m1_64, stck, 0)
+ C(0xb27c, STCKF, S, SCF, la2, 0, new, m1_64, stck, 0)
+/* STORE CLOCK EXTENDED */
+ C(0xb278, STCKE, S, Z, 0, a2, 0, 0, stcke, 0)
+
/* STORE FACILITY LIST EXTENDED */
C(0xb2b0, STFLE, S, SFLE, 0, a2, 0, 0, stfle, 0)
/* STORE FPC */
@@ -1020,11 +1026,6 @@
F(0x8000, SSM, S, Z, 0, m2_8u, 0, 0, ssm, 0, IF_PRIV)
/* SIGNAL PROCESSOR */
F(0xae00, SIGP, RS_a, Z, 0, a2, 0, 0, sigp, 0, IF_PRIV)
-/* STORE CLOCK */
- C(0xb205, STCK, S, Z, la2, 0, new, m1_64, stck, 0)
- C(0xb27c, STCKF, S, SCF, la2, 0, new, m1_64, stck, 0)
-/* STORE CLOCK EXTENDED */
- C(0xb278, STCKE, S, Z, 0, a2, 0, 0, stcke, 0)
/* STORE CLOCK COMPARATOR */
F(0xb207, STCKC, S, Z, la2, 0, new, m1_64a, stckc, 0, IF_PRIV)
/* STORE CONTROL */
--
2.17.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v3 0/2] target/s390x: Implement STCK et al for CONFIG_USER_ONLY
2019-02-12 5:30 [Qemu-devel] [PATCH v3 0/2] target/s390x: Implement STCK et al for CONFIG_USER_ONLY Richard Henderson
2019-02-12 5:30 ` [Qemu-devel] [PATCH v3 1/2] target/s390x: Split out s390-tod.h Richard Henderson
2019-02-12 5:30 ` [Qemu-devel] [PATCH v3 2/2] target/s390x: Implement STCK et al for CONFIG_USER_ONLY Richard Henderson
@ 2019-02-12 9:11 ` Cornelia Huck
2 siblings, 0 replies; 4+ messages in thread
From: Cornelia Huck @ 2019-02-12 9:11 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-devel, qemu-s390x
On Mon, 11 Feb 2019 21:30:42 -0800
Richard Henderson <richard.henderson@linaro.org> wrote:
> Changes since v2:
> * Fix botched subject line, include r-b tags.
>
> Changes since v1:
> * Move more of hw/s390x/tod.h to a new header.
> * Use time2tod.
>
>
> r~
>
>
> Richard Henderson (2):
> target/s390x: Split out s390-tod.h
> target/s390x: Implement STCK et al for CONFIG_USER_ONLY
>
> include/hw/s390x/tod.h | 16 +---------------
> target/s390x/helper.h | 2 +-
> target/s390x/s390-tod.h | 29 +++++++++++++++++++++++++++++
> target/s390x/misc_helper.c | 34 ++++++++++++++++++++++------------
> target/s390x/translate.c | 2 ++
> target/s390x/insn-data.def | 11 ++++++-----
> 6 files changed, 61 insertions(+), 33 deletions(-)
> create mode 100644 target/s390x/s390-tod.h
>
Thanks, applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-02-12 9:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-12 5:30 [Qemu-devel] [PATCH v3 0/2] target/s390x: Implement STCK et al for CONFIG_USER_ONLY Richard Henderson
2019-02-12 5:30 ` [Qemu-devel] [PATCH v3 1/2] target/s390x: Split out s390-tod.h Richard Henderson
2019-02-12 5:30 ` [Qemu-devel] [PATCH v3 2/2] target/s390x: Implement STCK et al for CONFIG_USER_ONLY Richard Henderson
2019-02-12 9:11 ` [Qemu-devel] [PATCH v3 0/2] " Cornelia Huck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).