aboutsummaryrefslogtreecommitdiff
path: root/drivers
AgeCommit message (Collapse)Author
2008-01-30KVM: MMU: Use mmu_set_spte() for real-mode shadowsAvi Kivity
In addition to removing some duplicated code, this also handles the unlikely case of real-mode code updating a guest page table. This can happen when one vcpu (in real mode) touches a second vcpu's (in protected mode) page tables, or if a vcpu switches to real mode, touches page tables, and switches back. Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: MMU: Adjust mmu_set_spte() debug code for gpte removalAvi Kivity
Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: MMU: Move set_pte() into guest paging mode independent codeAvi Kivity
As set_pte() no longer references either a gpte or the guest walker, we can move it out of paging mode dependent code (which compiles twice and is generally nasty). Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: MMU: Remove walker argument to set_pte()Avi Kivity
Unused. Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: MMU: Pass pte dirty flag to set_pte() instead of calculating it on-siteAvi Kivity
This allows us to remove its dependency on pt_element_t. Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: MMU: No need to pick up nx bit from guest pteAvi Kivity
We already set it according to cumulative access permissions. Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: MMU: Fix inherited permissions for emulated guest pte updatesAvi Kivity
When we emulate a guest pte write, we fail to apply the correct inherited permissions from the parent ptes. Now that we store inherited permissions in the shadow page, we can use that to update the pte permissions correctly. Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: MMU: Move pte access calculation into a helper functionAvi Kivity
Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: MMU: Set nx bit correctly on shadow ptesAvi Kivity
While the page table walker correctly generates a guest page fault if a guest tries to execute a non-executable page, the shadow code does not mark it non-executable. This means that if a guest accesses an nx page first with a read access, then subsequent code fetch accesses will succeed. Fix by setting the nx bit on shadow ptes. Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: MMU: Simplify calculation of pte accessAvi Kivity
The nx bit is awkwardly placed in the 63rd bit position; furthermore it has a reversed meaning compared to the other bits, which means we can't use a bitwise and to calculate compounded access masks. So, we simplify things by creating a new 3-bit exec/write/user access word, and doing all calculations in that. Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: MMU: Use cmpxchg for pte updates on walk_addr()Marcelo Tosatti
In preparation for multi-threaded guest pte walking, use cmpxchg() when updating guest pte's. This guarantees that the assignment of the dirty bit can't be lost if two CPU's are faulting the same address simultaneously. [avi: fix kunmap_atomic() parameters] Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: SVM: Trap access to the cr8 registerAvi Kivity
Later we may be able to use the virtual tpr feature, but for now, just trap it. Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: x86 emulator: Fix stack instructions on 64-bit modeAvi Kivity
Stack instructions are always 64-bit on 64-bit mode; many of the emulated stack instructions did not take that into account. Fix by adding a 'Stack' bitflag and setting the operand size appropriately during the decode stage (except for 'push r/m', which is in a group with a few other instructions, so it gets its own treatment). This fixes random crashes on Vista x64. Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: SVM: Emulate read/write access to cr8Joerg Roedel
This patch adds code to emulate the access to the cr8 register to the x86 instruction emulator in kvm. This is needed on svm, where there is no hardware decode for control register access. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Markus Rechberger <markus.rechberger@amd.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: VMX: Avoid exit when setting cr8 if the local apic is in the kernelAvi Kivity
With apic in userspace, we must exit to userspace after a cr8 write in order to update the tpr. But if the apic is in the kernel, the exit is unnecessary. Noticed by Joerg Roedel. Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: x86 emulator: fix eflags preparation for emulationAvi Kivity
We prepare eflags for the emulated instruction, then clobber it with an 'andl'. Fix by popping eflags as the last thing in the sequence. Patch taken from Xen (16143:959b4b92b6bf) Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: Use generalized exception queue for injecting #UDAvi Kivity
Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: Replace #GP injection by the generalized exception queueAvi Kivity
Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: Replace page fault injection by the generalized exception queueAvi Kivity
Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: Generalize exception injection mechanismAvi Kivity
Instead of each subarch doing its own thing, add an API for queuing an injection, and manage failed exception injection centerally (i.e., if an inject failed due to a shadow page fault, we need to requeue it). Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: MMU: Remove unused prev_shadow_ent variable from fetch()Marcelo Tosatti
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: Convert KVM from ->nopage() to ->fault()npiggin@suse.de
Signed-off-by: Nick Piggin <npiggin@suse.de> Cc: kvm-devel@lists.sourceforge.net Cc: avi@qumranet.com Cc: linux-kernel@vger.kernel.org Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: Portability: Create kvm_arch_vcpu_runnable() functionHollis Blanchard
This abstracts the detail of x86 hlt and INIT modes into a function. Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> Acked-by: Carsten Otte <cotte@de.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: Portability: Stop including x86-specific headers in kvm_main.cHollis Blanchard
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: Portability: Move IO device definitions to its own header fileHollis Blanchard
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> Acked-by: Carsten Otte <cotte@de.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: Portability: Move address types to their own header fileHollis Blanchard
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> Acked-by: Carsten Otte <cotte@de.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: Extend ioapic code to support iosapicZhang Xiantao
iosapic supports an additional mmio EOI register compared to ioapic. Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: Replace dest_Lowest_Prio and dest_Fixed with self-defined macrosZhang Xiantao
Change dest_Loest_Prio -> IOAPIC_LOWEST_PRIORITY dest_Fixed -> IOAPIC_FIXED the original names are x86 specific, while the ioapic code will be reused for ia64. Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: Replace kvm_lapic with kvm_vcpu in ioapic/lapic interfaceZhang Xiantao
This patch replaces lapic structure with kvm_vcpu in ioapic.c, making ioapic independent of the local apic, as required by ia64. Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: SVM: Remove KVM specific defines for MSR_EFERCarlo Marcelo Arenas Belon
This patch removes the KVM specific defines for MSR_EFER that were being used in the svm support file and migrates all references to use instead the ones from the kernel headers that are used everywhere else and that have the same values. Signed-off-by: Carlo Marcelo Arenas Belon <carenas@sajinet.com.pe> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: Export include/linux/kvm.h only if $ARCH actually supports KVMAvi Kivity
Currently, make headers_check barfs due to <asm/kvm.h>, which <linux/kvm.h> includes, not existing. Rather than add a zillion <asm/kvm.h>s, export kvm.h only if the arch actually supports it. Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: Correct kvm_init() error paths not freeing bad_pge.Zhang Xiantao
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: Portability: Move KVM_INTERRUPT vcpu ioctl to x86.cZhang Xiantao
Other archs doesn't need it. Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: x86 emulator: unify four switch statements into twoAvi Kivity
Unify the special instruction switch with the regular instruction switch, and the two byte special instruction switch with the regular two byte instruction switch. That makes it much easier to find an instruction or the place an instruction needs to be added in. Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: x86 emulator: unify two switchesAvi Kivity
The rep prefix cleanup left two switch () statements next to each other. Unify them. Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: x86 emulator: Move rep processing before instruction executionAvi Kivity
Currently rep processing is handled somewhere in the middle of instruction processing. Move it to a sensible place. Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: x86 emulator: cmps instructionGuillaume Thouvenin
Add emulation for the cmps instruction. This lets OpenBSD boot on kvm. Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin@ext.bull.net> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: x86 emulator: Rename 'cr2' to 'memop'Sheng Yang
Previous patches have removed the dependency on cr2; we can now stop passing it to the emulator and rename uses to 'memop'. Signed-off-by: Sheng Yang <sheng.yang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: MMU: mark pages that were inserted to the shadow pages table as accessedIzik Eidus
Mark guest pages as accessed when removed from the shadow page tables for better lru processing. Signed-off-by: Izik Eidus <izike@qumranet.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: Remove misleading check for mmio during event injectionAvi Kivity
mmio was already handled in kvm_arch_vcpu_ioctl_run(), so no need to check again. Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: x86 emulator: address size and operand size overrides are stickyAvi Kivity
Current implementation is to toggle, which is incorrect. Patch ported from corresponding Xen code. Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: x86 emulator: Make a distinction between repeat prefixes F3 and F2Guillaume Thouvenin
cmps and scas instructions accept repeat prefixes F3 and F2. So in order to emulate those prefixed instructions we need to be able to know if prefixes are REP/REPE/REPZ or REPNE/REPNZ. Currently kvm doesn't make this distinction. This patch introduces this distinction. Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin@ext.bull.net> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: Portability: Move unalias_gfn to arch dependent fileZhang Xiantao
Non-x86 archs don't need this mechanism. Move it to arch, and keep its interface in common. Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Acked-by: Carsten Otte <cotte@de.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: VMX: Remove the secondary execute control dependency on irqchipSheng Yang
The state of SECONDARY_VM_EXEC_CONTROL shouldn't depend on in-kernel IRQ chip, this patch fix this. Signed-off-by: Sheng Yang <sheng.yang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: Enhance guest cpuid managementDan Kenigsberg
The current cpuid management suffers from several problems, which inhibit passing through the host feature set to the guest: - No way to tell which features the host supports While some features can be supported with no changes to kvm, others need explicit support. That means kvm needs to vet the feature set before it is passed to the guest. - No support for indexed or stateful cpuid entries Some cpuid entries depend on ecx as well as on eax, or on internal state in the processor (running cpuid multiple times with the same input returns different output). The current cpuid machinery only supports keying on eax. - No support for save/restore/migrate The internal state above needs to be exposed to userspace so it can be saved or migrated. This patch adds extended cpuid support by means of three new ioctls: - KVM_GET_SUPPORTED_CPUID: get all cpuid entries the host (and kvm) supports - KVM_SET_CPUID2: sets the vcpu's cpuid table - KVM_GET_CPUID2: gets the vcpu's cpuid table, including hidden state [avi: fix original KVM_SET_CPUID not removing nx on non-nx hosts as it did before] Signed-off-by: Dan Kenigsberg <danken@qumranet.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: Disallow fork() and similar games when using a VMAvi Kivity
We don't want the meaning of guest userspace changing under our feet. Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: MMU: Rename 'release_page'Avi Kivity
Rename the awkwardly named variable. Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: MMU: Rename variables of type 'struct kvm_mmu_page *'Avi Kivity
These are traditionally named 'page', but even more traditionally, that name is reserved for variables that point to a 'struct page'. Rename them to 'sp' (for "shadow page"). Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: Remove gpa_to_hpa()Avi Kivity
Converting last uses along the way. Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-01-30KVM: MMU: Remove gva_to_hpa()Avi Kivity
No longer used. Signed-off-by: Avi Kivity <avi@qumranet.com>