diff options
author | Avi Kivity <avi@redhat.com> | 2010-05-13 04:50:19 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-05-19 04:41:11 -0400 |
commit | 8fbf065d625617bbbf6b72d5f78f84ad13c8b547 (patch) | |
tree | 6d292b9ffff8e567b09289dbebfe9a8e826c76ea /arch/x86 | |
parent | 98001d8d017cea1ee0f9f35c6227bbd63ef5005b (diff) |
KVM: x86: Add missing locking to arch specific vcpu ioctls
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kvm/x86.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index f0846d2aa956..39f495802050 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -1833,6 +1833,7 @@ static int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu, | |||
1833 | { | 1833 | { |
1834 | int r; | 1834 | int r; |
1835 | 1835 | ||
1836 | vcpu_load(vcpu); | ||
1836 | r = -E2BIG; | 1837 | r = -E2BIG; |
1837 | if (cpuid->nent < vcpu->arch.cpuid_nent) | 1838 | if (cpuid->nent < vcpu->arch.cpuid_nent) |
1838 | goto out; | 1839 | goto out; |
@@ -1844,6 +1845,7 @@ static int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu, | |||
1844 | 1845 | ||
1845 | out: | 1846 | out: |
1846 | cpuid->nent = vcpu->arch.cpuid_nent; | 1847 | cpuid->nent = vcpu->arch.cpuid_nent; |
1848 | vcpu_put(vcpu); | ||
1847 | return r; | 1849 | return r; |
1848 | } | 1850 | } |
1849 | 1851 | ||
@@ -2134,6 +2136,7 @@ static int kvm_vcpu_ioctl_x86_setup_mce(struct kvm_vcpu *vcpu, | |||
2134 | int r; | 2136 | int r; |
2135 | unsigned bank_num = mcg_cap & 0xff, bank; | 2137 | unsigned bank_num = mcg_cap & 0xff, bank; |
2136 | 2138 | ||
2139 | vcpu_load(vcpu); | ||
2137 | r = -EINVAL; | 2140 | r = -EINVAL; |
2138 | if (!bank_num || bank_num >= KVM_MAX_MCE_BANKS) | 2141 | if (!bank_num || bank_num >= KVM_MAX_MCE_BANKS) |
2139 | goto out; | 2142 | goto out; |
@@ -2148,6 +2151,7 @@ static int kvm_vcpu_ioctl_x86_setup_mce(struct kvm_vcpu *vcpu, | |||
2148 | for (bank = 0; bank < bank_num; bank++) | 2151 | for (bank = 0; bank < bank_num; bank++) |
2149 | vcpu->arch.mce_banks[bank*4] = ~(u64)0; | 2152 | vcpu->arch.mce_banks[bank*4] = ~(u64)0; |
2150 | out: | 2153 | out: |
2154 | vcpu_put(vcpu); | ||
2151 | return r; | 2155 | return r; |
2152 | } | 2156 | } |
2153 | 2157 | ||
@@ -2456,7 +2460,9 @@ long kvm_arch_vcpu_ioctl(struct file *filp, | |||
2456 | r = -EFAULT; | 2460 | r = -EFAULT; |
2457 | if (copy_from_user(&mce, argp, sizeof mce)) | 2461 | if (copy_from_user(&mce, argp, sizeof mce)) |
2458 | goto out; | 2462 | goto out; |
2463 | vcpu_load(vcpu); | ||
2459 | r = kvm_vcpu_ioctl_x86_set_mce(vcpu, &mce); | 2464 | r = kvm_vcpu_ioctl_x86_set_mce(vcpu, &mce); |
2465 | vcpu_put(vcpu); | ||
2460 | break; | 2466 | break; |
2461 | } | 2467 | } |
2462 | case KVM_GET_VCPU_EVENTS: { | 2468 | case KVM_GET_VCPU_EVENTS: { |