aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2010-05-13 05:35:17 -0400
committerAvi Kivity <avi@redhat.com>2010-08-01 03:35:48 -0400
commit93736624635235cc5372ffca6d62816d02170724 (patch)
tree801205636b4d6da4127a6d33873902d690431f52
parent19483d144023f7f4817dedafe26d5fe9ff2e7087 (diff)
KVM: Consolidate arch specific vcpu ioctl locking
Now that all arch specific ioctls have centralized locking, it is easy to move it to the central dispatcher. Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r--arch/powerpc/kvm/powerpc.c11
-rw-r--r--arch/s390/kvm/kvm-s390.c13
-rw-r--r--arch/x86/kvm/x86.c2
-rw-r--r--virt/kvm/kvm_main.c2
4 files changed, 10 insertions, 18 deletions
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index caeed7b31bf9..a1d87508892e 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -512,17 +512,16 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
512 void __user *argp = (void __user *)arg; 512 void __user *argp = (void __user *)arg;
513 long r; 513 long r;
514 514
515 if (ioctl == KVM_INTERRUPT) { 515 switch (ioctl) {
516 case KVM_INTERRUPT: {
516 struct kvm_interrupt irq; 517 struct kvm_interrupt irq;
517 r = -EFAULT; 518 r = -EFAULT;
518 if (copy_from_user(&irq, argp, sizeof(irq))) 519 if (copy_from_user(&irq, argp, sizeof(irq)))
519 goto out_nolock; 520 goto out;
520 r = kvm_vcpu_ioctl_interrupt(vcpu, &irq); 521 r = kvm_vcpu_ioctl_interrupt(vcpu, &irq);
521 goto out_nolock; 522 goto out;
522 } 523 }
523 524
524 vcpu_load(vcpu);
525 switch (ioctl) {
526 case KVM_ENABLE_CAP: 525 case KVM_ENABLE_CAP:
527 { 526 {
528 struct kvm_enable_cap cap; 527 struct kvm_enable_cap cap;
@@ -537,8 +536,6 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
537 } 536 }
538 537
539out: 538out:
540 vcpu_put(vcpu);
541out_nolock:
542 return r; 539 return r;
543} 540}
544 541
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index fd169f658bf8..0cb0da7822d5 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -638,16 +638,16 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
638 void __user *argp = (void __user *)arg; 638 void __user *argp = (void __user *)arg;
639 long r; 639 long r;
640 640
641 if (ioctl == KVM_S390_INTERRUPT) { 641 switch (ioctl) {
642 case KVM_S390_INTERRUPT: {
642 struct kvm_s390_interrupt s390int; 643 struct kvm_s390_interrupt s390int;
643 644
645 r = -EFAULT;
644 if (copy_from_user(&s390int, argp, sizeof(s390int))) 646 if (copy_from_user(&s390int, argp, sizeof(s390int)))
645 return -EFAULT; 647 break;
646 return kvm_s390_inject_vcpu(vcpu, &s390int); 648 r = kvm_s390_inject_vcpu(vcpu, &s390int);
649 break;
647 } 650 }
648
649 vcpu_load(vcpu);
650 switch (ioctl) {
651 case KVM_S390_STORE_STATUS: 651 case KVM_S390_STORE_STATUS:
652 r = kvm_s390_vcpu_store_status(vcpu, arg); 652 r = kvm_s390_vcpu_store_status(vcpu, arg);
653 break; 653 break;
@@ -666,7 +666,6 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
666 default: 666 default:
667 r = -EINVAL; 667 r = -EINVAL;
668 } 668 }
669 vcpu_put(vcpu);
670 return r; 669 return r;
671} 670}
672 671
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 999b017011f4..4c2096f30d90 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2298,7 +2298,6 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
2298 int r; 2298 int r;
2299 struct kvm_lapic_state *lapic = NULL; 2299 struct kvm_lapic_state *lapic = NULL;
2300 2300
2301 vcpu_load(vcpu);
2302 switch (ioctl) { 2301 switch (ioctl) {
2303 case KVM_GET_LAPIC: { 2302 case KVM_GET_LAPIC: {
2304 r = -EINVAL; 2303 r = -EINVAL;
@@ -2496,7 +2495,6 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
2496 r = -EINVAL; 2495 r = -EINVAL;
2497 } 2496 }
2498out: 2497out:
2499 vcpu_put(vcpu);
2500 kfree(lapic); 2498 kfree(lapic);
2501 return r; 2499 return r;
2502} 2500}
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index e0fb0988a3fe..35532c964710 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1578,9 +1578,7 @@ out_free2:
1578 break; 1578 break;
1579 } 1579 }
1580 default: 1580 default:
1581 vcpu_put(vcpu);
1582 r = kvm_arch_vcpu_ioctl(filp, ioctl, arg); 1581 r = kvm_arch_vcpu_ioctl(filp, ioctl, arg);
1583 vcpu_load(vcpu);
1584 } 1582 }
1585out: 1583out:
1586 vcpu_put(vcpu); 1584 vcpu_put(vcpu);