qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-s390x@nongnu.org, Thomas Huth <thuth@redhat.com>,
	Cornelia Huck <cohuck@redhat.com>,
	Richard Henderson <rth@twiddle.net>,
	David Hildenbrand <david@redhat.com>
Subject: [Qemu-devel] [PATCH v1 15/33] s390x/tcg: Implement VECTOR LOAD TO BLOCK BOUNDARY
Date: Tue, 26 Feb 2019 12:38:57 +0100	[thread overview]
Message-ID: <20190226113915.20150-16-david@redhat.com> (raw)
In-Reply-To: <20190226113915.20150-1-david@redhat.com>

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.

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.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 target/s390x/helper.h           |  3 +++
 target/s390x/insn-data.def      |  2 ++
 target/s390x/translate_vx.inc.c | 25 +++++++++++++++++++++++++
 target/s390x/vec_helper.c       | 20 ++++++++++++++++++++
 4 files changed, 50 insertions(+)

diff --git a/target/s390x/helper.h b/target/s390x/helper.h
index bb659257f6..6c745ba0f6 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)
 
+/* === Vector Support Instructions === */
+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 65ff8bbd2e..2ab88938ff 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)
 
 #ifndef CONFIG_USER_ONLY
 /* COMPARE AND SWAP AND PURGE */
diff --git a/target/s390x/translate_vx.inc.c b/target/s390x/translate_vx.inc.c
index c9f57afd4a..b5ed3bd89f 100644
--- a/target/s390x/translate_vx.inc.c
+++ b/target/s390x/translate_vx.inc.c
@@ -403,3 +403,28 @@ static DisasJumpType op_vlm(DisasContext *s, DisasOps *o)
     }
     return DISAS_NEXT;
 }
