KVM: move code related to KVM_SET_BOOT_CPU_ID to x86
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 29 Jul 2015 09:56:48 +0000 (11:56 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 29 Jul 2015 12:27:21 +0000 (14:27 +0200)
This is another remnant of ia64 support.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/x86.c
include/linux/kvm_host.h
virt/kvm/kvm_main.c

index fa32b5314dcdad94d377b59f1b5233f2a55a1f32..2f9e504f9f0c85b7a98e748a2f6871d6e1001a39 100644 (file)
@@ -667,6 +667,7 @@ struct kvm_arch {
        #endif
 
        bool boot_vcpu_runs_old_kvmclock;
+       u32 bsp_vcpu_id;
 
        u64 disabled_quirks;
 };
@@ -1215,5 +1216,7 @@ int __x86_set_memory_region(struct kvm *kvm,
                            const struct kvm_userspace_memory_region *mem);
 int x86_set_memory_region(struct kvm *kvm,
                          const struct kvm_userspace_memory_region *mem);
+bool kvm_vcpu_is_reset_bsp(struct kvm_vcpu *vcpu);
+bool kvm_vcpu_is_bsp(struct kvm_vcpu *vcpu);
 
 #endif /* _ASM_X86_KVM_HOST_H */
index 28076c266a9a3aee5f165509e76d2e85b26ae2dd..c675ea3351cfc854f786442d973ef5d36e1c0072 100644 (file)
@@ -2461,6 +2461,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
        case KVM_CAP_TSC_DEADLINE_TIMER:
        case KVM_CAP_ENABLE_CAP_VM:
        case KVM_CAP_DISABLE_QUIRKS:
+       case KVM_CAP_SET_BOOT_CPU_ID:
 #ifdef CONFIG_KVM_DEVICE_ASSIGNMENT
        case KVM_CAP_ASSIGN_DEV_IRQ:
        case KVM_CAP_PCI_2_3:
@@ -3777,6 +3778,15 @@ long kvm_arch_vm_ioctl(struct file *filp,
                r = kvm_vm_ioctl_reinject(kvm, &control);
                break;
        }
+       case KVM_SET_BOOT_CPU_ID:
+               r = 0;
+               mutex_lock(&kvm->lock);
+               if (atomic_read(&kvm->online_vcpus) != 0)
+                       r = -EBUSY;
+               else
+                       kvm->arch.bsp_vcpu_id = arg;
+               mutex_unlock(&kvm->lock);
+               break;
        case KVM_XEN_HVM_CONFIG: {
                r = -EFAULT;
                if (copy_from_user(&kvm->arch.xen_hvm_config, argp,
@@ -7291,6 +7301,17 @@ void kvm_arch_check_processor_compat(void *rtn)
        kvm_x86_ops->check_processor_compatibility(rtn);
 }
 
+bool kvm_vcpu_is_reset_bsp(struct kvm_vcpu *vcpu)
+{
+       return vcpu->kvm->arch.bsp_vcpu_id == vcpu->vcpu_id;
+}
+EXPORT_SYMBOL_GPL(kvm_vcpu_is_reset_bsp);
+
+bool kvm_vcpu_is_bsp(struct kvm_vcpu *vcpu)
+{
+       return (vcpu->arch.apic_base & MSR_IA32_APICBASE_BSP) != 0;
+}
+
 bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu)
 {
        return irqchip_in_kernel(vcpu->kvm) == (vcpu->arch.apic != NULL);
index 51103f0feb7e21e6c4d8a525c5939551046a42f3..bd1097a95704f9bd36eb9f9930093bfaaa7e6a8a 100644 (file)
@@ -364,9 +364,6 @@ struct kvm {
        struct kvm_memslots *memslots[KVM_ADDRESS_SPACE_NUM];
        struct srcu_struct srcu;
        struct srcu_struct irq_srcu;
-#ifdef CONFIG_KVM_APIC_ARCHITECTURE
-       u32 bsp_vcpu_id;
-#endif
        struct kvm_vcpu *vcpus[KVM_MAX_VCPUS];
        atomic_t online_vcpus;
        int last_boosted_vcpu;
@@ -1059,22 +1056,9 @@ static inline int kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
 #endif /* CONFIG_HAVE_KVM_EVENTFD */
 
 #ifdef CONFIG_KVM_APIC_ARCHITECTURE
-static inline bool kvm_vcpu_is_reset_bsp(struct kvm_vcpu *vcpu)
-{
-       return vcpu->kvm->bsp_vcpu_id == vcpu->vcpu_id;
-}
-
-static inline bool kvm_vcpu_is_bsp(struct kvm_vcpu *vcpu)
-{
-       return (vcpu->arch.apic_base & MSR_IA32_APICBASE_BSP) != 0;
-}
-
 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)
index 8b8a4445367011b31afdb06f5363a120ea1db019..8dc4828f623f15259c95bf9c745c37566358fe58 100644 (file)
@@ -2618,9 +2618,6 @@ static long kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg)
        case KVM_CAP_USER_MEMORY:
        case KVM_CAP_DESTROY_MEMORY_REGION_WORKS:
        case KVM_CAP_JOIN_MEMORY_REGIONS_WORKS:
-#ifdef CONFIG_KVM_APIC_ARCHITECTURE
-       case KVM_CAP_SET_BOOT_CPU_ID:
-#endif
        case KVM_CAP_INTERNAL_ERROR_DATA:
 #ifdef CONFIG_HAVE_KVM_MSI
        case KVM_CAP_SIGNAL_MSI:
@@ -2716,17 +2713,6 @@ static long kvm_vm_ioctl(struct file *filp,
                r = kvm_ioeventfd(kvm, &data);
                break;
        }
-#ifdef CONFIG_KVM_APIC_ARCHITECTURE
-       case KVM_SET_BOOT_CPU_ID:
-               r = 0;
-               mutex_lock(&kvm->lock);
-               if (atomic_read(&kvm->online_vcpus) != 0)
-                       r = -EBUSY;
-               else
-                       kvm->bsp_vcpu_id = arg;
-               mutex_unlock(&kvm->lock);
-               break;
-#endif
 #ifdef CONFIG_HAVE_KVM_MSI
        case KVM_SIGNAL_MSI: {
                struct kvm_msi msi;