From nobody Wed Oct 29 09:12:06 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512396414468395.50166650668905; Mon, 4 Dec 2017 06:06:54 -0800 (PST) Received: from localhost ([::1]:43390 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eLrOM-0005Do-Jt for importer@patchew.org; Mon, 04 Dec 2017 09:06:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51510) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eLrKL-0001P2-0z for qemu-devel@nongnu.org; Mon, 04 Dec 2017 09:02:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eLrKE-0006zU-RT for qemu-devel@nongnu.org; Mon, 04 Dec 2017 09:02:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52340) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eLrKE-0006z5-Ji; Mon, 04 Dec 2017 09:02:26 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ADB2B5F159; Mon, 4 Dec 2017 14:02:25 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-70.ams2.redhat.com [10.36.116.70]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DF4F65E86; Mon, 4 Dec 2017 14:02:18 +0000 (UTC) From: David Hildenbrand To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 4 Dec 2017 15:01:48 +0100 Message-Id: <20171204140150.20483-8-david@redhat.com> In-Reply-To: <20171204140150.20483-1-david@redhat.com> References: <20171204140150.20483-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 04 Dec 2017 14:02:25 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 for-2.12 7/9] s390x/tcg: implement extract-CPU-time facility X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Alexander Graf , Christian Borntraeger , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It only provies the EXTRACT CPU TIME instruction. We can reuse the stpt helper, which calculates the CPU timer value. As the instruction is not priviledged, but we don't have a CPU timer value in case of linux user, we simply fake the CPU timer to be 0. Signed-off-by: David Hildenbrand --- target/s390x/cpu_models.c | 1 + target/s390x/insn-data.def | 2 ++ target/s390x/translate.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 94d24e423d..0be037eac1 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -834,6 +834,7 @@ static void add_qemu_cpu_model_features(S390FeatBitmap = fbm) S390_FEAT_STORE_CLOCK_FAST, S390_FEAT_MOVE_WITH_OPTIONAL_SPEC, S390_FEAT_ETF3_ENH, + S390_FEAT_EXTRACT_CPU_TIME, S390_FEAT_COMPARE_AND_SWAP_AND_STORE, S390_FEAT_COMPARE_AND_SWAP_AND_STORE_2, S390_FEAT_GENERAL_INSTRUCTIONS_EXT, diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def index f7b66b0091..5e33bd27ff 100644 --- a/target/s390x/insn-data.def +++ b/target/s390x/insn-data.def @@ -369,6 +369,8 @@ C(0xb24f, EAR, RRE, Z, 0, 0, new, r1_32, ear, 0) /* EXTRACT CPU ATTRIBUTE */ C(0xeb4c, ECAG, RSY_a, GIE, 0, a2, r1, 0, ecag, 0) +/* EXTRACT CPU TIME */ + C(0xc801, ECTG, SSF, ECT, 0, 0, 0, 0, ectg, 0) /* EXTRACT FPC */ C(0xb38c, EFPC, RRE, Z, 0, 0, new, r1_32, efpc, 0) /* EXTRACT PSW */ diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 1e4079464a..e0f55fc8e9 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -3887,6 +3887,41 @@ static ExitStatus op_spm(DisasContext *s, DisasOps *= o) return NO_EXIT; } =20 +static ExitStatus op_ectg(DisasContext *s, DisasOps *o) +{ + int b1 =3D get_field(s->fields, b1); + int d1 =3D get_field(s->fields, d1); + int b2 =3D get_field(s->fields, b2); + int d2 =3D get_field(s->fields, d2); + int r3 =3D get_field(s->fields, r3); + TCGv_i64 tmp =3D tcg_temp_new_i64(); + + /* fetch all operands first */ + o->in1 =3D tcg_temp_new_i64(); + tcg_gen_addi_i64(o->in1, regs[b1], d1); + o->in2 =3D tcg_temp_new_i64(); + tcg_gen_addi_i64(o->in2, regs[b2], d2); + o->addr1 =3D get_address(s, 0, r3, 0); + + /* load the third operand into r3 before modifying anything */ + tcg_gen_qemu_ld64(regs[r3], o->addr1, get_mem_index(s)); + +#ifndef CONFIG_USER_ONLY + /* subtract CPU timer from first operand and store in GR0 */ + gen_helper_stpt(tmp, cpu_env); + tcg_gen_sub_i64(regs[0], o->in1, tmp); +#else + /* we don't have a CPU timer, fake value 0 */ + tcg_gen_mov_i64(regs[0], o->in1); +#endif + + /* store second operand in GR1 */ + tcg_gen_mov_i64(regs[1], o->in2); + + tcg_temp_free_i64(tmp); + return NO_EXIT; +} + #ifndef CONFIG_USER_ONLY static ExitStatus op_spka(DisasContext *s, DisasOps *o) { @@ -5639,6 +5674,7 @@ enum DisasInsnEnum { #define FAC_MSA3 S390_FEAT_MSA_EXT_3 /* msa-extension-3 facility */ #define FAC_MSA4 S390_FEAT_MSA_EXT_4 /* msa-extension-4 facility */ #define FAC_MSA5 S390_FEAT_MSA_EXT_5 /* msa-extension-5 facility */ +#define FAC_ECT S390_FEAT_EXTRACT_CPU_TIME =20 static const DisasInsn insn_info[] =3D { #include "insn-data.def" --=20 2.14.3