aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/ia64/kvm/kvm-ia64.c5
-rw-r--r--arch/x86/kvm/x86.c8
-rw-r--r--include/linux/kvm_host.h7
-rw-r--r--virt/kvm/kvm_main.c4
4 files changed, 24 insertions, 0 deletions
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index d8ddbba6fe7d..f5104b7c52cd 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -1172,6 +1172,11 @@ out:
1172 1172
1173#define PALE_RESET_ENTRY 0x80000000ffffffb0UL 1173#define PALE_RESET_ENTRY 0x80000000ffffffb0UL
1174 1174
1175bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu)
1176{
1177 return irqchip_in_kernel(vcpu->kcm) == (vcpu->arch.apic != NULL);
1178}
1179
1175int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) 1180int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
1176{ 1181{
1177 struct kvm_vcpu *v; 1182 struct kvm_vcpu *v;
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 03a1fd47a6d3..9477dc6cccae 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3199,6 +3199,9 @@ long kvm_arch_vm_ioctl(struct file *filp,
3199 r = -EEXIST; 3199 r = -EEXIST;
3200 if (kvm->arch.vpic) 3200 if (kvm->arch.vpic)
3201 goto create_irqchip_unlock; 3201 goto create_irqchip_unlock;
3202 r = -EINVAL;
3203 if (atomic_read(&kvm->online_vcpus))
3204 goto create_irqchip_unlock;
3202 r = -ENOMEM; 3205 r = -ENOMEM;
3203 vpic = kvm_create_pic(kvm); 3206 vpic = kvm_create_pic(kvm);
3204 if (vpic) { 3207 if (vpic) {
@@ -6107,6 +6110,11 @@ void kvm_arch_check_processor_compat(void *rtn)
6107 kvm_x86_ops->check_processor_compatibility(rtn); 6110 kvm_x86_ops->check_processor_compatibility(rtn);
6108} 6111}
6109 6112
6113bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu)
6114{
6115 return irqchip_in_kernel(vcpu->kvm) == (vcpu->arch.apic != NULL);
6116}
6117
6110int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) 6118int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
6111{ 6119{
6112 struct page *page; 6120 struct page *page;
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 355e44555c39..e42d85ae8541 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -805,6 +805,13 @@ static inline bool kvm_vcpu_is_bsp(struct kvm_vcpu *vcpu)
805{ 805{
806 return vcpu->kvm->bsp_vcpu_id == vcpu->vcpu_id; 806 return vcpu->kvm->bsp_vcpu_id == vcpu->vcpu_id;
807} 807}
808
809bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu);
810
811#else
812
813static inline bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu) { return true; }
814
808#endif 815#endif
809 816
810#ifdef __KVM_HAVE_DEVICE_ASSIGNMENT 817#ifdef __KVM_HAVE_DEVICE_ASSIGNMENT
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index e4431ada5947..94e148e38719 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1651,6 +1651,10 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id)
1651 goto vcpu_destroy; 1651 goto vcpu_destroy;
1652 1652
1653 mutex_lock(&kvm->lock); 1653 mutex_lock(&kvm->lock);
1654 if (!kvm_vcpu_compatible(vcpu)) {
1655 r = -EINVAL;
1656 goto unlock_vcpu_destroy;
1657 }
1654 if (atomic_read(&kvm->online_vcpus) == KVM_MAX_VCPUS) { 1658 if (atomic_read(&kvm->online_vcpus) == KVM_MAX_VCPUS) {
1655 r = -EINVAL; 1659 r = -EINVAL;
1656 goto unlock_vcpu_destroy; 1660 goto unlock_vcpu_destroy;