aboutsummaryrefslogtreecommitdiff
path: root/arch/x86
AgeCommit message (Collapse)AuthorFilesLines
2010-05-17KVM: Get rid of dead function gva_to_page()Gui Jianfeng1-14/+0
Nobody use gva_to_page() anymore, get rid of it. Signed-off-by: Gui Jianfeng <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
2010-05-17KVM: MMU: Remove unused varialbe in rmap_next()Gui Jianfeng1-2/+0
Remove unused varialbe in rmap_next() Signed-off-by: Gui Jianfeng <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
2010-05-17KVM: MMU: Make use of is_large_pte() in walkerGui Jianfeng1-2/+2
Make use of is_large_pte() instead of checking PT_PAGE_SIZE_MASK bit directly. Signed-off-by: Gui Jianfeng <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
2010-05-17KVM: MMU: Move sync_page() first pte address calculation out of loopGui Jianfeng1-2/+4
Move first pte address calculation out of loop to save some cycles. Signed-off-by: Gui Jianfeng <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
2010-05-17KVM: MMU: Drop cr4.pge from shadow page roleAvi Kivity3-4/+1
Since commit bf47a760f66ad, we no longer handle ptes with the global bit set specially, so there is no reason to distinguish between shadow pages created with cr4.gpe set and clear. Such tracking is expensive when the guest toggles cr4.pge, so drop it. Signed-off-by: Avi Kivity <[email protected]>
2010-05-17KVM: use the correct RCU API for PROVE_RCU=yLai Jiangshan4-6/+14
The RCU/SRCU API have already changed for proving RCU usage. I got the following dmesg when PROVE_RCU=y because we used incorrect API. This patch coverts rcu_deference() to srcu_dereference() or family API. =================================================== [ INFO: suspicious rcu_dereference_check() usage. ] --------------------------------------------------- arch/x86/kvm/mmu.c:3020 invoked rcu_dereference_check() without protection! other info that might help us debug this: rcu_scheduler_active = 1, debug_locks = 0 2 locks held by qemu-system-x86/8550: #0: (&kvm->slots_lock){+.+.+.}, at: [<ffffffffa011a6ac>] kvm_set_memory_region+0x29/0x50 [kvm] #1: (&(&kvm->mmu_lock)->rlock){+.+...}, at: [<ffffffffa012262d>] kvm_arch_commit_memory_region+0xa6/0xe2 [kvm] stack backtrace: Pid: 8550, comm: qemu-system-x86 Not tainted 2.6.34-rc4-tip-01028-g939eab1 #27 Call Trace: [<ffffffff8106c59e>] lockdep_rcu_dereference+0xaa/0xb3 [<ffffffffa012f6c1>] kvm_mmu_calculate_mmu_pages+0x44/0x7d [kvm] [<ffffffffa012263e>] kvm_arch_commit_memory_region+0xb7/0xe2 [kvm] [<ffffffffa011a5d7>] __kvm_set_memory_region+0x636/0x6e2 [kvm] [<ffffffffa011a6ba>] kvm_set_memory_region+0x37/0x50 [kvm] [<ffffffffa015e956>] vmx_set_tss_addr+0x46/0x5a [kvm_intel] [<ffffffffa0126592>] kvm_arch_vm_ioctl+0x17a/0xcf8 [kvm] [<ffffffff810a8692>] ? unlock_page+0x27/0x2c [<ffffffff810bf879>] ? __do_fault+0x3a9/0x3e1 [<ffffffffa011b12f>] kvm_vm_ioctl+0x364/0x38d [kvm] [<ffffffff81060cfa>] ? up_read+0x23/0x3d [<ffffffff810f3587>] vfs_ioctl+0x32/0xa6 [<ffffffff810f3b19>] do_vfs_ioctl+0x495/0x4db [<ffffffff810e6b2f>] ? fget_light+0xc2/0x241 [<ffffffff810e416c>] ? do_sys_open+0x104/0x116 [<ffffffff81382d6d>] ? retint_swapgs+0xe/0x13 [<ffffffff810f3ba6>] sys_ioctl+0x47/0x6a [<ffffffff810021db>] system_call_fastpath+0x16/0x1b Signed-off-by: Lai Jiangshan <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
2010-05-17Merge branch 'perf'Avi Kivity39-3265/+3187
Signed-off-by: Avi Kivity <[email protected]>
2010-05-17KVM: MMU: cleanup for hlist walk restartXiao Guangrong1-5/+10
Quote from Avi: |Just change the assignment to a 'goto restart;' please, |I don't like playing with list_for_each internals. Signed-off-by: Xiao Guangrong <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: prevent spurious exit to userspace during task switch emulation.Gleb Natapov2-4/+14
If kvm_task_switch() fails code exits to userspace without specifying exit reason, so the previous exit reason is reused by userspace. Fix this by specifying exit reason correctly. Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: MMU: remove unused parameter in mmu_parent_walk()Xiao Guangrong1-13/+11
'vcpu' is unused, remove it Signed-off-by: Xiao Guangrong <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: MMU: reduce 'struct kvm_mmu_page' sizeXiao Guangrong1-2/+2
Define 'multimapped' as 'bool'. Signed-off-by: Xiao Guangrong <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: MMU: remove unused struct kvm_unsync_walkXiao Guangrong1-5/+0
Remove 'struct kvm_unsync_walk' since it's not used. Signed-off-by: Xiao Guangrong <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: fix emulator_task_switch() return value.Gleb Natapov2-4/+5
emulator_task_switch() should return -1 for failure and 0 for success to the caller, just like x86_emulate_insn() does. Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: MMU: Replace role.glevels with role.cr4_paeAvi Kivity3-9/+10
There is no real distinction between glevels=3 and glevels=4; both have exactly the same format and the code is treated exactly the same way. Drop role.glevels and replace is with role.cr4_pae (which is meaningful). This simplifies the code a bit. As a side effect, it allows sharing shadow page tables between pae and longmode guest page tables at the same guest page. Signed-off-by: Avi Kivity <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: x86: Push potential exception error code on task switchesJan Kiszka7-10/+48
When a fault triggers a task switch, the error code, if existent, has to be pushed on the new task's stack. Implement the missing bits. Signed-off-by: Jan Kiszka <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: x86: Terminate early if task_switch_16/32 failedJan Kiszka1-0/+2
Stop the switch immediately if task_switch_16/32 returned an error. Only if that step succeeded, the switch should actually take place and update any register states. Signed-off-by: Jan Kiszka <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: x86: get rid of mmu_only parameter in emulator_write_emulated()Gleb Natapov1-25/+11
We can call kvm_mmu_pte_write() directly from emulator_cmpxchg_emulated() instead of passing mmu_only down to emulator_write_emulated_onepage() and call it there. Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: move DR register access handling into generic codeGleb Natapov4-134/+93
Currently both SVM and VMX have their own DR handling code. Move it to x86.c. Acked-by: Jan Kiszka <[email protected]> Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: SVM: implement NEXTRIPsave SVM featureAndre Przywara2-6/+11
On SVM we set the instruction length of skipped instructions to hard-coded, well known values, which could be wrong when (bogus, but valid) prefixes (REX, segment override) are used. Newer AMD processors (Fam10h 45nm and better, aka. PhenomII or AthlonII) have an explicit NEXTRIP field in the VMCB containing the desired information. Since it is cheap to do so, we use this field to override the guessed value on newer processors. A fix for older CPUs would be rather expensive, as it would require to fetch and partially decode the instruction. As the problem is not a security issue and needs special, handcrafted code to trigger (no compiler will ever generate such code), I omit a fix for older CPUs. If someone is interested, I have both a patch for these CPUs as well as demo code triggering this issue: It segfaults under KVM, but runs perfectly on native Linux. Signed-off-by: Andre Przywara <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: Fix MAXPHYADDR calculation when cpuid does not support itAvi Kivity1-0/+4
MAXPHYADDR is derived from cpuid 0x80000008, but when that isn't present, we get some random value. Fix by checking first that cpuid 0x80000008 is supported. Acked-by: Pekka Enberg <[email protected]> Signed-off-by: Avi Kivity <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: Trace emulated instructionsAvi Kivity2-0/+90
Log emulated instructions in ftrace, especially if they failed. Signed-off-by: Avi Kivity <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: x86 emulator: Don't overwrite decode cacheAvi Kivity1-9/+10
Currently if we an instruction spans a page boundary, when we fetch the second half we overwrite the first half. This prevents us from tracing the full instruction opcodes. Fix by appending the second half to the first. Signed-off-by: Avi Kivity <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: MMU: remove unnecessary NX check in walk_addrXiao Guangrong1-1/+1
After is_rsvd_bits_set() checks, EFER.NXE must be enabled if NX bit is seted Signed-off-by: Xiao Guangrong <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: MMU: remove unused fieldXiao Guangrong2-3/+0
kvm_mmu_page.oos_link is not used, so remove it Signed-off-by: Xiao Guangrong <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: MMU: cleanup/fix mmu audit codeXiao Guangrong1-7/+8
This patch does: - 'sp' parameter in inspect_spte_fn() is not used, so remove it - fix 'kvm' and 'slots' is not defined in count_rmaps() - fix a bug in inspect_spte_has_rmap() Signed-off-by: Xiao Guangrong <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: MMU: Disassociate direct maps from guest levelsAvi Kivity1-0/+2
Direct maps are linear translations for a section of memory, used for real mode or with large pages. As such, they are independent of the guest levels. Teach the mmu about this by making page->role.glevels = 0 for direct maps. This allows direct maps to be shared among real mode and the various paging modes. Signed-off-by: Avi Kivity <[email protected]>
2010-05-17KVM: MMU: check reserved bits only if CR4.PSE=1 or CR4.PAE=1Xiao Guangrong1-3/+9
- Check reserved bits only if CR4.PAE=1 or CR4.PSE=1 when guest #PF occurs - Fix a typo in reset_rsvds_bits_mask() Signed-off-by: Xiao Guangrong <[email protected]> Reviewed-by: Marcelo Tosatti <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
2010-05-17KVM: x86: document KVM_REQ_PENDING_TIMER usageMarcelo Tosatti1-1/+2
Document that KVM_REQ_PENDING_TIMER is implicitly used during guest entry. Signed-off-by: Marcelo Tosatti <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
2010-05-17KVM: x86 emulator: fix unlocked CMPXCHG8B emulationGleb Natapov1-1/+0
When CMPXCHG8B is executed without LOCK prefix it is racy. Preserve this behaviour in emulator too. Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
2010-05-17KVM: x86 emulator: add decoding of CMPXCHG8B dst operandGleb Natapov1-14/+10
Decode CMPXCHG8B destination operand in decoding stage. Fixes regression introduced by "If LOCK prefix is used dest arg should be memory" commit. This commit relies on dst operand be decoded at the beginning of an instruction emulation. Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
2010-05-17KVM: x86 emulator: commit rflags as part of registers commitGleb Natapov3-2/+8
Make sure that rflags is committed only after successful instruction emulation. Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
2010-05-17KVM: x86: Fix 32-bit build breakage due to typoJan Kiszka1-1/+1
Signed-off-by: Jan Kiszka <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
2010-05-17KVM: small kvm_arch_vcpu_ioctl_run() cleanup.Gleb Natapov1-26/+6
Unify all conditions that get us back into emulator after returning from userspace. Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: x86 emulator: introduce pio in string read ahead.Gleb Natapov2-5/+48
To optimize "rep ins" instruction do IO in big chunks ahead of time instead of doing it only when required during instruction emulation. Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: x86 emulator: restart string instruction without going back to a guest.Gleb Natapov3-12/+42
Currently when string instruction is only partially complete we go back to a guest mode, guest tries to reexecute instruction and exits again and at this point emulation continues. Avoid all of this by restarting instruction without going back to a guest mode, but return to a guest mode each 1024 iterations to allow interrupt injection. Pending exception causes immediate guest entry too. Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: x86 emulator: remove saved_eipGleb Natapov1-8/+1
c->eip is never written back in case of emulation failure, so no need to set it to old value. Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: x86 emulator: Move string pio emulation into emulator.cGleb Natapov3-230/+32
Currently emulation is done outside of emulator so things like doing ins/outs to/from mmio are broken it also makes it hard (if not impossible) to implement single stepping in the future. The implementation in this patch is not efficient since it exits to userspace for each IO while previous implementation did 'ins' in batches. Further patch that implements pio in string read ahead address this problem. Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: x86 emulator: fix in/out emulation.Gleb Natapov6-133/+178
in/out emulation is broken now. The breakage is different depending on where IO device resides. If it is in userspace emulator reports emulation failure since it incorrectly interprets kvm_emulate_pio() return value. If IO device is in the kernel emulation of 'in' will do nothing since kvm_emulate_pio() stores result directly into vcpu registers, so emulator will overwrite result of emulation during commit of shadowed register. Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: x86 emulator: during rep emulation decrement ECX only if emulation ↵Gleb Natapov1-7/+8
succeeded Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: x86 emulator: add decoding of X,Y parameters from Intel SDMGleb Natapov1-81/+44
Add decoding of X,Y parameters from Intel SDM which are used by string instruction to specify source and destination. Use this new decoding to implement movs, cmps, stos, lods in a generic way. Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: x86 emulator: populate OP_MEM operand during decoding.Gleb Natapov1-37/+29
All struct operand fields are initialized during decoding for all operand types except OP_MEM, but there is no reason for that. Move OP_MEM operand initialization into decoding stage for consistency. Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: Use task switch from emulator.cGleb Natapov2-545/+22
Remove old task switch code from x86.c Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: x86 emulator: Use load_segment_descriptor() instead of ↵Gleb Natapov1-5/+5
kvm_load_segment_descriptor() Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: x86 emulator: Emulate task switch in emulator.cGleb Natapov2-0/+568
Implement emulation of 16/32 bit task switch in emulator.c Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: x86 emulator: Provide more callbacks for x86 emulator.Gleb Natapov2-15/+131
Provide get_cached_descriptor(), set_cached_descriptor(), get_segment_selector(), set_segment_selector(), get_gdt(), write_std() callbacks. Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: x86 emulator: cleanup grp3 return valueGleb Natapov1-8/+4
When x86_emulate_insn() does not know how to emulate instruction it exits via cannot_emulate label in all cases except when emulating grp3. Fix that. Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: x86 emulator: If LOCK prefix is used dest arg should be memory.Gleb Natapov1-1/+1
If LOCK prefix is used dest arg should be memory, otherwise instruction should generate #UD. Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: x86 emulator: do not call writeback if msr access fails.Gleb Natapov1-2/+2
Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: x86 emulator: fix return values of syscall/sysenter/sysexit emulationsGleb Natapov1-6/+11
Return X86EMUL_PROPAGATE_FAULT is fault was injected. Also inject #UD for those instruction when appropriate. Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
2010-05-17KVM: x86 emulator: fix mov dr to inject #UD when needed.Gleb Natapov1-6/+12
If CR4.DE=1 access to registers DR4/DR5 cause #UD. Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>