blob: 6ed8175ca7e76a52d6b576294dc7da53be011604 [file] [log] [blame]
Christian Borntraeger5288fbf2008-03-25 18:47:31 +01001/*
2 * sigp.c - handlinge interprocessor communication
3 *
Christian Ehrhardt9ace9032009-05-20 15:34:55 +02004 * Copyright IBM Corp. 2008,2009
Christian Borntraeger5288fbf2008-03-25 18:47:31 +01005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License (version 2 only)
8 * as published by the Free Software Foundation.
9 *
10 * Author(s): Carsten Otte <cotte@de.ibm.com>
11 * Christian Borntraeger <borntraeger@de.ibm.com>
Christian Ehrhardt9ace9032009-05-20 15:34:55 +020012 * Christian Ehrhardt <ehrhardt@de.ibm.com>
Christian Borntraeger5288fbf2008-03-25 18:47:31 +010013 */
14
15#include <linux/kvm.h>
16#include <linux/kvm_host.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090017#include <linux/slab.h>
Heiko Carstens9b747532012-06-26 16:06:37 +020018#include <asm/sigp.h>
Christian Borntraeger5288fbf2008-03-25 18:47:31 +010019#include "gaccess.h"
20#include "kvm-s390.h"
21
Martin Schwidefsky00963692008-07-25 15:51:00 +020022static int __sigp_sense(struct kvm_vcpu *vcpu, u16 cpu_addr,
Christian Borntraeger5a32c1a2012-01-11 11:20:32 +010023 u64 *reg)
Christian Borntraeger5288fbf2008-03-25 18:47:31 +010024{
Christian Borntraeger180c12f2008-06-27 15:05:40 +020025 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +010026 int rc;
27
28 if (cpu_addr >= KVM_MAX_VCPUS)
Heiko Carstensea1918d2012-06-26 16:06:40 +020029 return SIGP_CC_NOT_OPERATIONAL;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +010030
Christian Borntraegerb037a4f2009-05-12 17:21:50 +020031 spin_lock(&fi->lock);
Christian Borntraeger5288fbf2008-03-25 18:47:31 +010032 if (fi->local_int[cpu_addr] == NULL)
Heiko Carstensea1918d2012-06-26 16:06:40 +020033 rc = SIGP_CC_NOT_OPERATIONAL;
Cornelia Huck9e6dabe2011-11-17 11:00:41 +010034 else if (!(atomic_read(fi->local_int[cpu_addr]->cpuflags)
Cornelia Huck21b26c02012-06-26 16:06:41 +020035 & (CPUSTAT_ECALL_PEND | CPUSTAT_STOPPED)))
36 rc = SIGP_CC_ORDER_CODE_ACCEPTED;
37 else {
Christian Borntraeger5288fbf2008-03-25 18:47:31 +010038 *reg &= 0xffffffff00000000UL;
Cornelia Huck21b26c02012-06-26 16:06:41 +020039 if (atomic_read(fi->local_int[cpu_addr]->cpuflags)
40 & CPUSTAT_ECALL_PEND)
41 *reg |= SIGP_STATUS_EXT_CALL_PENDING;
42 if (atomic_read(fi->local_int[cpu_addr]->cpuflags)
43 & CPUSTAT_STOPPED)
44 *reg |= SIGP_STATUS_STOPPED;
Heiko Carstensea1918d2012-06-26 16:06:40 +020045 rc = SIGP_CC_STATUS_STORED;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +010046 }
Christian Borntraegerb037a4f2009-05-12 17:21:50 +020047 spin_unlock(&fi->lock);
Christian Borntraeger5288fbf2008-03-25 18:47:31 +010048
49 VCPU_EVENT(vcpu, 4, "sensed status of cpu %x rc %x", cpu_addr, rc);
50 return rc;
51}
52
53static int __sigp_emergency(struct kvm_vcpu *vcpu, u16 cpu_addr)
54{
Christian Borntraeger180c12f2008-06-27 15:05:40 +020055 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
56 struct kvm_s390_local_interrupt *li;
57 struct kvm_s390_interrupt_info *inti;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +010058 int rc;
59
60 if (cpu_addr >= KVM_MAX_VCPUS)
Heiko Carstensea1918d2012-06-26 16:06:40 +020061 return SIGP_CC_NOT_OPERATIONAL;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +010062
63 inti = kzalloc(sizeof(*inti), GFP_KERNEL);
64 if (!inti)
65 return -ENOMEM;
66
67 inti->type = KVM_S390_INT_EMERGENCY;
Christian Ehrhardt7697e71f2011-10-18 12:27:15 +020068 inti->emerg.code = vcpu->vcpu_id;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +010069
Christian Borntraegerb037a4f2009-05-12 17:21:50 +020070 spin_lock(&fi->lock);
Christian Borntraeger5288fbf2008-03-25 18:47:31 +010071 li = fi->local_int[cpu_addr];
72 if (li == NULL) {
Heiko Carstensea1918d2012-06-26 16:06:40 +020073 rc = SIGP_CC_NOT_OPERATIONAL;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +010074 kfree(inti);
75 goto unlock;
76 }
77 spin_lock_bh(&li->lock);
78 list_add_tail(&inti->list, &li->list);
79 atomic_set(&li->active, 1);
80 atomic_set_mask(CPUSTAT_EXT_INT, li->cpuflags);
81 if (waitqueue_active(&li->wq))
82 wake_up_interruptible(&li->wq);
83 spin_unlock_bh(&li->lock);
Heiko Carstensea1918d2012-06-26 16:06:40 +020084 rc = SIGP_CC_ORDER_CODE_ACCEPTED;
Christian Ehrhardt7697e71f2011-10-18 12:27:15 +020085 VCPU_EVENT(vcpu, 4, "sent sigp emerg to cpu %x", cpu_addr);
Christian Borntraeger5288fbf2008-03-25 18:47:31 +010086unlock:
Christian Borntraegerb037a4f2009-05-12 17:21:50 +020087 spin_unlock(&fi->lock);
Christian Ehrhardt7697e71f2011-10-18 12:27:15 +020088 return rc;
89}
90
91static int __sigp_external_call(struct kvm_vcpu *vcpu, u16 cpu_addr)
92{
93 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
94 struct kvm_s390_local_interrupt *li;
95 struct kvm_s390_interrupt_info *inti;
96 int rc;
97
98 if (cpu_addr >= KVM_MAX_VCPUS)
Heiko Carstensea1918d2012-06-26 16:06:40 +020099 return SIGP_CC_NOT_OPERATIONAL;
Christian Ehrhardt7697e71f2011-10-18 12:27:15 +0200100
101 inti = kzalloc(sizeof(*inti), GFP_KERNEL);
102 if (!inti)
103 return -ENOMEM;
104
105 inti->type = KVM_S390_INT_EXTERNAL_CALL;
106 inti->extcall.code = vcpu->vcpu_id;
107
108 spin_lock(&fi->lock);
109 li = fi->local_int[cpu_addr];
110 if (li == NULL) {
Heiko Carstensea1918d2012-06-26 16:06:40 +0200111 rc = SIGP_CC_NOT_OPERATIONAL;
Christian Ehrhardt7697e71f2011-10-18 12:27:15 +0200112 kfree(inti);
113 goto unlock;
114 }
115 spin_lock_bh(&li->lock);
116 list_add_tail(&inti->list, &li->list);
117 atomic_set(&li->active, 1);
118 atomic_set_mask(CPUSTAT_EXT_INT, li->cpuflags);
119 if (waitqueue_active(&li->wq))
120 wake_up_interruptible(&li->wq);
121 spin_unlock_bh(&li->lock);
Heiko Carstensea1918d2012-06-26 16:06:40 +0200122 rc = SIGP_CC_ORDER_CODE_ACCEPTED;
Christian Ehrhardt7697e71f2011-10-18 12:27:15 +0200123 VCPU_EVENT(vcpu, 4, "sent sigp ext call to cpu %x", cpu_addr);
124unlock:
125 spin_unlock(&fi->lock);
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100126 return rc;
127}
128
Christian Ehrhardt9ace9032009-05-20 15:34:55 +0200129static int __inject_sigp_stop(struct kvm_s390_local_interrupt *li, int action)
130{
131 struct kvm_s390_interrupt_info *inti;
132
Julia Lawall9940fa82010-06-08 18:58:11 +0200133 inti = kzalloc(sizeof(*inti), GFP_ATOMIC);
Christian Ehrhardt9ace9032009-05-20 15:34:55 +0200134 if (!inti)
135 return -ENOMEM;
136 inti->type = KVM_S390_SIGP_STOP;
137
138 spin_lock_bh(&li->lock);
Jens Freimann24a13042012-02-06 10:59:05 +0100139 if ((atomic_read(li->cpuflags) & CPUSTAT_STOPPED))
140 goto out;
Christian Ehrhardt9ace9032009-05-20 15:34:55 +0200141 list_add_tail(&inti->list, &li->list);
142 atomic_set(&li->active, 1);
143 atomic_set_mask(CPUSTAT_STOP_INT, li->cpuflags);
144 li->action_bits |= action;
145 if (waitqueue_active(&li->wq))
146 wake_up_interruptible(&li->wq);
Jens Freimann24a13042012-02-06 10:59:05 +0100147out:
Christian Ehrhardt9ace9032009-05-20 15:34:55 +0200148 spin_unlock_bh(&li->lock);
149
Heiko Carstensea1918d2012-06-26 16:06:40 +0200150 return SIGP_CC_ORDER_CODE_ACCEPTED;
Christian Ehrhardt9ace9032009-05-20 15:34:55 +0200151}
152
153static int __sigp_stop(struct kvm_vcpu *vcpu, u16 cpu_addr, int action)
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100154{
Christian Borntraeger180c12f2008-06-27 15:05:40 +0200155 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
156 struct kvm_s390_local_interrupt *li;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100157 int rc;
158
159 if (cpu_addr >= KVM_MAX_VCPUS)
Heiko Carstensea1918d2012-06-26 16:06:40 +0200160 return SIGP_CC_NOT_OPERATIONAL;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100161
Christian Borntraegerb037a4f2009-05-12 17:21:50 +0200162 spin_lock(&fi->lock);
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100163 li = fi->local_int[cpu_addr];
164 if (li == NULL) {
Heiko Carstensea1918d2012-06-26 16:06:40 +0200165 rc = SIGP_CC_NOT_OPERATIONAL;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100166 goto unlock;
167 }
Christian Ehrhardt9ace9032009-05-20 15:34:55 +0200168
169 rc = __inject_sigp_stop(li, action);
170
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100171unlock:
Christian Borntraegerb037a4f2009-05-12 17:21:50 +0200172 spin_unlock(&fi->lock);
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100173 VCPU_EVENT(vcpu, 4, "sent sigp stop to cpu %x", cpu_addr);
174 return rc;
175}
176
Christian Ehrhardt9ace9032009-05-20 15:34:55 +0200177int kvm_s390_inject_sigp_stop(struct kvm_vcpu *vcpu, int action)
178{
179 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
180 return __inject_sigp_stop(li, action);
181}
182
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100183static int __sigp_set_arch(struct kvm_vcpu *vcpu, u32 parameter)
184{
185 int rc;
186
187 switch (parameter & 0xff) {
188 case 0:
Heiko Carstensea1918d2012-06-26 16:06:40 +0200189 rc = SIGP_CC_NOT_OPERATIONAL;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100190 break;
191 case 1:
192 case 2:
Heiko Carstensea1918d2012-06-26 16:06:40 +0200193 rc = SIGP_CC_ORDER_CODE_ACCEPTED;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100194 break;
195 default:
Heiko Carstensb8e660b2010-02-26 22:37:41 +0100196 rc = -EOPNOTSUPP;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100197 }
198 return rc;
199}
200
201static int __sigp_set_prefix(struct kvm_vcpu *vcpu, u16 cpu_addr, u32 address,
Christian Borntraeger5a32c1a2012-01-11 11:20:32 +0100202 u64 *reg)
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100203{
Christian Borntraeger180c12f2008-06-27 15:05:40 +0200204 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
Roel Kluin53cb7802009-08-07 10:39:25 +0200205 struct kvm_s390_local_interrupt *li = NULL;
Christian Borntraeger180c12f2008-06-27 15:05:40 +0200206 struct kvm_s390_interrupt_info *inti;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100207 int rc;
208 u8 tmp;
209
210 /* make sure that the new value is valid memory */
211 address = address & 0x7fffe000u;
Carsten Otte092670c2011-07-24 10:48:22 +0200212 if (copy_from_guest_absolute(vcpu, &tmp, address, 1) ||
213 copy_from_guest_absolute(vcpu, &tmp, address + PAGE_SIZE, 1)) {
Heiko Carstens07444262012-06-26 16:06:39 +0200214 *reg &= 0xffffffff00000000UL;
Heiko Carstens9b747532012-06-26 16:06:37 +0200215 *reg |= SIGP_STATUS_INVALID_PARAMETER;
Heiko Carstensea1918d2012-06-26 16:06:40 +0200216 return SIGP_CC_STATUS_STORED;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100217 }
218
219 inti = kzalloc(sizeof(*inti), GFP_KERNEL);
220 if (!inti)
Heiko Carstensea1918d2012-06-26 16:06:40 +0200221 return SIGP_CC_BUSY;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100222
Christian Borntraegerb037a4f2009-05-12 17:21:50 +0200223 spin_lock(&fi->lock);
Roel Kluin53cb7802009-08-07 10:39:25 +0200224 if (cpu_addr < KVM_MAX_VCPUS)
225 li = fi->local_int[cpu_addr];
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100226
Roel Kluin53cb7802009-08-07 10:39:25 +0200227 if (li == NULL) {
Heiko Carstens07444262012-06-26 16:06:39 +0200228 *reg &= 0xffffffff00000000UL;
229 *reg |= SIGP_STATUS_INCORRECT_STATE;
Heiko Carstensea1918d2012-06-26 16:06:40 +0200230 rc = SIGP_CC_STATUS_STORED;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100231 kfree(inti);
232 goto out_fi;
233 }
234
235 spin_lock_bh(&li->lock);
236 /* cpu must be in stopped state */
Cornelia Huck9e6dabe2011-11-17 11:00:41 +0100237 if (!(atomic_read(li->cpuflags) & CPUSTAT_STOPPED)) {
Heiko Carstens07444262012-06-26 16:06:39 +0200238 *reg &= 0xffffffff00000000UL;
239 *reg |= SIGP_STATUS_INCORRECT_STATE;
Heiko Carstensea1918d2012-06-26 16:06:40 +0200240 rc = SIGP_CC_STATUS_STORED;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100241 kfree(inti);
242 goto out_li;
243 }
244
245 inti->type = KVM_S390_SIGP_SET_PREFIX;
246 inti->prefix.address = address;
247
248 list_add_tail(&inti->list, &li->list);
249 atomic_set(&li->active, 1);
250 if (waitqueue_active(&li->wq))
251 wake_up_interruptible(&li->wq);
Heiko Carstensea1918d2012-06-26 16:06:40 +0200252 rc = SIGP_CC_ORDER_CODE_ACCEPTED;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100253
254 VCPU_EVENT(vcpu, 4, "set prefix of cpu %02x to %x", cpu_addr, address);
255out_li:
256 spin_unlock_bh(&li->lock);
257out_fi:
Christian Borntraegerb037a4f2009-05-12 17:21:50 +0200258 spin_unlock(&fi->lock);
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100259 return rc;
260}
261
Cornelia Huckbd59d3a2011-11-17 11:00:42 +0100262static int __sigp_sense_running(struct kvm_vcpu *vcpu, u16 cpu_addr,
Christian Borntraeger5a32c1a2012-01-11 11:20:32 +0100263 u64 *reg)
Cornelia Huckbd59d3a2011-11-17 11:00:42 +0100264{
265 int rc;
266 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
267
268 if (cpu_addr >= KVM_MAX_VCPUS)
Heiko Carstensea1918d2012-06-26 16:06:40 +0200269 return SIGP_CC_NOT_OPERATIONAL;
Cornelia Huckbd59d3a2011-11-17 11:00:42 +0100270
271 spin_lock(&fi->lock);
272 if (fi->local_int[cpu_addr] == NULL)
Heiko Carstensea1918d2012-06-26 16:06:40 +0200273 rc = SIGP_CC_NOT_OPERATIONAL;
Cornelia Huckbd59d3a2011-11-17 11:00:42 +0100274 else {
275 if (atomic_read(fi->local_int[cpu_addr]->cpuflags)
276 & CPUSTAT_RUNNING) {
277 /* running */
Heiko Carstensea1918d2012-06-26 16:06:40 +0200278 rc = SIGP_CC_ORDER_CODE_ACCEPTED;
Cornelia Huckbd59d3a2011-11-17 11:00:42 +0100279 } else {
280 /* not running */
281 *reg &= 0xffffffff00000000UL;
Heiko Carstens9b747532012-06-26 16:06:37 +0200282 *reg |= SIGP_STATUS_NOT_RUNNING;
Heiko Carstensea1918d2012-06-26 16:06:40 +0200283 rc = SIGP_CC_STATUS_STORED;
Cornelia Huckbd59d3a2011-11-17 11:00:42 +0100284 }
285 }
286 spin_unlock(&fi->lock);
287
288 VCPU_EVENT(vcpu, 4, "sensed running status of cpu %x rc %x", cpu_addr,
289 rc);
290
291 return rc;
292}
293
Jens Freimann151104a2012-02-08 08:28:29 +0100294static int __sigp_restart(struct kvm_vcpu *vcpu, u16 cpu_addr)
295{
Jens Freimann151104a2012-02-08 08:28:29 +0100296 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
297 struct kvm_s390_local_interrupt *li;
Heiko Carstensea1918d2012-06-26 16:06:40 +0200298 int rc = SIGP_CC_ORDER_CODE_ACCEPTED;
Jens Freimann151104a2012-02-08 08:28:29 +0100299
300 if (cpu_addr >= KVM_MAX_VCPUS)
Heiko Carstensea1918d2012-06-26 16:06:40 +0200301 return SIGP_CC_NOT_OPERATIONAL;
Jens Freimann151104a2012-02-08 08:28:29 +0100302
303 spin_lock(&fi->lock);
304 li = fi->local_int[cpu_addr];
305 if (li == NULL) {
Heiko Carstensea1918d2012-06-26 16:06:40 +0200306 rc = SIGP_CC_NOT_OPERATIONAL;
Jens Freimann151104a2012-02-08 08:28:29 +0100307 goto out;
308 }
309
310 spin_lock_bh(&li->lock);
311 if (li->action_bits & ACTION_STOP_ON_STOP)
Heiko Carstensea1918d2012-06-26 16:06:40 +0200312 rc = SIGP_CC_BUSY;
Jens Freimann151104a2012-02-08 08:28:29 +0100313 else
314 VCPU_EVENT(vcpu, 4, "sigp restart %x to handle userspace",
315 cpu_addr);
316 spin_unlock_bh(&li->lock);
317out:
318 spin_unlock(&fi->lock);
319 return rc;
320}
321
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100322int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu)
323{
324 int r1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4;
325 int r3 = vcpu->arch.sie_block->ipa & 0x000f;
326 int base2 = vcpu->arch.sie_block->ipb >> 28;
327 int disp2 = ((vcpu->arch.sie_block->ipb & 0x0fff0000) >> 16);
328 u32 parameter;
Christian Borntraeger5a32c1a2012-01-11 11:20:32 +0100329 u16 cpu_addr = vcpu->run->s.regs.gprs[r3];
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100330 u8 order_code;
331 int rc;
332
Christian Borntraeger3eb77d52008-11-17 14:50:35 +0100333 /* sigp in userspace can exit */
334 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
335 return kvm_s390_inject_program_int(vcpu,
336 PGM_PRIVILEGED_OPERATION);
337
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100338 order_code = disp2;
339 if (base2)
Christian Borntraeger5a32c1a2012-01-11 11:20:32 +0100340 order_code += vcpu->run->s.regs.gprs[base2];
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100341
342 if (r1 % 2)
Christian Borntraeger5a32c1a2012-01-11 11:20:32 +0100343 parameter = vcpu->run->s.regs.gprs[r1];
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100344 else
Christian Borntraeger5a32c1a2012-01-11 11:20:32 +0100345 parameter = vcpu->run->s.regs.gprs[r1 + 1];
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100346
347 switch (order_code) {
348 case SIGP_SENSE:
349 vcpu->stat.instruction_sigp_sense++;
350 rc = __sigp_sense(vcpu, cpu_addr,
Christian Borntraeger5a32c1a2012-01-11 11:20:32 +0100351 &vcpu->run->s.regs.gprs[r1]);
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100352 break;
Christian Ehrhardt7697e71f2011-10-18 12:27:15 +0200353 case SIGP_EXTERNAL_CALL:
354 vcpu->stat.instruction_sigp_external_call++;
355 rc = __sigp_external_call(vcpu, cpu_addr);
356 break;
Heiko Carstens9b747532012-06-26 16:06:37 +0200357 case SIGP_EMERGENCY_SIGNAL:
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100358 vcpu->stat.instruction_sigp_emergency++;
359 rc = __sigp_emergency(vcpu, cpu_addr);
360 break;
361 case SIGP_STOP:
362 vcpu->stat.instruction_sigp_stop++;
Christian Ehrhardt9ace9032009-05-20 15:34:55 +0200363 rc = __sigp_stop(vcpu, cpu_addr, ACTION_STOP_ON_STOP);
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100364 break;
Heiko Carstens9b747532012-06-26 16:06:37 +0200365 case SIGP_STOP_AND_STORE_STATUS:
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100366 vcpu->stat.instruction_sigp_stop++;
Jens Freimann9ec2d6d2012-02-06 10:59:06 +0100367 rc = __sigp_stop(vcpu, cpu_addr, ACTION_STORE_ON_STOP |
368 ACTION_STOP_ON_STOP);
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100369 break;
Heiko Carstens9b747532012-06-26 16:06:37 +0200370 case SIGP_SET_ARCHITECTURE:
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100371 vcpu->stat.instruction_sigp_arch++;
372 rc = __sigp_set_arch(vcpu, parameter);
373 break;
374 case SIGP_SET_PREFIX:
375 vcpu->stat.instruction_sigp_prefix++;
376 rc = __sigp_set_prefix(vcpu, cpu_addr, parameter,
Christian Borntraeger5a32c1a2012-01-11 11:20:32 +0100377 &vcpu->run->s.regs.gprs[r1]);
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100378 break;
Cornelia Huckbd59d3a2011-11-17 11:00:42 +0100379 case SIGP_SENSE_RUNNING:
380 vcpu->stat.instruction_sigp_sense_running++;
381 rc = __sigp_sense_running(vcpu, cpu_addr,
Christian Borntraeger5a32c1a2012-01-11 11:20:32 +0100382 &vcpu->run->s.regs.gprs[r1]);
Cornelia Huckbd59d3a2011-11-17 11:00:42 +0100383 break;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100384 case SIGP_RESTART:
385 vcpu->stat.instruction_sigp_restart++;
Jens Freimann151104a2012-02-08 08:28:29 +0100386 rc = __sigp_restart(vcpu, cpu_addr);
Heiko Carstensea1918d2012-06-26 16:06:40 +0200387 if (rc == SIGP_CC_BUSY)
Jens Freimann151104a2012-02-08 08:28:29 +0100388 break;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100389 /* user space must know about restart */
390 default:
Heiko Carstensb8e660b2010-02-26 22:37:41 +0100391 return -EOPNOTSUPP;
Christian Borntraeger5288fbf2008-03-25 18:47:31 +0100392 }
393
394 if (rc < 0)
395 return rc;
396
397 vcpu->arch.sie_block->gpsw.mask &= ~(3ul << 44);
398 vcpu->arch.sie_block->gpsw.mask |= (rc & 3ul) << 44;
399 return 0;
400}