[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [Bug 1815024] [NEW] SIGILL on instruction "stck" under
From: |
Thomas Huth |
Subject: |
Re: [Qemu-devel] [Bug 1815024] [NEW] SIGILL on instruction "stck" under qemu-s390x in user mode |
Date: |
Thu, 7 Feb 2019 12:26:42 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 |
On 2019-02-07 12:05, Giovanni Mascellani wrote:
> Hi, thanks for answering!
>
> Il 07/02/19 11:49, Cornelia Huck ha scritto:
>> Did that work before commit 7de3b1cdc67 ("s390x/tcg: properly implement
>> the TOD")?
>
> It does not seem so
The problem is rather that the STCK instruction is fenced with
"#ifndef CONFIG_USER_ONLY" ... quick-n-dirty hack to allow it:
diff --git a/target/s390x/helper.h b/target/s390x/helper.h
index 018e9dd..8baa784 100644
--- a/target/s390x/helper.h
+++ b/target/s390x/helper.h
@@ -122,12 +122,13 @@ 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/insn-data.def b/target/s390x/insn-data.def
index dab805f..41e2911 100644
--- a/target/s390x/insn-data.def
+++ b/target/s390x/insn-data.def
@@ -962,6 +962,10 @@
D(0xb93e, KIMD, RRE, MSA, 0, 0, 0, 0, msa, 0, S390_FEAT_TYPE_KIMD)
D(0xb93f, KLMD, RRE, MSA, 0, 0, 0, 0, msa, 0, S390_FEAT_TYPE_KLMD)
+/* 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)
+
#ifndef CONFIG_USER_ONLY
/* COMPARE AND SWAP AND PURGE */
E(0xb250, CSP, RRE, Z, r1_32u, ra2, r1_P, 0, csp, 0, MO_TEUL,
IF_PRIV)
@@ -1020,9 +1024,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 */
diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c
index 52262f6..b9eea7f 100644
--- a/target/s390x/misc_helper.c
+++ b/target/s390x/misc_helper.c
@@ -396,6 +396,16 @@ uint32_t HELPER(sigp)(CPUS390XState *env, uint64_t
order_code, uint32_t r1,
return cc;
}
+
+#else
+
+uint64_t HELPER(stck)(CPUS390XState *env)
+{
+ uint64_t ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
+
+ return (ns << 9) / 125 + (((ns & 0xff80000000000000ull) / 125) << 9);
+}
+
#endif
#ifndef CONFIG_USER_ONLY
diff --git a/target/s390x/translate.c b/target/s390x/translate.c
index 639084a..177e281 100644
--- a/target/s390x/translate.c
+++ b/target/s390x/translate.c
@@ -4034,6 +4034,14 @@ static DisasJumpType op_ectg(DisasContext *s, DisasOps
*o)
return DISAS_NEXT;
}
+static DisasJumpType op_stck(DisasContext *s, DisasOps *o)
+{
+ gen_helper_stck(o->out, cpu_env);
+ /* ??? We don't implement clock states. */
+ gen_op_movi_cc(s, 0);
+ return DISAS_NEXT;
+}
+
#ifndef CONFIG_USER_ONLY
static DisasJumpType op_spka(DisasContext *s, DisasOps *o)
{
@@ -4061,14 +4069,6 @@ static DisasJumpType op_stap(DisasContext *s, DisasOps
*o)
return DISAS_NEXT;
}
-static DisasJumpType op_stck(DisasContext *s, DisasOps *o)
-{
- gen_helper_stck(o->out, cpu_env);
- /* ??? We don't implement clock states. */
- gen_op_movi_cc(s, 0);
- return DISAS_NEXT;
-}
-
static DisasJumpType op_stcke(DisasContext *s, DisasOps *o)
{
TCGv_i64 c1 = tcg_temp_new_i64();
... then your test program works fine without crashing.
Thomas
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [Bug 1815024] [NEW] SIGILL on instruction "stck" under qemu-s390x in user mode, Giovanni Mascellani, 2019/02/07
- [Qemu-devel] [Bug 1815024] Re: SIGILL on instruction "stck" under qemu-s390x in user mode, Giovanni Mascellani, 2019/02/07
- [Qemu-devel] [Bug 1815024] Re: SIGILL on instruction "stck" under qemu-s390x in user mode, Giovanni Mascellani, 2019/02/07
- [Qemu-devel] [Bug 1815024] Re: SIGILL on instruction "stck" under qemu-s390x in user mode, Giovanni Mascellani, 2019/02/07
- Re: [Qemu-devel] [Bug 1815024] [NEW] SIGILL on instruction "stck" under qemu-s390x in user mode, Cornelia Huck, 2019/02/07
- Re: [Qemu-devel] [Bug 1815024] [NEW] SIGILL on instruction "stck" under qemu-s390x in user mode, Giovanni Mascellani, 2019/02/07
- Re: [Qemu-devel] [Bug 1815024] [NEW] SIGILL on instruction "stck" under qemu-s390x in user mode,
Thomas Huth <=
- Re: [Qemu-devel] [Bug 1815024] [NEW] SIGILL on instruction "stck" under qemu-s390x in user mode, Giovanni Mascellani, 2019/02/07
- Re: [Qemu-devel] [Bug 1815024] [NEW] SIGILL on instruction "stck" under qemu-s390x in user mode, Thomas Huth, 2019/02/07
- Re: [Qemu-devel] [Bug 1815024] [NEW] SIGILL on instruction "stck" under qemu-s390x in user mode, Richard Henderson, 2019/02/07
- Re: [Qemu-devel] [Bug 1815024] [NEW] SIGILL on instruction "stck" under qemu-s390x in user mode, Thomas Huth, 2019/02/07
- Re: [Qemu-devel] [Bug 1815024] [NEW] SIGILL on instruction "stck" under qemu-s390x in user mode, Richard Henderson, 2019/02/07
- Re: [Qemu-devel] [Bug 1815024] [NEW] SIGILL on instruction "stck" under qemu-s390x in user mode, Giovanni Mascellani, 2019/02/07
- Re: [Qemu-devel] [Bug 1815024] [NEW] SIGILL on instruction "stck" under qemu-s390x in user mode, Thomas Huth, 2019/02/07
[Qemu-devel] [Bug 1815024] Re: SIGILL on instruction "stck" under qemu-s390x in user mode, Thomas Huth, 2019/02/22