From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: thuth@redhat.com, aurelien@aurel32.net
Subject: [Qemu-devel] [PATCH v2] target/s390x: Enforce instruction features
Date: Thu, 15 Jun 2017 22:15:26 -0700 [thread overview]
Message-ID: <20170616051526.6814-1-rth@twiddle.net> (raw)
Introduce a synthetic feature (type MISC) to handle disabling of
the enforcing of features at translation time.
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
target/s390x/cpu_features.c | 4 +++-
target/s390x/cpu_features_def.h | 1 +
target/s390x/cpu_models.c | 5 +++++
target/s390x/translate.c | 9 +++++++++
4 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/target/s390x/cpu_features.c b/target/s390x/cpu_features.c
index 42fd9d7..8d542c0 100644
--- a/target/s390x/cpu_features.c
+++ b/target/s390x/cpu_features.c
@@ -24,7 +24,7 @@
}
/* indexed by feature number for easy lookup */
-static const S390FeatDef s390_features[] = {
+static const S390FeatDef s390_features[S390_FEAT_MAX] = {
FEAT_INIT("esan3", S390_FEAT_TYPE_STFL, 0, "Instructions marked as n3"),
FEAT_INIT("zarch", S390_FEAT_TYPE_STFL, 1, "z/Architecture architectural mode"),
FEAT_INIT("dateh", S390_FEAT_TYPE_STFL, 3, "DAT-enhancement facility"),
@@ -251,6 +251,8 @@ static const S390FeatDef s390_features[] = {
FEAT_INIT("pcc-xts-eaes-256", S390_FEAT_TYPE_PCC, 60, "PCC Compute-XTS-Parameter-Using-Encrypted-AES-256"),
FEAT_INIT("ppno-sha-512-drng", S390_FEAT_TYPE_PPNO, 3, "PPNO SHA-512-DRNG"),
+
+ FEAT_INIT("tcg-all-insns", S390_FEAT_TYPE_MISC, 0, "Enable all insns supported by TCG"),
};
const S390FeatDef *s390_feat_def(S390Feat feat)
diff --git a/target/s390x/cpu_features_def.h b/target/s390x/cpu_features_def.h
index aa5ab8d..0726c54 100644
--- a/target/s390x/cpu_features_def.h
+++ b/target/s390x/cpu_features_def.h
@@ -225,6 +225,7 @@ typedef enum {
S390_FEAT_PCC_XTS_EAES_128,
S390_FEAT_PCC_XTS_EAES_256,
S390_FEAT_PPNO_SHA_512_DRNG,
+ S390_FEAT_TCG_ALL_INSNS,
S390_FEAT_MAX,
} S390Feat;
diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
index 478bcc6..641552e 100644
--- a/target/s390x/cpu_models.c
+++ b/target/s390x/cpu_models.c
@@ -685,6 +685,11 @@ static void add_qemu_cpu_model_features(S390FeatBitmap fbm)
S390_FEAT_GENERAL_INSTRUCTIONS_EXT,
S390_FEAT_EXECUTE_EXT,
S390_FEAT_STFLE_45,
+
+ /* There are other features that are only partially implemented.
+ We do not advertise those above. Indicate that we should not
+ enforce PGM_OPERATION for insns without the feature bit set. */
+ S390_FEAT_TCG_ALL_INSNS,
};
int i;
diff --git a/target/s390x/translate.c b/target/s390x/translate.c
index af18ffb..69c1f94 100644
--- a/target/s390x/translate.c
+++ b/target/s390x/translate.c
@@ -55,6 +55,7 @@ typedef struct DisasFields DisasFields;
struct DisasContext {
struct TranslationBlock *tb;
+ const unsigned long *features;
const DisasInsn *insn;
DisasFields *fields;
uint64_t ex_value;
@@ -5600,6 +5601,12 @@ static ExitStatus translate_one(CPUS390XState *env, DisasContext *s)
}
#endif
+ /* Check for insn feature enabled. */
+ if (s->features && !test_bit(insn->fac, s->features)) {
+ gen_program_exception(s, PGM_OPERATION);
+ return EXIT_NORETURN;
+ }
+
/* Check for insn specification exceptions. */
if (insn->spec) {
int spec = insn->spec, excp = 0, r;
@@ -5726,6 +5733,8 @@ void gen_intermediate_code(CPUS390XState *env, struct TranslationBlock *tb)
}
dc.tb = tb;
+ dc.features = (s390_has_feat(S390_FEAT_TCG_ALL_INSNS)
+ ? NULL : cpu->model->features);
dc.pc = pc_start;
dc.cc_op = CC_OP_DYNAMIC;
dc.ex_value = tb->cs_base;
--
2.9.4
next reply other threads:[~2017-06-16 5:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-16 5:15 Richard Henderson [this message]
2017-06-16 8:55 ` [Qemu-devel] [PATCH v2] target/s390x: Enforce instruction features no-reply
2017-06-19 7:52 ` 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=20170616051526.6814-1-rth@twiddle.net \
--to=rth@twiddle.net \
--cc=aurelien@aurel32.net \
--cc=qemu-devel@nongnu.org \
--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).