aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/kvm/kvm-s390.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2010-05-13 05:21:46 -0400
committerAvi Kivity <avi@redhat.com>2010-08-01 03:35:47 -0400
commitbc923cc93b7719576f20687e4cb07751601fbbb3 (patch)
treecc0ac66996c852bf1fb767fd980b30e63c2e05c8 /arch/s390/kvm/kvm-s390.c
parent526b78ad1a9e66ef240ad7c757988de039e42229 (diff)
KVM: s390: Centrally lock arch specific vcpu ioctls
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/s390/kvm/kvm-s390.c')
-rw-r--r--arch/s390/kvm/kvm-s390.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 0d0e0add0201..fd169f658bf8 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -363,9 +363,7 @@ int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
363 363
364static int kvm_arch_vcpu_ioctl_initial_reset(struct kvm_vcpu *vcpu) 364static int kvm_arch_vcpu_ioctl_initial_reset(struct kvm_vcpu *vcpu)
365{ 365{
366 vcpu_load(vcpu);
367 kvm_s390_vcpu_initial_reset(vcpu); 366 kvm_s390_vcpu_initial_reset(vcpu);
368 vcpu_put(vcpu);
369 return 0; 367 return 0;
370} 368}
371 369
@@ -415,14 +413,12 @@ static int kvm_arch_vcpu_ioctl_set_initial_psw(struct kvm_vcpu *vcpu, psw_t psw)
415{ 413{
416 int rc = 0; 414 int rc = 0;
417 415
418 vcpu_load(vcpu);
419 if (atomic_read(&vcpu->arch.sie_block->cpuflags) & CPUSTAT_RUNNING) 416 if (atomic_read(&vcpu->arch.sie_block->cpuflags) & CPUSTAT_RUNNING)
420 rc = -EBUSY; 417 rc = -EBUSY;
421 else { 418 else {
422 vcpu->run->psw_mask = psw.mask; 419 vcpu->run->psw_mask = psw.mask;
423 vcpu->run->psw_addr = psw.addr; 420 vcpu->run->psw_addr = psw.addr;
424 } 421 }
425 vcpu_put(vcpu);
426 return rc; 422 return rc;
427} 423}
428 424
@@ -573,7 +569,7 @@ static int __guestcopy(struct kvm_vcpu *vcpu, u64 guestdest, const void *from,
573 * KVM_S390_STORE_STATUS_NOADDR: -> 0x1200 on 64 bit 569 * KVM_S390_STORE_STATUS_NOADDR: -> 0x1200 on 64 bit
574 * KVM_S390_STORE_STATUS_PREFIXED: -> prefix 570 * KVM_S390_STORE_STATUS_PREFIXED: -> prefix
575 */ 571 */
576int __kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr) 572static int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr)
577{ 573{
578 const unsigned char archmode = 1; 574 const unsigned char archmode = 1;
579 int prefix; 575 int prefix;
@@ -635,45 +631,43 @@ int __kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr)
635 return 0; 631 return 0;
636} 632}
637 633
638static int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr)
639{
640 int rc;
641
642 vcpu_load(vcpu);
643 rc = __kvm_s390_vcpu_store_status(vcpu, addr);
644 vcpu_put(vcpu);
645 return rc;
646}
647
648long kvm_arch_vcpu_ioctl(struct file *filp, 634long kvm_arch_vcpu_ioctl(struct file *filp,
649 unsigned int ioctl, unsigned long arg) 635 unsigned int ioctl, unsigned long arg)
650{ 636{
651 struct kvm_vcpu *vcpu = filp->private_data; 637 struct kvm_vcpu *vcpu = filp->private_data;
652 void __user *argp = (void __user *)arg; 638 void __user *argp = (void __user *)arg;
639 long r;
653 640
654 switch (ioctl) { 641 if (ioctl == KVM_S390_INTERRUPT) {
655 case KVM_S390_INTERRUPT: {
656 struct kvm_s390_interrupt s390int; 642 struct kvm_s390_interrupt s390int;
657 643
658 if (copy_from_user(&s390int, argp, sizeof(s390int))) 644 if (copy_from_user(&s390int, argp, sizeof(s390int)))
659 return -EFAULT; 645 return -EFAULT;
660 return kvm_s390_inject_vcpu(vcpu, &s390int); 646 return kvm_s390_inject_vcpu(vcpu, &s390int);
661 } 647 }
648
649 vcpu_load(vcpu);
650 switch (ioctl) {
662 case KVM_S390_STORE_STATUS: 651 case KVM_S390_STORE_STATUS:
663 return kvm_s390_vcpu_store_status(vcpu, arg); 652 r = kvm_s390_vcpu_store_status(vcpu, arg);
653 break;
664 case KVM_S390_SET_INITIAL_PSW: { 654 case KVM_S390_SET_INITIAL_PSW: {
665 psw_t psw; 655 psw_t psw;
666 656
657 r = -EFAULT;
667 if (copy_from_user(&psw, argp, sizeof(psw))) 658 if (copy_from_user(&psw, argp, sizeof(psw)))
668 return -EFAULT; 659 break;
669 return kvm_arch_vcpu_ioctl_set_initial_psw(vcpu, psw); 660 r = kvm_arch_vcpu_ioctl_set_initial_psw(vcpu, psw);
661 break;
670 } 662 }
671 case KVM_S390_INITIAL_RESET: 663 case KVM_S390_INITIAL_RESET:
672 return kvm_arch_vcpu_ioctl_initial_reset(vcpu); 664 r = kvm_arch_vcpu_ioctl_initial_reset(vcpu);
665 break;
673 default: 666 default:
674 ; 667 r = -EINVAL;
675 } 668 }
676 return -EINVAL; 669 vcpu_put(vcpu);
670 return r;
677} 671}
678 672
679/* Section: memory related */ 673/* Section: memory related */