[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 23/30] s390x/tcg: implement SIGP CONDITIONAL EMER
From: |
David Hildenbrand |
Subject: |
[Qemu-devel] [PATCH v2 23/30] s390x/tcg: implement SIGP CONDITIONAL EMERGENCY SIGNAL |
Date: |
Thu, 28 Sep 2017 22:37:01 +0200 |
Mostly analogous to the kernel/KVM version (so I assume the checks are
correct :) ). As a preparation for TCG.
Signed-off-by: David Hildenbrand <address@hidden>
---
target/s390x/cpu.h | 1 +
target/s390x/sigp.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index 6b92b0751a..7f4f03f410 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -590,6 +590,7 @@ struct sysib_322 {
#define SIGP_SET_PREFIX 0x0d
#define SIGP_STORE_STATUS_ADDR 0x0e
#define SIGP_SET_ARCH 0x12
+#define SIGP_COND_EMERGENCY 0x13
#define SIGP_SENSE_RUNNING 0x15
#define SIGP_STORE_ADTL_STATUS 0x17
diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c
index d492885787..ce8fda9d01 100644
--- a/target/s390x/sigp.c
+++ b/target/s390x/sigp.c
@@ -290,6 +290,40 @@ static void sigp_set_prefix(CPUState *cs, run_on_cpu_data
arg)
si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;
}
+static void sigp_cond_emergency(S390CPU *src_cpu, S390CPU *dst_cpu,
+ SigpInfo *si)
+{
+ const uint64_t psw_int_mask = PSW_MASK_IO | PSW_MASK_EXT;
+ uint16_t p_asn, s_asn, asn;
+ uint64_t psw_addr, psw_mask;
+ bool idle;
+
+ if (!tcg_enabled()) {
+ /* handled in KVM */
+ set_sigp_status(si, SIGP_STAT_INVALID_ORDER);
+ return;
+ }
+
+ /* this looks racy, but these values are only used when STOPPED */
+ idle = CPU(dst_cpu)->halted;
+ psw_addr = dst_cpu->env.psw.addr;
+ psw_mask = dst_cpu->env.psw.mask;
+ asn = si->param;
+ p_asn = dst_cpu->env.cregs[4] & 0xffff; /* Primary ASN */
+ s_asn = dst_cpu->env.cregs[3] & 0xffff; /* Secondary ASN */
+
+ if (s390_cpu_get_state(dst_cpu) != CPU_STATE_STOPPED ||
+ (psw_mask & psw_int_mask) != psw_int_mask ||
+ (idle && psw_addr != 0) ||
+ (!idle && (asn == p_asn || asn == s_asn))) {
+ cpu_inject_emergency_signal(dst_cpu, src_cpu->env.core_id);
+ } else {
+ set_sigp_status(si, SIGP_STAT_INCORRECT_STATE);
+ }
+
+ si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;
+}
+
static void sigp_sense_running(S390CPU *dst_cpu, SigpInfo *si)
{
if (!tcg_enabled()) {
@@ -369,6 +403,9 @@ static int handle_sigp_single_dst(S390CPU *cpu, S390CPU
*dst_cpu, uint8_t order,
case SIGP_CPU_RESET:
run_on_cpu(CPU(dst_cpu), sigp_cpu_reset, RUN_ON_CPU_HOST_PTR(&si));
break;
+ case SIGP_COND_EMERGENCY:
+ sigp_cond_emergency(cpu, dst_cpu, &si);
+ break;
case SIGP_SENSE_RUNNING:
sigp_sense_running(dst_cpu, &si);
break;
--
2.13.5
- [Qemu-devel] [PATCH v2 13/30] s390x/kvm: factor out storing of CPU status, (continued)
- [Qemu-devel] [PATCH v2 13/30] s390x/kvm: factor out storing of CPU status, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 14/30] s390x/kvm: factor out storing of adtl CPU status, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 15/30] s390x/kvm: drop two debug prints, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 16/30] s390x/kvm: factor out SIGP code into sigp.c, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 17/30] MAINTAINERS: use s390 KVM maintainers for target/s390x/sigp.c, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 18/30] s390x/kvm: factor out actual handling of STOP interrupts, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 20/30] s390x/tcg: implement SIGP SENSE, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 19/30] s390x/tcg: implement SIGP SENSE RUNNING STATUS, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 21/30] s390x/tcg: implement SIGP EXTERNAL CALL, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 22/30] s390x/tcg: implement SIGP EMERGENCY SIGNAL, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 23/30] s390x/tcg: implement SIGP CONDITIONAL EMERGENCY SIGNAL,
David Hildenbrand <=
- [Qemu-devel] [PATCH v2 24/30] s390x/tcg: implement STOP and RESET interrupts for TCG, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 25/30] s390x/tcg: flush the tlb on SIGP SET PREFIX, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 26/30] s390x/tcg: switch to new SIGP handling code, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 27/30] s390x/cpumodel: allow to enable SENSE RUNNING STATUS for qemu, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 28/30] s390x/tcg: unlock NMI, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 29/30] s390x/tcg: refactor stfl(e) to use s390_get_feat_block(), David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 30/30] target/s390x: special handling when starting a CPU with WAIT PSW, David Hildenbrand, 2017/09/28