+
+static DisasJumpType op_vlbb(DisasContext *s, DisasOps *o)
+{
+    const int64_t block_size = (1ull << (get_field(s->fields, m3) + 6));
+    const int v1_offs = 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 = tcg_temp_new_i64();
+    a0 = 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
index 3e21e440ba..d2f510ed07 100644
--- a/target/s390x/vec_helper.c
+++ b/target/s390x/vec_helper.c
@@ -11,8 +11,13 @@
  */
 #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"
 
 /*
  * Each vector is stored as two 64bit host values. So when talking about
@@ -88,3 +93,18 @@ void s390_vec_write_element64(S390Vector *v, uint8_t enr, uint64_t data)
     g_assert(enr < 2);
     v->doubleword[enr] = data;
 }
+
+void HELPER(vll)(CPUS390XState *env, void *v1, uint64_t addr, uint64_t bytes)
+{
+    S390Vector tmp = {};
+    int i;
+
+    bytes = MIN(bytes, 16);
+    for (i = 0; i < bytes; i++) {
+        uint8_t byte = cpu_ldub_data_ra(env, addr, GETPC());
+
+        s390_vec_write_element8(&tmp, i, byte);
+        addr = wrap_address(env, addr + 1);
+    }
+    *(S390Vector *)v1 = tmp;
+}
-- 
2.17.2

  parent reply	other threads:[~2019-02-26 11:40 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-26 11:38 [Qemu-devel] [PATCH v1 00/33] s390x/tcg: Vector Instruction Support Part 1 David Hildenbrand
2019-02-26 11:38 ` [Qemu-devel] [PATCH v1 01/33] s390x/tcg: Define vector instruction formats David Hildenbrand
2019-02-26 18:24   ` Richard Henderson
2019-02-26 11:38 ` [Qemu-devel] [PATCH v1 02/33] s390x/tcg: Check vector register instructions at central point David Hildenbrand
2019-02-26 18:26   ` Richard Henderson
2019-02-26 11:38 ` [Qemu-devel] [PATCH v1 03/33] s390x: Add one temporary vector register in CPU state for TCG David Hildenbrand
2019-02-26 18:36   ` Richard Henderson
2019-02-26 18:45     ` David Hildenbrand
2019-02-26 11:38 ` [Qemu-devel] [PATCH v1 04/33] s390x/tcg: Utilities for vector instruction helpers David Hildenbrand
2019-02-26 11:38 ` [Qemu-devel] [PATCH v1 05/33] s390x/tcg: Implement VECTOR GATHER ELEMENT David Hildenbrand
2019-02-26 18:44   ` Richard Henderson
2019-02-26 11:38 ` [Qemu-devel] [PATCH v1 06/33] s390x/tcg: Implement VECTOR GENERATE BYTE MASK David Hildenbrand
2019-02-26 19:12   ` Richard Henderson
2019-02-26 19:23     ` David Hildenbrand
2019-02-26 21:23       ` David Hildenbrand
2019-02-26 11:38 ` [Qemu-devel] [PATCH v1 07/33] s390x/tcg: Implement VECTOR GENERATE MASK David Hildenbrand
2019-02-26 21:16   ` David Hildenbrand
2019-02-27 15:29     ` Richard Henderson
2019-02-26 11:38 ` [Qemu-devel] [PATCH v1 08/33] s390x/tcg: Implement VECTOR LOAD David Hildenbrand
2019-02-27 15:39   ` Richard Henderson
2019-02-28  7:48     ` David Hildenbrand
2019-02-28 16:34       ` Richard Henderson
2019-02-28 16:40         ` David Hildenbrand
2019-02-26 11:38 ` [Qemu-devel] [PATCH v1 09/33] s390x/tcg: Implement VECTOR LOAD AND REPLICATE David Hildenbrand
2019-02-27 15:40   ` Richard Henderson
2019-02-26 11:38 ` [Qemu-devel] [PATCH v1 10/33] s390x/tcg: Implement VECTOR LOAD ELEMENT David Hildenbrand
2019-02-27 15:42   ` Richard Henderson
2019-02-26 11:38 ` [Qemu-devel] [PATCH v1 11/33] s390x/tcg: Implement VECTOR LOAD ELEMENT IMMEDIATE David Hildenbrand
2019-02-27 15:44   ` Richard Henderson
2019-02-26 11:38 ` [Qemu-devel] [PATCH v1 12/33] s390x/tcg: Implement VECTOR LOAD GR FROM VR ELEMENT David Hildenbrand
2019-02-27 15:53   ` Richard Henderson
2019-02-28  8:27     ` David Hildenbrand
2019-02-28 17:10       ` Richard Henderson
2019-02-26 11:38 ` [Qemu-devel] [PATCH v1 13/33] s390x/tcg: Implement VECTOR LOAD LOGICAL ELEMENT AND ZERO David Hildenbrand
2019-02-27 15:56   ` Richard Henderson
2019-02-28  8:30     ` David Hildenbrand
2019-02-26 11:38 ` [Qemu-devel] [PATCH v1 14/33] s390x/tcg: Implement VECTOR LOAD MULTIPLE David Hildenbrand
2019-02-27 16:02   ` Richard Henderson
2019-02-28  8:36     ` David Hildenbrand
2019-02-28 17:15       ` Richard Henderson
2019-02-28 19:05         ` David Hildenbrand
2019-03-01  6:34           ` Richard Henderson
2019-02-26 11:38 ` David Hildenbrand [this message]
2019-02-27 16:08   ` [Qemu-devel] [PATCH v1 15/33] s390x/tcg: Implement VECTOR LOAD TO BLOCK BOUNDARY Richard Henderson
2019-02-28  8:40     ` David Hildenbrand
2019-02-26 11:38 ` [Qemu-devel] [PATCH v1 16/33] s390x/tcg: Implement VECTOR LOAD VR ELEMENT FROM GR David Hildenbrand
2019-02-27 16:08   ` Richard Henderson
2019-02-26 11:38 ` [Qemu-devel] [PATCH v1 17/33] s390x/tcg: Implement VECTOR LOAD VR FROM GRS DISJOINT David Hildenbrand
2019-02-27 16:10   ` Richard Henderson
2019-02-26 11:39 ` [Qemu-devel] [PATCH v1 18/33] s390x/tcg: Implement VECTOR LOAD WITH LENGTH David Hildenbrand
2019-02-27 16:12   ` Richard Henderson
2019-02-26 11:39 ` [Qemu-devel] [PATCH v1 19/33] s390x/tcg: Implement VECTOR MERGE (HIGH|LOW) David Hildenbrand
2019-02-27 16:14   ` Richard Henderson
2019-02-27 16:20   ` Richard Henderson
2019-02-28  8:54     ` David Hildenbrand
2019-02-26 11:39 ` [Qemu-devel] [PATCH v1 20/33] s390x/tcg: Implement VECTOR PACK David Hildenbrand
2019-02-27 23:11   ` Richard Henderson
2019-02-26 11:39 ` [Qemu-devel] [PATCH v1 21/33] s390x/tcg: Implement VECTOR PACK (LOGICAL) SATURATE David Hildenbrand
2019-02-27 23:18   ` Richard Henderson
2019-02-27 23:24   ` Richard Henderson
2019-02-26 11:39 ` [Qemu-devel] [PATCH v1 22/33] s390x/tcg: Implement VECTOR PERMUTE David Hildenbrand
2019-02-27 23:21   ` Richard Henderson
2019-02-26 11:39 ` [Qemu-devel] [PATCH v1 23/33] s390x/tcg: Implement VECTOR PERMUTE DOUBLEWORD IMMEDIATE David Hildenbrand
2019-02-27 23:26   ` Richard Henderson
2019-02-26 11:39 ` [Qemu-devel] [PATCH v1 24/33] s390x/tcg: Implement VECTOR REPLICATE David Hildenbrand
2019-02-27 23:29   ` Richard Henderson
2019-02-27 23:31   ` Richard Henderson
2019-02-26 11:39 ` [Qemu-devel] [PATCH v1 25/33] s390x/tcg: Implement VECTOR REPLICATE IMMEDIATE David Hildenbrand
2019-02-27 23:39   ` Richard Henderson
2019-02-28  9:07     ` David Hildenbrand
2019-02-26 11:39 ` [Qemu-devel] [PATCH v1 26/33] s390x/tcg: Implement VECTOR SCATTER ELEMENT David Hildenbrand
2019-02-27 23:40   ` Richard Henderson
2019-02-26 11:39 ` [Qemu-devel] [PATCH v1 27/33] s390x/tcg: Implement VECTOR SELECT David Hildenbrand
2019-02-27 23:42   ` Richard Henderson
2019-02-28  9:09     ` David Hildenbrand
2019-02-26 11:39 ` [Qemu-devel] [PATCH v1 28/33] s390x/tcg: Implement VECTOR SIGN EXTEND TO DOUBLEWORD David Hildenbrand
2019-02-27 23:43   ` Richard Henderson
2019-02-26 11:39 ` [Qemu-devel] [PATCH v1 29/33] s390x/tcg: Implement VECTOR STORE David Hildenbrand
2019-02-27 23:46   ` Richard Henderson
2019-02-28  9:11     ` David Hildenbrand
2019-02-26 11:39 ` [Qemu-devel] [PATCH v1 30/33] s390x/tcg: Implement VECTOR STORE ELEMENT David Hildenbrand
2019-02-27 23:47   ` Richard Henderson
2019-02-26 11:39 ` [Qemu-devel] [PATCH v1 31/33] s390x/tcg: Implement VECTOR STORE MULTIPLE David Hildenbrand
2019-02-27 23:48   ` Richard Henderson
2019-02-26 11:39 ` [Qemu-devel] [PATCH v1 32/33] s390x/tcg: Implement VECTOR STORE WITH LENGTH David Hildenbrand
2019-02-27 23:49   ` Richard Henderson
2019-02-28  9:13     ` David Hildenbrand
2019-02-26 11:39 ` [Qemu-devel] [PATCH v1 33/33] s390x/tcg: Implement VECTOR UNPACK * David Hildenbrand
2019-02-28  0:03   ` Richard Henderson
2019-02-28  9:28     ` David Hildenbrand
2019-02-28 10:54       ` David Hildenbrand
2019-02-28 18:22         ` Richard Henderson
2019-02-28 19:45           ` David Hildenbrand
2019-02-28  7:24 ` [Qemu-devel] [PATCH v1 00/33] s390x/tcg: Vector Instruction Support Part 1 David Hildenbrand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190226113915.20150-16-david@redhat.com \
    --to=david@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).