From nobody Sat Sep 28 22:13:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552296011832875.0817185165204; Mon, 11 Mar 2019 02:20:11 -0700 (PDT) Received: from localhost ([127.0.0.1]:58002 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3H6N-0007KE-7C for importer@patchew.org; Mon, 11 Mar 2019 05:20:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43334) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3GrQ-0003cY-FT for qemu-devel@nongnu.org; Mon, 11 Mar 2019 05:04:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3GrN-0005sy-Ki for qemu-devel@nongnu.org; Mon, 11 Mar 2019 05:04:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28855) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3GrN-0005rv-BF; Mon, 11 Mar 2019 05:04:37 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1951D308FBA9; Mon, 11 Mar 2019 09:04:36 +0000 (UTC) Received: from localhost (ovpn-117-96.ams2.redhat.com [10.36.117.96]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9A60F60C64; Mon, 11 Mar 2019 09:04:35 +0000 (UTC) From: Cornelia Huck To: Peter Maydell Date: Mon, 11 Mar 2019 10:03:04 +0100 Message-Id: <20190311090322.21603-16-cohuck@redhat.com> In-Reply-To: <20190311090322.21603-1-cohuck@redhat.com> References: <20190311090322.21603-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 11 Mar 2019 09:04:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 15/33] s390x/tcg: Implement VECTOR LOAD TO BLOCK BOUNDARY 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: qemu-s390x@nongnu.org, Cornelia Huck , qemu-devel@nongnu.org, David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Very similar to LOAD COUNT TO BLOCK BOUNDARY, but instead of only calculating, the actual vector is loaded. Use a temporary vector to not modify the real vector on exceptions. Initialize that one to zero, to not leak any data. Provide a fast path if we're loading a full vector. As we don't have gvec ool handlers for single vectors, just calculate the vector address manually. We can reuse the helper later on for VECTOR LOAD WITH LENGTH. In fact, we are going to name it "vll" right from the beginning, because that's a better match. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand Message-Id: <20190307121539.12842-15-david@redhat.com> Signed-off-by: Cornelia Huck --- target/s390x/Makefile.objs | 1 + target/s390x/helper.h | 3 +++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 25 +++++++++++++++++++ target/s390x/vec_helper.c | 44 +++++++++++++++++++++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 target/s390x/vec_helper.c diff --git a/target/s390x/Makefile.objs b/target/s390x/Makefile.objs index 22a9a9927acb..68eeee3d2f9b 100644 --- a/target/s390x/Makefile.objs +++ b/target/s390x/Makefile.objs @@ -1,6 +1,7 @@ obj-y +=3D cpu.o cpu_models.o cpu_features.o gdbstub.o interrupt.o helper.o obj-$(CONFIG_TCG) +=3D translate.o cc_helper.o excp_helper.o fpu_helper.o obj-$(CONFIG_TCG) +=3D int_helper.o mem_helper.o misc_helper.o crypto_help= er.o +obj-$(CONFIG_TCG) +=3D vec_helper.o obj-$(CONFIG_SOFTMMU) +=3D machine.o ioinst.o arch_dump.o mmu_helper.o dia= g.o obj-$(CONFIG_SOFTMMU) +=3D sigp.o obj-$(CONFIG_KVM) +=3D kvm.o diff --git a/target/s390x/helper.h b/target/s390x/helper.h index bb659257f6cd..6c745ba0f6ad 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -124,6 +124,9 @@ DEF_HELPER_5(msa, i32, env, i32, i32, i32, i32) DEF_HELPER_FLAGS_1(stpt, TCG_CALL_NO_RWG, i64, env) DEF_HELPER_FLAGS_1(stck, TCG_CALL_NO_RWG_SE, i64, env) =20 +/* =3D=3D=3D Vector Support Instructions =3D=3D=3D */ +DEF_HELPER_FLAGS_4(vll, TCG_CALL_NO_WG, void, env, ptr, i64, i64) + #ifndef CONFIG_USER_ONLY DEF_HELPER_3(servc, i32, env, i64, i64) DEF_HELPER_4(diag, void, env, i32, i32, i32) diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def index fa0f3a90034d..ad8df5283cfd 100644 --- a/target/s390x/insn-data.def +++ b/target/s390x/insn-data.def @@ -1002,6 +1002,8 @@ F(0xe704, VLLEZ, VRX, V, la2, 0, 0, 0, vllez, 0, IF_VEC) /* VECTOR LOAD MULTIPLE */ F(0xe736, VLM, VRS_a, V, la2, 0, 0, 0, vlm, 0, IF_VEC) +/* VECTOR LOAD TO BLOCK BOUNDARY */ + F(0xe707, VLBB, VRX, V, la2, 0, 0, 0, vlbb, 0, IF_VEC) =20 #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */ diff --git a/target/s390x/translate_vx.inc.c b/target/s390x/translate_vx.in= c.c index 083f5c621334..f1eb45890201 100644 --- a/target/s390x/translate_vx.inc.c +++ b/target/s390x/translate_vx.inc.c @@ -446,3 +446,28 @@ static DisasJumpType op_vlm(DisasContext *s, DisasOps = *o) tcg_temp_free_i64(t1); return DISAS_NEXT; } + +static DisasJumpType op_vlbb(DisasContext *s, DisasOps *o) +{ + const int64_t block_size =3D (1ull << (get_field(s->fields, m3) + 6)); + const int v1_offs =3D vec_full_reg_offset(get_field(s->fields, v1)); + TCGv_ptr a0; + TCGv_i64 bytes; + + if (get_field(s->fields, m3) > 6) { + gen_program_exception(s, PGM_SPECIFICATION); + return DISAS_NORETURN; + } + + bytes =3D tcg_temp_new_i64(); + a0 =3D tcg_temp_new_ptr(); + /* calculate the number of bytes until the next block boundary */ + tcg_gen_ori_i64(bytes, o->addr1, -block_size); + tcg_gen_neg_i64(bytes, bytes); + + tcg_gen_addi_ptr(a0, cpu_env, v1_offs); + gen_helper_vll(cpu_env, a0, o->addr1, bytes); + tcg_temp_free_i64(bytes); + tcg_temp_free_ptr(a0); + return DISAS_NEXT; +} diff --git a/target/s390x/vec_helper.c b/target/s390x/vec_helper.c new file mode 100644 index 000000000000..5b2333a8d666 --- /dev/null +++ b/target/s390x/vec_helper.c @@ -0,0 +1,44 @@ +/* + * QEMU TCG support -- s390x vector support instructions + * + * Copyright (C) 2019 Red Hat Inc + * + * Authors: + * David Hildenbrand + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "cpu.h" +#include "internal.h" +#include "vec.h" +#include "tcg/tcg.h" +#include "exec/helper-proto.h" +#include "exec/cpu_ldst.h" +#include "exec/exec-all.h" + +void HELPER(vll)(CPUS390XState *env, void *v1, uint64_t addr, uint64_t byt= es) +{ + if (likely(bytes >=3D 16)) { + uint64_t t0, t1; + + t0 =3D cpu_ldq_data_ra(env, addr, GETPC()); + addr =3D wrap_address(env, addr + 8); + t1 =3D cpu_ldq_data_ra(env, addr, GETPC()); + s390_vec_write_element64(v1, 0, t0); + s390_vec_write_element64(v1, 1, t1); + } else { + S390Vector tmp =3D {}; + int i; + + for (i =3D 0; i < bytes; i++) { + uint8_t byte =3D cpu_ldub_data_ra(env, addr, GETPC()); + + s390_vec_write_element8(&tmp, i, byte); + addr =3D wrap_address(env, addr + 1); + } + *(S390Vector *)v1 =3D tmp; + } +} --=20 2.17.2