KVM: s390: Add the SIGP order CONDITIONAL EMERGENCY SIGNAL
authorThomas Huth <thuth@linux.vnet.ibm.com>
Thu, 21 Nov 2013 15:01:48 +0000 (16:01 +0100)
committerCornelia Huck <cornelia.huck@de.ibm.com>
Wed, 11 Dec 2013 18:04:37 +0000 (19:04 +0100)
This patch adds the missing SIGP order "conditional emergency
signal" by calling the "emergency signal" SIGP handler if the
required conditions are met.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
arch/s390/include/asm/sigp.h
arch/s390/kvm/sigp.c

index 5a87d16d3e7c949c420d91558f5bb3513079e0f9..c002cd529c7158ab1fda9a41fd8d21ef7b630799 100644 (file)
@@ -12,6 +12,7 @@
 #define SIGP_SET_PREFIX                     13
 #define SIGP_STORE_STATUS_AT_ADDRESS 14
 #define SIGP_SET_ARCHITECTURE       18
+#define SIGP_COND_EMERGENCY_SIGNAL   19
 #define SIGP_SENSE_RUNNING          21
 
 /* SIGP condition codes */
index bc0d85a24b1b2f961607c54b2b3283bb95817c5b..eee1402349f2f6ad14b89071825516736770cc37 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * handling interprocessor communication
  *
- * Copyright IBM Corp. 2008, 2009
+ * Copyright IBM Corp. 2008, 2013
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License (version 2 only)
@@ -89,6 +89,37 @@ unlock:
        return rc;
 }
 
+static int __sigp_conditional_emergency(struct kvm_vcpu *vcpu, u16 cpu_addr,
+                                       u16 asn, u64 *reg)
+{
+       struct kvm_vcpu *dst_vcpu = NULL;
+       const u64 psw_int_mask = PSW_MASK_IO | PSW_MASK_EXT;
+       u16 p_asn, s_asn;
+       psw_t *psw;
+       u32 flags;
+
+       if (cpu_addr < KVM_MAX_VCPUS)
+               dst_vcpu = kvm_get_vcpu(vcpu->kvm, cpu_addr);
+       if (!dst_vcpu)
+               return SIGP_CC_NOT_OPERATIONAL;
+       flags = atomic_read(&dst_vcpu->arch.sie_block->cpuflags);
+       psw = &dst_vcpu->arch.sie_block->gpsw;
+       p_asn = dst_vcpu->arch.sie_block->gcr[4] & 0xffff;  /* Primary ASN */
+       s_asn = dst_vcpu->arch.sie_block->gcr[3] & 0xffff;  /* Secondary ASN */
+
+       /* Deliver the emergency signal? */
+       if (!(flags & CPUSTAT_STOPPED)
+           || (psw->mask & psw_int_mask) != psw_int_mask
+           || ((flags & CPUSTAT_WAIT) && psw->addr != 0)
+           || (!(flags & CPUSTAT_WAIT) && (asn == p_asn || asn == s_asn))) {
+               return __sigp_emergency(vcpu, cpu_addr);
+       } else {
+               *reg &= 0xffffffff00000000UL;
+               *reg |= SIGP_STATUS_INCORRECT_STATE;
+               return SIGP_CC_STATUS_STORED;
+       }
+}
+
 static int __sigp_external_call(struct kvm_vcpu *vcpu, u16 cpu_addr)
 {
        struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
@@ -417,6 +448,10 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu)
                rc = __sigp_set_prefix(vcpu, cpu_addr, parameter,
                                       &vcpu->run->s.regs.gprs[r1]);
                break;
+       case SIGP_COND_EMERGENCY_SIGNAL:
+               rc = __sigp_conditional_emergency(vcpu, cpu_addr, parameter,
+                                                 &vcpu->run->s.regs.gprs[r1]);
+               break;
        case SIGP_SENSE_RUNNING:
                vcpu->stat.instruction_sigp_sense_running++;
                rc = __sigp_sense_running(vcpu, cpu_addr,