17 #include <linux/slab.h>
39 *reg &= 0xffffffff00000000
UL;
48 spin_unlock(&fi->
lock);
50 VCPU_EVENT(vcpu, 4,
"sensed status of cpu %x rc %x", cpu_addr, rc);
54 static int __sigp_emergency(
struct kvm_vcpu *vcpu,
u16 cpu_addr)
78 spin_lock_bh(&li->
lock);
82 if (waitqueue_active(&li->
wq))
84 spin_unlock_bh(&li->
lock);
86 VCPU_EVENT(vcpu, 4,
"sent sigp emerg to cpu %x", cpu_addr);
88 spin_unlock(&fi->
lock);
92 static int __sigp_external_call(
struct kvm_vcpu *vcpu,
u16 cpu_addr)
109 spin_lock(&fi->
lock);
116 spin_lock_bh(&li->
lock);
120 if (waitqueue_active(&li->
wq))
122 spin_unlock_bh(&li->
lock);
124 VCPU_EVENT(vcpu, 4,
"sent sigp ext call to cpu %x", cpu_addr);
126 spin_unlock(&fi->
lock);
139 spin_lock_bh(&li->
lock);
146 if (waitqueue_active(&li->
wq))
149 spin_unlock_bh(&li->
lock);
154 static int __sigp_stop(
struct kvm_vcpu *vcpu,
u16 cpu_addr,
int action)
163 spin_lock(&fi->
lock);
170 rc = __inject_sigp_stop(li, action);
173 spin_unlock(&fi->
lock);
174 VCPU_EVENT(vcpu, 4,
"sent sigp stop to cpu %x", cpu_addr);
181 return __inject_sigp_stop(li, action);
184 static int __sigp_set_arch(
struct kvm_vcpu *vcpu,
u32 parameter)
188 switch (parameter & 0xff) {
212 address = address & 0x7fffe000
u;
213 if (copy_from_guest_absolute(vcpu, &tmp, address, 1) ||
214 copy_from_guest_absolute(vcpu, &tmp, address +
PAGE_SIZE, 1)) {
215 *reg &= 0xffffffff00000000
UL;
224 spin_lock(&fi->
lock);
229 *reg &= 0xffffffff00000000
UL;
236 spin_lock_bh(&li->
lock);
239 *reg &= 0xffffffff00000000
UL;
251 if (waitqueue_active(&li->
wq))
255 VCPU_EVENT(vcpu, 4,
"set prefix of cpu %02x to %x", cpu_addr, address);
257 spin_unlock_bh(&li->
lock);
259 spin_unlock(&fi->
lock);
263 static int __sigp_sense_running(
struct kvm_vcpu *vcpu,
u16 cpu_addr,
272 spin_lock(&fi->
lock);
282 *reg &= 0xffffffff00000000
UL;
287 spin_unlock(&fi->
lock);
289 VCPU_EVENT(vcpu, 4,
"sensed running status of cpu %x rc %x", cpu_addr,
295 static int __sigp_restart(
struct kvm_vcpu *vcpu,
u16 cpu_addr)
304 spin_lock(&fi->
lock);
311 spin_lock_bh(&li->
lock);
315 VCPU_EVENT(vcpu, 4,
"sigp restart %x to handle userspace",
317 spin_unlock_bh(&li->
lock);
319 spin_unlock(&fi->
lock);
325 int r1 = (vcpu->
arch.sie_block->ipa & 0x00f0) >> 4;
326 int r3 = vcpu->
arch.sie_block->ipa & 0x000f;
327 int base2 = vcpu->
arch.sie_block->ipb >> 28;
328 int disp2 = ((vcpu->
arch.sie_block->ipb & 0x0fff0000) >> 16);
330 u16 cpu_addr = vcpu->
run->s.regs.gprs[
r3];
341 order_code += vcpu->
run->s.regs.gprs[
base2];
344 parameter = vcpu->
run->s.regs.gprs[
r1];
346 parameter = vcpu->
run->s.regs.gprs[r1 + 1];
348 trace_kvm_s390_handle_sigp(vcpu, order_code, cpu_addr, parameter);
349 switch (order_code) {
351 vcpu->
stat.instruction_sigp_sense++;
352 rc = __sigp_sense(vcpu, cpu_addr,
353 &vcpu->
run->s.regs.gprs[r1]);
356 vcpu->
stat.instruction_sigp_external_call++;
357 rc = __sigp_external_call(vcpu, cpu_addr);
360 vcpu->
stat.instruction_sigp_emergency++;
361 rc = __sigp_emergency(vcpu, cpu_addr);
364 vcpu->
stat.instruction_sigp_stop++;
368 vcpu->
stat.instruction_sigp_stop++;
373 vcpu->
stat.instruction_sigp_arch++;
374 rc = __sigp_set_arch(vcpu, parameter);
377 vcpu->
stat.instruction_sigp_prefix++;
378 rc = __sigp_set_prefix(vcpu, cpu_addr, parameter,
379 &vcpu->
run->s.regs.gprs[r1]);
382 vcpu->
stat.instruction_sigp_sense_running++;
383 rc = __sigp_sense_running(vcpu, cpu_addr,
384 &vcpu->
run->s.regs.gprs[r1]);
387 vcpu->
stat.instruction_sigp_restart++;
388 rc = __sigp_restart(vcpu, cpu_addr);
399 vcpu->
arch.sie_block->gpsw.mask &= ~(3ul << 44);
400 vcpu->
arch.sie_block->gpsw.mask |= (rc & 3ul) << 44;