diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2016-06-13 08:50:04 -0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-06-15 18:05:00 -0400 |
commit | 557abc40d121358883d2da8bc8bf976d6e8ec332 (patch) | |
tree | 2ff0bd1c4012d2b07eddc0078b7fd8c0d537cc1d | |
parent | 6c7caebc26c5f0b618f0ef6b851e9f5f27c3812f (diff) |
KVM: remove kvm_vcpu_compatible
The new created_vcpus field makes it possible to avoid the race between
irqchip and VCPU creation in a much nicer way; just check under kvm->lock
whether a VCPU has already been created.
We can then remove KVM_APIC_ARCHITECTURE too, because at this point the
symbol is only governing the default definition of kvm_vcpu_compatible.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | arch/x86/kvm/Kconfig | 1 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 11 | ||||
-rw-r--r-- | include/linux/kvm_host.h | 6 | ||||
-rw-r--r-- | virt/kvm/Kconfig | 3 | ||||
-rw-r--r-- | virt/kvm/kvm_main.c | 4 |
5 files changed, 3 insertions, 22 deletions
diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig index 639a6e34500c..ab8e32f7b9a8 100644 --- a/arch/x86/kvm/Kconfig +++ b/arch/x86/kvm/Kconfig | |||
@@ -32,7 +32,6 @@ config KVM | |||
32 | select HAVE_KVM_IRQ_BYPASS | 32 | select HAVE_KVM_IRQ_BYPASS |
33 | select HAVE_KVM_IRQ_ROUTING | 33 | select HAVE_KVM_IRQ_ROUTING |
34 | select HAVE_KVM_EVENTFD | 34 | select HAVE_KVM_EVENTFD |
35 | select KVM_APIC_ARCHITECTURE | ||
36 | select KVM_ASYNC_PF | 35 | select KVM_ASYNC_PF |
37 | select USER_RETURN_NOTIFIER | 36 | select USER_RETURN_NOTIFIER |
38 | select KVM_MMIO | 37 | select KVM_MMIO |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index bf227212aebb..ab2f45a50bb5 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -3774,7 +3774,7 @@ static int kvm_vm_ioctl_enable_cap(struct kvm *kvm, | |||
3774 | r = -EEXIST; | 3774 | r = -EEXIST; |
3775 | if (irqchip_in_kernel(kvm)) | 3775 | if (irqchip_in_kernel(kvm)) |
3776 | goto split_irqchip_unlock; | 3776 | goto split_irqchip_unlock; |
3777 | if (atomic_read(&kvm->online_vcpus)) | 3777 | if (kvm->created_vcpus) |
3778 | goto split_irqchip_unlock; | 3778 | goto split_irqchip_unlock; |
3779 | r = kvm_setup_empty_irq_routing(kvm); | 3779 | r = kvm_setup_empty_irq_routing(kvm); |
3780 | if (r) | 3780 | if (r) |
@@ -3839,7 +3839,7 @@ long kvm_arch_vm_ioctl(struct file *filp, | |||
3839 | if (kvm->arch.vpic) | 3839 | if (kvm->arch.vpic) |
3840 | goto create_irqchip_unlock; | 3840 | goto create_irqchip_unlock; |
3841 | r = -EINVAL; | 3841 | r = -EINVAL; |
3842 | if (atomic_read(&kvm->online_vcpus)) | 3842 | if (kvm->created_vcpus) |
3843 | goto create_irqchip_unlock; | 3843 | goto create_irqchip_unlock; |
3844 | r = -ENOMEM; | 3844 | r = -ENOMEM; |
3845 | vpic = kvm_create_pic(kvm); | 3845 | vpic = kvm_create_pic(kvm); |
@@ -3995,7 +3995,7 @@ long kvm_arch_vm_ioctl(struct file *filp, | |||
3995 | case KVM_SET_BOOT_CPU_ID: | 3995 | case KVM_SET_BOOT_CPU_ID: |
3996 | r = 0; | 3996 | r = 0; |
3997 | mutex_lock(&kvm->lock); | 3997 | mutex_lock(&kvm->lock); |
3998 | if (atomic_read(&kvm->online_vcpus) != 0) | 3998 | if (kvm->created_vcpus) |
3999 | r = -EBUSY; | 3999 | r = -EBUSY; |
4000 | else | 4000 | else |
4001 | kvm->arch.bsp_vcpu_id = arg; | 4001 | kvm->arch.bsp_vcpu_id = arg; |
@@ -7639,11 +7639,6 @@ bool kvm_vcpu_is_bsp(struct kvm_vcpu *vcpu) | |||
7639 | return (vcpu->arch.apic_base & MSR_IA32_APICBASE_BSP) != 0; | 7639 | return (vcpu->arch.apic_base & MSR_IA32_APICBASE_BSP) != 0; |
7640 | } | 7640 | } |
7641 | 7641 | ||
7642 | bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu) | ||
7643 | { | ||
7644 | return irqchip_in_kernel(vcpu->kvm) == lapic_in_kernel(vcpu); | ||
7645 | } | ||
7646 | |||
7647 | struct static_key kvm_no_apic_vcpu __read_mostly; | 7642 | struct static_key kvm_no_apic_vcpu __read_mostly; |
7648 | EXPORT_SYMBOL_GPL(kvm_no_apic_vcpu); | 7643 | EXPORT_SYMBOL_GPL(kvm_no_apic_vcpu); |
7649 | 7644 | ||
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 63c6ab30bc81..0640ee92b978 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
@@ -1105,12 +1105,6 @@ static inline int kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) | |||
1105 | 1105 | ||
1106 | #endif /* CONFIG_HAVE_KVM_EVENTFD */ | 1106 | #endif /* CONFIG_HAVE_KVM_EVENTFD */ |
1107 | 1107 | ||
1108 | #ifdef CONFIG_KVM_APIC_ARCHITECTURE | ||
1109 | bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu); | ||
1110 | #else | ||
1111 | static inline bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu) { return true; } | ||
1112 | #endif | ||
1113 | |||
1114 | static inline void kvm_make_request(int req, struct kvm_vcpu *vcpu) | 1108 | static inline void kvm_make_request(int req, struct kvm_vcpu *vcpu) |
1115 | { | 1109 | { |
1116 | /* | 1110 | /* |
diff --git a/virt/kvm/Kconfig b/virt/kvm/Kconfig index e5d6108f5e85..b0cc1a34db27 100644 --- a/virt/kvm/Kconfig +++ b/virt/kvm/Kconfig | |||
@@ -16,9 +16,6 @@ config HAVE_KVM_EVENTFD | |||
16 | bool | 16 | bool |
17 | select EVENTFD | 17 | select EVENTFD |
18 | 18 | ||
19 | config KVM_APIC_ARCHITECTURE | ||
20 | bool | ||
21 | |||
22 | config KVM_MMIO | 19 | config KVM_MMIO |
23 | bool | 20 | bool |
24 | 21 | ||
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 15b757ae64e1..ef54b4c31792 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -2368,10 +2368,6 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id) | |||
2368 | goto vcpu_destroy; | 2368 | goto vcpu_destroy; |
2369 | 2369 | ||
2370 | mutex_lock(&kvm->lock); | 2370 | mutex_lock(&kvm->lock); |
2371 | if (!kvm_vcpu_compatible(vcpu)) { | ||
2372 | r = -EINVAL; | ||
2373 | goto unlock_vcpu_destroy; | ||
2374 | } | ||
2375 | if (kvm_get_vcpu_by_id(kvm, id)) { | 2371 | if (kvm_get_vcpu_by_id(kvm, id)) { |
2376 | r = -EEXIST; | 2372 | r = -EEXIST; |
2377 | goto unlock_vcpu_destroy; | 2373 | goto unlock_vcpu_destroy; |