From nobody Wed Nov 5 07:34:29 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 1533870330138385.97154057430237; Thu, 9 Aug 2018 20:05:30 -0700 (PDT) Received: from localhost ([::1]:53998 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnxjx-0007Bo-L6 for importer@patchew.org; Thu, 09 Aug 2018 23:05:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnxi9-0005vS-QU for qemu-devel@nongnu.org; Thu, 09 Aug 2018 23:03:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnxi9-0003ZI-1M for qemu-devel@nongnu.org; Thu, 09 Aug 2018 23:03:33 -0400 Received: from mail-qk0-x230.google.com ([2607:f8b0:400d:c09::230]:35649) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fnxi8-0003Yp-SF; Thu, 09 Aug 2018 23:03:32 -0400 Received: by mail-qk0-x230.google.com with SMTP id u21-v6so5521528qku.2; Thu, 09 Aug 2018 20:03:32 -0700 (PDT) Received: from WAL-L-PZ01.rocketsoftware.com ([2620:117:0:a::c]) by smtp.gmail.com with ESMTPSA id i1-v6sm4457425qtj.65.2018.08.09.20.03.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 20:03: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=eDR+ql8m/VROH6izyDCjsTMs6kUhoR3lU/IKIvjDKe0=; b=qofjIFOVjTv87ueWpHd3Rhha2Fs2nstEx5jPO7pBkFNApDfp3JH6vJhrvYGZku+YML zFx0AgHYvhM/xma6xwrVdLlyA4Pj6vpTATh+3jz5sraD0DGvXAblnDarvyoWvvFWQxS2 WGeD4bZklQyRSs+r1qsxlK7XBfgfRrkzDlaFVTbJ6OohFT5TbYqKEf0BWT0+porpMnOO fJa2mWBIT6rY9Ke2RKxwgdsmM2MLnFo+ZF6k/wGHkgmmv9+RAcGhWDMKdc82DP2xvBWj 4VMGwCwQRfxlgQoIqdpwkea8UrVBOjTmJTWSBAVFmRDEhEPWbcQb6h9qOisID5RcPwv6 EI6g== 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=eDR+ql8m/VROH6izyDCjsTMs6kUhoR3lU/IKIvjDKe0=; b=c5tJ7jaQQ07aStWf/mdYtR5+Fe5ghv9dwlHgI6WQfBjbWxL99OXb9BgS/jRPCw/ssW nGpTW9kM7i66HqwybI38h+Tjffb7IN70FiIHzv60nfVXwdhr+HpV710/yJ5H4kiS0DZh JxT8uukS8X1ggtFiUEnqWXNcGxSMh2dCetmKBwGnentaEnzgYoOuQwVoq6o8V1LIxQmP ecKJNLEOdOlqbV8235i5Qx+Ple0IXT9E0/Oyjr/4Rb1EHme/rgszvyRUS07rVJxbSsw3 Y+mnzhkCRgs1IY25RbF3hgv42Eo/2smjVdQzaNyFoDN2HUEMW7oMmi13FQB0reG9bBOn ioow== X-Gm-Message-State: AOUpUlF7mRp4aVj41S1OuJTmNbDt5a3gpT2KA1u6Gm1IMGc3DKLz2qYH 1RGDk3Y4JVsjCeIHqldQtJhxTrWX4+c= X-Google-Smtp-Source: AA+uWPzESUOwQE/XgeKDkgeBjajvgzKa7sACGgVFnT4kiG0JScEIsN+0OCIvfqvMcjSFmjbAiA5DxA== X-Received: by 2002:ae9:e118:: with SMTP id g24-v6mr4136049qkm.306.1533870211886; Thu, 09 Aug 2018 20:03:31 -0700 (PDT) From: Pavel Zbitskiy To: qemu-devel@nongnu.org Date: Thu, 9 Aug 2018 23:01:33 -0400 Message-Id: <20180810030139.25916-2-pavel.zbitskiy@gmail.com> In-Reply-To: <20180810030139.25916-1-pavel.zbitskiy@gmail.com> References: <20180810030139.25916-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::230 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 Reviewed-by: Thomas Huth --- tests/tcg/s390x/Makefile.target | 3 +++ tests/tcg/s390x/hello-s390x.c | 7 +++++++ 2 files changed, 10 insertions(+) create mode 100644 tests/tcg/s390x/Makefile.target create mode 100644 tests/tcg/s390x/hello-s390x.c 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 07:34:29 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 1533870340893451.4188248846866; Thu, 9 Aug 2018 20:05:40 -0700 (PDT) Received: from localhost ([::1]:54002 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnxkB-0007yh-Bz for importer@patchew.org; Thu, 09 Aug 2018 23:05:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnxiK-00063T-Bu for qemu-devel@nongnu.org; Thu, 09 Aug 2018 23:03:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnxiJ-0003uD-AF for qemu-devel@nongnu.org; Thu, 09 Aug 2018 23:03:44 -0400 Received: from mail-qk0-x22c.google.com ([2607:f8b0:400d:c09::22c]:34551) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fnxiJ-0003t0-5p; Thu, 09 Aug 2018 23:03:43 -0400 Received: by mail-qk0-x22c.google.com with SMTP id b66-v6so5537358qkj.1; Thu, 09 Aug 2018 20:03:43 -0700 (PDT) Received: from WAL-L-PZ01.rocketsoftware.com ([2620:117:0:a::c]) by smtp.gmail.com with ESMTPSA id i1-v6sm4457425qtj.65.2018.08.09.20.03.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 20:03:41 -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=5xF+eJSkYgXngLdnDHpCrT3MkKnxFYSaIoaMAUzu0QU=; b=FO+FBWn7xVsZqBRtY1s2sHMve4Jp5NyUKhcIySzSJ2JJ8hNA2SkKnoJHsy1rUXgx8v eVSDYiYEFg6TDkEQ9OIOtcyiqSL+xbS6sDeFuTeyf0Nj9nj8RFR9iYHC7wVIrFbCDYXw sTlITf51TKo6ZLjXKPmkpohUUcEf7sQ/EgAZaet/ctGM8mJq49+gHxxvKFTkC45TBXE2 4Fhv5SkLn6yaaJr1KJZ1IgyjAXX75Otl5q7SxNkISr52Vh8UVhphxUqUPpPM2tCfVmkQ ubKD5lZUGH8jHjWmCyBDFUbl7UuXWSdwvINLgnIjVpqn9XWDEkJNuhTExFI4wpG0GaQe Z9eg== 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=5xF+eJSkYgXngLdnDHpCrT3MkKnxFYSaIoaMAUzu0QU=; b=W7H1XLeLtfY2qkAtJzBjf4kkpScsHEPoB84bN47uPTG0iuh9Ii4CEESqZWIus2NThc sPUos88PAJFn0L7u1MesDgTCE/ED3T8HDDkHMTyMbn8mm7NP9nKo4VHeC50nowLwsJxE ceDUswBnMez1u54NAa0geM+psIkXY90OBM5mzDKE1y00vecQdGI+M6x1Ty0f8nchs2qP TAbQlOL8UTFGfoYwpk6TTvfk4P8nAofhc3wsmNdwj0V52aiIcqaZT96p+WnbBhRQMAco aeWKdufDj1SUjkvNYhDH5xmReBH2ISRIf62LyzPQ20XaEhRcYLaAMgwZc/bVA4yW1jWb Lr1A== X-Gm-Message-State: AOUpUlEsZXy1nk8rqs1HCTBAMV+f/MQmQACMwgzzBYoVbkujZRiG6bfJ C737PMejgKUW1mIU5/OmAurOxIWj7KY= X-Google-Smtp-Source: AA+uWPycrFidJhb7ra8URTS0hQ/OWcd3a1vPr/oHs8H7lQRhyTroY8daFMfAsl2pV/bkTVtmahdKsQ== X-Received: by 2002:a37:1fdf:: with SMTP id n92-v6mr4422372qkh.333.1533870222266; Thu, 09 Aug 2018 20:03:42 -0700 (PDT) From: Pavel Zbitskiy To: qemu-devel@nongnu.org Date: Thu, 9 Aug 2018 23:01:34 -0400 Message-Id: <20180810030139.25916-3-pavel.zbitskiy@gmail.com> In-Reply-To: <20180810030139.25916-1-pavel.zbitskiy@gmail.com> References: <20180810030139.25916-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::22c 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. Signed-off-by: Pavel Zbitskiy --- target/s390x/insn-data.def | 3 +++ target/s390x/translate.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) 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..316ff79250 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -1463,6 +1463,39 @@ static DisasJumpType op_bas(DisasContext *s, DisasOp= s *o) } } =20 +static void save_link_info(DisasContext *s, DisasOps *o) +{ + TCGv_i64 t; + + if (s->base.tb->flags & (FLAG_MASK_32 | FLAG_MASK_64)) { + tcg_gen_movi_i64(o->out, pc_to_link_info(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); + return DISAS_PC_UPDATED; + } else { + return DISAS_NEXT; + } +} + static DisasJumpType op_basi(DisasContext *s, DisasOps *o) { tcg_gen_movi_i64(o->out, pc_to_link_info(s, s->pc_tmp)); --=20 2.18.0 From nobody Wed Nov 5 07:34:29 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 1533870462314889.0932258056584; Thu, 9 Aug 2018 20:07:42 -0700 (PDT) Received: from localhost ([::1]:54017 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnxm9-0001g8-87 for importer@patchew.org; Thu, 09 Aug 2018 23:07:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44022) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnxiL-00064e-QS for qemu-devel@nongnu.org; Thu, 09 Aug 2018 23:03:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnxiK-0003zE-QZ for qemu-devel@nongnu.org; Thu, 09 Aug 2018 23:03:45 -0400 Received: from mail-qk0-x244.google.com ([2607:f8b0:400d:c09::244]:35786) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fnxiK-0003xP-Ld; Thu, 09 Aug 2018 23:03:44 -0400 Received: by mail-qk0-x244.google.com with SMTP id u21-v6so5521782qku.2; Thu, 09 Aug 2018 20:03:44 -0700 (PDT) Received: from WAL-L-PZ01.rocketsoftware.com ([2620:117:0:a::c]) by smtp.gmail.com with ESMTPSA id i1-v6sm4457425qtj.65.2018.08.09.20.03.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 20:03:43 -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=F03cFq8cikBW6PLTuESXSPCnXy9C7RX3u1qiuPP0f6s=; b=MIqsfocIVkE9wDLcjLLc6wAXfjnO0Tx2FTvORwLs9GrKrH58VlrwAnU5P+yZInHunZ uzTei79n9F79jUKmSWMUH14+HEgWl+sDuNvmjudXsWdX/HIayuBmGZPRTUPdwFSAcBHt WSYVMSuFMiDZEcCY9EsnWvHCVh/zH/c/826YDwmHE6jiFrofIBnp/cldQ3wX+1hjyBqG 4zquQTulHqx7aUtur6zvPD4+ZBZfk8cc+M0ui+uaND/MdDBUlDQkfzg+M5JWoQmx2IeH SdOG0CqoTpOMrrPJNz83K0N5dRcWJolX6/WuvhU2UEKkFJ8UbWPg9MLzGQ2WfBXVz1+K N23A== 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=F03cFq8cikBW6PLTuESXSPCnXy9C7RX3u1qiuPP0f6s=; b=MXTSLyUBrU7XMaCKK3qwD2WiD5Q0u8I5tJVgDSCHImughvjk9zYsu/VXDQamG914hF V4Yb4vny0nds3YdwsOCVZemulpvutN/S6L1pkVW8WSTnJ4hpu5bF5o2L5lQYUJWHZVAH R7j4loTCKVy6nFubNcnEW4eC6PBoAPOkZExGzE0xW6OlNZ3fRdBuz7V4GJ8vGi6iqlnR k59Q7rurx+uVgGr74jgHnZjO55hCyyJzU8vZS0OV8FdiW7yR9IhVMd0moF+/8cWCuqQK 4I5mBz6L79if1PhHgTHzP94SBEfm1HONJUlg/jY86Vg2B6DFWceqoFEoMR2ORrjmQgN7 JgBQ== X-Gm-Message-State: AOUpUlGrUr6Rmfjij2Z6TsnteGZVhM5qL9eTz41XTQvAA/s83Dp168Gu Na4g3EfmJLRdERLEpDloR1dq3rpaidk= X-Google-Smtp-Source: AA+uWPxDrplb35uaubhPYxWhx/DAZ+0ue3I9mGxShdHUD/EACp90QMMf3oN5aMI7aYJ6ddYO0jy4Mw== X-Received: by 2002:a37:c887:: with SMTP id t7-v6mr4330116qkl.300.1533870223746; Thu, 09 Aug 2018 20:03:43 -0700 (PDT) From: Pavel Zbitskiy To: qemu-devel@nongnu.org Date: Thu, 9 Aug 2018 23:01:35 -0400 Message-Id: <20180810030139.25916-4-pavel.zbitskiy@gmail.com> In-Reply-To: <20180810030139.25916-1-pavel.zbitskiy@gmail.com> References: <20180810030139.25916-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::244 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 316ff79250..d0d2c3412f 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -2051,9 +2051,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 07:34:29 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 1533870475612886.4956153614116; Thu, 9 Aug 2018 20:07:55 -0700 (PDT) Received: from localhost ([::1]:54020 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnxmM-0001qu-Ir for importer@patchew.org; Thu, 09 Aug 2018 23:07:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnxiN-000663-Cj for qemu-devel@nongnu.org; Thu, 09 Aug 2018 23:03:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnxiM-00043g-G5 for qemu-devel@nongnu.org; Thu, 09 Aug 2018 23:03:47 -0400 Received: from mail-qt0-x22c.google.com ([2607:f8b0:400d:c0d::22c]:33368) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fnxiM-00042V-BP; Thu, 09 Aug 2018 23:03:46 -0400 Received: by mail-qt0-x22c.google.com with SMTP id c15-v6so8951194qtp.0; Thu, 09 Aug 2018 20:03:46 -0700 (PDT) Received: from WAL-L-PZ01.rocketsoftware.com ([2620:117:0:a::c]) by smtp.gmail.com with ESMTPSA id i1-v6sm4457425qtj.65.2018.08.09.20.03.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 20:03:44 -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=R/zYizD8qj0nGYRPK174l1I+UDVDEZJW4JT14os92wM=; b=agBK/5XYxl3yAcLrQVF5KDU2V++d9nwpzWK/DZ2jrkAMDMhIhDgBUlyV1nZL7MrGrY lNHUOc7HoWwo4ucupWlcT1yJ+iDqtloVesyyBQ4wDHXeswQ4yD3AM/LbWza8pQ/RTjeh AI35G+iLoxUTFGcicfGOdaz9iAbM7w1VqUwf1AvZ2/fVyXjW+heSHob20cLtOm0ae9AY gdBIiuUhvEGWNQx0fNT+uvUHDCrUcZUpDqOh1S4WsH/gPFyLrU+17cg9+lsv21rZ96mP PNiaU7wbW+dzxhVeU/TIopXNQXFcC9WsPT4cKimhdH+K8iwhWRnzyMdXJCg+ilC/64Pm 50vA== 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=R/zYizD8qj0nGYRPK174l1I+UDVDEZJW4JT14os92wM=; b=ePTL7J0izFvyeubNyEprf6LF5HbQkqmbupE3pg7OQzFncnuc15vfCHQ/9B6z8Y24a2 Qp7xueJrSiZBUCx+kkdq928dq6ps/687gecfUGPqNRNHX9gCClnjO68Weehmb1YtJF+R GdFtbPFhSvjzalwFYU++hcXlXsQ6adKkI5EsYN9Z4oZi41xZZX2L0nFkB1eySdYQHDtl Naifig+AqlGN9Sa1kUF38sx8kRRkwU5LGy/7jcv61zy+OsnlBWPCWvgRn1lOZJ0ukoV8 uUT8bq8v1wgxLxVD6X9LDTy3bYk3npKNoLMA541XeWJMWjoy6zq052pO1sVVtouZj6HK /Pag== X-Gm-Message-State: AOUpUlHUdoRl4q7jYFZqLtxsNInDNtgxCB00o6EM2V5LINex/pi5p/vC F/V6zpxiBjT8/t4+IDNjDvftHqm3MwM= X-Google-Smtp-Source: AA+uWPzBVbHZHMQ47YsGUN0k3ih8BLjg44R2sbT9MAo2ED3HFEouK09N3lbm7WzSos4ixx019Bi0cg== X-Received: by 2002:ac8:1acd:: with SMTP id h13-v6mr4638523qtk.206.1533870225373; Thu, 09 Aug 2018 20:03:45 -0700 (PDT) From: Pavel Zbitskiy To: qemu-devel@nongnu.org Date: Thu, 9 Aug 2018 23:01:36 -0400 Message-Id: <20180810030139.25916-5-pavel.zbitskiy@gmail.com> In-Reply-To: <20180810030139.25916-1-pavel.zbitskiy@gmail.com> References: <20180810030139.25916-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::22c 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 --- 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 d0d2c3412f..6f8fbda222 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -2437,20 +2437,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 07:34:29 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1533870572999765.5217616337549; Thu, 9 Aug 2018 20:09:32 -0700 (PDT) Received: from localhost ([::1]:54030 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnxno-00039B-T5 for importer@patchew.org; Thu, 09 Aug 2018 23:09:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44078) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnxiP-000688-H7 for qemu-devel@nongnu.org; Thu, 09 Aug 2018 23:03:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnxiO-000482-5G for qemu-devel@nongnu.org; Thu, 09 Aug 2018 23:03:49 -0400 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:36208) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fnxiN-00046J-Uc; Thu, 09 Aug 2018 23:03:48 -0400 Received: by mail-qt0-x244.google.com with SMTP id t5-v6so8926499qtn.3; Thu, 09 Aug 2018 20:03:47 -0700 (PDT) Received: from WAL-L-PZ01.rocketsoftware.com ([2620:117:0:a::c]) by smtp.gmail.com with ESMTPSA id i1-v6sm4457425qtj.65.2018.08.09.20.03.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 20:03:46 -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=iCXhVKKehhd1VGJDR/Rf+A1pcDxzYaIR7NwwKFJC2tMLDeNPJzf3BYMxk7YkFrvxEy oeEgxI5v9kUU610bsz0TBRHTH/mApH8mixxmyyQ2To9c0YND7B30me5+BAf9u3P8ePvb sf0RTmtg6KVEQjyNmqFWe6Vkv5SeONH+f4udPP4RM5KXPOxVpxn2Zh04YxfIj4kTkbPY NEhXYtt2+3qFtN8RO1cXPuTdBXympYFiWsAXkbNk5taGcvePOvAT7CxeLnxRA0BpcaH/ ozouir0QwwHzZhF8w2j4MTZTLxgZ6R7bSoHt9kZjSQhuJ7NPR/95uFLJI3s/RRF12VLg Wk4Q== 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=IwVgcUVy1LzZEfj9xx0L6gyZCs2MZDEx6MoHCpkShN43u3X5u2uJzDbbHb/T6JvPZp GOC/KbZ9yCPmkz3pAQO07glio6pdi8UWDz34G13TaecXn2ha7b3lV8jsyYZeJt3emdgd COYfFSEj8HU+w4vwraeHWtBM/djsHyLvlY2GHURj9Y/QXrjLO9XUC3KU/sZo/kBv8YLM CVL6x+TQgRzZqAhWhAA+KYxeRpEsPhq06ALNxRovqySJ2m6OAUwyX8Rr4JpocyxPXz6m ROShQzWc97jTySbO3tDeODsoABUpfjbgZ41jqyGJPZ192Az+YNNhll8lVfjUOZxwnIWt 8IAw== X-Gm-Message-State: AOUpUlEm9fUqshVnCiwXMAPUxJL+sgcD0Ki2aoNUP+5hfAC1zNi0H6ga Rp6tXjjkBSGM7LoyAXEWwy8tHlcZFkA= X-Google-Smtp-Source: AA+uWPzkP9woSd8OxjVlQV8nwKa3A/aS5nBGMlC/1wbNlG4aA0bXeKY5mqO25z3aXU+s4bN2e+oUoA== X-Received: by 2002:aed:235a:: with SMTP id i26-v6mr4654121qtc.382.1533870226925; Thu, 09 Aug 2018 20:03:46 -0700 (PDT) From: Pavel Zbitskiy To: qemu-devel@nongnu.org Date: Thu, 9 Aug 2018 23:01:37 -0400 Message-Id: <20180810030139.25916-6-pavel.zbitskiy@gmail.com> In-Reply-To: <20180810030139.25916-1-pavel.zbitskiy@gmail.com> References: <20180810030139.25916-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::244 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 07:34:29 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 15338703959951021.2810106590921; Thu, 9 Aug 2018 20:06:35 -0700 (PDT) Received: from localhost ([::1]:54011 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnxl4-0000qc-SE for importer@patchew.org; Thu, 09 Aug 2018 23:06:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnxiQ-00068x-89 for qemu-devel@nongnu.org; Thu, 09 Aug 2018 23:03:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnxiP-0004BD-EQ for qemu-devel@nongnu.org; Thu, 09 Aug 2018 23:03:50 -0400 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]:44469) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fnxiP-0004A8-9R; Thu, 09 Aug 2018 23:03:49 -0400 Received: by mail-qt0-x242.google.com with SMTP id b15-v6so8852094qtp.11; Thu, 09 Aug 2018 20:03:49 -0700 (PDT) Received: from WAL-L-PZ01.rocketsoftware.com ([2620:117:0:a::c]) by smtp.gmail.com with ESMTPSA id i1-v6sm4457425qtj.65.2018.08.09.20.03.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 20:03:47 -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=BV4WN+AaurihIjW0NPhlY6Sq+TgS+qGzkdHmdcL2bLngI+y64RuHj8AgwPupHVQqDW 1myaWUDenQmRh/PYZ+ylFAWTpREat44DaJjXuXvi0qlAg6CCpw3E6/oQ00PznBuVuVZl 8Z0pSr+fgvfAhlzNg+SWza0EhllSY6jF5zynFqy5BNThu3kQuWsVuhIduAkvk0yyu2sD MZJPaGBXz/uZ8fVQaM6/8uVgvGtz+JCs025DhA15AlFzjnnVnxxzvrghnHg8DY5iAYys O8eOKMTRfAq5TNsEGBTIz/y1u0oLtUVcgWRIrbmS6nUaRO8nCSEWUSV7JXAyIPytUwFV E89Q== 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=Nl8zJTgFLHfU2g/69a8HtNfZLFi1RDNoKaZSemCcKXX7KBMrARkwAlH2TO9QOCRj8f 0SpQfw9XBvAgbcn5muYAXB8ISOZvZVN6cr7gcosGzVzPtXFDaS6K0Dp/G0YkxYu58+Q1 Fa6gdXqm+qmgiUmuEOpcD6GLvLm2BCJKRtM90swsACi0mZ71knEayjVj8r/r4JH87XkI lCwNaD/qvWxCcmToW0D34MisIahyTcZYMNh7tYS4xjPUIN0YGShJk51ta6Q17huF1ICf pLUBouYV+irVgb8OpXYoLaVePHORWez1qmk0LDBRSX/LQJO74+tC9PL3pjFcR1YKfJad lKcg== X-Gm-Message-State: AOUpUlH3ZXRck/mXVfO6GHjsBK06PvfVDACBMDBRSRpeY6m6pXExPEst 0xNkff9exs3S5c+2oeEMbUr0+Jar2t0= X-Google-Smtp-Source: AA+uWPwU1mxFLUOgmBrZGkCrcCR/ZVpMi2axhacIjgbf/IvKfzHBYZQQT+gQXJfJMnAHuwfb68jJFA== X-Received: by 2002:ac8:fc9:: with SMTP id f9-v6mr4837844qtk.377.1533870228318; Thu, 09 Aug 2018 20:03:48 -0700 (PDT) From: Pavel Zbitskiy To: qemu-devel@nongnu.org Date: Thu, 9 Aug 2018 23:01:38 -0400 Message-Id: <20180810030139.25916-7-pavel.zbitskiy@gmail.com> In-Reply-To: <20180810030139.25916-1-pavel.zbitskiy@gmail.com> References: <20180810030139.25916-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 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 --- 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 07:34:29 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 1533870638886253.77416053222407; Thu, 9 Aug 2018 20:10:38 -0700 (PDT) Received: from localhost ([::1]:54036 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnxos-0004L5-JI for importer@patchew.org; Thu, 09 Aug 2018 23:10:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnxiS-0006BO-Io for qemu-devel@nongnu.org; Thu, 09 Aug 2018 23:03:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnxiR-0004FA-4m for qemu-devel@nongnu.org; Thu, 09 Aug 2018 23:03:52 -0400 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:33929) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fnxiQ-0004Dw-V5; Thu, 09 Aug 2018 23:03:51 -0400 Received: by mail-qt0-x243.google.com with SMTP id m13-v6so8930961qth.1; Thu, 09 Aug 2018 20:03:50 -0700 (PDT) Received: from WAL-L-PZ01.rocketsoftware.com ([2620:117:0:a::c]) by smtp.gmail.com with ESMTPSA id i1-v6sm4457425qtj.65.2018.08.09.20.03.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 20:03:49 -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=TuuTw94Y/4LM5XkeW6FZDljgYSKceVD4X/P9zPlq/N8=; b=hsHzQQRZRVgw6RxObaAXRS3tshNLu42tEQJXSAbgBiqOMMkHb55YJKZ9ROjPmzJA36 yVVAuphAwHponAquURt6zpmMyWBaUbVM1w+pXfiqwXEbzU6dJD4waHO+fZfcyBo0aIDp CUfRnKc+LZl4tJWwxNmKrjzvDcooMmQ18NfDgD8xVmhz5cVJqw7TDx3rylwFx3Wf0hbz stCzv799sBVehJS0JShRM18f49Th3r6tmM9Z9UjK5teP5oD8m7x4jSYYy0+TBrEqYsjb unU5xcJ6lnkQAwLm567CmH+5bZWJta91ZfVadI9WB+g/ICqc8j60AN8wMVYbBCI5BenY cfDg== 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=TuuTw94Y/4LM5XkeW6FZDljgYSKceVD4X/P9zPlq/N8=; b=DuixvFM1T4hmTgcR3a07cFjF21KfVK159z26eThzxGYeswgALuvOjg9Vdgtxx7Q0Mw w1P4MS2+qR1snhy66TBX+RjOkpUk2MQTKgUL1gwq47ifYFmZx9qH1DseKCeDd1I1XOXx JMTFtgda40SYnrry4kVjcL7n4s37WVvI3RQnvzQ4zHU8ymU1BWBd1rAoqp1G7tLu2g0c MAdaAWW0UPOCDqU02iGGeAIr4AEUWyWFCRptExYqwpianR9vRsSIgQX6RDmdeoy+sSni mNW8CYPjFtOscXmPyzY9QRSydG264MRmJmyfxANyMJ9tSdPt1QNbfjfPxqHczj/1UkPa Um5A== X-Gm-Message-State: AOUpUlHQXn8/RSdpv2m3G8zQRdG2liWNRcL4sZxnJLBPn1VqufxDpp5F E44Kw/fLfe9IdoAbXKystC1vM75EiNw= X-Google-Smtp-Source: AA+uWPx8/8FllUnSCwH/6z9qV0TpSYysSaZGvjsOxUgFjOqRObCD2Gn9bDHKWTWcdM/Z8th7KWfI3w== X-Received: by 2002:aed:22e9:: with SMTP id q38-v6mr4853780qtc.179.1533870229978; Thu, 09 Aug 2018 20:03:49 -0700 (PDT) From: Pavel Zbitskiy To: qemu-devel@nongnu.org Date: Thu, 9 Aug 2018 23:01:39 -0400 Message-Id: <20180810030139.25916-8-pavel.zbitskiy@gmail.com> In-Reply-To: <20180810030139.25916-1-pavel.zbitskiy@gmail.com> References: <20180810030139.25916-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 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 6f8fbda222..48a97a37ff 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -2107,6 +2107,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