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 02/33] s390x/tcg: Check vector register instructions at central point
Date: Tue, 26 Feb 2019 12:38:44 +0100	[thread overview]
Message-ID: <20190226113915.20150-3-david@redhat.com> (raw)
In-Reply-To: <20190226113915.20150-1-david@redhat.com>

Check them at a central point. We'll use a new instruction flag to
flag all vector instructions (IF_VEC) and handle it very similar to
AFP, whereby we use another unused position in the PSW mask to store
the state of vector register enablement per translation block.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 target/s390x/cpu.h       |  7 +++++++
 target/s390x/translate.c | 12 ++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index b71ac5183d..cb6d77053a 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -257,6 +257,7 @@ extern const struct VMStateDescription vmstate_s390_cpu;
 /* PSW defines */
 #undef PSW_MASK_PER
 #undef PSW_MASK_UNUSED_2
+#undef PSW_MASK_UNUSED_3
 #undef PSW_MASK_DAT
 #undef PSW_MASK_IO
 #undef PSW_MASK_EXT
@@ -276,6 +277,7 @@ extern const struct VMStateDescription vmstate_s390_cpu;
 
 #define PSW_MASK_PER            0x4000000000000000ULL
 #define PSW_MASK_UNUSED_2       0x2000000000000000ULL
+#define PSW_MASK_UNUSED_3       0x1000000000000000ULL
 #define PSW_MASK_DAT            0x0400000000000000ULL
 #define PSW_MASK_IO             0x0200000000000000ULL
 #define PSW_MASK_EXT            0x0100000000000000ULL
@@ -323,12 +325,14 @@ extern const struct VMStateDescription vmstate_s390_cpu;
 
 /* we'll use some unused PSW positions to store CR flags in tb flags */
 #define FLAG_MASK_AFP           (PSW_MASK_UNUSED_2 >> FLAG_MASK_PSW_SHIFT)
+#define FLAG_MASK_VECTOR        (PSW_MASK_UNUSED_3 >> FLAG_MASK_PSW_SHIFT)
 
 /* Control register 0 bits */
 #define CR0_LOWPROT             0x0000000010000000ULL
 #define CR0_SECONDARY           0x0000000004000000ULL
 #define CR0_EDAT                0x0000000000800000ULL
 #define CR0_AFP                 0x0000000000040000ULL
+#define CR0_VECTOR              0x0000000000020000ULL
 #define CR0_EMERGENCY_SIGNAL_SC 0x0000000000004000ULL
 #define CR0_EXTERNAL_CALL_SC    0x0000000000002000ULL
 #define CR0_CKC_SC              0x0000000000000800ULL
@@ -373,6 +377,9 @@ static inline void cpu_get_tb_cpu_state(CPUS390XState* env, target_ulong *pc,
     if (env->cregs[0] & CR0_AFP) {
         *flags |= FLAG_MASK_AFP;
     }
+    if (env->cregs[0] & CR0_VECTOR) {
+        *flags |= FLAG_MASK_VECTOR;
+    }
 }
 
 /* PER bits from control register 9 */
diff --git a/target/s390x/translate.c b/target/s390x/translate.c
index 1d8030f8cd..d52c02c572 100644
--- a/target/s390x/translate.c
+++ b/target/s390x/translate.c
@@ -1203,6 +1203,7 @@ typedef struct {
 #define IF_BFP      0x0008      /* binary floating point instruction */
 #define IF_DFP      0x0010      /* decimal floating point instruction */
 #define IF_PRIV     0x0020      /* privileged instruction */
+#define IF_VEC      0x0040      /* vector instruction */
 
 struct DisasInsn {
     unsigned opc:16;
@@ -6337,11 +6338,22 @@ static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s)
             if (insn->flags & IF_DFP) {
                 dxc = 3;
             }
+            if (insn->flags & IF_VEC) {
+                dxc = 0xfe;
+            }
             if (dxc) {
                 gen_data_exception(dxc);
                 return DISAS_NORETURN;
             }
         }
+
+        /* if vector instructions not enabled, executing them is forbidden */
+        if (insn->flags & IF_VEC) {
+            if (!((s->base.tb->flags & FLAG_MASK_VECTOR))) {
+                gen_data_exception(0xfe);
+                return DISAS_NORETURN;
+            }
+        }
     }
 
     /* Check for insn specification exceptions.  */
-- 
2.17.2

  parent reply	other threads:[~2019-02-26 11:39 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 ` David Hildenbrand [this message]
2019-02-26 18:26   ` [Qemu-devel] [PATCH v1 02/33] s390x/tcg: Check vector register instructions at central point 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 ` [Qemu-devel] [PATCH v1 15/33] s390x/tcg: Implement VECTOR LOAD TO BLOCK BOUNDARY David Hildenbrand
2019-02-27 16:08   ` 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-3-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).