aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm/kvm_main.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-07-24 15:01:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-24 15:01:20 -0400
commit5fecc9d8f59e765c2a48379dd7c6f5cf88c7d75a (patch)
treed1fc25d9650d3ac24591bba6f5e2e7a1afc54796 /virt/kvm/kvm_main.c
parent3c4cfadef6a1665d9cd02a543782d03d3e6740c6 (diff)
parent1a577b72475d161b6677c05abe57301362023bb2 (diff)
Merge tag 'kvm-3.6-1' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull KVM updates from Avi Kivity: "Highlights include - full big real mode emulation on pre-Westmere Intel hosts (can be disabled with emulate_invalid_guest_state=0) - relatively small ppc and s390 updates - PCID/INVPCID support in guests - EOI avoidance; 3.6 guests should perform better on 3.6 hosts on interrupt intensive workloads) - Lockless write faults during live migration - EPT accessed/dirty bits support for new Intel processors" Fix up conflicts in: - Documentation/virtual/kvm/api.txt: Stupid subchapter numbering, added next to each other. - arch/powerpc/kvm/booke_interrupts.S: PPC asm changes clashing with the KVM fixes - arch/s390/include/asm/sigp.h, arch/s390/kvm/sigp.c: Duplicated commits through the kvm tree and the s390 tree, with subsequent edits in the KVM tree. * tag 'kvm-3.6-1' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (93 commits) KVM: fix race with level interrupts x86, hyper: fix build with !CONFIG_KVM_GUEST Revert "apic: fix kvm build on UP without IOAPIC" KVM guest: switch to apic_set_eoi_write, apic_write apic: add apic_set_eoi_write for PV use KVM: VMX: Implement PCID/INVPCID for guests with EPT KVM: Add x86_hyper_kvm to complete detect_hypervisor_platform check KVM: PPC: Critical interrupt emulation support KVM: PPC: e500mc: Fix tlbilx emulation for 64-bit guests KVM: PPC64: booke: Set interrupt computation mode for 64-bit host KVM: PPC: bookehv: Add ESR flag to Data Storage Interrupt KVM: PPC: bookehv64: Add support for std/ld emulation. booke: Added crit/mc exception handler for e500v2 booke/bookehv: Add host crit-watchdog exception support KVM: MMU: document mmu-lock and fast page fault KVM: MMU: fix kvm_mmu_pagetable_walk tracepoint KVM: MMU: trace fast page fault KVM: MMU: fast path of handling guest page fault KVM: MMU: introduce SPTE_MMU_WRITEABLE bit KVM: MMU: fold tlb flush judgement into mmu_spte_update ...
Diffstat (limited to 'virt/kvm/kvm_main.c')
-rw-r--r--virt/kvm/kvm_main.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 44ee7124b16d..246852397e30 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -516,16 +516,32 @@ out_err_nodisable:
516 return ERR_PTR(r); 516 return ERR_PTR(r);
517} 517}
518 518
519/*
520 * Avoid using vmalloc for a small buffer.
521 * Should not be used when the size is statically known.
522 */
523void *kvm_kvzalloc(unsigned long size)
524{
525 if (size > PAGE_SIZE)
526 return vzalloc(size);
527 else
528 return kzalloc(size, GFP_KERNEL);
529}
530
531void kvm_kvfree(const void *addr)
532{
533 if (is_vmalloc_addr(addr))
534 vfree(addr);
535 else
536 kfree(addr);
537}
538
519static void kvm_destroy_dirty_bitmap(struct kvm_memory_slot *memslot) 539static void kvm_destroy_dirty_bitmap(struct kvm_memory_slot *memslot)
520{ 540{
521 if (!memslot->dirty_bitmap) 541 if (!memslot->dirty_bitmap)
522 return; 542 return;
523 543
524 if (2 * kvm_dirty_bitmap_bytes(memslot) > PAGE_SIZE) 544 kvm_kvfree(memslot->dirty_bitmap);
525 vfree(memslot->dirty_bitmap);
526 else
527 kfree(memslot->dirty_bitmap);
528
529 memslot->dirty_bitmap = NULL; 545 memslot->dirty_bitmap = NULL;
530} 546}
531 547
@@ -617,11 +633,7 @@ static int kvm_create_dirty_bitmap(struct kvm_memory_slot *memslot)
617#ifndef CONFIG_S390 633#ifndef CONFIG_S390
618 unsigned long dirty_bytes = 2 * kvm_dirty_bitmap_bytes(memslot); 634 unsigned long dirty_bytes = 2 * kvm_dirty_bitmap_bytes(memslot);
619 635
620 if (dirty_bytes > PAGE_SIZE) 636 memslot->dirty_bitmap = kvm_kvzalloc(dirty_bytes);
621 memslot->dirty_bitmap = vzalloc(dirty_bytes);
622 else
623 memslot->dirty_bitmap = kzalloc(dirty_bytes, GFP_KERNEL);
624
625 if (!memslot->dirty_bitmap) 637 if (!memslot->dirty_bitmap)
626 return -ENOMEM; 638 return -ENOMEM;
627 639
@@ -1586,7 +1598,7 @@ void kvm_vcpu_on_spin(struct kvm_vcpu *me)
1586 */ 1598 */
1587 for (pass = 0; pass < 2 && !yielded; pass++) { 1599 for (pass = 0; pass < 2 && !yielded; pass++) {
1588 kvm_for_each_vcpu(i, vcpu, kvm) { 1600 kvm_for_each_vcpu(i, vcpu, kvm) {
1589 if (!pass && i < last_boosted_vcpu) { 1601 if (!pass && i <= last_boosted_vcpu) {
1590 i = last_boosted_vcpu; 1602 i = last_boosted_vcpu;
1591 continue; 1603 continue;
1592 } else if (pass && i > last_boosted_vcpu) 1604 } else if (pass && i > last_boosted_vcpu)
@@ -2213,7 +2225,7 @@ static long kvm_dev_ioctl_check_extension_generic(long arg)
2213 case KVM_CAP_SIGNAL_MSI: 2225 case KVM_CAP_SIGNAL_MSI:
2214#endif 2226#endif
2215 return 1; 2227 return 1;
2216#ifdef CONFIG_HAVE_KVM_IRQCHIP 2228#ifdef KVM_CAP_IRQ_ROUTING
2217 case KVM_CAP_IRQ_ROUTING: 2229 case KVM_CAP_IRQ_ROUTING:
2218 return KVM_MAX_IRQ_ROUTES; 2230 return KVM_MAX_IRQ_ROUTES;
2219#endif 2231#endif