[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[qemu-s390x] [PULL 31/46] target/s390x: special handling when starting a
From: |
Cornelia Huck |
Subject: |
[qemu-s390x] [PULL 31/46] target/s390x: special handling when starting a CPU with WAIT PSW |
Date: |
Fri, 20 Oct 2017 13:54:03 +0200 |
From: David Hildenbrand <address@hidden>
When we try to start a CPU with a WAIT PSW, we have to take care that
TCG will actually try to continue executing instructions.
We must therefore really only unhalt the CPU if we don't have a WAIT
PSW. Also document the special order for restart interrupts, which
load a new PSW and change the state to operating.
To keep KVM working, simply don't have a look at the WAIT bit when
loading the PSW. Otherwise the behavior of a restart interrupt when
a CPU stopped would be changed.
Signed-off-by: David Hildenbrand <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Signed-off-by: Cornelia Huck <address@hidden>
---
target/s390x/cpu.c | 11 +++++++++--
target/s390x/sigp.c | 6 +++++-
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index 92f6707bcb..95f4283188 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -337,8 +337,15 @@ unsigned int s390_cpu_set_state(uint8_t cpu_state, S390CPU
*cpu)
break;
case CPU_STATE_OPERATING:
case CPU_STATE_LOAD:
- /* unhalt the cpu for common infrastructure */
- s390_cpu_unhalt(cpu);
+ /*
+ * Starting a CPU with a PSW WAIT bit set:
+ * KVM: handles this internally and triggers another WAIT exit.
+ * TCG: will actually try to continue to run. Don't unhalt, will
+ * be done when the CPU actually has work (an interrupt).
+ */
+ if (!tcg_enabled() || !(cpu->env.psw.mask & PSW_MASK_WAIT)) {
+ s390_cpu_unhalt(cpu);
+ }
break;
default:
error_report("Requested CPU state is not a valid S390 CPU state: %u",
diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c
index 964c75a736..ac3f8e7dc2 100644
--- a/target/s390x/sigp.c
+++ b/target/s390x/sigp.c
@@ -232,8 +232,12 @@ static void sigp_restart(CPUState *cs, run_on_cpu_data arg)
case CPU_STATE_STOPPED:
/* the restart irq has to be delivered prior to any other pending irq
*/
cpu_synchronize_state(cs);
- do_restart_interrupt(&cpu->env);
+ /*
+ * Set OPERATING (and unhalting) before loading the restart PSW.
+ * load_psw() will then properly halt the CPU again if necessary (TCG).
+ */
s390_cpu_set_state(CPU_STATE_OPERATING, cpu);
+ do_restart_interrupt(&cpu->env);
break;
case CPU_STATE_OPERATING:
cpu_inject_restart(cpu);
--
2.13.6
- [qemu-s390x] [PULL 20/46] s390x/tcg: implement SIGP SENSE RUNNING STATUS, (continued)
- [qemu-s390x] [PULL 20/46] s390x/tcg: implement SIGP SENSE RUNNING STATUS, Cornelia Huck, 2017/10/20
- [qemu-s390x] [PULL 22/46] s390x/tcg: implement SIGP EXTERNAL CALL, Cornelia Huck, 2017/10/20
- [qemu-s390x] [PULL 18/46] s390x/kvm: factor out SIGP code into sigp.c, Cornelia Huck, 2017/10/20
- [qemu-s390x] [PULL 23/46] s390x/tcg: implement SIGP EMERGENCY SIGNAL, Cornelia Huck, 2017/10/20
- [qemu-s390x] [PULL 24/46] s390x/tcg: implement SIGP CONDITIONAL EMERGENCY SIGNAL, Cornelia Huck, 2017/10/20
- [qemu-s390x] [PULL 25/46] s390x/tcg: implement STOP and RESET interrupts for TCG, Cornelia Huck, 2017/10/20
- [qemu-s390x] [PULL 26/46] s390x/tcg: flush the tlb on SIGP SET PREFIX, Cornelia Huck, 2017/10/20
- [qemu-s390x] [PULL 28/46] s390x/cpumodel: allow to enable SENSE RUNNING STATUS for qemu, Cornelia Huck, 2017/10/20
- [qemu-s390x] [PULL 27/46] s390x/tcg: switch to new SIGP handling code, Cornelia Huck, 2017/10/20
- [qemu-s390x] [PULL 30/46] s390x/tcg: refactor stfl(e) to use s390_get_feat_block(), Cornelia Huck, 2017/10/20
- [qemu-s390x] [PULL 31/46] target/s390x: special handling when starting a CPU with WAIT PSW,
Cornelia Huck <=
- [qemu-s390x] [PULL 29/46] s390x/tcg: unlock NMI, Cornelia Huck, 2017/10/20
- [qemu-s390x] [PULL 32/46] virtio-ccw: Add the virtio-input devices for CCW bus, Cornelia Huck, 2017/10/20
- [qemu-s390x] [PULL 33/46] s390x/MAINTAINERS: add mailing list, Cornelia Huck, 2017/10/20
- [qemu-s390x] [PULL 34/46] s390x/event-facility: variable-length event masks, Cornelia Huck, 2017/10/20
- [qemu-s390x] [PULL 35/46] s390x: fix cpu object referrence leak in s390x_new_cpu(), Cornelia Huck, 2017/10/20
- [qemu-s390x] [PULL 36/46] s390x: move s390x_new_cpu() into board code, Cornelia Huck, 2017/10/20
- [qemu-s390x] [PULL 37/46] s390x/css: IO instr handler ending control, Cornelia Huck, 2017/10/20
- [qemu-s390x] [PULL 39/46] s390x: refactor error handling for XSCH handler, Cornelia Huck, 2017/10/20
- [qemu-s390x] [PULL 38/46] s390x: improve error handling for SSCH and RSCH, Cornelia Huck, 2017/10/20
- [qemu-s390x] [PULL 40/46] s390x: refactor error handling for CSCH handler, Cornelia Huck, 2017/10/20