aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
Commit message (Collapse)AuthorAgeFilesLines
...
* KVM: x86 emulator: emulate CLTS internallyAvi Kivity2011-05-222-8/+11
| | | | | | | | | Avoid using ctxt->vcpu; we can do everything with ->get_cr() and ->set_cr(). A side effect is that we no longer activate the fpu on emulated CLTS; but that should be very rare. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Replace calls to is_pae() and is_paging with ->get_cr()Avi Kivity2011-05-221-2/+2
| | | | | | Avoid use of ctxt->vcpu. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: drop use of is_long_mode()Avi Kivity2011-05-221-7/+12
| | | | | | | Requires ctxt->vcpu, which is to be abolished. Replace with open calls to get_msr(). Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: add and use new callbacks set_idt(), set_gdt()Avi Kivity2011-05-222-21/+19
| | | | | | Replacing direct calls to realmode_lgdt(), realmode_lidt(). Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: avoid using ctxt->vcpu in check_perm() callbacksAvi Kivity2011-05-221-2/+2
| | | | | | Unneeded for register access. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: drop vcpu argument from intercept callbackAvi Kivity2011-05-222-3/+3
| | | | | | Making the emulator caller agnostic. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: drop vcpu argument from cr/dr/cpl/msr callbacksAvi Kivity2011-05-222-52/+66
| | | | | | Making the emulator caller agnostic. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: drop vcpu argument from segment/gdt/idt callbacksAvi Kivity2011-05-222-74/+77
| | | | | | | | | Making the emulator caller agnostic. [Takuya Yoshikawa: fix typo leading to LDT failures] Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: drop vcpu argument from pio callbacksAvi Kivity2011-05-112-9/+15
| | | | | | Making the emulator caller agnostic. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: drop vcpu argument from memory read/write callbacksAvi Kivity2011-05-112-49/+59
| | | | | | Making the emulator caller agnostic. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: whitespace cleanupsAvi Kivity2011-05-111-42/+54
| | | | | | Clean up lines longer than 80 columns. No code changes. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: emulator: Use linearize() when fetching instructionsNelson Elhage2011-05-111-8/+18
| | | | | | | | | | Since segments need to be handled slightly differently when fetching instructions, we add a __linearize helper that accepts a new 'fetch' boolean. [avi: fix oops caused by wrong segmented_address initialization order] Signed-off-by: Nelson Elhage <nelhage@ksplice.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: X86: Update last_guest_tsc in vcpu_putJoerg Roedel2011-05-111-1/+1
| | | | | | | | | | | | The last_guest_tsc is used in vcpu_load to adjust the tsc_offset since tsc-scaling is merged. So the last_guest_tsc needs to be updated in vcpu_put instead of the the last_host_tsc. This is fixed with this patch. Reported-by: Jan Kiszka <jan.kiszka@web.de> Tested-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: Fix nested sel_cr0 intercept path with decode-assistsJoerg Roedel2011-05-111-0/+3
| | | | | | | | | | | | | This patch fixes a bug in the nested-svm path when decode-assists is available on the machine. After a selective-cr0 intercept is detected the rip is advanced unconditionally. This causes the l1-guest to continue running with an l2-rip. This bug was with the sel_cr0 unit-test on decode-assists capable hardware. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Handle wraparound in (cs_base + offset) when fetching insnsNelson Elhage2011-05-111-1/+4
| | | | | | | | | | Currently, setting a large (i.e. negative) base address for %cs does not work on a 64-bit host. The "JOS" teaching operating system, used by MIT and other universities, relies on such segments while bootstrapping its way to full virtual memory management. Signed-off-by: Nelson Elhage <nelhage@ksplice.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: remove useless function declaration kvm_inject_pit_timer_irqs()Duan Jiong2011-05-111-1/+0
| | | | | | | | | Just remove useless function define kvm_inject_pit_timer_irqs() from file arch/x86/kvm/i8254.h Signed-off-by:Duan Jiong<djduanjiong@gmail.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: remove useless function declarations from file arch/x86/kvm/irq.hDuan Jiong2011-05-111-2/+0
| | | | | | | | Just remove useless function define kvm_pic_clear_isr_ack() and pit_has_pending_timer() Signed-off-by: Duan Jiong<djduanjiong@gmail.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: fix push of wrong eip when doing softintSerge E. Hallyn2011-05-113-6/+13
| | | | | | | | | | When doing a soft int, we need to bump eip before pushing it to the stack. Otherwise we'll do the int a second time. [apw@canonical.com: merged eip update as per Jan's recommendation.] Signed-off-by: Serge E. Hallyn <serge.hallyn@ubuntu.com> Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Use em_push() instead of emulate_push()Takuya Yoshikawa2011-05-111-25/+17
| | | | | | | | | | | em_push() is a simple wrapper of emulate_push(). So this patch replaces emulate_push() with em_push() and removes the unnecessary former. In addition, the unused ops arguments are removed from emulate_pusha() and emulate_grp45(). Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Make emulate_push() store the value directlyTakuya Yoshikawa2011-05-111-53/+34
| | | | | | | | | | | | | | PUSH emulation stores the value by calling writeback() after setting the dst operand appropriately in emulate_push(). This writeback() using dst is not needed at all because we know the target is the stack. So this patch makes emulate_push() call, newly introduced, segmented_write() directly. By this, many inlined writeback()'s are removed. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Disable writeback for CMP emulationTakuya Yoshikawa2011-05-111-1/+1
| | | | | | | | | | This stops "CMP r/m, reg" to write back the data into memory. Pointed out by Avi. The writeback suppression now covers CMP, CMPS, SCAS. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: VMX: Ensure that vmx_create_vcpu always returns proper errorJan Kiszka2011-05-111-2/+3
| | | | | | | | | | In case certain allocations fail, vmx_create_vcpu may return 0 as error instead of a negative value encoded via ERR_PTR. This causes a NULL pointer dereferencing later on in kvm_vm_ioctl_vcpu_create. Reported-by: Sasha Levin <levinsasha928@gmail.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: emulator: do not needlesly sync registers from emulator ctxt to vcpuGleb Natapov2011-05-111-9/+38
| | | | | | | | | | | | | Currently we sync registers back and forth before/after exiting to userspace for IO, but during IO device model shouldn't need to read/write the registers, so we can as well skip those sync points. The only exaception is broken vmware backdor interface. The new code sync registers content during IO only if registers are read from/written to by userspace in the middle of the IO operation and this almost never happens in practise. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: implement segment permission checksAvi Kivity2011-05-111-0/+63
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: move desc_limit_scaled()Avi Kivity2011-05-111-7/+7
| | | | | | For reuse later. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: move linearize() downwardsAvi Kivity2011-05-111-15/+15
| | | | | | So it can call emulate_gp() without forward declarations. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: pass access size and read/write intent to linearize()Avi Kivity2011-05-111-5/+6
| | | | | | Needed for segment read/write checks. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: change address linearization to return an error codeAvi Kivity2011-05-111-8/+39
| | | | | | Preparing to add segment checks. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: move invlpg emulation into a functionAvi Kivity2011-05-111-4/+10
| | | | | | It's going to get more complicated soon. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Add helpers for memory access using segmented addressesAvi Kivity2011-05-111-23/+52
| | | | | | Will help later adding proper segment checks. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: Fix fault-rip on vmsave/vmload emulationJoerg Roedel2011-05-111-6/+6
| | | | | | | | | | When the emulation of vmload or vmsave fails because the guest passed an unsupported physical address it gets an #GP with rip pointing to the instruction after vmsave/vmload. This is a bug and fixed by this patch. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: X86: Implement userspace interface to set virtual_tsc_khzJoerg Roedel2011-05-112-0/+55
| | | | | | | | | | This patch implements two new vm-ioctls to get and set the virtual_tsc_khz if the machine supports tsc-scaling. Setting the tsc-frequency is only possible before userspace creates any vcpu. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: X86: Delegate tsc-offset calculation to architecture codeJoerg Roedel2011-05-113-5/+21
| | | | | | | | | | With TSC scaling in SVM the tsc-offset needs to be calculated differently. This patch propagates this calculation into the architecture specific modules so that this complexity can be handled there. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: X86: Implement call-back to propagate virtual_tsc_khzJoerg Roedel2011-05-112-0/+44
| | | | | | | | | | | This patch implements a call-back into the architecture code to allow the propagation of changes to the virtual tsc_khz of the vcpu. On SVM it updates the tsc_ratio variable, on VMX it does nothing. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: X86: Make tsc_delta calculation a function of guest tscJoerg Roedel2011-05-111-2/+7
| | | | | | | | | | | | The calculation of the tsc_delta value to ensure a forward-going tsc for the guest is a function of the host-tsc. This works as long as the guests tsc_khz is equal to the hosts tsc_khz. With tsc-scaling hardware support this is not longer true and the tsc_delta needs to be calculated using guest_tsc values. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: X86: Let kvm-clock report the right tsc frequencyJoerg Roedel2011-05-111-10/+15
| | | | | | | | This patch changes the kvm_guest_time_update function to use TSC frequency the guest actually has for updating its clock. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: Implement infrastructure for TSC_RATE_MSRJoerg Roedel2011-05-111-1/+53
| | | | | | | | | This patch enhances the kvm_amd module with functions to support the TSC_RATE_MSR which can be used to set a given tsc frequency for the guest vcpu. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Drop EFER.SVME requirement from VMMCALLAvi Kivity2011-05-111-1/+1
| | | | | | | VMMCALL requires EFER.SVME to be enabled in the host, not in the guest, which is what check_svme() checks. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Re-add VendorSpecific tag to VMMCALL insnAvi Kivity2011-05-111-1/+1
| | | | | | | | VMMCALL needs the VendorSpecific tag so that #UD emulation (called if a guest running on AMD was migrated to an Intel host) is allowed to process the instruction. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: MMU: remove mmu_seq verification on pte update pathXiao Guangrong2011-05-112-14/+6
| | | | | | | | The mmu_seq verification can be removed since we get the pfn in the protection of mmu_lock. Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: do not open code return values from the emulatorGleb Natapov2011-05-111-3/+3
| | | | | Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: Remove base_addresss in kvm_pit since it is unusedJustin P. Mattock2011-05-111-1/+0
| | | | | | | | The patch below removes unsigned long base_addresss; in i8254.h since it is unused. Signed-off-by: Justin P. Mattock <justinmattock@gmail.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: Remove nested sel_cr0_write handling codeJoerg Roedel2011-05-111-52/+26
| | | | | | | | | | | This patch removes all the old code which handled the nested selective cr0 write intercepts. This code was only in place as a work-around until the instruction emulator is capable of doing the same. This is the case with this patch-set and so the code can be removed. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: Add checks for IO instructionsJoerg Roedel2011-05-112-15/+66
| | | | | | | | | | This patch adds code to check for IOIO intercepts on instructions decoded by the KVM instruction emulator. [avi: fix build error due to missing #define D2bvIP] Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: Add intercept checks for one-byte instructionsJoerg Roedel2011-05-112-2/+16
| | | | | | | | This patch add intercept checks for emulated one-byte instructions to the KVM instruction emulation path. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: Add intercept checks for remaining twobyte instructionsJoerg Roedel2011-05-112-7/+37
| | | | | | | | This patch adds intercepts checks for the remaining twobyte instructions to the KVM instruction emulator. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: Add intercept checks for remaining group7 instructionsJoerg Roedel2011-05-112-2/+30
| | | | | | | | This patch implements the emulator intercept checks for the RDTSCP, MONITOR, and MWAIT instructions. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: Add intercept checks for SVM instructionsJoerg Roedel2011-05-112-1/+51
| | | | | | | | | This patch adds the necessary code changes in the instruction emulator and the extensions to svm.c to implement intercept checks for the svm instructions. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: Add intercept checks for descriptor table accessesJoerg Roedel2011-05-112-2/+20
| | | | | | | | | This patch add intercept checks into the KVM instruction emulator to check for the 8 instructions that access the descriptor table addresses. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: Add intercept check for accessing dr registersJoerg Roedel2011-05-112-15/+54
| | | | | | | | This patch adds the intercept checks for instruction accessing the debug registers. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>