diff options
author | Richard Henderson <rth@twiddle.net> | 2013-09-06 09:31:37 -0700 |
---|---|---|
committer | Richard Henderson <rth@twiddle.net> | 2015-02-03 12:06:37 -0800 |
commit | 8612c935831647c193281992738f96292428b9e6 (patch) | |
tree | c57edee8caed0955bb55fd049954a87c783bf9b4 /target-s390x/translate.c | |
parent | 16017c48547960539fcadb1f91d252124f442482 (diff) |
target-s390: Implement SAM specification exception
Also, these are user-mode instructions; allow their use
in CONFIG_USER_ONLY.
Signed-off-by: Richard Henderson <rth@twiddle.net>
Diffstat (limited to 'target-s390x/translate.c')
-rw-r--r-- | target-s390x/translate.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/target-s390x/translate.c b/target-s390x/translate.c index ab01bc004e..1338bb5a34 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -2925,19 +2925,42 @@ static ExitStatus op_sacf(DisasContext *s, DisasOps *o) /* Addressing mode has changed, so end the block. */ return EXIT_PC_STALE; } +#endif static ExitStatus op_sam(DisasContext *s, DisasOps *o) { int sam = s->insn->data; - TCGv_i64 tsam = tcg_const_i64(sam); + TCGv_i64 tsam; + uint64_t mask; - /* Overwrite PSW_MASK_64 and PSW_MASK_32 */ - tcg_gen_deposit_i64(psw_mask, psw_mask, tsam, 31, 2); + switch (sam) { + case 0: + mask = 0xffffff; + break; + case 1: + mask = 0x7fffffff; + break; + default: + mask = -1; + break; + } + + /* Bizzare but true, we check the address of the current insn for the + specification exception, not the next to be executed. Thus the PoO + documents that Bad Things Happen two bytes before the end. */ + if (s->pc & ~mask) { + gen_program_exception(s, PGM_SPECIFICATION); + return EXIT_NORETURN; + } + s->next_pc &= mask; + tsam = tcg_const_i64(sam); + tcg_gen_deposit_i64(psw_mask, psw_mask, tsam, 31, 2); tcg_temp_free_i64(tsam); + + /* Always exit the TB, since we (may have) changed execution mode. */ return EXIT_PC_STALE; } -#endif static ExitStatus op_sar(DisasContext *s, DisasOps *o) { |