summaryrefslogtreecommitdiffstats
path: root/drivers/kvm/kvm_main.c
Commit message (Collapse)AuthorAgeFilesLines
* KVM: Move drivers/kvm/* to virt/kvm/Avi Kivity2008-01-301-1393/+0Star
| | | | Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Move arch dependent files to new directory arch/x86/kvm/Avi Kivity2008-01-301-1/+1
| | | | | | | This paves the way for multiple architecture support. Note that while ioapic.c could potentially be shared with ia64, it is also moved. Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Introduce kvm_vcpu_archZhang Xiantao2008-01-301-1/+1
| | | | | | | | | Move all the architecture-specific fields in kvm_vcpu into a new struct kvm_vcpu_arch. Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Acked-by: Carsten Otte <cotte@de.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Convert KVM from ->nopage() to ->fault()npiggin@suse.de2008-01-301-27/+15Star
| | | | | | | | Signed-off-by: Nick Piggin <npiggin@suse.de> Cc: kvm-devel@lists.sourceforge.net Cc: avi@qumranet.com Cc: linux-kernel@vger.kernel.org Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Create kvm_arch_vcpu_runnable() functionHollis Blanchard2008-01-301-2/+1Star
| | | | | | | | This abstracts the detail of x86 hlt and INIT modes into a function. Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> Acked-by: Carsten Otte <cotte@de.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Stop including x86-specific headers in kvm_main.cHollis Blanchard2008-01-301-3/+0Star
| | | | | Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Move IO device definitions to its own header fileHollis Blanchard2008-01-301-0/+1
| | | | | | Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> Acked-by: Carsten Otte <cotte@de.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Correct kvm_init() error paths not freeing bad_pge.Zhang Xiantao2008-01-301-13/+15
| | | | | Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Move KVM_INTERRUPT vcpu ioctl to x86.cZhang Xiantao2008-01-301-29/+0Star
| | | | | | | Other archs doesn't need it. Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Move unalias_gfn to arch dependent fileZhang Xiantao2008-01-301-14/+0Star
| | | | | | | | | Non-x86 archs don't need this mechanism. Move it to arch, and keep its interface in common. Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Acked-by: Carsten Otte <cotte@de.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Disallow fork() and similar games when using a VMAvi Kivity2008-01-301-0/+9
| | | | | | We don't want the meaning of guest userspace changing under our feet. Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Add statistic for remote tlb flushesAvi Kivity2008-01-301-0/+3
| | | | Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Split vcpu creation to avoid vcpu_load() before preemption setupAvi Kivity2008-01-301-0/+4
| | | | | | | | Split kvm_arch_vcpu_create() into kvm_arch_vcpu_create() and kvm_arch_vcpu_setup(), enabling preemption notification between the two. This mean that we can now do vcpu_load() within kvm_arch_vcpu_setup(). Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Split kvm_set_memory_region() to have an arch calloutZhang Xiantao2008-01-301-33/+5Star
| | | | | | | | Moving !user_alloc case to kvm_arch to avoid unnecessary code logic in non-x86 platform. Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Recalculate mmu pages needed for every memory region changeZhang Xiantao2008-01-301-17/+4Star
| | | | | | | | Instead of incrementally changing the mmu cache size for every memory slot operation, recalculate it from scratch. This is simpler and safer. Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: MMU: Selectively set PageDirty when releasing guest memoryIzik Eidus2008-01-301-3/+9
| | | | | | | | | Improve dirty bit setting for pages that kvm release, until now every page that we released we marked dirty, from now only pages that have potential to get dirty we mark dirty. Signed-off-by: Izik Eidus <izike@qumranet.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Correct consistent typo: "destory" -> "destroy"Hollis Blanchard2008-01-301-1/+1
| | | | | Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Simplify kvm_clear_guest_page()Izik Eidus2008-01-301-16/+2Star
| | | | | | | | Use kvm_write_guest_page() with empty_zero_page, instead of doing kmap and memset. Signed-off-by: Izik Eidus <izike@qumranet.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: MMU initialization and teardown splitZhang Xiantao2008-01-301-8/+0Star
| | | | | | | Move out kvm_mmu init and exit functionality from kvm_main.c Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Move kvm_vcpu_ioctl_get_dirty_log to arch-specific fileZhang Xiantao2008-01-301-15/+4Star
| | | | | | | | Meanwhile keep the interface in common, and leave as more logic in common as possible. Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Extend stats support for VM statsAvi Kivity2008-01-301-3/+23
| | | | | | This is in addition to the current virtual cpu statistics. Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Add two hooks to handle kvm_create and destroy vmZhang Xiantao2008-01-301-36/+6Star
| | | | | | | | Add two arch hooks to handle kvm_create_vm and kvm destroy_vm. Now, just put io_bus init and destory in common. Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Remove __init attributes for kvm_init_debug and kvm_init_msr_listZhang Xiantao2008-01-301-1/+1
| | | | | | | Since their callers are not declared with __init. Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Remove ptr comparisons to 0Joe Perches2008-01-301-1/+2
| | | | | | | Fix sparse warnings "Using plain integer as NULL pointer" Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Make kvm_vcpu_ioctl_translate arch dependentZhang Xiantao2008-01-301-23/+1Star
| | | | | | | Move kvm_vcpu_ioctl_translate to arch, since mmu would be put under arch. Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: move KVM_CHECK_EXTENSIONZhang Xiantao2008-01-301-16/+2Star
| | | | | | | | | Make KVM_CHECK_EXTENSION code into a function, all archs can define its capability independently. Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Acked-by: Carsten Otte <cotte@de.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Move x86 specific code from kvm_init() to kvm_arch()Zhang Xiantao2008-01-301-20/+6Star
| | | | | | Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Acked-by: Carsten Otte <cotte@de.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Combine kvm_init and kvm_init_x86Zhang Xiantao2008-01-301-39/+22Star
| | | | | | | | Will be called once arch module registers itself. Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Acked-by: Carsten Otte <cotte@de.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Add vcpu and hardware management arch hooksZhang Xiantao2008-01-301-95/+18Star
| | | | | | | | | | | | | | | | | | | | | | Add the following hooks: void decache_vcpus_on_cpu(int cpu); int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu); void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu); void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu); void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu); void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu); struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id); void kvm_arch_vcpu_destory(struct kvm_vcpu *vcpu); int kvm_arch_vcpu_reset(struct kvm_vcpu *vcpu); void kvm_arch_hardware_enable(void *garbage); void kvm_arch_hardware_disable(void *garbage); int kvm_arch_hardware_setup(void); void kvm_arch_hardware_unsetup(void); void kvm_arch_check_processor_compat(void *rtn); Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Move kvm_x86_ops to x86.cZhang Xiantao2008-01-301-1/+0Star
| | | | | | Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Acked-by: Carsten Otte <cotte@de.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Move some includes to x86.cZhang Xiantao2008-01-301-2/+0Star
| | | | | | | | | Move some includes to x86.c from kvm_main.c, since the related functions have been moved to x86.c Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Acked-by: Carsten Otte <cotte@de.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Change kvm_{read,write}_guest() to use copy_{from,to}_user()Izik Eidus2008-01-301-24/+14Star
| | | | | | | | | This changes kvm_write_guest_page/kvm_read_guest_page to use copy_to_user/read_from_user, as a result we get better speed and better dirty bit tracking. Signed-off-by: Izik Eidus <izike@qumranet.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: introduce gfn_to_hva()Izik Eidus2008-01-301-8/+17
| | | | | | | Convert a guest frame number to the corresponding host virtual address. Signed-off-by: Izik Eidus <izike@qumranet.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: add kvm_is_error_hva()Izik Eidus2008-01-301-0/+11
| | | | | | | | Check for the "error hva", an address outside the user address space that signals a bad gfn. Signed-off-by: Izik Eidus <izike@qumranet.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Simplify CPU_TASKS_FROZEN cpu notifier handlingAvi Kivity2008-01-301-3/+1Star
| | | | Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Add make_page_dirty() to kvm_clear_guest_page()Dor Laor2008-01-301-0/+1
| | | | | | | | Every write access to guest pages should be tracked. Signed-off-by: Dor Laor <dor.laor@qumranet.com> Signed-off-by: Izik Eidus <izike@qumranet.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Move x86 vcpu ioctl handlers to x86.cHollis Blanchard2008-01-301-436/+6Star
| | | | | Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Move x86 FPU handling to x86.cHollis Blanchard2008-01-301-105/+2Star
| | | | | Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Move x86 instruction emulation code to x86.cHollis Blanchard2008-01-301-176/+1Star
| | | | | Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Make exported debugfs data architecture-specificHollis Blanchard2008-01-301-25/+0Star
| | | | | Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Make mark_page_dirty() work for aliased pages too.Uri Lublin2008-01-301-1/+1
| | | | | | | Recommended by Izik Eidus. Signed-off-by: Uri Lublin <uril@qumranet.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Move pio emulation functions to x86.cCarsten Otte2008-01-301-248/+0Star
| | | | | | | | | | | | | | This patch moves implementation of the following functions from kvm_main.c to x86.c: free_pio_guest_pages, vcpu_find_pio_dev, pio_copy_data, complete_pio, kernel_pio, pio_string_write, kvm_emulate_pio, kvm_emulate_pio_string The function inject_gp, which was duplicated by yesterday's patch series, is removed from kvm_main.c now because it is not needed anymore. Signed-off-by: Carsten Otte <cotte@de.ibm.com> Acked-by: Hollis Blanchard <hollisb@us.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Move x86 emulation and mmio device hook to x86.cCarsten Otte2008-01-301-357/+0Star
| | | | | | | | | | | | | | | | This patch moves the following functions to from kvm_main.c to x86.c: emulator_read/write_std, vcpu_find_pervcpu_dev, vcpu_find_mmio_dev, emulator_read/write_emulated, emulator_write_phys, emulator_write_emulated_onepage, emulator_cmpxchg_emulated, get_setment_base, emulate_invlpg, emulate_clts, emulator_get/set_dr, kvm_report_emulation_failure, emulate_instruction The following data type is moved to x86.c: struct x86_emulate_ops emulate_ops Signed-off-by: Carsten Otte <cotte@de.ibm.com> Acked-by: Hollis Blanchard <hollisb@us.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Move kvm_get/set_msr[_common] to x86.cCarsten Otte2008-01-301-133/+0Star
| | | | | | | | | | This patch moves the implementation of the functions of kvm_get/set_msr, kvm_get/set_msr_common, and set_efer from kvm_main.c to x86.c. The definition of EFER_RESERVED_BITS is moved too. Signed-off-by: Carsten Otte <cotte@de.ibm.com> Acked-by: Hollis Blanchard <hollisb@us.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Fix gfn_to_page() acquiring mmap_sem twiceAnthony Liguori2008-01-301-4/+18
| | | | | | | | | | | | KVM's nopage handler calls gfn_to_page() which acquires the mmap_sem when calling out to get_user_pages(). nopage handlers are already invoked with the mmap_sem held though. Introduce a __gfn_to_page() for use by the nopage handler which requires the lock to already be held. This was noticed by tglx. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: VMX: Enable memory mapped TPR shadow (FlexPriority)Sheng Yang2008-01-301-17/+39
| | | | | | | | | | This patch based on CR8/TPR patch, and enable the TPR shadow (FlexPriority) for 32bit Windows. Since TPR is accessed very frequently by 32bit Windows, especially SMP guest, with FlexPriority enabled, we saw significant performance gain. Signed-off-by: Sheng Yang <sheng.yang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Move control register helper functions to x86.cCarsten Otte2008-01-301-219/+0Star
| | | | | | | | | | | | | | | | | | This patch moves the definitions of CR0_RESERVED_BITS, CR4_RESERVED_BITS, and CR8_RESERVED_BITS along with the following functions from kvm_main.c to x86.c: set_cr0(), set_cr3(), set_cr4(), set_cr8(), get_cr8(), lmsw(), load_pdptrs() The static function wrapper inject_gp is duplicated in kvm_main.c and x86.c for now, the version in kvm_main.c should disappear once the last user of it is gone too. The function load_pdptrs is no longer static, and now defined in x86.h for the time being, until the last user of it is gone from kvm_main.c. Signed-off-by: Carsten Otte <cotte@de.ibm.com> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> Acked-by: Hollis Blanchard <hollisb@us.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: move get/set_apic_base to x86.cCarsten Otte2008-01-301-19/+0Star
| | | | | | | | | | This patch moves the implementation of get_apic_base and set_apic_base from kvm_main.c to x86.c Signed-off-by: Carsten Otte <cotte@de.ibm.com> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> Acked-by: Hollis Blanchard <hollisb@us.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Move memory segmentation to x86.cCarsten Otte2008-01-301-42/+0Star
| | | | | | | | | | | | This patch moves the definition of segment_descriptor_64 for AMD64 and EM64T from kvm_main.c to segment_descriptor.h. It also adds a proper #ifndef...#define...#endif around that header file. The implementation of segment_base is moved from kvm_main.c to x86.c. Signed-off-by: Carsten Otte <cotte@de.ibm.com> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> Acked-by: Hollis Blanchard <hollisb@us.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
* KVM: Portability: Split kvm_vm_ioctl v3Carsten Otte2008-01-301-249/+6Star
| | | | | | | | | | | | | | | | | | | | This patch splits kvm_vm_ioctl into archtecture independent parts, and x86 specific parts which go to kvm_arch_vcpu_ioctl in x86.c. The patch is unchanged since last submission. Common ioctls for all architectures are: KVM_CREATE_VCPU, KVM_GET_DIRTY_LOG, KVM_SET_USER_MEMORY_REGION x86 specific ioctls are: KVM_SET_MEMORY_REGION, KVM_GET/SET_NR_MMU_PAGES, KVM_SET_MEMORY_ALIAS, KVM_CREATE_IRQCHIP, KVM_CREATE_IRQ_LINE, KVM_GET/SET_IRQCHIP KVM_SET_TSS_ADDR Signed-off-by: Carsten Otte <cotte@de.ibm.com> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> Acked-by: Hollis Blanchard <hollisb@us.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>