From d4827355f6bccc3255950b952b7bcb1d15e55064 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Wed, 15 Oct 2014 17:52:49 +0200 Subject: [PATCH 1/2] s390x: Fix sclp console input When injecting an sclp console interrupt into the guest, we increase the PC by 4 for some reason. I have no idea why I put that code there, but it's clearly wrong. Remove the increment. This patch fixes sclp serial input for the ccw machine. Signed-off-by: Alexander Graf Reviewed-by: Bastian Koppelmann --- target-s390x/interrupt.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/target-s390x/interrupt.c b/target-s390x/interrupt.c index 23a9114f5a..1404d0afdd 100644 --- a/target-s390x/interrupt.c +++ b/target-s390x/interrupt.c @@ -22,9 +22,7 @@ void s390_sclp_extint(uint32_t parm) kvm_s390_service_interrupt(parm); } else { S390CPU *dummy_cpu = s390_cpu_addr2state(0); - CPUS390XState *env = &dummy_cpu->env; - env->psw.addr += 4; cpu_inject_ext(dummy_cpu, EXT_SERVICE, parm, 0); } } From 44dd33ba8f60b5f513399f673351127af16bd304 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Wed, 15 Oct 2014 18:06:07 +0200 Subject: [PATCH 2/2] s390x: Implement SAM{24,31,64} 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 Reviewed-by: Bastian Koppelmann Reviewed-by: Richard Henderson --- target-s390x/insn-data.def | 6 +++--- target-s390x/translate.c | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/target-s390x/insn-data.def b/target-s390x/insn-data.def index b42ebb6a1a..4d2feb6977 100644 --- a/target-s390x/insn-data.def +++ b/target-s390x/insn-data.def @@ -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 */ diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 0cb036f667..dbf1993d46 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -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)