From nobody Wed Nov 5 12:15:31 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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153482003642198.51073541618803; Mon, 20 Aug 2018 19:53:56 -0700 (PDT) Received: from localhost ([::1]:50365 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frwnm-0005GT-Hg for importer@patchew.org; Mon, 20 Aug 2018 22:53:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frwlU-00046f-RR for qemu-devel@nongnu.org; Mon, 20 Aug 2018 22:51:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1frwlU-0004fl-2b for qemu-devel@nongnu.org; Mon, 20 Aug 2018 22:51:28 -0400 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:38213) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1frwlT-0004fZ-U2; Mon, 20 Aug 2018 22:51:28 -0400 Received: by mail-qt0-x243.google.com with SMTP id x7-v6so9343556qtk.5; Mon, 20 Aug 2018 19:51:27 -0700 (PDT) Received: from WAL-L-PZ01.rocketsoftware.com (inet-64-112-177-9.bos.netblazr.com. [64.112.177.9]) by smtp.gmail.com with ESMTPSA id d100-v6sm4897991qkh.34.2018.08.20.19.51.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 19:51:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NnmgDXEQMGI6UTn9ETE2TvJJVwHesQtyb5Q5gtvU5ss=; b=V3htgCVVAVDHff/sse21MlSRYxGKUQIU9F3b9JRlVnU2fUoeVLXTOfz+xR0UQNEoU/ Sb1Cube6R6Bvb/DfJRmcF37hZ9HdVJ26UZv414EGecO1zkE3JT9JlcI33+nDEw685PMq LZL8eUuGyvXC6Q9riobcXrl2ZtQyjg9CwFkL/XpG4cCPp047RQYVTL9zFzoAWfLvlWln GyK+3TUIyCgiBV66IcRKTZF6rigyHVA+8td1+2M28tZA1MtHGphJniC0YYpB6vhXkoE7 rgY6CBHS1IHFFnOOTYwGeBm/kNWukikmzaz8EXZhXMS2Qc7qckncJazgZAWwxR2VE3tX qw6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NnmgDXEQMGI6UTn9ETE2TvJJVwHesQtyb5Q5gtvU5ss=; b=VrWaYfdfugHdkyKLcSWzKZsNzBy+cSD//ZTpWsVlL+TiqwJHdAfI8V5MD4j3DqKkkL OFX0U88mLrm1azVCTSMeA96xdXoEa+rrUkqqtB8ldSHzBUyUjFStuYVJdEl7nBUr8SD4 3kayhnZ1+MW82uixggbHiJ0n2zU0nUfh4YSlIbnPgwId8iDsYagKDXqcayNP5uk4TeYG iB6HTC5YJC7Uq5GMX7yGdB+f79mcJrOj+1PR9c0jPT4v/wGxKDW/YtlvNSTzMCjjQdFD Dj9Bop/zjp1HBj7LD0jC+ojQC6q0l7eXMf56jUK7I7WZnWP4mhzJK1huBxJ9TQB6h5R9 Hkkw== X-Gm-Message-State: AOUpUlFhGl7eWT3WcC11Jqj1X97PK/g+oR5ZVDZe/cY4rABgdWEG4eFg rOgAo+ppePEef6IHAXSlbt2XbdWksmE= X-Google-Smtp-Source: AA+uWPxf+wwlGw6Eazb9ufJo6lBPGhPx725C8zneYdkQSEBZDf1QZpLObB0LPNEPos9hKGyQvlKTHg== X-Received: by 2002:a0c:fa4e:: with SMTP id k14-v6mr36868700qvo.35.1534819887385; Mon, 20 Aug 2018 19:51:27 -0700 (PDT) From: Pavel Zbitskiy To: qemu-devel@nongnu.org Date: Mon, 20 Aug 2018 22:50:58 -0400 Message-Id: <20180821025104.19604-2-pavel.zbitskiy@gmail.com> In-Reply-To: <20180821025104.19604-1-pavel.zbitskiy@gmail.com> References: <20180821025104.19604-1-pavel.zbitskiy@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::243 Subject: [Qemu-devel] [PATCH 1/7] tests/tcg: add a simple s390x test 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: Pavel Zbitskiy , qemu-s390x@nongnu.org, cohuck@redhat.com, richard.henderson@linaro.org, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Copied from alpha. Signed-off-by: Pavel Zbitskiy Reviewed-by: David Hildenbrand --- MAINTAINERS | 1 + tests/tcg/s390x/Makefile.target | 3 +++ tests/tcg/s390x/hello-s390x.c | 7 +++++++ 3 files changed, 11 insertions(+) create mode 100644 tests/tcg/s390x/Makefile.target create mode 100644 tests/tcg/s390x/hello-s390x.c diff --git a/MAINTAINERS b/MAINTAINERS index 6902a568f4..27af17caa7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -253,6 +253,7 @@ S: Maintained F: target/s390x/ F: hw/s390x/ F: disas/s390.c +F: tests/tcg/s390x/ L: qemu-s390x@nongnu.org =20 SH4 diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.tar= get new file mode 100644 index 0000000000..9f4076901f --- /dev/null +++ b/tests/tcg/s390x/Makefile.target @@ -0,0 +1,3 @@ +VPATH+=3D$(SRC_PATH)/tests/tcg/s390x +CFLAGS+=3D-march=3DzEC12 -m64 +TESTS+=3Dhello-s390x diff --git a/tests/tcg/s390x/hello-s390x.c b/tests/tcg/s390x/hello-s390x.c new file mode 100644 index 0000000000..3dc0a05f2b --- /dev/null +++ b/tests/tcg/s390x/hello-s390x.c @@ -0,0 +1,7 @@ +#include + +int main(void) +{ + write(1, "hello\n", 6); + return 0; +} --=20 2.18.0 From nobody Wed Nov 5 12:15:31 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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1534820037406848.115577274732; Mon, 20 Aug 2018 19:53:57 -0700 (PDT) Received: from localhost ([::1]:50366 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frwno-0005Hp-An for importer@patchew.org; Mon, 20 Aug 2018 22:53:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frwlW-00046g-C7 for qemu-devel@nongnu.org; Mon, 20 Aug 2018 22:51:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1frwlV-0004gY-JJ for qemu-devel@nongnu.org; Mon, 20 Aug 2018 22:51:30 -0400 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:37409) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1frwlV-0004gN-Et; Mon, 20 Aug 2018 22:51:29 -0400 Received: by mail-qt0-x241.google.com with SMTP id n6-v6so18638207qtl.4; Mon, 20 Aug 2018 19:51:29 -0700 (PDT) Received: from WAL-L-PZ01.rocketsoftware.com (inet-64-112-177-9.bos.netblazr.com. [64.112.177.9]) by smtp.gmail.com with ESMTPSA id d100-v6sm4897991qkh.34.2018.08.20.19.51.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 19:51:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DpbgLp8wct0YhozG0iWNjnDk+BOlqqTiSDODFGUJjZc=; b=HFKl+WVrsbGPV7Esible+66NDOtbLQya1fDbbsEGcw11VQgaZIbk82lvCLFfsuw4Y7 KXoLVCDYKvSysnBMf8Ra8kejAmwd/3v5nl40b8A03kyjMKUGWf/B6AKZz0bMvhwBGcTi jtN7YpiwMo74nrzzxZH0N5dzlWDSf0k0kui6zCsbux97seis/6RzOFcqFDooUBTPU/1k lfkjEll3fl13hbolZlxpvz3ZHBskxZkz+cti3QVN4U16YuI0CIFrwN5XyGQdxfqO0lQx b9wMhJ9gA8a2aYesPQ7Bd2hQAMEY9kWzLFYO22HZ5A3ADHaeW+CLO7vUdHKH5oLB2Tab zDRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DpbgLp8wct0YhozG0iWNjnDk+BOlqqTiSDODFGUJjZc=; b=idDGtk6va2kD78R3Yi9sOvfA25jQSrTY8hbArNOabNe7F9oh/pmzprHCDcMo2wsGh1 D6cwoyZyqX49OPm/a/P+wJ2YldNSIwkIbZZGZ9t2QYWEzzV1P1PjuwhQb+/0pocZC5h5 7KxzZK93CY8wA17vGLEPuEFifM0lVDFK+ctOwgx+b0SbfnlgKxUP8fuRbF/sKlGqpzc+ FGev+Gk1ZvD2wTUW3BpT4BqtOOJvotSI9pVsSjoIKIZXieselexHYmJR99RYJFwjjYqd qMoir376ZqYwtZd9O54CqEplcs0BoHAvMPUuEfsqyEF2WKGov+FOddiPya8faTIurZAr BBow== X-Gm-Message-State: AOUpUlFNftOFY6EikUo4B5+OMvwbzkC2M5J7WtrnEXpCgvrOWL2wREfU sU1hs4jgknbC+9v0Yh5fqkT8JQYorwA= X-Google-Smtp-Source: AA+uWPypXPcbjXKTwvhW3da3RIiPWgKAk2Xi7Esny6kuhnfMrLcmblvRGPpYXZXjofAk+vg6M+mDbQ== X-Received: by 2002:a0c:891a:: with SMTP id 26-v6mr44402860qvp.195.1534819888889; Mon, 20 Aug 2018 19:51:28 -0700 (PDT) From: Pavel Zbitskiy To: qemu-devel@nongnu.org Date: Mon, 20 Aug 2018 22:50:59 -0400 Message-Id: <20180821025104.19604-3-pavel.zbitskiy@gmail.com> In-Reply-To: <20180821025104.19604-1-pavel.zbitskiy@gmail.com> References: <20180821025104.19604-1-pavel.zbitskiy@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::241 Subject: [Qemu-devel] [PATCH 2/7] target/s390x: add BAL and BALR instructions 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: Pavel Zbitskiy , david@redhat.com, cohuck@redhat.com, richard.henderson@linaro.org, Alexander Graf , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" These instructions are provided for compatibility purposes and are used only by old software, in the new code BAS and BASR are preferred. The difference between the old and new instruction exists only in the 24-bit mode. In addition, fix BAS polluting high 32 bits of the first operand in 24- and 31-bit addressing modes. Signed-off-by: Pavel Zbitskiy Reviewed-by: David Hildenbrand --- target/s390x/insn-data.def | 3 +++ target/s390x/translate.c | 55 +++++++++++++++++++++++++++++++++----- 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def index 5c6f33ed9c..9c7b434fca 100644 --- a/target/s390x/insn-data.def +++ b/target/s390x/insn-data.def @@ -102,6 +102,9 @@ D(0x9400, NI, SI, Z, la1, i2_8u, new, 0, ni, nz64, MO_UB) D(0xeb54, NIY, SIY, LD, la1, i2_8u, new, 0, ni, nz64, MO_UB) =20 +/* BRANCH AND LINK */ + C(0x0500, BALR, RR_a, Z, 0, r2_nz, r1, 0, bal, 0) + C(0x4500, BAL, RX_a, Z, 0, a2, r1, 0, bal, 0) /* BRANCH AND SAVE */ C(0x0d00, BASR, RR_a, Z, 0, r2_nz, r1, 0, bas, 0) C(0x4d00, BAS, RX_a, Z, 0, a2, r1, 0, bas, 0) diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 57c03cbf58..111d575c41 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -84,14 +84,22 @@ static uint64_t inline_branch_hit[CC_OP_MAX]; static uint64_t inline_branch_miss[CC_OP_MAX]; #endif =20 -static uint64_t pc_to_link_info(DisasContext *s, uint64_t pc) +static void pc_to_link_info(TCGv_i64 out, DisasContext *s, uint64_t pc) { - if (!(s->base.tb->flags & FLAG_MASK_64)) { - if (s->base.tb->flags & FLAG_MASK_32) { - return pc | 0x80000000; + TCGv_i64 tmp; + + if (s->base.tb->flags & FLAG_MASK_32) { + if (s->base.tb->flags & FLAG_MASK_64) { + tcg_gen_movi_i64(out, pc); + return; } + pc |=3D 0x80000000; } - return pc; + assert(!(s->base.tb->flags & FLAG_MASK_64)); + tmp =3D tcg_temp_new_i64(); + tcg_gen_movi_i64(tmp, pc); + tcg_gen_deposit_i64(out, out, tmp, 0, 32); + tcg_temp_free_i64(tmp); } =20 static TCGv_i64 psw_addr; @@ -1453,7 +1461,40 @@ static DisasJumpType op_ni(DisasContext *s, DisasOps= *o) =20 static DisasJumpType op_bas(DisasContext *s, DisasOps *o) { - tcg_gen_movi_i64(o->out, pc_to_link_info(s, s->pc_tmp)); + pc_to_link_info(o->out, s, s->pc_tmp); + if (o->in2) { + tcg_gen_mov_i64(psw_addr, o->in2); + per_branch(s, false); + return DISAS_PC_UPDATED; + } else { + return DISAS_NEXT; + } +} + +static void save_link_info(DisasContext *s, DisasOps *o) +{ + TCGv_i64 t; + + if (s->base.tb->flags & (FLAG_MASK_32 | FLAG_MASK_64)) { + pc_to_link_info(o->out, s, s->pc_tmp); + return; + } + gen_op_calc_cc(s); + tcg_gen_andi_i64(o->out, o->out, 0xffffffff00000000ull); + tcg_gen_ori_i64(o->out, o->out, ((s->ilen / 2) << 30) | s->pc_tmp); + t =3D tcg_temp_new_i64(); + tcg_gen_shri_i64(t, psw_mask, 16); + tcg_gen_andi_i64(t, t, 0x0f000000); + tcg_gen_or_i64(o->out, o->out, t); + tcg_gen_extu_i32_i64(t, cc_op); + tcg_gen_shli_i64(t, t, 28); + tcg_gen_or_i64(o->out, o->out, t); + tcg_temp_free_i64(t); +} + +static DisasJumpType op_bal(DisasContext *s, DisasOps *o) +{ + save_link_info(s, o); if (o->in2) { tcg_gen_mov_i64(psw_addr, o->in2); per_branch(s, false); @@ -1465,7 +1506,7 @@ static DisasJumpType op_bas(DisasContext *s, DisasOps= *o) =20 static DisasJumpType op_basi(DisasContext *s, DisasOps *o) { - tcg_gen_movi_i64(o->out, pc_to_link_info(s, s->pc_tmp)); + pc_to_link_info(o->out, s, s->pc_tmp); return help_goto_direct(s, s->base.pc_next + 2 * get_field(s->fields, = i2)); } =20 --=20 2.18.0 From nobody Wed Nov 5 12:15:31 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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1534820172153399.6985742664681; Mon, 20 Aug 2018 19:56:12 -0700 (PDT) Received: from localhost ([::1]:50387 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frwq3-00087Y-3S for importer@patchew.org; Mon, 20 Aug 2018 22:56:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54353) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frwlX-00047u-Qq for qemu-devel@nongnu.org; Mon, 20 Aug 2018 22:51:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1frwlW-0004hO-TW for qemu-devel@nongnu.org; Mon, 20 Aug 2018 22:51:31 -0400 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:45957) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1frwlW-0004h3-Ov; Mon, 20 Aug 2018 22:51:30 -0400 Received: by mail-qt0-x241.google.com with SMTP id y5-v6so18607691qti.12; Mon, 20 Aug 2018 19:51:30 -0700 (PDT) Received: from WAL-L-PZ01.rocketsoftware.com (inet-64-112-177-9.bos.netblazr.com. [64.112.177.9]) by smtp.gmail.com with ESMTPSA id d100-v6sm4897991qkh.34.2018.08.20.19.51.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 19:51:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6MTOPPfWgEiD5Qa/dGXvBQi5ClyI+2IVfWZ0NTcoYMQ=; b=PHwJYkc+efXU3KUuHjxPM5t4Zgy4HIS/Kbh7YiQwUGzg43ubkKmx2Wz+pc2fWSQnCc nts6t2JHfl+FqTL2jRum0ab3MPtgaqfwbuC2Ck6wBCyOJy7uch/+FP4DOFXWH7EfHcMT 9zquYtoRNaoa3/OtJoyUEbLN5LvxlfOMJbP3tARJMU3UvBrW9Pgtm8bahGdQMjkCEg5I qArxoZq+5cvbDyrfrsfukOgKiohq0MWKTV6K9qnc6FNvdnfsLKRbuHXAdiSBpcik7Ay1 M3Gl7LCCKpPWY4n24L4NqUcTbHJgUb5StecvUiJImXbYjWI2fxMmzSqq8jdpqEUYebFr 8JyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6MTOPPfWgEiD5Qa/dGXvBQi5ClyI+2IVfWZ0NTcoYMQ=; b=fz7SOjXrFvdnk7voBiIy2jZZVvK6k1qmkZy4kHwKAlrfErQ7bWbpReunUEX0BmDpXe V1bmrfh3mQcsYJLpJYkWyWF3aov1PD826EdbvLV43VzkZJrK8g8vrqzkN0XDVhY8+SjR xnBL+EiBZ/NlqYeXjXiF0m9racMd2CholjZgBDcLAxtGk1K1ZR/AyoQaczA6s+iaWt7L yzi+rhkJt05o4B2E3PK+R+EA90SD31e5Xql5p7qwUV2CoWEDJVjplDOyt445XRiYM4nu +kK2NOKsl6jyGQN2J+Bd2nlOO67pdg3REkLx4+Mt4vvLXnYzSEZ2tWoESSb+fXWujZS1 ZIKw== X-Gm-Message-State: AOUpUlGjPwAgyfLuzw/t4Y2Plv4I9apaA5/D8MjX90qSG1WKg2Kz9KpI vgGJnlIfehNZabK2TGTsKtFcV5WfmNE= X-Google-Smtp-Source: AA+uWPxFoQ06GkngF6P6Hoy4lERcrnu48DXmpQsml33osrfafmBd3NtT+iyXiqkoKhHK9HSNDaEvHg== X-Received: by 2002:ac8:234f:: with SMTP id b15-v6mr47178544qtb.336.1534819890244; Mon, 20 Aug 2018 19:51:30 -0700 (PDT) From: Pavel Zbitskiy To: qemu-devel@nongnu.org Date: Mon, 20 Aug 2018 22:51:00 -0400 Message-Id: <20180821025104.19604-4-pavel.zbitskiy@gmail.com> In-Reply-To: <20180821025104.19604-1-pavel.zbitskiy@gmail.com> References: <20180821025104.19604-1-pavel.zbitskiy@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::241 Subject: [Qemu-devel] [PATCH 3/7] target/s390x: fix CSST decoding and runtime alignment check 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: Pavel Zbitskiy , david@redhat.com, cohuck@redhat.com, richard.henderson@linaro.org, Alexander Graf , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" CSST is defined as: C(0xc802, CSST, SSF, CASS, la1, a2, 0, 0, csst, 0) It means that the first parameter is handled by in1_la1(). in1_la1() fills addr1 field, and not in1. Furthermore, when extract32() is used for the alignment check, the third parameter should specify the number of trailing bits that must be 0. For FC these numbers are: FC=3D0 (word, 4 bytes): 2 FC=3D1 (double word, 8 bytes): 3 FC=3D2 (quad word, 16 bytes): 4 For SC these numbers correspond to the size: SC=3D0: 0 SC=3D1: 1 SC=3D2: 2 SC=3D3: 3 SC=3D4: 4 Signed-off-by: Pavel Zbitskiy Reviewed-by: David Hildenbrand --- target/s390x/mem_helper.c | 2 +- target/s390x/translate.c | 4 +-- tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/csst.c | 43 +++++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 tests/tcg/s390x/csst.c diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index e21a47fb4d..c94dbf3fcb 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -1442,7 +1442,7 @@ static uint32_t do_csst(CPUS390XState *env, uint32_t = r3, uint64_t a1, } =20 /* Sanity check the alignments. */ - if (extract32(a1, 0, 4 << fc) || extract32(a2, 0, 1 << sc)) { + if (extract32(a1, 0, fc + 2) || extract32(a2, 0, sc)) { goto spec_exception; } =20 diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 111d575c41..929fc2db28 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -2059,9 +2059,9 @@ static DisasJumpType op_csst(DisasContext *s, DisasOp= s *o) TCGv_i32 t_r3 =3D tcg_const_i32(r3); =20 if (tb_cflags(s->base.tb) & CF_PARALLEL) { - gen_helper_csst_parallel(cc_op, cpu_env, t_r3, o->in1, o->in2); + gen_helper_csst_parallel(cc_op, cpu_env, t_r3, o->addr1, o->in2); } else { - gen_helper_csst(cc_op, cpu_env, t_r3, o->in1, o->in2); + gen_helper_csst(cc_op, cpu_env, t_r3, o->addr1, o->in2); } tcg_temp_free_i32(t_r3); =20 diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.tar= get index 9f4076901f..f62f950d8e 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -1,3 +1,4 @@ VPATH+=3D$(SRC_PATH)/tests/tcg/s390x CFLAGS+=3D-march=3DzEC12 -m64 TESTS+=3Dhello-s390x +TESTS+=3Dcsst diff --git a/tests/tcg/s390x/csst.c b/tests/tcg/s390x/csst.c new file mode 100644 index 0000000000..1dae9071fb --- /dev/null +++ b/tests/tcg/s390x/csst.c @@ -0,0 +1,43 @@ +#include +#include + +int main(void) +{ + uint64_t parmlist[] =3D { + 0xfedcba9876543210ull, + 0, + 0x7777777777777777ull, + 0, + }; + uint64_t op1 =3D 0x0123456789abcdefull; + uint64_t op2 =3D 0; + uint64_t op3 =3D op1; + uint64_t cc; + + asm volatile( + " lghi %%r0,%[flags]\n" + " la %%r1,%[parmlist]\n" + " csst %[op1],%[op2],%[op3]\n" + " ipm %[cc]\n" + : [op1] "+m" (op1), + [op2] "+m" (op2), + [op3] "+r" (op3), + [cc] "=3Dr" (cc) + : [flags] "K" (0x0301), + [parmlist] "m" (parmlist) + : "r0", "r1", "cc", "memory"); + cc =3D (cc >> 28) & 3; + if (cc) { + write(1, "bad cc\n", 7); + return 1; + } + if (op1 !=3D parmlist[0]) { + write(1, "bad op1\n", 8); + return 1; + } + if (op2 !=3D parmlist[2]) { + write(1, "bad op2\n", 8); + return 1; + } + return 0; +} --=20 2.18.0 From nobody Wed Nov 5 12:15:31 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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1534820259803845.8042872446791; Mon, 20 Aug 2018 19:57:39 -0700 (PDT) Received: from localhost ([::1]:50391 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frwrS-0000Xo-Rb for importer@patchew.org; Mon, 20 Aug 2018 22:57:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54384) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frwlc-0004Ak-Aa for qemu-devel@nongnu.org; Mon, 20 Aug 2018 22:51:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1frwlY-0004im-PX for qemu-devel@nongnu.org; Mon, 20 Aug 2018 22:51:36 -0400 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:41431) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1frwlY-0004iP-K1; Mon, 20 Aug 2018 22:51:32 -0400 Received: by mail-qk0-x241.google.com with SMTP id h138-v6so7422850qke.8; Mon, 20 Aug 2018 19:51:32 -0700 (PDT) Received: from WAL-L-PZ01.rocketsoftware.com (inet-64-112-177-9.bos.netblazr.com. [64.112.177.9]) by smtp.gmail.com with ESMTPSA id d100-v6sm4897991qkh.34.2018.08.20.19.51.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 19:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YQLliVHU55ssZlnms3jBVv+Ym3hnkhp3vCf4sXpDc/s=; b=i7oiFJ3V/17gdatuGBZqHq5jNTspIyzI/Y1ZdlCkJLov4++iOae6r0Imu/IXnQM8CY NuuzZln9yL4XtV9T4zQAeshgkAcFetYvm9Mhg7s/En/dVNha2LoJDVXibtV1/VGpBjmt wtmuthOm3ER9rGIR5t5ULUW33883XPWxbF+IEs6CLoW38CYGSTjA0tyrUBs6/FAafkhO wDE9FtA4umk/IAJf/93gSl0cpjKc6mPApyURdKQ8Btb3n9436RREczVmi3HLwQ7ZjaIE C+/xrgHJfLQKHjWx1WrGdkJB8kzMpyP90rt4PQwvFOC4xMGrjmEVNhtKSWy5O0nOfv1o SZzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YQLliVHU55ssZlnms3jBVv+Ym3hnkhp3vCf4sXpDc/s=; b=RP6fLT30pKX1gECkp9aEoc+dza3zJuT9SVU1BpKBWDwsZ6RGZYZteXaom074abwxXx 6ckwhNO4WRstIMG8B7ElWmsMaRXgkyLPfJxuGognW8mxHzCZ7QHHa3sx8kTKWESp+9is bi2x9c3RILQGD5BDBXU3oczHe1LGVwou4skh6KTZ4M4w74Zd6jMaJ64NMggObG5Au9bG tp5cxLfCWlYkZT/WTkLMhwR3VY1DNX24KnVVadMLxaSmkCSfkcrE3SWnhIExr3tfmac8 ymUKhNtv7PWJUTLMm9u2Y2rhCS8X310tfPiXuilwxNhKPkXAFDf9dq1X7YL1/m+VgKnk bLzQ== X-Gm-Message-State: AOUpUlErqMQvbG8R6zd07unOu2ZS5slK7nIL34Z6eZwSzwhwweOe9xWD HmOLMAxmknVCav1uHaZjjevVMk7ok4E= X-Google-Smtp-Source: AA+uWPyKIiQqoHvqjPUXl0E6C7hfcMNu8zNXWmwZbd9jmOciIotE9VXD7mhoF0+eXbBul7ktq8BDEA== X-Received: by 2002:a37:b744:: with SMTP id h65-v6mr45284988qkf.161.1534819891876; Mon, 20 Aug 2018 19:51:31 -0700 (PDT) From: Pavel Zbitskiy To: qemu-devel@nongnu.org Date: Mon, 20 Aug 2018 22:51:01 -0400 Message-Id: <20180821025104.19604-5-pavel.zbitskiy@gmail.com> In-Reply-To: <20180821025104.19604-1-pavel.zbitskiy@gmail.com> References: <20180821025104.19604-1-pavel.zbitskiy@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::241 Subject: [Qemu-devel] [PATCH 4/7] target/s390x: fix IPM polluting irrelevant bits 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: Pavel Zbitskiy , david@redhat.com, cohuck@redhat.com, richard.henderson@linaro.org, Alexander Graf , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Suppose psw.mask=3D0x0000000080000000, cc=3D2, r1=3D0 and we do "ipm 1". This command must touch only bits 32-39, so the expected output is r1=3D0x20000000. However, currently qemu yields r1=3D0x20008000, because irrelevant parts of PSW leak into r1 during program mask transfer. Signed-off-by: Pavel Zbitskiy Reviewed-by: David Hildenbrand --- target/s390x/translate.c | 17 +++++++---------- tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/ipm.c | 22 ++++++++++++++++++++++ 3 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 tests/tcg/s390x/ipm.c diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 929fc2db28..f58b36b789 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -2445,20 +2445,17 @@ static DisasJumpType op_insi(DisasContext *s, Disas= Ops *o) =20 static DisasJumpType op_ipm(DisasContext *s, DisasOps *o) { - TCGv_i64 t1; + TCGv_i64 t1, t2; =20 gen_op_calc_cc(s); - tcg_gen_andi_i64(o->out, o->out, ~0xff000000ull); - t1 =3D tcg_temp_new_i64(); - tcg_gen_shli_i64(t1, psw_mask, 20); - tcg_gen_shri_i64(t1, t1, 36); - tcg_gen_or_i64(o->out, o->out, t1); - - tcg_gen_extu_i32_i64(t1, cc_op); - tcg_gen_shli_i64(t1, t1, 28); - tcg_gen_or_i64(o->out, o->out, t1); + tcg_gen_extract_i64(t1, psw_mask, 40, 4); + t2 =3D tcg_temp_new_i64(); + tcg_gen_extu_i32_i64(t2, cc_op); + tcg_gen_deposit_i64(t1, t1, t2, 4, 60); + tcg_gen_deposit_i64(o->out, o->out, t1, 24, 8); tcg_temp_free_i64(t1); + tcg_temp_free_i64(t2); return DISAS_NEXT; } =20 diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.tar= get index f62f950d8e..c800a582e5 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -2,3 +2,4 @@ VPATH+=3D$(SRC_PATH)/tests/tcg/s390x CFLAGS+=3D-march=3DzEC12 -m64 TESTS+=3Dhello-s390x TESTS+=3Dcsst +TESTS+=3Dipm diff --git a/tests/tcg/s390x/ipm.c b/tests/tcg/s390x/ipm.c new file mode 100644 index 0000000000..742f3a18c5 --- /dev/null +++ b/tests/tcg/s390x/ipm.c @@ -0,0 +1,22 @@ +#include +#include + +int main(void) +{ + uint32_t op1 =3D 0x55555555; + uint32_t op2 =3D 0x44444444; + uint64_t cc =3D 0xffffffffffffffffull; + + asm volatile( + " clc 0(4,%[op1]),0(%[op2])\n" + " ipm %[cc]\n" + : [cc] "+r" (cc) + : [op1] "r" (&op1), + [op2] "r" (&op2) + : "cc"); + if (cc !=3D 0xffffffff20ffffffull) { + write(1, "bad cc\n", 7); + return 1; + } + return 0; +} --=20 2.18.0 From nobody Wed Nov 5 12:15:31 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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1534820042365343.4423233215424; Mon, 20 Aug 2018 19:54:02 -0700 (PDT) Received: from localhost ([::1]:50367 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frwnx-0005P5-52 for importer@patchew.org; Mon, 20 Aug 2018 22:54:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frwlc-0004Al-Ak for qemu-devel@nongnu.org; Mon, 20 Aug 2018 22:51:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1frwlZ-0004jI-Ud for qemu-devel@nongnu.org; Mon, 20 Aug 2018 22:51:36 -0400 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:42397) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1frwlZ-0004jB-Pr; Mon, 20 Aug 2018 22:51:33 -0400 Received: by mail-qt0-x243.google.com with SMTP id z8-v6so18619763qto.9; Mon, 20 Aug 2018 19:51:33 -0700 (PDT) Received: from WAL-L-PZ01.rocketsoftware.com (inet-64-112-177-9.bos.netblazr.com. [64.112.177.9]) by smtp.gmail.com with ESMTPSA id d100-v6sm4897991qkh.34.2018.08.20.19.51.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 19:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zdQWDJOmUYpmFJBRbkyACEJ+k0XvtQEvzxuRCC+WAfA=; b=i2FgmYtCId0BzdK81E525lKlhhWkx0Q9h/xHfrk0Z3Yq6oH/vKJvAyBPeOEHdTtTHZ m2XLorV5WAF5JLJpxN3BxWOaSchhk5vCWaXxEaWQYZwi2QEl2LzlLQBY52dOpu4veU64 A05AzkLjRuJtBP1f63B7SsrYq8IE+z36HaOsKMznd13r/j8HDd4UwKmE6Ia4Ijd+TkiS 58aOI3xQAcnlxiP7z4hP3KE+xiI7LlRysrzxJOhzYfoIApZrpI4YiNTti6/XH8wzb+x/ 2NoY13CZFIWGeLiF5Md6fc2/pTaP5p/HtRxxvPt9Io5n56FCSiQ5Mfn4MVA5MZOLnMKJ 5Bqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zdQWDJOmUYpmFJBRbkyACEJ+k0XvtQEvzxuRCC+WAfA=; b=b/fevJVDJNpaE9RJI1fhXyxzZYj9jGF350l2FidBYP8EhHMpioJbVUEzB+wd70ODn8 EaigN1Sb/YWzJQzPps+5DARBVXZy8+jO0D7DAPznWHXyIbOiQK/cGsjk7OJfAG5HmI66 OhX5Dur1o3u7j0Ce3UlgUoAgQE7NQ/fLy19F2qY7/bWFvPYhOK4LvEGqW2Z6gVPCGjqo vuTGrGjoYnSwe099PJ936JG7SqbY0x8OFmFdyEPXFFI+1GWGXYPfmfxUtr6xqWqjHz6K HMqn0EQaWkyr0M1RQVZxob3faDQBLDtr7NflxWIZDUTqV3gVjlDKIAYTTosecPMCH9s2 TWjA== X-Gm-Message-State: APzg51C0ZP85BmY2CzzF7R2fwADtzq+vK0KvA1XycJjs8Y2HWOZ//ZQV 2C1xYw3qNRBZ99xWiq1K/3RBxZpkeBE= X-Google-Smtp-Source: ANB0Vdbr7oTxooWF9tm8a3LeT8q5qZX/anDD26gLsEyO9mNY1sEAJAJCZxH0Nw4d2d9RQKlqIvVd7Q== X-Received: by 2002:a0c:af5a:: with SMTP id j26-v6mr5898870qvc.191.1534819893282; Mon, 20 Aug 2018 19:51:33 -0700 (PDT) From: Pavel Zbitskiy To: qemu-devel@nongnu.org Date: Mon, 20 Aug 2018 22:51:02 -0400 Message-Id: <20180821025104.19604-6-pavel.zbitskiy@gmail.com> In-Reply-To: <20180821025104.19604-1-pavel.zbitskiy@gmail.com> References: <20180821025104.19604-1-pavel.zbitskiy@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::243 Subject: [Qemu-devel] [PATCH 5/7] target/s390x: add EX support for TRT and TRTR 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: Pavel Zbitskiy , david@redhat.com, cohuck@redhat.com, richard.henderson@linaro.org, Alexander Graf , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Improves "b213c9f5: target/s390x: Implement TRTR" by introducing the intermediate functions, which are compatible with dx_helper type. Signed-off-by: Pavel Zbitskiy Reviewed-by: David Hildenbrand --- target/s390x/mem_helper.c | 16 +++++++++++ tests/tcg/s390x/Makefile.target | 2 ++ tests/tcg/s390x/exrl-trt.c | 48 +++++++++++++++++++++++++++++++++ tests/tcg/s390x/exrl-trtr.c | 48 +++++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+) create mode 100644 tests/tcg/s390x/exrl-trt.c create mode 100644 tests/tcg/s390x/exrl-trtr.c diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index c94dbf3fcb..704d0193b5 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -1299,12 +1299,26 @@ static inline uint32_t do_helper_trt(CPUS390XState = *env, int len, return 0; } =20 +static uint32_t do_helper_trt_fwd(CPUS390XState *env, uint32_t len, + uint64_t array, uint64_t trans, + uintptr_t ra) +{ + return do_helper_trt(env, len, array, trans, 1, ra); +} + uint32_t HELPER(trt)(CPUS390XState *env, uint32_t len, uint64_t array, uint64_t trans) { return do_helper_trt(env, len, array, trans, 1, GETPC()); } =20 +static uint32_t do_helper_trt_bkwd(CPUS390XState *env, uint32_t len, + uint64_t array, uint64_t trans, + uintptr_t ra) +{ + return do_helper_trt(env, len, array, trans, -1, ra); +} + uint32_t HELPER(trtr)(CPUS390XState *env, uint32_t len, uint64_t array, uint64_t trans) { @@ -2193,12 +2207,14 @@ void HELPER(ex)(CPUS390XState *env, uint32_t ilen, = uint64_t r1, uint64_t addr) typedef uint32_t (*dx_helper)(CPUS390XState *, uint32_t, uint64_t, uint64_t, uintptr_t); static const dx_helper dx[16] =3D { + [0x0] =3D do_helper_trt_bkwd, [0x2] =3D do_helper_mvc, [0x4] =3D do_helper_nc, [0x5] =3D do_helper_clc, [0x6] =3D do_helper_oc, [0x7] =3D do_helper_xc, [0xc] =3D do_helper_tr, + [0xd] =3D do_helper_trt_fwd, }; dx_helper helper =3D dx[opc & 0xf]; =20 diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.tar= get index c800a582e5..7de4376f52 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -3,3 +3,5 @@ CFLAGS+=3D-march=3DzEC12 -m64 TESTS+=3Dhello-s390x TESTS+=3Dcsst TESTS+=3Dipm +TESTS+=3Dexrl-trt +TESTS+=3Dexrl-trtr diff --git a/tests/tcg/s390x/exrl-trt.c b/tests/tcg/s390x/exrl-trt.c new file mode 100644 index 0000000000..3c5323aecb --- /dev/null +++ b/tests/tcg/s390x/exrl-trt.c @@ -0,0 +1,48 @@ +#include +#include + +int main(void) +{ + char op1[] =3D "hello"; + char op2[256]; + uint64_t r1 =3D 0xffffffffffffffffull; + uint64_t r2 =3D 0xffffffffffffffffull; + uint64_t cc; + int i; + + for (i =3D 0; i < 256; i++) { + if (i =3D=3D 0) { + op2[i] =3D 0xaa; + } else { + op2[i] =3D 0; + } + } + asm volatile( + " j 2f\n" + "1: trt 0(1,%[op1]),0(%[op2])\n" + "2: exrl %[op1_len],1b\n" + " lgr %[r1],%%r1\n" + " lgr %[r2],%%r2\n" + " ipm %[cc]\n" + : [r1] "+r" (r1), + [r2] "+r" (r2), + [cc] "=3Dr" (cc) + : [op1] "r" (&op1), + [op1_len] "r" (5), + [op2] "r" (&op2) + : "r1", "r2", "cc"); + cc =3D (cc >> 28) & 3; + if (cc !=3D 2) { + write(1, "bad cc\n", 7); + return 1; + } + if ((char *)r1 !=3D &op1[5]) { + write(1, "bad r1\n", 7); + return 1; + } + if (r2 !=3D 0xffffffffffffffaaull) { + write(1, "bad r2\n", 7); + return 1; + } + return 0; +} diff --git a/tests/tcg/s390x/exrl-trtr.c b/tests/tcg/s390x/exrl-trtr.c new file mode 100644 index 0000000000..c33153ad7e --- /dev/null +++ b/tests/tcg/s390x/exrl-trtr.c @@ -0,0 +1,48 @@ +#include +#include + +int main(void) +{ + char op1[] =3D {0, 1, 2, 3}; + char op2[256]; + uint64_t r1 =3D 0xffffffffffffffffull; + uint64_t r2 =3D 0xffffffffffffffffull; + uint64_t cc; + int i; + + for (i =3D 0; i < 256; i++) { + if (i =3D=3D 1) { + op2[i] =3D 0xbb; + } else { + op2[i] =3D 0; + } + } + asm volatile( + " j 2f\n" + "1: trtr 3(1,%[op1]),0(%[op2])\n" + "2: exrl %[op1_len],1b\n" + " lgr %[r1],%%r1\n" + " lgr %[r2],%%r2\n" + " ipm %[cc]\n" + : [r1] "+r" (r1), + [r2] "+r" (r2), + [cc] "=3Dr" (cc) + : [op1] "r" (&op1), + [op1_len] "r" (3), + [op2] "r" (&op2) + : "r1", "r2", "cc"); + cc =3D (cc >> 28) & 3; + if (cc !=3D 1) { + write(1, "bad cc\n", 7); + return 1; + } + if ((char *)r1 !=3D &op1[1]) { + write(1, "bad r1\n", 7); + return 1; + } + if (r2 !=3D 0xffffffffffffffbbull) { + write(1, "bad r2\n", 7); + return 1; + } + return 0; +} --=20 2.18.0 From nobody Wed Nov 5 12:15:31 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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1534820330145943.8092089030552; Mon, 20 Aug 2018 19:58:50 -0700 (PDT) Received: from localhost ([::1]:50394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frwsa-00017x-UH for importer@patchew.org; Mon, 20 Aug 2018 22:58:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frwlc-0004Am-Af for qemu-devel@nongnu.org; Mon, 20 Aug 2018 22:51:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1frwlb-0004ju-C9 for qemu-devel@nongnu.org; Mon, 20 Aug 2018 22:51:36 -0400 Received: from mail-qk0-x236.google.com ([2607:f8b0:400d:c09::236]:38148) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1frwlb-0004jg-84; Mon, 20 Aug 2018 22:51:35 -0400 Received: by mail-qk0-x236.google.com with SMTP id g197-v6so830938qke.5; Mon, 20 Aug 2018 19:51:34 -0700 (PDT) Received: from WAL-L-PZ01.rocketsoftware.com (inet-64-112-177-9.bos.netblazr.com. [64.112.177.9]) by smtp.gmail.com with ESMTPSA id d100-v6sm4897991qkh.34.2018.08.20.19.51.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 19:51:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LbyHSl2hUt8aBAYCRJx6cP1mlH3i/VVzz9/twYYyQPc=; b=XMKGrGzl9QCpQLZVZVhVIXhjk3eHub7G4LWC2fCP+YtKV0Uzo8/ytBOhThbe4XeucW k43b44w3vHZItVQfdy3ZKUXGfSgj+H9NkceIyEOdDWVJYyRn5uyeVMpmFnZCRjCDJQph 8wQut5PZuoApIg+K4uWQpB99y5/fcixXah4axSbg5c9ma+Zwvalj5z6U1iE7by7bnUpu 7bdiZH80Cqpkw7r+4f7TSEYgV0UseDdoLz+2JTKinaWTCV58s0kHZv1WeLWdcZKpJ4fx h9pR1zp0x/uFb4dLwJVORtACjVF380S1nz38eN45nBgTn80f1Yha8n8OoxFI0+yJsr0h jQKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LbyHSl2hUt8aBAYCRJx6cP1mlH3i/VVzz9/twYYyQPc=; b=uEnbCPk/JQu+KqEEN5XFN+4M1fWwtA4qCxIW9LKzIj+tvB6xhpp6wf39Vt5k0hzJ6k PoV0qXw7xCDj/EcrHuVf1p5NtDdMPmu4cQ0o9rRf961heDEfj5lhFZkCloe4pfzydR3B pRiELzOpgcmfxa/rDu8y9quXIDS3Dr3mvNefnsUu01CHPBz3STwMO+bY2jvN0EEepq/4 JaK0z0ecX2POug3948d2DJTJa2GS1ZXolTazOVkYuudYF0dZIhDd+kNs6lbf0fEhQOoE oTP6tsKZd4fYDOLPeK7ANo9fgfuUroDgNBT/k003+Mf0xfvGEcU5E1bGysdSppdSw2c3 i5hw== X-Gm-Message-State: AOUpUlHVPjAhFfGL4Ulnuzn4d5zZiVeHXHtuE3NSIraMYU2ZqP9z5f9D DJv/N3f3Zx43+MqbL9VxZVJCatURuEI= X-Google-Smtp-Source: AA+uWPxvhrdlEi2K7q4pdkzGLb0j0ugzvWuOtm+0Zm5/AQHPLofLj0cNWtx2Vdw7slkgt7u4fxgoDQ== X-Received: by 2002:a37:2b8d:: with SMTP id r13-v6mr17080294qkr.198.1534819894410; Mon, 20 Aug 2018 19:51:34 -0700 (PDT) From: Pavel Zbitskiy To: qemu-devel@nongnu.org Date: Mon, 20 Aug 2018 22:51:03 -0400 Message-Id: <20180821025104.19604-7-pavel.zbitskiy@gmail.com> In-Reply-To: <20180821025104.19604-1-pavel.zbitskiy@gmail.com> References: <20180821025104.19604-1-pavel.zbitskiy@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::236 Subject: [Qemu-devel] [PATCH 6/7] target/s390x: fix PACK reading 1 byte less and writing 1 byte more 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: Pavel Zbitskiy , david@redhat.com, cohuck@redhat.com, richard.henderson@linaro.org, Alexander Graf , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" PACK fails on the test from the Principles of Operation: F1F2F3F4 becomes 0000234C instead of 0001234C due to an off-by-one error. Furthermore, it overwrites one extra byte to the left of F1. If len_dest is 0, then we only want to flip the 1st byte and never loop over the rest. Therefore, the loop condition should be > and not >=3D. If len_src is 1, then we should flip the 1st byte and pack the 2nd. Since len_src is already decremented before the loop, the first condition should be >=3D, and not >. Likewise for len_src =3D=3D 2 and the second condition. Signed-off-by: Pavel Zbitskiy Reviewed-by: David Hildenbrand --- target/s390x/mem_helper.c | 6 +++--- tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/pack.c | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 tests/tcg/s390x/pack.c diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 704d0193b5..bacae4f503 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -1019,15 +1019,15 @@ void HELPER(pack)(CPUS390XState *env, uint32_t len,= uint64_t dest, uint64_t src) len_src--; =20 /* now pack every value */ - while (len_dest >=3D 0) { + while (len_dest > 0) { b =3D 0; =20 - if (len_src > 0) { + if (len_src >=3D 0) { b =3D cpu_ldub_data_ra(env, src, ra) & 0x0f; src--; len_src--; } - if (len_src > 0) { + if (len_src >=3D 0) { b |=3D cpu_ldub_data_ra(env, src, ra) << 4; src--; len_src--; diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.tar= get index 7de4376f52..151dc075aa 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -5,3 +5,4 @@ TESTS+=3Dcsst TESTS+=3Dipm TESTS+=3Dexrl-trt TESTS+=3Dexrl-trtr +TESTS+=3Dpack diff --git a/tests/tcg/s390x/pack.c b/tests/tcg/s390x/pack.c new file mode 100644 index 0000000000..4be36f29a7 --- /dev/null +++ b/tests/tcg/s390x/pack.c @@ -0,0 +1,21 @@ +#include + +int main(void) +{ + char data[] =3D {0xaa, 0xaa, 0xf1, 0xf2, 0xf3, 0xc4, 0xaa, 0xaa}; + char exp[] =3D {0xaa, 0xaa, 0x00, 0x01, 0x23, 0x4c, 0xaa, 0xaa}; + int i; + + asm volatile( + " pack 2(4,%[data]),2(4,%[data])\n" + : + : [data] "r" (&data[0]) + : "memory"); + for (i =3D 0; i < 8; i++) { + if (data[i] !=3D exp[i]) { + write(1, "bad data\n", 9); + return 1; + } + } + return 0; +} --=20 2.18.0 From nobody Wed Nov 5 12:15:31 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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1534820171138833.8301823328159; Mon, 20 Aug 2018 19:56:11 -0700 (PDT) Received: from localhost ([::1]:50386 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frwq2-00086a-2j for importer@patchew.org; Mon, 20 Aug 2018 22:56:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frwlg-0004DH-7j for qemu-devel@nongnu.org; Mon, 20 Aug 2018 22:51:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1frwle-0004lp-7w for qemu-devel@nongnu.org; Mon, 20 Aug 2018 22:51:40 -0400 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]:41732) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1frwld-0004kL-QG; Mon, 20 Aug 2018 22:51:38 -0400 Received: by mail-qt0-x242.google.com with SMTP id e19-v6so18630704qtp.8; Mon, 20 Aug 2018 19:51:36 -0700 (PDT) Received: from WAL-L-PZ01.rocketsoftware.com (inet-64-112-177-9.bos.netblazr.com. [64.112.177.9]) by smtp.gmail.com with ESMTPSA id d100-v6sm4897991qkh.34.2018.08.20.19.51.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 19:51:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DDU2T++AG1+T036R3odwIsHd2DpbZwmswJ0m+issXw8=; b=ptcUEAXsHnEIWUe/cN6i3mLi4kOjY+DR4CSQpyDY4EaH6+HIa6Z0VRLALw/1Fb4ViC SlxwvYJ5OKV2YOaLOCub1SlpHlPd2dQblccf+x4hM3ZNjQ1Niz5kFg+J17OV1eRWMFNI buUx/ZCaxHqr5URuukAaAJ6vEGe6Jy7ccSRGtgm8TQoFwt7MSUt16c0SUjmWKmOadajT +rEmDNPaaJGk2MzLbF4XRagAv7NXyrbrJKvlK/4dYX8gtfelruj5G0z7tq3olSe3nv+Q 2udZj4l1URnP8LdNRrd+z6pZznTjv7a2kGa+bimup9+Qwq8c2IGCfW/f8S+lcn5iRd+R eifA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DDU2T++AG1+T036R3odwIsHd2DpbZwmswJ0m+issXw8=; b=OBU5PHCsR3tGvw4AHaMjMTydI88wlLWBKicI5cTPZOMN0fYwvoLqYsFVOqW8xEZAg2 ZXU8GAJ/Hd+miesW5qs9zNcLylB8eZRr2C64yGwR9ms0p+2DDK4LuDLnJtyuKV9UXqKP Xz3r2L3vcjK7QPER0lulUBh/l8e4byYkGBKdKvvPI9nyxNoZ3XxRIVOqAakt4gxpClX3 SAYkZGHccdOUnuPjIsFi+gwynjKZs2gQylAZmVIGK98XzEO+IMogQQ9+4P1wS351fG8D Y7juoddZpzTEuwrTCokiKfza1ltAc31oYXua6s48poldJ/MpBnJ4Fl97TioLeMJrGYsE +80Q== X-Gm-Message-State: APzg51AuJUfhYnoyzNzGai0LxbWoIQeUmSYNokp70epNk7+hkPfDimVR W4SQ2bfrCu1CWgIekxfUBayu1gtmAvM= X-Google-Smtp-Source: ANB0VdaF8Rk+XD3Qycln4i/P4QqXyR+ZMJW3X2OXdlbs342BsfBYbWAuNloJf3I0qNFRbKZKOgUmUQ== X-Received: by 2002:a0c:af34:: with SMTP id i49-v6mr11706478qvc.125.1534819895787; Mon, 20 Aug 2018 19:51:35 -0700 (PDT) From: Pavel Zbitskiy To: qemu-devel@nongnu.org Date: Mon, 20 Aug 2018 22:51:04 -0400 Message-Id: <20180821025104.19604-8-pavel.zbitskiy@gmail.com> In-Reply-To: <20180821025104.19604-1-pavel.zbitskiy@gmail.com> References: <20180821025104.19604-1-pavel.zbitskiy@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::242 Subject: [Qemu-devel] [PATCH 7/7] target/s390x: implement CVB, CVBY and CVBG 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: Pavel Zbitskiy , david@redhat.com, cohuck@redhat.com, richard.henderson@linaro.org, Alexander Graf , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Convert to Binary - counterparts of the already implemented Convert to Decimal (CVD*) instructions. Example from the Principles of Operation: 25594C becomes 63FA. Signed-off-by: Pavel Zbitskiy --- target/s390x/helper.h | 1 + target/s390x/insn-data.def | 4 +++ target/s390x/int_helper.c | 50 +++++++++++++++++++++++++++++++++ target/s390x/translate.c | 10 +++++++ tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/cvb.c | 18 ++++++++++++ 6 files changed, 84 insertions(+) create mode 100644 tests/tcg/s390x/cvb.c diff --git a/target/s390x/helper.h b/target/s390x/helper.h index 97c60ca7bc..46baaee0ab 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -88,6 +88,7 @@ DEF_HELPER_FLAGS_4(tcxb, TCG_CALL_NO_RWG_SE, i32, env, i6= 4, i64, i64) DEF_HELPER_FLAGS_2(sqeb, TCG_CALL_NO_WG, i64, env, i64) DEF_HELPER_FLAGS_2(sqdb, TCG_CALL_NO_WG, i64, env, i64) DEF_HELPER_FLAGS_3(sqxb, TCG_CALL_NO_WG, i64, env, i64, i64) +DEF_HELPER_FLAGS_3(cvb, TCG_CALL_NO_WG, i64, env, i64, i32) DEF_HELPER_FLAGS_1(cvd, TCG_CALL_NO_RWG_SE, i64, s32) DEF_HELPER_FLAGS_4(pack, TCG_CALL_NO_WG, void, env, i32, i64, i64) DEF_HELPER_FLAGS_4(pka, TCG_CALL_NO_WG, void, env, i64, i64, i32) diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def index 9c7b434fca..1b29a5e044 100644 --- a/target/s390x/insn-data.def +++ b/target/s390x/insn-data.def @@ -284,6 +284,10 @@ D(0xec73, CLFIT, RIE_a, GIE, r1_32u, i2_32u, 0, 0, ct, 0, 1) D(0xec71, CLGIT, RIE_a, GIE, r1_o, i2_32u, 0, 0, ct, 0, 1) =20 +/* CONVERT TO BINARY */ + C(0x4f00, CVB, RX_a, Z, 0, a2, new, r1_32, cvb, 0) + C(0xe306, CVBY, RXY_a, LD, 0, a2, new, r1_32, cvb, 0) + C(0xe30e, CVBG, RXY_a, Z, 0, a2, r1, 0, cvb, 0) /* CONVERT TO DECIMAL */ C(0x4e00, CVD, RX_a, Z, r1_o, a2, 0, 0, cvd, 0) C(0xe326, CVDY, RXY_a, LD, r1_o, a2, 0, 0, cvd, 0) diff --git a/target/s390x/int_helper.c b/target/s390x/int_helper.c index abf77a94e6..66c6dc8b3a 100644 --- a/target/s390x/int_helper.c +++ b/target/s390x/int_helper.c @@ -24,6 +24,7 @@ #include "exec/exec-all.h" #include "qemu/host-utils.h" #include "exec/helper-proto.h" +#include "exec/cpu_ldst.h" =20 /* #define DEBUG_HELPER */ #ifdef DEBUG_HELPER @@ -118,6 +119,55 @@ uint64_t HELPER(divu64)(CPUS390XState *env, uint64_t a= h, uint64_t al, return ret; } =20 +static void general_operand_exception(CPUS390XState *env, uintptr_t ra) +{ +#ifndef CONFIG_USER_ONLY + LowCore *lowcore; + + lowcore =3D cpu_map_lowcore(env); + lowcore->data_exc_code =3D 0; + cpu_unmap_lowcore(lowcore); +#endif + s390_program_interrupt(env, PGM_DATA, ILEN_AUTO, ra); +} + +uint64_t HELPER(cvb)(CPUS390XState *env, uint64_t src, uint32_t n) +{ + int i, j; + uintptr_t ra =3D GETPC(); + int64_t dec, sign =3D 0, digit, val =3D 0, pow10 =3D 0; + + for (i =3D 0; i < n; i++) { + dec =3D cpu_ldq_data_ra(env, src + (n - i - 1) * 8, ra); + for (j =3D 0; j < 16; j++, dec >>=3D 4) { + if (i =3D=3D 0 && j =3D=3D 0) { + sign =3D dec & 0xf; + if (sign < 0xa) { + general_operand_exception(env, ra); + } + continue; + } + digit =3D dec & 0xf; + if (digit > 0x9) { + general_operand_exception(env, ra); + } + if (i =3D=3D 0 && j =3D=3D 1) { + if (sign =3D=3D 0xb || sign =3D=3D 0xd) { + val =3D -digit; + pow10 =3D -10; + } else { + val =3D digit; + pow10 =3D 10; + } + } else { + val +=3D digit * pow10; + pow10 *=3D 10; + } + } + } + return val; +} + uint64_t HELPER(cvd)(int32_t reg) { /* positive 0 */ diff --git a/target/s390x/translate.c b/target/s390x/translate.c index f58b36b789..b3cbfead5d 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -2115,6 +2115,16 @@ static DisasJumpType op_csp(DisasContext *s, DisasOp= s *o) } #endif =20 +static DisasJumpType op_cvb(DisasContext *s, DisasOps *o) +{ + uint64_t n =3D ((s->fields->op =3D=3D 0xE3) && (s->fields->op2 =3D=3D = 0x0E)) ? + /* CVBG */ 2 : + /* CVB, CVBY */ 1; + + gen_helper_cvb(o->out, cpu_env, o->in2, tcg_const_i32(n)); + return DISAS_NEXT; +} + static DisasJumpType op_cvd(DisasContext *s, DisasOps *o) { TCGv_i64 t1 =3D tcg_temp_new_i64(); diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.tar= get index 151dc075aa..990dfb26ff 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -6,3 +6,4 @@ TESTS+=3Dipm TESTS+=3Dexrl-trt TESTS+=3Dexrl-trtr TESTS+=3Dpack +TESTS+=3Dcvb diff --git a/tests/tcg/s390x/cvb.c b/tests/tcg/s390x/cvb.c new file mode 100644 index 0000000000..3a72e132aa --- /dev/null +++ b/tests/tcg/s390x/cvb.c @@ -0,0 +1,18 @@ +#include +#include + +int main(void) +{ + uint64_t data =3D 0x000000000025594cull; + uint64_t result =3D 0; + + asm volatile( + " cvb %[result],%[data]\n" + : [result] "+r" (result) + : [data] "m" (data)); + if (result !=3D 0x63fa) { + write(1, "bad result\n", 11); + return 1; + } + return 0; +} --=20 2.18.0