Commit d71ba788 authored by Paolo Bonzini's avatar Paolo Bonzini

KVM: move code related to KVM_SET_BOOT_CPU_ID to x86

This is another remnant of ia64 support.
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 554726d3
...@@ -667,6 +667,7 @@ struct kvm_arch { ...@@ -667,6 +667,7 @@ struct kvm_arch {
#endif #endif
bool boot_vcpu_runs_old_kvmclock; bool boot_vcpu_runs_old_kvmclock;
u32 bsp_vcpu_id;
u64 disabled_quirks; u64 disabled_quirks;
}; };
...@@ -1215,5 +1216,7 @@ int __x86_set_memory_region(struct kvm *kvm, ...@@ -1215,5 +1216,7 @@ int __x86_set_memory_region(struct kvm *kvm,
const struct kvm_userspace_memory_region *mem); const struct kvm_userspace_memory_region *mem);
int x86_set_memory_region(struct kvm *kvm, int x86_set_memory_region(struct kvm *kvm,
const struct kvm_userspace_memory_region *mem); 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 */ #endif /* _ASM_X86_KVM_HOST_H */
...@@ -2461,6 +2461,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) ...@@ -2461,6 +2461,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
case KVM_CAP_TSC_DEADLINE_TIMER: case KVM_CAP_TSC_DEADLINE_TIMER:
case KVM_CAP_ENABLE_CAP_VM: case KVM_CAP_ENABLE_CAP_VM:
case KVM_CAP_DISABLE_QUIRKS: case KVM_CAP_DISABLE_QUIRKS:
case KVM_CAP_SET_BOOT_CPU_ID:
#ifdef CONFIG_KVM_DEVICE_ASSIGNMENT #ifdef CONFIG_KVM_DEVICE_ASSIGNMENT
case KVM_CAP_ASSIGN_DEV_IRQ: case KVM_CAP_ASSIGN_DEV_IRQ:
case KVM_CAP_PCI_2_3: case KVM_CAP_PCI_2_3:
...@@ -3777,6 +3778,15 @@ long kvm_arch_vm_ioctl(struct file *filp, ...@@ -3777,6 +3778,15 @@ long kvm_arch_vm_ioctl(struct file *filp,
r = kvm_vm_ioctl_reinject(kvm, &control); r = kvm_vm_ioctl_reinject(kvm, &control);
break; 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: { case KVM_XEN_HVM_CONFIG: {
r = -EFAULT; r = -EFAULT;
if (copy_from_user(&kvm->arch.xen_hvm_config, argp, if (copy_from_user(&kvm->arch.xen_hvm_config, argp,
...@@ -7291,6 +7301,17 @@ void kvm_arch_check_processor_compat(void *rtn) ...@@ -7291,6 +7301,17 @@ void kvm_arch_check_processor_compat(void *rtn)
kvm_x86_ops->check_processor_compatibility(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) bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu)
{ {
return irqchip_in_kernel(vcpu->kvm) == (vcpu->arch.apic != NULL); return irqchip_in_kernel(vcpu->kvm) == (vcpu->arch.apic != NULL);
......
...@@ -364,9 +364,6 @@ struct kvm { ...@@ -364,9 +364,6 @@ struct kvm {
struct kvm_memslots *memslots[KVM_ADDRESS_SPACE_NUM]; struct kvm_memslots *memslots[KVM_ADDRESS_SPACE_NUM];
struct srcu_struct srcu; struct srcu_struct srcu;
struct srcu_struct irq_srcu; struct srcu_struct irq_srcu;
#ifdef CONFIG_KVM_APIC_ARCHITECTURE
u32 bsp_vcpu_id;
#endif
struct kvm_vcpu *vcpus[KVM_MAX_VCPUS]; struct kvm_vcpu *vcpus[KVM_MAX_VCPUS];
atomic_t online_vcpus; atomic_t online_vcpus;
int last_boosted_vcpu; int last_boosted_vcpu;
...@@ -1059,22 +1056,9 @@ static inline int kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) ...@@ -1059,22 +1056,9 @@ 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 #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); bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu);
#else #else
static inline bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu) { return true; } static inline bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu) { return true; }
#endif #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)
......
...@@ -2618,9 +2618,6 @@ static long kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg) ...@@ -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_USER_MEMORY:
case KVM_CAP_DESTROY_MEMORY_REGION_WORKS: case KVM_CAP_DESTROY_MEMORY_REGION_WORKS:
case KVM_CAP_JOIN_MEMORY_REGIONS_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: case KVM_CAP_INTERNAL_ERROR_DATA:
#ifdef CONFIG_HAVE_KVM_MSI #ifdef CONFIG_HAVE_KVM_MSI
case KVM_CAP_SIGNAL_MSI: case KVM_CAP_SIGNAL_MSI:
...@@ -2716,17 +2713,6 @@ static long kvm_vm_ioctl(struct file *filp, ...@@ -2716,17 +2713,6 @@ static long kvm_vm_ioctl(struct file *filp,
r = kvm_ioeventfd(kvm, &data); r = kvm_ioeventfd(kvm, &data);
break; 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 #ifdef CONFIG_HAVE_KVM_MSI
case KVM_SIGNAL_MSI: { case KVM_SIGNAL_MSI: {
struct kvm_msi msi; struct kvm_msi msi;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment