diff options
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r-- | arch/x86/kvm/x86.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 2288ad829b32..b989e1f1e5d3 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -155,11 +155,6 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { | |||
155 | 155 | ||
156 | u64 __read_mostly host_xcr0; | 156 | u64 __read_mostly host_xcr0; |
157 | 157 | ||
158 | static inline u32 bit(int bitno) | ||
159 | { | ||
160 | return 1 << (bitno & 31); | ||
161 | } | ||
162 | |||
163 | static void kvm_on_user_return(struct user_return_notifier *urn) | 158 | static void kvm_on_user_return(struct user_return_notifier *urn) |
164 | { | 159 | { |
165 | unsigned slot; | 160 | unsigned slot; |
@@ -2560,6 +2555,7 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu, | |||
2560 | !kvm_exception_is_soft(vcpu->arch.exception.nr); | 2555 | !kvm_exception_is_soft(vcpu->arch.exception.nr); |
2561 | events->exception.nr = vcpu->arch.exception.nr; | 2556 | events->exception.nr = vcpu->arch.exception.nr; |
2562 | events->exception.has_error_code = vcpu->arch.exception.has_error_code; | 2557 | events->exception.has_error_code = vcpu->arch.exception.has_error_code; |
2558 | events->exception.pad = 0; | ||
2563 | events->exception.error_code = vcpu->arch.exception.error_code; | 2559 | events->exception.error_code = vcpu->arch.exception.error_code; |
2564 | 2560 | ||
2565 | events->interrupt.injected = | 2561 | events->interrupt.injected = |
@@ -2573,12 +2569,14 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu, | |||
2573 | events->nmi.injected = vcpu->arch.nmi_injected; | 2569 | events->nmi.injected = vcpu->arch.nmi_injected; |
2574 | events->nmi.pending = vcpu->arch.nmi_pending; | 2570 | events->nmi.pending = vcpu->arch.nmi_pending; |
2575 | events->nmi.masked = kvm_x86_ops->get_nmi_mask(vcpu); | 2571 | events->nmi.masked = kvm_x86_ops->get_nmi_mask(vcpu); |
2572 | events->nmi.pad = 0; | ||
2576 | 2573 | ||
2577 | events->sipi_vector = vcpu->arch.sipi_vector; | 2574 | events->sipi_vector = vcpu->arch.sipi_vector; |
2578 | 2575 | ||
2579 | events->flags = (KVM_VCPUEVENT_VALID_NMI_PENDING | 2576 | events->flags = (KVM_VCPUEVENT_VALID_NMI_PENDING |
2580 | | KVM_VCPUEVENT_VALID_SIPI_VECTOR | 2577 | | KVM_VCPUEVENT_VALID_SIPI_VECTOR |
2581 | | KVM_VCPUEVENT_VALID_SHADOW); | 2578 | | KVM_VCPUEVENT_VALID_SHADOW); |
2579 | memset(&events->reserved, 0, sizeof(events->reserved)); | ||
2582 | } | 2580 | } |
2583 | 2581 | ||
2584 | static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu, | 2582 | static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu, |
@@ -2623,6 +2621,7 @@ static void kvm_vcpu_ioctl_x86_get_debugregs(struct kvm_vcpu *vcpu, | |||
2623 | dbgregs->dr6 = vcpu->arch.dr6; | 2621 | dbgregs->dr6 = vcpu->arch.dr6; |
2624 | dbgregs->dr7 = vcpu->arch.dr7; | 2622 | dbgregs->dr7 = vcpu->arch.dr7; |
2625 | dbgregs->flags = 0; | 2623 | dbgregs->flags = 0; |
2624 | memset(&dbgregs->reserved, 0, sizeof(dbgregs->reserved)); | ||
2626 | } | 2625 | } |
2627 | 2626 | ||
2628 | static int kvm_vcpu_ioctl_x86_set_debugregs(struct kvm_vcpu *vcpu, | 2627 | static int kvm_vcpu_ioctl_x86_set_debugregs(struct kvm_vcpu *vcpu, |
@@ -3106,6 +3105,7 @@ static int kvm_vm_ioctl_get_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps) | |||
3106 | sizeof(ps->channels)); | 3105 | sizeof(ps->channels)); |
3107 | ps->flags = kvm->arch.vpit->pit_state.flags; | 3106 | ps->flags = kvm->arch.vpit->pit_state.flags; |
3108 | mutex_unlock(&kvm->arch.vpit->pit_state.lock); | 3107 | mutex_unlock(&kvm->arch.vpit->pit_state.lock); |
3108 | memset(&ps->reserved, 0, sizeof(ps->reserved)); | ||
3109 | return r; | 3109 | return r; |
3110 | } | 3110 | } |
3111 | 3111 | ||
@@ -3169,10 +3169,6 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, | |||
3169 | struct kvm_memslots *slots, *old_slots; | 3169 | struct kvm_memslots *slots, *old_slots; |
3170 | unsigned long *dirty_bitmap; | 3170 | unsigned long *dirty_bitmap; |
3171 | 3171 | ||
3172 | spin_lock(&kvm->mmu_lock); | ||
3173 | kvm_mmu_slot_remove_write_access(kvm, log->slot); | ||
3174 | spin_unlock(&kvm->mmu_lock); | ||
3175 | |||
3176 | r = -ENOMEM; | 3172 | r = -ENOMEM; |
3177 | dirty_bitmap = vmalloc(n); | 3173 | dirty_bitmap = vmalloc(n); |
3178 | if (!dirty_bitmap) | 3174 | if (!dirty_bitmap) |
@@ -3194,6 +3190,10 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, | |||
3194 | dirty_bitmap = old_slots->memslots[log->slot].dirty_bitmap; | 3190 | dirty_bitmap = old_slots->memslots[log->slot].dirty_bitmap; |
3195 | kfree(old_slots); | 3191 | kfree(old_slots); |
3196 | 3192 | ||
3193 | spin_lock(&kvm->mmu_lock); | ||
3194 | kvm_mmu_slot_remove_write_access(kvm, log->slot); | ||
3195 | spin_unlock(&kvm->mmu_lock); | ||
3196 | |||
3197 | r = -EFAULT; | 3197 | r = -EFAULT; |
3198 | if (copy_to_user(log->dirty_bitmap, dirty_bitmap, n)) { | 3198 | if (copy_to_user(log->dirty_bitmap, dirty_bitmap, n)) { |
3199 | vfree(dirty_bitmap); | 3199 | vfree(dirty_bitmap); |
@@ -3486,6 +3486,7 @@ long kvm_arch_vm_ioctl(struct file *filp, | |||
3486 | user_ns.clock = kvm->arch.kvmclock_offset + now_ns; | 3486 | user_ns.clock = kvm->arch.kvmclock_offset + now_ns; |
3487 | local_irq_enable(); | 3487 | local_irq_enable(); |
3488 | user_ns.flags = 0; | 3488 | user_ns.flags = 0; |
3489 | memset(&user_ns.pad, 0, sizeof(user_ns.pad)); | ||
3489 | 3490 | ||
3490 | r = -EFAULT; | 3491 | r = -EFAULT; |
3491 | if (copy_to_user(argp, &user_ns, sizeof(user_ns))) | 3492 | if (copy_to_user(argp, &user_ns, sizeof(user_ns))) |
@@ -3972,8 +3973,10 @@ int kvm_emulate_wbinvd(struct kvm_vcpu *vcpu) | |||
3972 | return X86EMUL_CONTINUE; | 3973 | return X86EMUL_CONTINUE; |
3973 | 3974 | ||
3974 | if (kvm_x86_ops->has_wbinvd_exit()) { | 3975 | if (kvm_x86_ops->has_wbinvd_exit()) { |
3976 | preempt_disable(); | ||
3975 | smp_call_function_many(vcpu->arch.wbinvd_dirty_mask, | 3977 | smp_call_function_many(vcpu->arch.wbinvd_dirty_mask, |
3976 | wbinvd_ipi, NULL, 1); | 3978 | wbinvd_ipi, NULL, 1); |
3979 | preempt_enable(); | ||
3977 | cpumask_clear(vcpu->arch.wbinvd_dirty_mask); | 3980 | cpumask_clear(vcpu->arch.wbinvd_dirty_mask); |
3978 | } | 3981 | } |
3979 | wbinvd(); | 3982 | wbinvd(); |
@@ -4561,9 +4564,11 @@ static void kvm_timer_init(void) | |||
4561 | #ifdef CONFIG_CPU_FREQ | 4564 | #ifdef CONFIG_CPU_FREQ |
4562 | struct cpufreq_policy policy; | 4565 | struct cpufreq_policy policy; |
4563 | memset(&policy, 0, sizeof(policy)); | 4566 | memset(&policy, 0, sizeof(policy)); |
4564 | cpufreq_get_policy(&policy, get_cpu()); | 4567 | cpu = get_cpu(); |
4568 | cpufreq_get_policy(&policy, cpu); | ||
4565 | if (policy.cpuinfo.max_freq) | 4569 | if (policy.cpuinfo.max_freq) |
4566 | max_tsc_khz = policy.cpuinfo.max_freq; | 4570 | max_tsc_khz = policy.cpuinfo.max_freq; |
4571 | put_cpu(); | ||
4567 | #endif | 4572 | #endif |
4568 | cpufreq_register_notifier(&kvmclock_cpufreq_notifier_block, | 4573 | cpufreq_register_notifier(&kvmclock_cpufreq_notifier_block, |
4569 | CPUFREQ_TRANSITION_NOTIFIER); | 4574 | CPUFREQ_TRANSITION_NOTIFIER); |
@@ -5514,6 +5519,8 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, | |||
5514 | 5519 | ||
5515 | mmu_reset_needed |= kvm_read_cr4(vcpu) != sregs->cr4; | 5520 | mmu_reset_needed |= kvm_read_cr4(vcpu) != sregs->cr4; |
5516 | kvm_x86_ops->set_cr4(vcpu, sregs->cr4); | 5521 | kvm_x86_ops->set_cr4(vcpu, sregs->cr4); |
5522 | if (sregs->cr4 & X86_CR4_OSXSAVE) | ||
5523 | update_cpuid(vcpu); | ||
5517 | if (!is_long_mode(vcpu) && is_pae(vcpu)) { | 5524 | if (!is_long_mode(vcpu) && is_pae(vcpu)) { |
5518 | load_pdptrs(vcpu, vcpu->arch.walk_mmu, vcpu->arch.cr3); | 5525 | load_pdptrs(vcpu, vcpu->arch.walk_mmu, vcpu->arch.cr3); |
5519 | mmu_reset_needed = 1; | 5526 | mmu_reset_needed = 1; |