From: Cornelia Huck <cohuck@redhat.com>
To: peter.maydell@linaro.org
Cc: qemu-devel@nongnu.org, rth@twiddle.net, agraf@suse.de,
thuth@redhat.com, borntraeger@de.ibm.com, david@redhat.com,
Cornelia Huck <cohuck@redhat.com>
Subject: [Qemu-devel] [PULL 03/33] s390x/tcg: add basic MSA features
Date: Fri, 6 Oct 2017 11:59:26 +0200 [thread overview]
Message-ID: <20171006095956.27534-4-cohuck@redhat.com> (raw)
In-Reply-To: <20171006095956.27534-1-cohuck@redhat.com>
From: David Hildenbrand <david@redhat.com>
The STFLE bits for the MSA (extension) facilities simply indicate that
the respective instructions can be executed. The QUERY subfunction can then
be used to identify which features exactly are available.
Availability of subfunctions can also vary on real hardware. For now, we
simply implement a CPU model without any available subfunctions except
QUERY (which is always around).
As all MSA functions behave quite similarly, we can use one translation
handler for now. Prepare the code for implementation of actual subfunctions.
At least MSA is helpful for now, as older Linux kernels require this
facility when compiled for a z9 model. Allow to enable the facilities
for the qemu cpu model.
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20170920153016.3858-4-david@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
---
target/s390x/Makefile.objs | 2 +-
target/s390x/cpu_models.c | 4 +++
target/s390x/crypto_helper.c | 65 ++++++++++++++++++++++++++++++++++++++++++++
target/s390x/helper.h | 1 +
target/s390x/insn-data.def | 13 +++++++++
target/s390x/translate.c | 56 ++++++++++++++++++++++++++++++++++++++
6 files changed, 140 insertions(+), 1 deletion(-)
create mode 100644 target/s390x/crypto_helper.c
diff --git a/target/s390x/Makefile.objs b/target/s390x/Makefile.objs
index 9615256d81..c88ac81e84 100644
--- a/target/s390x/Makefile.objs
+++ b/target/s390x/Makefile.objs
@@ -1,6 +1,6 @@
obj-y += cpu.o cpu_models.o cpu_features.o gdbstub.o interrupt.o helper.o
obj-$(CONFIG_TCG) += translate.o cc_helper.o excp_helper.o fpu_helper.o
-obj-$(CONFIG_TCG) += int_helper.o mem_helper.o misc_helper.o
+obj-$(CONFIG_TCG) += int_helper.o mem_helper.o misc_helper.o crypto_helper.o
obj-$(CONFIG_SOFTMMU) += machine.o ioinst.o arch_dump.o mmu_helper.o diag.o
obj-$(CONFIG_KVM) += kvm.o
obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
index 5169379db5..1051a16ece 100644
--- a/target/s390x/cpu_models.c
+++ b/target/s390x/cpu_models.c
@@ -825,6 +825,7 @@ static void add_qemu_cpu_model_features(S390FeatBitmap fbm)
S390_FEAT_STFLE,
S390_FEAT_EXTENDED_IMMEDIATE,
S390_FEAT_EXTENDED_TRANSLATION_2,
+ S390_FEAT_MSA,
S390_FEAT_EXTENDED_TRANSLATION_3,
S390_FEAT_LONG_DISPLACEMENT,
S390_FEAT_LONG_DISPLACEMENT_FAST,
@@ -841,6 +842,9 @@ static void add_qemu_cpu_model_features(S390FeatBitmap fbm)
S390_FEAT_STFLE_49,
S390_FEAT_LOCAL_TLB_CLEARING,
S390_FEAT_STFLE_53,
+ S390_FEAT_MSA_EXT_5,
+ S390_FEAT_MSA_EXT_3,
+ S390_FEAT_MSA_EXT_4,
};
int i;
diff --git a/target/s390x/crypto_helper.c b/target/s390x/crypto_helper.c
new file mode 100644
index 0000000000..fa360a2d6e
--- /dev/null
+++ b/target/s390x/crypto_helper.c
@@ -0,0 +1,65 @@
+/*
+ * s390x crypto helpers
+ *
+ * Copyright (c) 2017 Red Hat Inc
+ *
+ * Authors:
+ * David Hildenbrand <david@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/main-loop.h"
+#include "internal.h"
+#include "exec/helper-proto.h"
+#include "exec/exec-all.h"
+#include "exec/cpu_ldst.h"
+
+uint32_t HELPER(msa)(CPUS390XState *env, uint32_t r1, uint32_t r2, uint32_t r3,
+ uint32_t type)
+{
+ const uintptr_t ra = GETPC();
+ const uint8_t mod = env->regs[0] & 0x80ULL;
+ const uint8_t fc = env->regs[0] & 0x7fULL;
+ CPUState *cs = CPU(s390_env_get_cpu(env));
+ uint8_t subfunc[16] = { 0 };
+ uint64_t param_addr;
+ int i;
+
+ switch (type) {
+ case S390_FEAT_TYPE_KMAC:
+ case S390_FEAT_TYPE_KIMD:
+ case S390_FEAT_TYPE_KLMD:
+ case S390_FEAT_TYPE_PCKMO:
+ case S390_FEAT_TYPE_PCC:
+ if (mod) {
+ cpu_restore_state(cs, ra);
+ program_interrupt(env, PGM_SPECIFICATION, 4);
+ return 0;
+ }
+ break;
+ }
+
+ s390_get_feat_block(type, subfunc);
+ if (!test_be_bit(fc, subfunc)) {
+ cpu_restore_state(cs, ra);
+ program_interrupt(env, PGM_SPECIFICATION, 4);
+ return 0;
+ }
+
+ switch (fc) {
+ case 0: /* query subfunction */
+ for (i = 0; i < 16; i++) {
+ param_addr = wrap_address(env, env->regs[1] + i);
+ cpu_stb_data_ra(env, param_addr, subfunc[i], ra);
+ }
+ break;
+ default:
+ /* we don't implement any other subfunction yet */
+ g_assert_not_reached();
+ }
+
+ return 0;
+}
diff --git a/target/s390x/helper.h b/target/s390x/helper.h
index 4b0290774e..75ba04fc15 100644
--- a/target/s390x/helper.h
+++ b/target/s390x/helper.h
@@ -115,6 +115,7 @@ DEF_HELPER_4(cu21, i32, env, i32, i32, i32)
DEF_HELPER_4(cu24, i32, env, i32, i32, i32)
DEF_HELPER_4(cu41, i32, env, i32, i32, i32)
DEF_HELPER_4(cu42, i32, env, i32, i32, i32)
+DEF_HELPER_5(msa, i32, env, i32, i32, i32, i32)
#ifndef CONFIG_USER_ONLY
DEF_HELPER_3(servc, i32, env, i64, i64)
diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def
index 84233a456d..d09f2ed538 100644
--- a/target/s390x/insn-data.def
+++ b/target/s390x/insn-data.def
@@ -941,6 +941,19 @@
/* UNPACK UNICODE */
C(0xe200, UNPKU, SS_a, E2, la1, a2, 0, 0, unpku, 0)
+/* MSA Instructions */
+ D(0xb91e, KMAC, RRE, MSA, 0, 0, 0, 0, msa, 0, S390_FEAT_TYPE_KMAC)
+ D(0xb928, PCKMO, RRE, MSA3, 0, 0, 0, 0, msa, 0, S390_FEAT_TYPE_PCKMO)
+ D(0xb92a, KMF, RRE, MSA4, 0, 0, 0, 0, msa, 0, S390_FEAT_TYPE_KMF)
+ D(0xb92b, KMO, RRE, MSA4, 0, 0, 0, 0, msa, 0, S390_FEAT_TYPE_KMO)
+ D(0xb92c, PCC, RRE, MSA4, 0, 0, 0, 0, msa, 0, S390_FEAT_TYPE_PCC)
+ D(0xb92d, KMCTR, RRF_b, MSA4, 0, 0, 0, 0, msa, 0, S390_FEAT_TYPE_KMCTR)
+ D(0xb92e, KM, RRE, MSA, 0, 0, 0, 0, msa, 0, S390_FEAT_TYPE_KM)
+ D(0xb92f, KMC, RRE, MSA, 0, 0, 0, 0, msa, 0, S390_FEAT_TYPE_KMC)
+ D(0xb93c, PPNO, RRE, MSA5, 0, 0, 0, 0, msa, 0, S390_FEAT_TYPE_PPNO)
+ D(0xb93e, KIMD, RRE, MSA, 0, 0, 0, 0, msa, 0, S390_FEAT_TYPE_KIMD)
+ D(0xb93f, KLMD, RRE, MSA, 0, 0, 0, 0, msa, 0, S390_FEAT_TYPE_KLMD)
+
#ifndef CONFIG_USER_ONLY
/* COMPARE AND SWAP AND PURGE */
D(0xb250, CSP, RRE, Z, r1_32u, ra2, r1_P, 0, csp, 0, MO_TEUL)
diff --git a/target/s390x/translate.c b/target/s390x/translate.c
index 59fde44d55..78ffd8ff24 100644
--- a/target/s390x/translate.c
+++ b/target/s390x/translate.c
@@ -2422,6 +2422,58 @@ static ExitStatus op_iske(DisasContext *s, DisasOps *o)
}
#endif
+static ExitStatus op_msa(DisasContext *s, DisasOps *o)
+{
+ int r1 = have_field(s->fields, r1) ? get_field(s->fields, r1) : 0;
+ int r2 = have_field(s->fields, r2) ? get_field(s->fields, r2) : 0;
+ int r3 = have_field(s->fields, r3) ? get_field(s->fields, r3) : 0;
+ TCGv_i32 t_r1, t_r2, t_r3, type;
+
+ switch (s->insn->data) {
+ case S390_FEAT_TYPE_KMCTR:
+ if (r3 & 1 || !r3) {
+ gen_program_exception(s, PGM_SPECIFICATION);
+ return EXIT_NORETURN;
+ }
+ /* FALL THROUGH */
+ case S390_FEAT_TYPE_PPNO:
+ case S390_FEAT_TYPE_KMF:
+ case S390_FEAT_TYPE_KMC:
+ case S390_FEAT_TYPE_KMO:
+ case S390_FEAT_TYPE_KM:
+ if (r1 & 1 || !r1) {
+ gen_program_exception(s, PGM_SPECIFICATION);
+ return EXIT_NORETURN;
+ }
+ /* FALL THROUGH */
+ case S390_FEAT_TYPE_KMAC:
+ case S390_FEAT_TYPE_KIMD:
+ case S390_FEAT_TYPE_KLMD:
+ if (r2 & 1 || !r2) {
+ gen_program_exception(s, PGM_SPECIFICATION);
+ return EXIT_NORETURN;
+ }
+ /* FALL THROUGH */
+ case S390_FEAT_TYPE_PCKMO:
+ case S390_FEAT_TYPE_PCC:
+ break;
+ default:
+ g_assert_not_reached();
+ };
+
+ t_r1 = tcg_const_i32(r1);
+ t_r2 = tcg_const_i32(r2);
+ t_r3 = tcg_const_i32(r3);
+ type = tcg_const_i32(s->insn->data);
+ gen_helper_msa(cc_op, cpu_env, t_r1, t_r2, t_r3, type);
+ set_cc_static(s);
+ tcg_temp_free_i32(t_r1);
+ tcg_temp_free_i32(t_r2);
+ tcg_temp_free_i32(t_r3);
+ tcg_temp_free_i32(type);
+ return NO_EXIT;
+}
+
static ExitStatus op_keb(DisasContext *s, DisasOps *o)
{
gen_helper_keb(cc_op, cpu_env, o->in1, o->in2);
@@ -5505,6 +5557,10 @@ enum DisasInsnEnum {
#define FAC_PPA S390_FEAT_STFLE_49 /* processor-assist */
#define FAC_LZRB S390_FEAT_STFLE_53 /* load-and-zero-rightmost-byte */
#define FAC_ETF3 S390_FEAT_EXTENDED_TRANSLATION_3
+#define FAC_MSA S390_FEAT_MSA /* message-security-assist facility */
+#define FAC_MSA3 S390_FEAT_MSA_EXT_3 /* msa-extension-3 facility */
+#define FAC_MSA4 S390_FEAT_MSA_EXT_4 /* msa-extension-4 facility */
+#define FAC_MSA5 S390_FEAT_MSA_EXT_5 /* msa-extension-5 facility */
static const DisasInsn insn_info[] = {
#include "insn-data.def"
--
2.13.6
next prev parent reply other threads:[~2017-10-06 10:00 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-06 9:59 [Qemu-devel] [PULL 00/33] next batch of s390x patches Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 01/33] s390x/tcg: implement spm (SET PROGRAM MASK) Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 02/33] s390x/tcg: move wrap_address() to internal.h Cornelia Huck
2017-10-06 9:59 ` Cornelia Huck [this message]
2017-10-06 9:59 ` [Qemu-devel] [PULL 04/33] s390x: use generic cpu_model parsing Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 05/33] s390x/kvm: fix and cleanup storing CPU status Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 06/33] s390x/css: introduce css data stream Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 07/33] s390x/css: use ccw " Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 08/33] virtio-ccw: " Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 09/33] 390x/css: introduce maximum data address checking Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 10/33] s390x/css: support ccw IDA Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 11/33] s390x/tcg: fix checking for invalid memory check Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 12/33] s390x/tcg: add MMU for real addresses Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 13/33] s390x/tcg: make lura(g) use the new _real mmu Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 14/33] s390x/tcg: make stora(g) " Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 15/33] s390x/tcg: make testblock " Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 16/33] s390x/tcg: make idte/ipte " Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 17/33] Revert "s390x/ccw: create s390 phb conditionally" Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 18/33] s390x/3270: IDA support for 3270 via CcwDataStream Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 19/33] s390x/3270: handle writes of arbitrary length Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 20/33] MAINTAINERS: use KVM s390x maintainers for kvm-stubs.c and kvm_s390x.h Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 21/33] s390x: raise CPU hotplug irq after really hotplugged Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 22/33] s390x/cpumodel: fix max STFL(E) bit number Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 23/33] target/s390x: get rid of next_core_id Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 24/33] s390x: introduce and use S390_MAX_CPUS Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 25/33] s390x/tcg: make STFL store into the lowcore Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 26/33] s390x: sort some devices into categories Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 27/33] s390x/css: fix css migration compat handling Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 28/33] s390/kvm: Support for get/set of extended TOD-Clock for guest Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 29/33] s390/kvm: make TOD setting failures fatal for migration Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 30/33] s390x/sclp: Mark the sclp device with user_creatable = false Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 31/33] s390x/sclp: mark sclp-cpu-hotplug as non-usercreatable Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 32/33] s390x/tcg: initialize machine check queue Cornelia Huck
2017-10-06 9:59 ` [Qemu-devel] [PULL 33/33] hw/s390x: Mark the "sclpquiesce" device with user_creatable = false Cornelia Huck
2017-10-06 16:00 ` [Qemu-devel] [PULL 00/33] next batch of s390x patches Peter Maydell
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=20171006095956.27534-4-cohuck@redhat.com \
--to=cohuck@redhat.com \
--cc=agraf@suse.de \
--cc=borntraeger@de.ibm.com \
--cc=david@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@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).