From: Thomas Huth <thuth@redhat.com>
To: Giovanni Mascellani <gio@debian.org>,
Cornelia Huck <cohuck@redhat.com>,
David Hildenbrand <david@redhat.com>
Cc: Bug 1815024 <1815024@bugs.launchpad.net>, qemu-devel@nongnu.org
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 [thread overview]
Message-ID: <ffb48b9f-fc99-0766-925c-4f79c692cba7@redhat.com> (raw)
In-Reply-To: <6c5ac94e-065f-e66a-2df2-5d8ac81c76e1@debian.org>
[-- Attachment #1: Type: text/plain, Size: 3964 bytes --]
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
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2019-02-07 11:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-07 9:46 [Qemu-devel] [Bug 1815024] [NEW] SIGILL on instruction "stck" under qemu-s390x in user mode Giovanni Mascellani
2019-02-07 9:46 ` [Qemu-devel] [Bug 1815024] " Giovanni Mascellani
2019-02-07 9:46 ` Giovanni Mascellani
2019-02-07 9:48 ` Giovanni Mascellani
2019-02-07 10:49 ` [Qemu-devel] [Bug 1815024] [NEW] " Cornelia Huck
2019-02-07 11:05 ` Giovanni Mascellani
2019-02-07 11:26 ` Thomas Huth [this message]
2019-02-07 11:46 ` Giovanni Mascellani
2019-02-07 12:01 ` Thomas Huth
2019-02-07 12:15 ` Richard Henderson
2019-02-07 12:36 ` Thomas Huth
2019-02-07 13:05 ` Richard Henderson
2019-02-07 13:00 ` Giovanni Mascellani
2019-02-07 13:09 ` Thomas Huth
2019-02-22 15:24 ` [Qemu-devel] [Bug 1815024] " Thomas Huth
2019-04-24 6:09 ` Thomas Huth
2019-04-24 6:09 ` Thomas Huth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ffb48b9f-fc99-0766-925c-4f79c692cba7@redhat.com \
--to=thuth@redhat.com \
--cc=1815024@bugs.launchpad.net \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=gio@debian.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).