aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* KVM: correct error-handling codeJulia Lawall2009-09-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This code is not executed before file has been initialized to the result of calling eventfd_fget. This function returns an ERR_PTR value in an error case instead of NULL. Thus the test that file is not NULL is always true. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @match exists@ expression x, E; statement S1, S2; @@ x = eventfd_fget(...) ... when != x = E ( * if (x == NULL || ...) S1 else S2 | * if (x == NULL && ...) S1 else S2 ) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: fix compile warnings on s390Heiko Carstens2009-09-101-3/+5
| | | | | | | | | | | | CC arch/s390/kvm/../../../virt/kvm/kvm_main.o arch/s390/kvm/../../../virt/kvm/kvm_main.c: In function '__kvm_set_memory_region': arch/s390/kvm/../../../virt/kvm/kvm_main.c:485: warning: unused variable 'j' arch/s390/kvm/../../../virt/kvm/kvm_main.c:484: warning: unused variable 'lpages' arch/s390/kvm/../../../virt/kvm/kvm_main.c:483: warning: unused variable 'ugfn' Cc: Carsten Otte <cotte@de.ibm.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: VMX: Check cpl before emulating debug register accessAvi Kivity2009-09-103-0/+16
| | | | | | | | | | Debug registers may only be accessed from cpl 0. Unfortunately, vmx will code to emulate the instruction even though it was issued from guest userspace, possibly leading to an unexpected trap later. Cc: stable@kernel.org Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: fix misreporting of coalesced interrupts by kvm tracerGleb Natapov2009-09-101-1/+1
| | | | | Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86: drop duplicate kvm_flush_remote_tlb callsMarcelo Tosatti2009-09-101-2/+0
| | | | | | | kvm_mmu_slot_remove_write_access already calls it. Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: VMX: call vmx_load_host_state() only if msr is cachedGleb Natapov2009-09-101-2/+2
| | | | | | | No need to call it before each kvm_(set|get)_msr_common() Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: VMX: Conditionally reload debug register 6Avi Kivity2009-09-101-5/+9
| | | | | | | | | | | | Only reload debug register 6 if we're running with the guest's debug registers. Saves around 150 cycles from the guest lightweight exit path. dr6 contains a couple of bits that are updated on #DB, so intercept that unconditionally and update those bits then. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: Use thread debug register storage instead of kvm specific dataAvi Kivity2009-09-102-18/+7
| | | | | | | | | | Instead of saving the debug registers from the processor to a kvm data structure, rely in the debug registers stored in the thread structure. This allows us not to save dr6 and dr7. Reduces lightweight vmexit cost by 350 cycles, or 11 percent. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM guest: do not batch pte updates from interrupt contextMarcelo Tosatti2009-09-101-6/+1
| | | | | | | | | | | | | | | | | | Commit b8bcfe997e4 made paravirt pte updates synchronous in interrupt context. Unfortunately the KVM pv mmu code caches the lazy/nonlazy mode internally, so a pte update from interrupt context during a lazy mmu operation can be batched while it should be performed synchronously. https://bugzilla.redhat.com/show_bug.cgi?id=518022 Drop the internal mode variable and use paravirt_get_lazy_mode(), which returns the correct state. Cc: stable@kernel.org Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: Fix coalesced interrupt reporting in IOAPICGleb Natapov2009-09-101-0/+2
| | | | | | | | | This bug was introduced by b4a2f5e723e4f7df467. Cc: stable@kernel.org Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM guest: fix bogus wallclock physical address calculationGlauber Costa2009-09-101-2/+2
| | | | | | | | | | | | | | The use of __pa() to calculate the address of a C-visible symbol is wrong, and can lead to unpredictable results. See arch/x86/include/asm/page.h for details. It should be replaced with __pa_symbol(), that does the correct math here, by taking relocations into account. This ensures the correct wallclock data structure physical address is passed to the hypervisor. Cc: stable@kernel.org Signed-off-by: Glauber Costa <glommer@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: VMX: Fix cr8 exiting control clobbering by EPTGleb Natapov2009-09-101-6/+3
| | | | | | | | | | Don't call adjust_vmx_controls() two times for the same control. It restores options that were dropped earlier. This loses us the cr8 exit control, which causes a massive performance regression Windows x64. Cc: stable@kernel.org Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: Optimize kvm_mmu_unprotect_page_virt() for tdpAvi Kivity2009-09-101-0/+3
| | | | | | | We know no pages are protected, so we can short-circuit the whole thing (including fairly nasty guest memory accesses). Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: Document KVM_CAP_IRQCHIPAvi Kivity2009-09-101-0/+76
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: Protect update_cr8_intercept() when running without an apicAvi Kivity2009-09-101-0/+3
| | | | | | | update_cr8_intercept() can be triggered from userspace while there is no apic present. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: VMX: Fix EPT with WP bit change during pagingSheng Yang2009-09-101-3/+3
| | | | | | | | | QNX update WP bit when paging enabled, which is not covered yet. This one fix QNX boot with EPT. Cc: stable@kernel.org Signed-off-by: Sheng Yang <sheng@linux.intel.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: Use kvm_{read,write}_guest_virt() to read and write segment descriptorsMikhail Ershov2009-09-101-8/+2
| | | | | | | | Segment descriptors tables can be placed on two non-contiguous pages. This patch makes reading segment descriptors by linear address. Signed-off-by: Mikhail Ershov <Mike.Ershov@gmail.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Add adc and sbb missing decoder flagsMohammed Gamal2009-09-101-2/+2
| | | | | | | | Add missing decoder flags for adc and sbb instructions (opcodes 0x14-0x15, 0x1c-0x1d) Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: Add missing #includeAvi Kivity2009-09-101-0/+2
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: Add __KERNEL__ guards to exported headersAvi Kivity2009-09-102-0/+8
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: export kvm_para.hMichael S. Tsirkin2009-09-102-0/+9
| | | | | | | | kvm_para.h contains userspace interface and so should be exported. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* Documentation: Update KVM list email addressAmit Shah2009-09-101-1/+1
| | | | | | | The KVM list moved to vger.kernel.org last year Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: Rename x86_emulate.c to emulate.cAvi Kivity2009-09-105-5/+5
| | | | | | We're in arch/x86, what could we possibly be emulating? Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: When switching to a vm8086 task, load segments as 16-bitAnthony Liguori2009-09-101-1/+8
| | | | | | | | | | | | | | According to 16.2.5 in the SDM, eflags.vm in the tss is consulted before loading and new segments. If eflags.vm == 1, then the segments are treated as 16-bit segments. The LDTR and TR are not normally available in vm86 mode so if they happen to somehow get loaded, they need to be treated as 32-bit segments. This fixes an invalid vmentry failure in a custom OS that was happening after a task switch into vm8086 mode. Since the segments were being mistakenly treated as 32-bit, we loaded garbage state. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: VMX: Adjust rflags if in real mode emulationAvi Kivity2009-09-101-1/+6
| | | | | | | We set rflags.vm86 when virtualizing real mode to do through vm8086 mode; so we need to take it out again when reading rflags. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: Move #endif KVM_CAP_IRQ_ROUTING to correct placeAvi Kivity2009-09-101-1/+1
| | | | | | The symbol only controls irq routing, not MSI-X. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: Drop tlb flush workaround in nptAvi Kivity2009-09-101-11/+2
| | | | | | | It is no longer possible to reproduce the problem any more, so presumably it has been fixed. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: Update cr8 intercept when APIC TPR is changed by userspaceGleb Natapov2009-09-101-0/+2
| | | | | | | | | Since on vcpu entry we do it only if apic is enabled we should do it when TPR is changed while apic is disabled. This happens when windows resets HW without setting TPR to zero. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: enable nested svm by defaultJoerg Roedel2009-09-101-1/+1
| | | | | | | | Nested SVM is (in my experience) stable enough to be enabled by default. So omit the requirement to pass a module parameter. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: check for nested VINTR flag in svm_interrupt_allowedJoerg Roedel2009-09-101-1/+1
| | | | | | | | Not checking for this flag breaks any nested hypervisor that does not set VINTR. So fix it with this patch. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: move nested_svm_intr main logic out of if-clauseJoerg Roedel2009-09-101-10/+11
| | | | | | | | This patch removes one indentation level from nested_svm_intr and makes the logic more readable. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: remove unnecessary is_nested check from svm_cpu_runJoerg Roedel2009-09-101-2/+1
| | | | | | | | This check is not necessary. We have to sync the vcpu->arch.cr2 always back to the VMCB. This patch remove the is_nested check. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: move special nested exit handling to separate functionJoerg Roedel2009-09-101-30/+50
| | | | | | | | | This patch moves the handling for special nested vmexits like #pf to a separate function. This makes the kvm_override parameter obsolete and makes the code more readable. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: handle errors in vmrun emulation path appropriatlyJoerg Roedel2009-09-101-1/+13
| | | | | | | | | If nested svm fails to load the msrpm the vmrun succeeds with the old msrpm which is not correct. This patch changes the logic to roll back to host mode in case the msrpm cannot be loaded. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: remove nested_svm_do and helper functionsJoerg Roedel2009-09-101-60/+0
| | | | | | | This function is not longer required. So remove it. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: clean up nested vmrun pathJoerg Roedel2009-09-101-12/+22
| | | | | | | | This patch removes the usage of nested_svm_do from the vmrun emulation path. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: clean up nestec vmload/vmsave pathsJoerg Roedel2009-09-101-19/+17
| | | | | | | | This patch removes the usage of nested_svm_do from the vmload and vmsave emulation code paths. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: clean up nested_svm_exit_handled_msrJoerg Roedel2009-09-101-17/+21
| | | | | | | | | | | This patch changes nested svm to call nested_svm_exit_handled_msr directly and not through nested_svm_do. [alex: fix oops due to nested kmap_atomics] Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: get rid of nested_svm_vmexit_realJoerg Roedel2009-09-101-12/+40
| | | | | | | | | | | | | This patch is the starting point of removing nested_svm_do from the nested svm code. The nested_svm_do function basically maps two guest physical pages to host virtual addresses and calls a passed function on it. This function pointer code flow is hard to read and not the best technical solution here. As a side effect this patch indroduces the nested_svm_[un]map helper functions. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: simplify nested_svm_check_exceptionJoerg Roedel2009-09-101-11/+8
| | | | | | | | Makes the code of this function more readable by removing on indentation level for the core logic. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: do nested vmexit in nested_svm_exit_handledJoerg Roedel2009-09-101-23/+19
| | | | | | | | | | If this function returns true a nested vmexit is required. Move that vmexit into the nested_svm_exit_handled function. This also simplifies the handling of nested #pf intercepts in this function. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Acked-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: consolidate nested_svm_exit_handledJoerg Roedel2009-09-101-60/+49
| | | | | | | | | | When caching guest intercepts there is no need anymore for the nested_svm_exit_handled_real function. So move its code into nested_svm_exit_handled. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Acked-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: cache nested interceptsJoerg Roedel2009-09-101-7/+23
| | | | | | | | | | | When the nested intercepts are cached we don't need to call get_user_pages and/or map the nested vmcb on every nested #vmexit to check who will handle the intercept. Further this patch aligns the emulated svm behavior better to real hardware. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: move nested svm state into seperate structJoerg Roedel2009-09-101-29/+33
| | | | | | | | | This makes it more clear for which purpose these members in the vcpu_svm exist. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Acked-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: complete interrupts after handling nested exitsJoerg Roedel2009-09-101-2/+3
| | | | | | | | | | The interrupt completion code must run after nested exits are handled because not injected interrupts or exceptions may be handled by the l1 guest first. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Acked-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: copy only necessary parts of the control area on vmrun/vmexitJoerg Roedel2009-09-101-2/+34
| | | | | | | | | | The vmcb control area contains more then 800 bytes of reserved fields which are unnecessarily copied. Fix this by introducing a copy function which only copies the relevant part and saves time. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Acked-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: optimize nested vmrunJoerg Roedel2009-09-101-7/+21
| | | | | | | | | Only copy the necessary parts of the vmcb save area on vmrun and save precious time. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Acked-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: optimize nested #vmexitJoerg Roedel2009-09-101-35/+33
| | | | | | | | | It is more efficient to copy only the relevant parts of the vmcb back to the nested vmcb when we emulate an vmexit. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Acked-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: add helper functions for global interrupt flagJoerg Roedel2009-09-101-8/+25
| | | | | | | | | This patch makes the code easier to read when it comes to setting, clearing and checking the status of the virtualized global interrupt flag for the VCPU. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* x86: Export kmap_atomic_to_page()Avi Kivity2009-09-101-0/+1
| | | | | | Needed by KVM. Signed-off-by: Avi Kivity <avi@redhat.com>