diff options
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r-- | arch/x86/kvm/i8254.c | 3 | ||||
-rw-r--r-- | arch/x86/kvm/lapic.c | 11 | ||||
-rw-r--r-- | arch/x86/kvm/mmu.c | 6 | ||||
-rw-r--r-- | arch/x86/kvm/paging_tmpl.h | 4 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 13 |
5 files changed, 21 insertions, 16 deletions
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c index 296aba49472a..15578f180e59 100644 --- a/arch/x86/kvm/i8254.c +++ b/arch/x86/kvm/i8254.c | |||
@@ -467,6 +467,9 @@ static int pit_ioport_read(struct kvm_io_device *this, | |||
467 | return -EOPNOTSUPP; | 467 | return -EOPNOTSUPP; |
468 | 468 | ||
469 | addr &= KVM_PIT_CHANNEL_MASK; | 469 | addr &= KVM_PIT_CHANNEL_MASK; |
470 | if (addr == 3) | ||
471 | return 0; | ||
472 | |||
470 | s = &pit_state->channels[addr]; | 473 | s = &pit_state->channels[addr]; |
471 | 474 | ||
472 | mutex_lock(&pit_state->lock); | 475 | mutex_lock(&pit_state->lock); |
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 3063a0c4858b..ba8c045da782 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c | |||
@@ -373,6 +373,12 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode, | |||
373 | if (unlikely(!apic_enabled(apic))) | 373 | if (unlikely(!apic_enabled(apic))) |
374 | break; | 374 | break; |
375 | 375 | ||
376 | if (trig_mode) { | ||
377 | apic_debug("level trig mode for vector %d", vector); | ||
378 | apic_set_vector(vector, apic->regs + APIC_TMR); | ||
379 | } else | ||
380 | apic_clear_vector(vector, apic->regs + APIC_TMR); | ||
381 | |||
376 | result = !apic_test_and_set_irr(vector, apic); | 382 | result = !apic_test_and_set_irr(vector, apic); |
377 | trace_kvm_apic_accept_irq(vcpu->vcpu_id, delivery_mode, | 383 | trace_kvm_apic_accept_irq(vcpu->vcpu_id, delivery_mode, |
378 | trig_mode, vector, !result); | 384 | trig_mode, vector, !result); |
@@ -383,11 +389,6 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode, | |||
383 | break; | 389 | break; |
384 | } | 390 | } |
385 | 391 | ||
386 | if (trig_mode) { | ||
387 | apic_debug("level trig mode for vector %d", vector); | ||
388 | apic_set_vector(vector, apic->regs + APIC_TMR); | ||
389 | } else | ||
390 | apic_clear_vector(vector, apic->regs + APIC_TMR); | ||
391 | kvm_vcpu_kick(vcpu); | 392 | kvm_vcpu_kick(vcpu); |
392 | break; | 393 | break; |
393 | 394 | ||
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 4c3e5b2314cb..89a49fb46a27 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c | |||
@@ -477,7 +477,7 @@ static int host_mapping_level(struct kvm *kvm, gfn_t gfn) | |||
477 | 477 | ||
478 | addr = gfn_to_hva(kvm, gfn); | 478 | addr = gfn_to_hva(kvm, gfn); |
479 | if (kvm_is_error_hva(addr)) | 479 | if (kvm_is_error_hva(addr)) |
480 | return page_size; | 480 | return PT_PAGE_TABLE_LEVEL; |
481 | 481 | ||
482 | down_read(¤t->mm->mmap_sem); | 482 | down_read(¤t->mm->mmap_sem); |
483 | vma = find_vma(current->mm, addr); | 483 | vma = find_vma(current->mm, addr); |
@@ -515,11 +515,9 @@ static int mapping_level(struct kvm_vcpu *vcpu, gfn_t large_gfn) | |||
515 | if (host_level == PT_PAGE_TABLE_LEVEL) | 515 | if (host_level == PT_PAGE_TABLE_LEVEL) |
516 | return host_level; | 516 | return host_level; |
517 | 517 | ||
518 | for (level = PT_DIRECTORY_LEVEL; level <= host_level; ++level) { | 518 | for (level = PT_DIRECTORY_LEVEL; level <= host_level; ++level) |
519 | |||
520 | if (has_wrprotected_page(vcpu->kvm, large_gfn, level)) | 519 | if (has_wrprotected_page(vcpu->kvm, large_gfn, level)) |
521 | break; | 520 | break; |
522 | } | ||
523 | 521 | ||
524 | return level - 1; | 522 | return level - 1; |
525 | } | 523 | } |
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index 58a0f1e88596..ede2131a9225 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h | |||
@@ -150,7 +150,9 @@ walk: | |||
150 | walker->table_gfn[walker->level - 1] = table_gfn; | 150 | walker->table_gfn[walker->level - 1] = table_gfn; |
151 | walker->pte_gpa[walker->level - 1] = pte_gpa; | 151 | walker->pte_gpa[walker->level - 1] = pte_gpa; |
152 | 152 | ||
153 | kvm_read_guest(vcpu->kvm, pte_gpa, &pte, sizeof(pte)); | 153 | if (kvm_read_guest(vcpu->kvm, pte_gpa, &pte, sizeof(pte))) |
154 | goto not_present; | ||
155 | |||
154 | trace_kvm_mmu_paging_element(pte, walker->level); | 156 | trace_kvm_mmu_paging_element(pte, walker->level); |
155 | 157 | ||
156 | if (!is_present_gpte(pte)) | 158 | if (!is_present_gpte(pte)) |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 6651dbf58675..a1e1bc9d412d 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -670,7 +670,7 @@ static void kvm_write_wall_clock(struct kvm *kvm, gpa_t wall_clock) | |||
670 | { | 670 | { |
671 | static int version; | 671 | static int version; |
672 | struct pvclock_wall_clock wc; | 672 | struct pvclock_wall_clock wc; |
673 | struct timespec now, sys, boot; | 673 | struct timespec boot; |
674 | 674 | ||
675 | if (!wall_clock) | 675 | if (!wall_clock) |
676 | return; | 676 | return; |
@@ -685,9 +685,7 @@ static void kvm_write_wall_clock(struct kvm *kvm, gpa_t wall_clock) | |||
685 | * wall clock specified here. guest system time equals host | 685 | * wall clock specified here. guest system time equals host |
686 | * system time for us, thus we must fill in host boot time here. | 686 | * system time for us, thus we must fill in host boot time here. |
687 | */ | 687 | */ |
688 | now = current_kernel_time(); | 688 | getboottime(&boot); |
689 | ktime_get_ts(&sys); | ||
690 | boot = ns_to_timespec(timespec_to_ns(&now) - timespec_to_ns(&sys)); | ||
691 | 689 | ||
692 | wc.sec = boot.tv_sec; | 690 | wc.sec = boot.tv_sec; |
693 | wc.nsec = boot.tv_nsec; | 691 | wc.nsec = boot.tv_nsec; |
@@ -762,6 +760,7 @@ static void kvm_write_guest_time(struct kvm_vcpu *v) | |||
762 | local_irq_save(flags); | 760 | local_irq_save(flags); |
763 | kvm_get_msr(v, MSR_IA32_TSC, &vcpu->hv_clock.tsc_timestamp); | 761 | kvm_get_msr(v, MSR_IA32_TSC, &vcpu->hv_clock.tsc_timestamp); |
764 | ktime_get_ts(&ts); | 762 | ktime_get_ts(&ts); |
763 | monotonic_to_bootbased(&ts); | ||
765 | local_irq_restore(flags); | 764 | local_irq_restore(flags); |
766 | 765 | ||
767 | /* With all the info we got, fill in the values */ | 766 | /* With all the info we got, fill in the values */ |
@@ -5072,12 +5071,13 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) | |||
5072 | GFP_KERNEL); | 5071 | GFP_KERNEL); |
5073 | if (!vcpu->arch.mce_banks) { | 5072 | if (!vcpu->arch.mce_banks) { |
5074 | r = -ENOMEM; | 5073 | r = -ENOMEM; |
5075 | goto fail_mmu_destroy; | 5074 | goto fail_free_lapic; |
5076 | } | 5075 | } |
5077 | vcpu->arch.mcg_cap = KVM_MAX_MCE_BANKS; | 5076 | vcpu->arch.mcg_cap = KVM_MAX_MCE_BANKS; |
5078 | 5077 | ||
5079 | return 0; | 5078 | return 0; |
5080 | 5079 | fail_free_lapic: | |
5080 | kvm_free_lapic(vcpu); | ||
5081 | fail_mmu_destroy: | 5081 | fail_mmu_destroy: |
5082 | kvm_mmu_destroy(vcpu); | 5082 | kvm_mmu_destroy(vcpu); |
5083 | fail_free_pio_data: | 5083 | fail_free_pio_data: |
@@ -5088,6 +5088,7 @@ fail: | |||
5088 | 5088 | ||
5089 | void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) | 5089 | void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) |
5090 | { | 5090 | { |
5091 | kfree(vcpu->arch.mce_banks); | ||
5091 | kvm_free_lapic(vcpu); | 5092 | kvm_free_lapic(vcpu); |
5092 | down_read(&vcpu->kvm->slots_lock); | 5093 | down_read(&vcpu->kvm->slots_lock); |
5093 | kvm_mmu_destroy(vcpu); | 5094 | kvm_mmu_destroy(vcpu); |