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>
This commit is contained in:
@@ -32,7 +32,6 @@ config KVM
|
|||||||
select HAVE_KVM_IRQ_BYPASS
|
select HAVE_KVM_IRQ_BYPASS
|
||||||
select HAVE_KVM_IRQ_ROUTING
|
select HAVE_KVM_IRQ_ROUTING
|
||||||
select HAVE_KVM_EVENTFD
|
select HAVE_KVM_EVENTFD
|
||||||
select KVM_APIC_ARCHITECTURE
|
|
||||||
select KVM_ASYNC_PF
|
select KVM_ASYNC_PF
|
||||||
select USER_RETURN_NOTIFIER
|
select USER_RETURN_NOTIFIER
|
||||||
select KVM_MMIO
|
select KVM_MMIO
|
||||||
|
|||||||
@@ -3774,7 +3774,7 @@ static int kvm_vm_ioctl_enable_cap(struct kvm *kvm,
|
|||||||
r = -EEXIST;
|
r = -EEXIST;
|
||||||
if (irqchip_in_kernel(kvm))
|
if (irqchip_in_kernel(kvm))
|
||||||
goto split_irqchip_unlock;
|
goto split_irqchip_unlock;
|
||||||
if (atomic_read(&kvm->online_vcpus))
|
if (kvm->created_vcpus)
|
||||||
goto split_irqchip_unlock;
|
goto split_irqchip_unlock;
|
||||||
r = kvm_setup_empty_irq_routing(kvm);
|
r = kvm_setup_empty_irq_routing(kvm);
|
||||||
if (r)
|
if (r)
|
||||||
@@ -3839,7 +3839,7 @@ long kvm_arch_vm_ioctl(struct file *filp,
|
|||||||
if (kvm->arch.vpic)
|
if (kvm->arch.vpic)
|
||||||
goto create_irqchip_unlock;
|
goto create_irqchip_unlock;
|
||||||
r = -EINVAL;
|
r = -EINVAL;
|
||||||
if (atomic_read(&kvm->online_vcpus))
|
if (kvm->created_vcpus)
|
||||||
goto create_irqchip_unlock;
|
goto create_irqchip_unlock;
|
||||||
r = -ENOMEM;
|
r = -ENOMEM;
|
||||||
vpic = kvm_create_pic(kvm);
|
vpic = kvm_create_pic(kvm);
|
||||||
@@ -3995,7 +3995,7 @@ long kvm_arch_vm_ioctl(struct file *filp,
|
|||||||
case KVM_SET_BOOT_CPU_ID:
|
case KVM_SET_BOOT_CPU_ID:
|
||||||
r = 0;
|
r = 0;
|
||||||
mutex_lock(&kvm->lock);
|
mutex_lock(&kvm->lock);
|
||||||
if (atomic_read(&kvm->online_vcpus) != 0)
|
if (kvm->created_vcpus)
|
||||||
r = -EBUSY;
|
r = -EBUSY;
|
||||||
else
|
else
|
||||||
kvm->arch.bsp_vcpu_id = arg;
|
kvm->arch.bsp_vcpu_id = arg;
|
||||||
@@ -7639,11 +7639,6 @@ bool kvm_vcpu_is_bsp(struct kvm_vcpu *vcpu)
|
|||||||
return (vcpu->arch.apic_base & MSR_IA32_APICBASE_BSP) != 0;
|
return (vcpu->arch.apic_base & MSR_IA32_APICBASE_BSP) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu)
|
|
||||||
{
|
|
||||||
return irqchip_in_kernel(vcpu->kvm) == lapic_in_kernel(vcpu);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct static_key kvm_no_apic_vcpu __read_mostly;
|
struct static_key kvm_no_apic_vcpu __read_mostly;
|
||||||
EXPORT_SYMBOL_GPL(kvm_no_apic_vcpu);
|
EXPORT_SYMBOL_GPL(kvm_no_apic_vcpu);
|
||||||
|
|
||||||
|
|||||||
@@ -1105,12 +1105,6 @@ static inline int kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
|
|||||||
|
|
||||||
#endif /* CONFIG_HAVE_KVM_EVENTFD */
|
#endif /* CONFIG_HAVE_KVM_EVENTFD */
|
||||||
|
|
||||||
#ifdef CONFIG_KVM_APIC_ARCHITECTURE
|
|
||||||
bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu);
|
|
||||||
#else
|
|
||||||
static inline bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu) { return true; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline void kvm_make_request(int req, struct kvm_vcpu *vcpu)
|
static inline void kvm_make_request(int req, struct kvm_vcpu *vcpu)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -16,9 +16,6 @@ config HAVE_KVM_EVENTFD
|
|||||||
bool
|
bool
|
||||||
select EVENTFD
|
select EVENTFD
|
||||||
|
|
||||||
config KVM_APIC_ARCHITECTURE
|
|
||||||
bool
|
|
||||||
|
|
||||||
config KVM_MMIO
|
config KVM_MMIO
|
||||||
bool
|
bool
|
||||||
|
|
||||||
|
|||||||
@@ -2368,10 +2368,6 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id)
|
|||||||
goto vcpu_destroy;
|
goto vcpu_destroy;
|
||||||
|
|
||||||
mutex_lock(&kvm->lock);
|
mutex_lock(&kvm->lock);
|
||||||
if (!kvm_vcpu_compatible(vcpu)) {
|
|
||||||
r = -EINVAL;
|
|
||||||
goto unlock_vcpu_destroy;
|
|
||||||
}
|
|
||||||
if (kvm_get_vcpu_by_id(kvm, id)) {
|
if (kvm_get_vcpu_by_id(kvm, id)) {
|
||||||
r = -EEXIST;
|
r = -EEXIST;
|
||||||
goto unlock_vcpu_destroy;
|
goto unlock_vcpu_destroy;
|
||||||
|
|||||||
Reference in New Issue
Block a user