summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* KVM: SVM: Fix EFER.LME being strippedZachary Amsden2010-08-011-1/+1
| | | | | | | | | | Must set VCPU register to be the guest notion of EFER even if that setting is not valid on hardware. This was masked by the set in set_efer until 7657fd5ace88e8092f5f3a84117e093d7b893f26 broke that. Fix is simply to set the VCPU register before stripping bits. Signed-off-by: Zachary Amsden <zamsden@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: MMU: don't check PT_WRITABLE_MASK directlyGui Jianfeng2010-08-011-4/+4
| | | | | | | Since we have is_writable_pte(), make use of it. Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: MMU: calculate correct gfn for small host pages backing large guest pagesLai Jiangshan2010-08-011-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Documentation/kvm/mmu.txt: gfn: Either the guest page table containing the translations shadowed by this page, or the base page frame for linear translations. See role.direct. But in function FNAME(fetch)(), sp->gfn is incorrect when one of following situations occurred: 1) guest is 32bit paging and the guest PDE maps a 4-MByte page (backed by 4k host pages), FNAME(fetch)() miss handling the quadrant. And if guest use pse-36, "table_gfn = gpte_to_gfn(gw->ptes[level - delta]);" is incorrect. 2) guest is long mode paging and the guest PDPTE maps a 1-GByte page (backed by 4k or 2M host pages). So we fix it to suit to the document and suit to the code which requires sp->gfn correct when sp->role.direct=1. We use the goal mapping gfn(gw->gfn) to calculate the base page frame for linear translations, it is simple and easy to be understood. Reported-by: Marcelo Tosatti <mtosatti@redhat.com> Reported-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: MMU: Calculate correct base gfn for direct non-DIR levelLai Jiangshan2010-08-011-1/+4
| | | | | | | | | | | | | | | | In Document/kvm/mmu.txt: gfn: Either the guest page table containing the translations shadowed by this page, or the base page frame for linear translations. See role.direct. But in __direct_map(), the base gfn calculation is incorrect, it does not calculate correctly when level=3 or 4. Fix by using PT64_LVL_ADDR_MASK() which accounts for all levels correctly. Reported-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: MMU: Don't allocate gfns page for direct mmu pagesLai Jiangshan2010-08-013-10/+35
| | | | | | | | | | | | | | | | | | | When sp->role.direct is set, sp->gfns does not contain any essential information, leaf sptes reachable from this sp are for a continuous guest physical memory range (a linear range). So sp->gfns[i] (if it was set) equals to sp->gfn + i. (PT_PAGE_TABLE_LEVEL) Obviously, it is not essential information, we can calculate it when need. It means we don't need sp->gfns when sp->role.direct=1, Thus we can save one page usage for every kvm_mmu_page. Note: Access to sp->gfns must be wrapped by kvm_mmu_page_get_gfn() or kvm_mmu_page_set_gfn(). It is only exposed in FNAME(sync_page). Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: VMX: Add constant for invalid guest state exit reasonMohammed Gamal2010-08-011-0/+1
| | | | | | | | For the sake of completeness, this patch adds a symbolic constant for VMX exit reason 0x21 (invalid guest state). Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: MMU: allow more page become unsync at getting sp timeXiao Guangrong2010-08-011-10/+37
| | | | | | | | | Allow more page become asynchronous at getting sp time, if need create new shadow page for gfn but it not allow unsync(level > 1), we should unsync all gfn's unsync page Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: MMU: allow more page become unsync at gfn mapping timeXiao Guangrong2010-08-011-44/+38
| | | | | | | | | | | | In current code, shadow page can become asynchronous only if one shadow page for a gfn, this rule is too strict, in fact, we can let all last mapping page(i.e, it's the pte page) become unsync, and sync them at invlpg or flush tlb time. This patch allow more page become asynchronous at gfn mapping time Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: Update Red Hat copyrightsAvi Kivity2010-08-0118-1/+32
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: correctly trace irq injectionGleb Natapov2010-08-011-3/+3
| | | | | | | | On SVM interrupts are injected by svm_set_irq() not svm_inject_irq(). The later is used only to wait for irq window. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: MMU: only update unsync page in invlpg pathXiao Guangrong2010-08-011-2/+6
| | | | | | | | Only unsync pages need updated at invlpg time since other shadow pages are write-protected Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: MMU: don't write-protect if have new mapping to unsync pageXiao Guangrong2010-08-011-4/+14
| | | | | | | | | | | | | | | | | | | Two cases maybe happen in kvm_mmu_get_page() function: - one case is, the goal sp is already in cache, if the sp is unsync, we only need update it to assure this mapping is valid, but not mark it sync and not write-protect sp->gfn since it not broke unsync rule(one shadow page for a gfn) - another case is, the goal sp not existed, we need create a new sp for gfn, i.e, gfn (may)has another shadow page, to keep unsync rule, we should sync(mark sync and write-protect) gfn's unsync shadow page. After enabling multiple unsync shadows, we sync those shadow pages only when the new sp not allow to become unsync(also for the unsyc rule, the new rule is: allow all pte page become unsync) Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: MMU: split kvm_sync_page() functionXiao Guangrong2010-08-011-4/+25
| | | | | | | | | | | Split kvm_sync_page() into kvm_sync_page() and kvm_sync_page_transient() to clarify the code address Avi's suggestion kvm_sync_page_transient() function only update shadow page but not mark it sync and not write protect sp->gfn. it will be used by later patch Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86: Use FPU APISheng Yang2010-08-012-52/+17
| | | | | | | 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-012-17/+2
| | | | | | | | | | 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>
* x86: Export FPU API for KVM useSheng Yang2010-08-014-1/+8
| | | | | | | Also add some constants. 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-014-18/+10
| | | | | | | 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: PPC: Centralize locking of arch specific vcpu ioctlsAvi Kivity2010-08-011-4/+8
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: s390: Centrally lock arch specific vcpu ioctlsAvi Kivity2010-08-011-23/+17
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86: Lock arch specific vcpu ioctls centrallyAvi Kivity2010-08-011-39/+2
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: move vcpu locking to dispatcher for generic vcpu ioctlsAvi Kivity2010-08-017-95/+17
| | | | | | | | | 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-011-2/+0
| | | | | | | | | 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: MMU: unalias gfn before sp->gfns[] comparison in sync_pageXiao Guangrong2010-08-011-3/+4
| | | | | | | | sp->gfns[] contain unaliased gfns, but gpte might contain pointer to aliased region. Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: MMU: remove rmap before clear spteXiao Guangrong2010-08-011-0/+1
| | | | | | | | Remove rmap before clear spte otherwise it will trigger BUG_ON() in some functions such as rmap_write_protect(). Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: MMU: use proper cache object freeing functionXiao Guangrong2010-08-011-8/+10
| | | | | | | Use kmem_cache_free to free objects allocated by kmem_cache_alloc. Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: remove CAP_SYS_RAWIO requirement from kvm_vm_ioctl_assign_irqAlex Williamson2010-08-011-3/+0
| | | | | | | | | | | Remove this check in an effort to allow kvm guests to run without root privileges. This capability check doesn't seem to add any security since the device needs to have already been added via the assign device ioctl and the io actually occurs through the pci sysfs interface. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: VMX: Only reset MMU when necessarySheng Yang2010-08-011-2/+14
| | | | | | | | | 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-012-6/+3
| | | | | | | | | | | 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: x86 emulator: Add missing decoder flags for xor instructionsMohammed Gamal2010-08-011-1/+1
| | | | | | | This adds missing decoder flags for xor instructions (opcodes 0x34 - 0x35) Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: Add missing decoder flags for sub instructionMohammed Gamal2010-08-011-1/+1
| | | | | | | This adds missing decoder flags for sub instructions (opcodes 0x2c - 0x2d) Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: Add test acc, imm instruction (opcodes 0xA8 - 0xA9)Mohammed Gamal2010-08-011-1/+4
| | | | | | | This adds test acc, imm instruction to the x86 emulator Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: pass correct parameter to kvm_mmu_free_some_pagesMarcelo Tosatti2010-08-011-2/+2
| | | | Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: VMX: VMXON/VMXOFF usage changesDongxiao Xu2010-08-011-7/+31
| | | | | | | | | | | | SDM suggests VMXON should be called before VMPTRLD, and VMXOFF should be called after doing VMCLEAR. Therefore in vmm coexistence case, we should firstly call VMXON before any VMCS operation, and then call VMXOFF after the operation is done. Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: VMX: VMCLEAR/VMPTRLD usage changesDongxiao Xu2010-08-011-1/+6
| | | | | | | | | | Originally VMCLEAR/VMPTRLD is called on vcpu migration. To support hosted VMM coexistance, VMCLEAR is executed on vcpu schedule out, and VMPTRLD is executed on vcpu schedule in. This could also eliminate the IPI when doing VMCLEAR. Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: VMX: Some minor changes to code structureDongxiao Xu2010-08-011-8/+8
| | | | | | | Do some preparations for vmm coexistence support. Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: VMX: Define new functions to wrapper direct call of asm codeDongxiao Xu2010-08-011-13/+23
| | | | | | | | Define vmcs_load() and kvm_cpu_vmxon() to avoid direct call of asm code. Also move VMXE bit operation out of kvm_cpu_vmxoff(). Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: update mmu documetation for role.nxeGui Jianfeng2010-08-011-1/+1
| | | | | | | | There's no member "cr4_nxe" in struct kvm_mmu_page_role, it names "nxe" now. Update mmu document. Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: MMU: Fix free memory accounting race in mmu_alloc_roots()Avi Kivity2010-08-011-3/+2
| | | | | | | | | | | We drop the mmu lock between freeing memory and allocating the roots; this allows some other vcpu to sneak in and allocate memory. While the race is benign (resulting only in temporary overallocation, not oom) it is simple and easy to fix by moving the freeing close to the allocation. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: inject #UD if instruction emulation fails and exit to userspaceGleb Natapov2010-08-015-61/+26
| | | | | | | | | | 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: Document KVM_SET_BOOT_CPU_IDAvi Kivity2010-08-011-0/+12
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: Document KVM_SET_IDENTITY_MAP ioctlAvi Kivity2010-08-011-0/+18
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: MMU: make kvm_mmu_zap_page() return the number of pages it actually freedGui Jianfeng2010-08-011-2/+3
| | | | | | | | | | Currently, kvm_mmu_zap_page() returning the number of freed children sp. This might confuse the caller, because caller don't know the actual freed number. Let's make kvm_mmu_zap_page() return the number of pages it actually freed. Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: MMU: Fix debug output error in walk_addr()Gui Jianfeng2010-08-011-1/+1
| | | | | | | Fix a debug output error in walk_addr Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: MMU: mark page table dirty when a pte is actually modifiedGui Jianfeng2010-08-011-2/+2
| | | | | | | | Sometime cmpxchg_gpte doesn't modify gpte, in such case, don't mark page table page as dirty. Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: Allow EFER.LMSLE to be set with nested svmJoerg Roedel2010-08-012-1/+3
| | | | | | | | | This patch enables setting of efer bit 13 which is allowed in all SVM capable processors. This is necessary for the SLES11 version of Xen 4.0 to boot with nested svm. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: Dump vmcb contents on failed vmrunJoerg Roedel2010-08-011-0/+95
| | | | | | | | This patch adds a function to dump the vmcb into the kernel log and calls it after a failed vmrun to ease debugging. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: Get rid of KVM_REQ_KICKAvi Kivity2010-08-012-7/+11
| | | | | | | | | | 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-013-50/+100
| | | | | | | | 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-012-20/+19
| | | | | | | 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-012-17/+12
| | | | | | | Emulator shouldn't access vcpu directly. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
OpenPOWER on IntegriCloud