aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
Commit message (Collapse)AuthorAge
...
* | | KVM: Prevent internal slots from being COWedAvi Kivity2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | If a process with a memory slot is COWed, the page will change its address (despite having an elevated reference count). This breaks internal memory slots which have their physical addresses loaded into vmcs registers (see the APIC access memory slot). Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: Add mini-API for vcpu->requestsAvi Kivity2010-08-01
| | | | | | | | | | | | | | | | | | Makes it a little more readable and hackable. Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: Remove kernel-allocated memory regionsAvi Kivity2010-08-01
| | | | | | | | | | | | | | | | | | | | | Equivalent (and better) functionality is provided by user-allocated memory regions. Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: Remove memory alias supportAvi Kivity2010-08-01
| | | | | | | | | | | | | | | | | | | | | As advertised in feature-removal-schedule.txt. Equivalent support is provided by overlapping memory regions. Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: Consolidate load/save temporary buffer allocation and freeingAvi Kivity2010-08-01
| | | | | | | | | | | | | | | | | | | | | Instead of three temporary variables and three free calls, have one temporary variable (with four names) and one free call. Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: Fix xsave and xcr save/restore memory leakAvi Kivity2010-08-01
| | | | | | | | | | | | | | | | | | We allocate temporary kernel buffers for these structures, but never free them. Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: x86: XSAVE/XRSTOR live migration supportSheng Yang2010-08-01
| | | | | | | | | | | | | | | | | | | | | This patch enable save/restore of xsave state. Signed-off-by: Sheng Yang <sheng@linux.intel.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* | | KVM: Fix mov cr3 #GP at wrong instructionAvi Kivity2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Intel, we call skip_emulated_instruction() even if we injected a #GP, resulting in the #GP pointing at the wrong address. Fix by injecting the exception and skipping the instruction at the same place, so we can do just one or the other. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* | | KVM: Fix mov cr4 #GP at wrong instructionAvi Kivity2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Intel, we call skip_emulated_instruction() even if we injected a #GP, resulting in the #GP pointing at the wrong address. Fix by injecting the exception and skipping the instruction at the same place, so we can do just one or the other. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* | | KVM: Fix mov cr0 #GP at wrong instructionAvi Kivity2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Intel, we call skip_emulated_instruction() even if we injected a #GP, resulting in the #GP pointing at the wrong address. Fix by injecting the exception and skipping the instruction at the same place, so we can do just one or the other. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* | | KVM: VMX: Enable XSAVE/XRSTOR for guestDexuan Cui2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch enable guest to use XSAVE/XRSTOR instructions. We assume that host_xcr0 would use all possible bits that OS supported. And we loaded xcr0 in the same way we handled fpu - do it as late as we can. Signed-off-by: Dexuan Cui <dexuan.cui@intel.com> Signed-off-by: Sheng Yang <sheng@linux.intel.com> Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: x86: use linux/uaccess.h instead of asm/uaccess.hLai Jiangshan2010-08-01
| | | | | | | | | | | | | | | | | | | | | Should use linux/uaccess.h instead of asm/uaccess.h Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* | | KVM: x86: Propagate fpu_alloc errorsJan Kiszka2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | Memory allocation may fail. Propagate such errors. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Reviewed-by: Sheng Yang <sheng@linux.intel.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: Update Red Hat copyrightsAvi Kivity2010-08-01
| | | | | | | | | | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: x86: Use FPU APISheng Yang2010-08-01
| | | | | | | | | | | | | | | | | | | | | Convert KVM to use generic FPU API. Signed-off-by: Sheng Yang <sheng@linux.intel.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: x86: Use unlazy_fpu() for host FPUSheng Yang2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can avoid unnecessary fpu load when userspace process didn't use FPU frequently. Derived from Avi's idea. Signed-off-by: Sheng Yang <sheng@linux.intel.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: Consolidate arch specific vcpu ioctl lockingAvi Kivity2010-08-01
| | | | | | | | | | | | | | | | | | | | | Now that all arch specific ioctls have centralized locking, it is easy to move it to the central dispatcher. Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: x86: Lock arch specific vcpu ioctls centrallyAvi Kivity2010-08-01
| | | | | | | | | | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: move vcpu locking to dispatcher for generic vcpu ioctlsAvi Kivity2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | All vcpu ioctls need to be locked, so instead of locking each one specifically we lock at the generic dispatcher. This patch only updates generic ioctls and leaves arch specific ioctls alone. Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: x86: cleanup unused local variableXiao Guangrong2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | fix: arch/x86/kvm/x86.c: In function ‘handle_emulation_failure’: arch/x86/kvm/x86.c:3844: warning: unused variable ‘ctxt’ Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* | | KVM: VMX: Only reset MMU when necessarySheng Yang2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | Only modifying some bits of CR0/CR4 needs paging mode switch. Modify EFER.NXE bit would result in reserved bit updates. Signed-off-by: Sheng Yang <sheng@linux.intel.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* | | KVM: x86: Clean up duplicate assignmentSheng Yang2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mmu.free() already set root_hpa to INVALID_PAGE, no need to do it again in the destory_kvm_mmu(). kvm_x86_ops->set_cr4() and set_efer() already assign cr4/efer to vcpu->arch.cr4/efer, no need to do it again later. Signed-off-by: Sheng Yang <sheng@linux.intel.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* | | KVM: inject #UD if instruction emulation fails and exit to userspaceGleb Natapov2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Do not kill VM when instruction emulation fails. Inject #UD and report failure to userspace instead. Userspace may choose to reenter guest if vcpu is in userspace (cpl == 3) in which case guest OS will kill offending process and continue running. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* | | KVM: Get rid of KVM_REQ_KICKAvi Kivity2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | KVM_REQ_KICK poisons vcpu->requests by having a bit set during normal operation. This causes the fast path check for a clear vcpu->requests to fail all the time, triggering tons of atomic operations. Fix by replacing KVM_REQ_KICK with a vcpu->guest_mode atomic. Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: x86 emulator: do not inject exception directly into vcpuGleb Natapov2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | Return exception as a result of instruction emulation and handle injection in KVM code. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: x86 emulator: move interruptibility state tracking out of emulatorGleb Natapov2010-08-01
| | | | | | | | | | | | | | | | | | | | | Emulator shouldn't access vcpu directly. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: x86 emulator: handle shadowed registers outside emulatorGleb Natapov2010-08-01
| | | | | | | | | | | | | | | | | | | | | Emulator shouldn't access vcpu directly. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: x86 emulator: set RFLAGS outside x86 emulator codeGleb Natapov2010-08-01
| | | | | | | | | | | | | | | | | | | | | Removes the need for set_flags() callback. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: x86 emulator: advance RIP outside x86 emulator codeGleb Natapov2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | Return new RIP as part of instruction emulation result instead of updating KVM's RIP from x86 emulator code. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: handle emulation failure case firstGleb Natapov2010-08-01
| | | | | | | | | | | | | | | | | | | | | If emulation failed return immediately. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: do not inject #PF in (read|write)_emulated() callbacksGleb Natapov2010-08-01
| | | | | | | | | | | | | | | | | | | | | Return error to x86 emulator instead of injection exception behind its back. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: remove export of emulator_write_emulated()Gleb Natapov2010-08-01
| | | | | | | | | | | | | | | | | | | | | It is not called directly outside of the file it's defined in anymore. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: x86 emulator: x86_emulate_insn() return -1 only in case of emulation ↵Gleb Natapov2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | failure Currently emulator returns -1 when emulation failed or IO is needed. Caller tries to guess whether emulation failed by looking at other variables. Make it easier for caller to recognise error condition by always returning -1 in case of failure. For this new emulator internal return value X86EMUL_IO_NEEDED is introduced. It is used to distinguish between error condition (which returns X86EMUL_UNHANDLEABLE) and condition that requires IO exit to userspace to continue emulation. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: fill in run->mmio details in (read|write)_emulated functionGleb Natapov2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fill in run->mmio details in (read|write)_emulated function just like pio does. There is no point in filling only vcpu fields there just to copy them into vcpu->run a little bit later. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: x86 emulator: make (get|set)_dr() callback return error if it failsGleb Natapov2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | Make (get|set)_dr() callback return error if it fails instead of injecting exception behind emulator's back. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: x86 emulator: make set_cr() callback return error if it failsGleb Natapov2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | Make set_cr() callback return error if it fails instead of injecting #GP behind emulator's back. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: x86 emulator: add get_cached_segment_base() callback to x86_emulate_opsGleb Natapov2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | On VMX it is expensive to call get_cached_descriptor() just to get segment base since multiple vmcs_reads are done instead of only one. Introduce new call back get_cached_segment_base() for efficiency. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: x86 emulator: add (set|get)_msr callbacks to x86_emulate_opsGleb Natapov2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | Add (set|get)_msr callbacks to x86_emulate_ops instead of calling them directly. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: x86 emulator: add (set|get)_dr callbacks to x86_emulate_opsGleb Natapov2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | Add (set|get)_dr callbacks to x86_emulate_ops instead of calling them directly. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: VMX: Avoid writing HOST_CR0 every entryAvi Kivity2010-08-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cr0.ts may change between entries, so we copy cr0 to HOST_CR0 before each entry. That is slow, so instead, set HOST_CR0 to have TS set unconditionally (which is a safe value), and issue a clts() just before exiting vcpu context if the task indeed owns the fpu. Saves ~50 cycles/exit. Signed-off-by: Avi Kivity <avi@redhat.com>
* | | KVM: x86: avoid unnecessary bitmap allocation when memslot is cleanTakuya Yoshikawa2010-08-01
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Although we always allocate a new dirty bitmap in x86's get_dirty_log(), it is only used as a zero-source of copy_to_user() and freed right after that when memslot is clean. This patch uses clear_user() instead of doing this unnecessary zero-source allocation. Performance improvement: as we can expect easily, the time needed to allocate a bitmap is completely reduced. In my test, the improved ioctl was about 4 to 10 times faster than the original one for clean slots. Furthermore, reducing memory allocations and copies will produce good effects to caches too. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Avi Kivity <avi@redhat.com>
* | KVM: Use kmalloc() instead of vmalloc() for KVM_[GS]ET_MSRAvi Kivity2010-07-23
|/ | | | | | | We don't need more than a page, and vmalloc() is slower (much slower recently due to a regression). Signed-off-by: Avi Kivity <avi@redhat.com>
* Merge branch 'kvm-updates/2.6.35' of git://git.kernel.org/pub/scm/virt/kvm/kvmLinus Torvalds2010-05-21
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 'kvm-updates/2.6.35' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (269 commits) KVM: x86: Add missing locking to arch specific vcpu ioctls KVM: PPC: Add missing vcpu_load()/vcpu_put() in vcpu ioctls KVM: MMU: Segregate shadow pages with different cr0.wp KVM: x86: Check LMA bit before set_efer KVM: Don't allow lmsw to clear cr0.pe KVM: Add cpuid.txt file KVM: x86: Tell the guest we'll warn it about tsc stability x86, paravirt: don't compute pvclock adjustments if we trust the tsc x86: KVM guest: Try using new kvm clock msrs KVM: x86: export paravirtual cpuid flags in KVM_GET_SUPPORTED_CPUID KVM: x86: add new KVMCLOCK cpuid feature KVM: x86: change msr numbers for kvmclock x86, paravirt: Add a global synchronization point for pvclock x86, paravirt: Enable pvclock flags in vcpu_time_info structure KVM: x86: Inject #GP with the right rip on efer writes KVM: SVM: Don't allow nested guest to VMMCALL into host KVM: x86: Fix exception reinjection forced to true KVM: Fix wallclock version writing race KVM: MMU: Don't read pdptrs with mmu spinlock held in mmu_alloc_roots KVM: VMX: enable VMXON check with SMX enabled (Intel TXT) ...
| * KVM: x86: Add missing locking to arch specific vcpu ioctlsAvi Kivity2010-05-19
| | | | | | | | Signed-off-by: Avi Kivity <avi@redhat.com>
| * KVM: x86: Check LMA bit before set_eferSheng Yang2010-05-19
| | | | | | | | | | | | | | | | kvm_x86_ops->set_efer() would execute vcpu->arch.efer = efer, so the checking of LMA bit didn't work. Signed-off-by: Sheng Yang <sheng@linux.intel.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
| * KVM: Don't allow lmsw to clear cr0.peAvi Kivity2010-05-19
| | | | | | | | | | | | | | | | | | | | The current lmsw implementation allows the guest to clear cr0.pe, contrary to the manual, which breaks EMM386.EXE. Fix by ORing the old cr0.pe with lmsw's operand. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
| * KVM: x86: Tell the guest we'll warn it about tsc stabilityGlauber Costa2010-05-19
| | | | | | | | | | | | | | | | | | | | This patch puts up the flag that tells the guest that we'll warn it about the tsc being trustworthy or not. By now, we also say it is not. Signed-off-by: Glauber Costa <glommer@redhat.com> Acked-by: Zachary Amsden <zamsden@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
| * KVM: x86: export paravirtual cpuid flags in KVM_GET_SUPPORTED_CPUIDGlauber Costa2010-05-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Right now, we were using individual KVM_CAP entities to communicate userspace about which cpuids we support. This is suboptimal, since it generates a delay between the feature arriving in the host, and being available at the guest. A much better mechanism is to list para features in KVM_GET_SUPPORTED_CPUID. This makes userspace automatically aware of what we provide. And if we ever add a new cpuid bit in the future, we have to do that again, which create some complexity and delay in feature adoption. Signed-off-by: Glauber Costa <glommer@redhat.com> Acked-by: Zachary Amsden <zamsden@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
| * KVM: x86: change msr numbers for kvmclockGlauber Costa2010-05-19
| | | | | | | | | | | | | | | | | | | | Avi pointed out a while ago that those MSRs falls into the pentium PMU range. So the idea here is to add new ones, and after a while, deprecate the old ones. Signed-off-by: Glauber Costa <glommer@redhat.com> Acked-by: Zachary Amsden <zamsden@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
| * KVM: x86: Inject #GP with the right rip on efer writesRoedel, Joerg2010-05-19
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes a bug in the KVM efer-msr write path. If a guest writes to a reserved efer bit the set_efer function injects the #GP directly. The architecture dependent wrmsr function does not see this, assumes success and advances the rip. This results in a #GP in the guest with the wrong rip. This patch fixes this by reporting efer write errors back to the architectural wrmsr function. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>