Skip to content

Commit

Permalink
s390x: Implement SAM{24,31,64}
Browse files Browse the repository at this point in the history
The SAM instructions simply change 2 bits in PSW.MASK to advertise
the current memory mode. While we can't fully guarantee that 31 bit
mode (or even remotely 24 bit mode) actually work correctly, we don't
check whether lpswe modifies these bits, so we shouldn't keep the
guest from executing SAM instructions either.

This patch implements all SAM instrutions with their actual PSW changing
semantics, making more recent Linux kernels boot properly which do issue
a SAM31 call during early boot.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Reviewed-by: Richard Henderson <rth@twiddle.net>
  • Loading branch information
agraf committed Nov 5, 2014
1 parent d482735 commit 44dd33b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions target-s390x/insn-data.def
Expand Up @@ -744,9 +744,9 @@
/* SERVICE CALL LOGICAL PROCESSOR (PV hypercall) */
C(0xb220, SERVC, RRE, Z, r1_o, r2_o, 0, 0, servc, 0)
/* SET ADDRESSING MODE */
/* We only do 64-bit, so accept this as a no-op.
Let SAM24 and SAM31 signal illegal instruction. */
C(0x010e, SAM64, E, Z, 0, 0, 0, 0, 0, 0)
D(0x010c, SAM24, E, Z, 0, 0, 0, 0, sam, 0, 0)
D(0x010d, SAM31, E, Z, 0, 0, 0, 0, sam, 0, 1)
D(0x010e, SAM64, E, Z, 0, 0, 0, 0, sam, 0, 3)
/* SET ADDRESS SPACE CONTROL FAST */
C(0xb279, SACF, S, Z, 0, a2, 0, 0, sacf, 0)
/* SET CLOCK */
Expand Down
12 changes: 12 additions & 0 deletions target-s390x/translate.c
Expand Up @@ -2925,6 +2925,18 @@ static ExitStatus op_sacf(DisasContext *s, DisasOps *o)
/* Addressing mode has changed, so end the block. */
return EXIT_PC_STALE;
}

static ExitStatus op_sam(DisasContext *s, DisasOps *o)
{
int sam = s->insn->data;
TCGv_i64 tsam = tcg_const_i64(sam);

/* Overwrite PSW_MASK_64 and PSW_MASK_32 */
tcg_gen_deposit_i64(psw_mask, psw_mask, tsam, 31, 2);

tcg_temp_free_i64(tsam);
return EXIT_PC_STALE;
}
#endif

static ExitStatus op_sar(DisasContext *s, DisasOps *o)
Expand Down

0 comments on commit 44dd33b

Please sign in to comment.