Zhang Xiantao [Fri, 14 Dec 2007 01:49:26 +0000 (09:49 +0800)]
KVM: Portability: Move kvm_vcpu_stat to x86.h
This patches moves kvm_vcpu_stat to x86.h, so every
arch can define its own kvm_vcpu_stat structure.
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>
Zhang Xiantao [Fri, 14 Dec 2007 01:45:31 +0000 (09:45 +0800)]
KVM: Portability: Expand the KVM_VCPU_COMM in kvm_vcpu structure.
This patches removes KVM_COMM macro, original it is hold
kvm_vcpu common fields.
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>
Zhang Xiantao [Fri, 14 Dec 2007 01:41:22 +0000 (09:41 +0800)]
KVM: Portability: Move kvm_vcpu definition back to kvm.h
This patches moves kvm_vcpu definition to kvm.h, and finally
kvm.h includes x86.h.
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>
Zhang Xiantao [Fri, 14 Dec 2007 01:35:10 +0000 (09:35 +0800)]
KVM: Portability: Split mmu-related static inline functions to mmu.h
Since these functions need to know the details of kvm or kvm_vcpu structure,
it can't be put in x86.h. Create mmu.h to hold them.
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>
Zhang Xiantao [Thu, 13 Dec 2007 15:50:52 +0000 (23:50 +0800)]
KVM: Portability: Introduce kvm_vcpu_arch
Move all the architecture-specific fields in kvm_vcpu into a new struct
kvm_vcpu_arch.
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>
Zhang Xiantao [Tue, 11 Dec 2007 12:36:00 +0000 (20:36 +0800)]
KVM: Portability: Move kvm{pic,ioapic} accesors to x86 specific code
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Marcelo Tosatti [Wed, 12 Dec 2007 15:46:12 +0000 (10:46 -0500)]
KVM: MMU: emulated cmpxchg8b should be atomic on i386
Emulate cmpxchg8b atomically on i386. This is required to avoid a guest
pte walker from seeing a splitted write.
[avi: make it compile]
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Joerg Roedel [Tue, 11 Dec 2007 14:36:57 +0000 (15:36 +0100)]
KVM: SVM: support writing 0 to K8 performance counter control registers
This lets SVM ignore writes of the value 0 to the performance counter control
registers. Thus enabling them will still fail in the guest, but a write of 0
which keeps them disabled is accepted. This is required to boot Windows
Vista 64bit.
[avi: avoid fall-thru in switch statement]
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>
Joerg Roedel [Wed, 12 Dec 2007 11:37:24 +0000 (12:37 +0100)]
KVM: LAPIC: minor debugging compile fix
This patch fixes a compile error of the LAPIC code with APIC debugging enabled.
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>
Marcelo Tosatti [Wed, 12 Dec 2007 00:12:27 +0000 (19:12 -0500)]
KVM: MMU: Fix SMP shadow instantiation race
There is a race where VCPU0 is shadowing a pagetable entry while VCPU1
is updating it, which results in a stale shadow copy.
Fix that by comparing the contents of the cached guest pte with the
current guest pte after write-protecting the guest pagetable.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Joerg Roedel [Thu, 6 Dec 2007 20:02:25 +0000 (21:02 +0100)]
KVM: SVM: Exit to userspace if write to cr8 and not using in-kernel apic
With this patch KVM on SVM will exit to userspace if the guest writes to CR8
and the in-kernel APIC is disabled.
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>
Avi Kivity [Sun, 9 Dec 2007 16:43:00 +0000 (18:43 +0200)]
KVM: MMU: Use mmu_set_spte() for real-mode shadows
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>
Avi Kivity [Sun, 9 Dec 2007 16:39:41 +0000 (18:39 +0200)]
KVM: MMU: Adjust mmu_set_spte() debug code for gpte removal
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Sun, 9 Dec 2007 15:40:31 +0000 (17:40 +0200)]
KVM: MMU: Move set_pte() into guest paging mode independent code
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>
Avi Kivity [Sun, 9 Dec 2007 15:33:46 +0000 (17:33 +0200)]
KVM: MMU: Remove walker argument to set_pte()
Unused.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Sun, 9 Dec 2007 15:32:30 +0000 (17:32 +0200)]
KVM: MMU: Pass pte dirty flag to set_pte() instead of calculating it on-site
This allows us to remove its dependency on pt_element_t.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Sun, 9 Dec 2007 15:27:52 +0000 (17:27 +0200)]
KVM: MMU: No need to pick up nx bit from guest pte
We already set it according to cumulative access permissions.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Sun, 9 Dec 2007 15:00:02 +0000 (17:00 +0200)]
KVM: MMU: Fix inherited permissions for emulated guest pte updates
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>
Avi Kivity [Sun, 9 Dec 2007 14:52:56 +0000 (16:52 +0200)]
KVM: MMU: Move pte access calculation into a helper function
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Sun, 9 Dec 2007 14:37:36 +0000 (16:37 +0200)]
KVM: MMU: Set nx bit correctly on shadow ptes
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>
Avi Kivity [Sun, 9 Dec 2007 14:15:46 +0000 (16:15 +0200)]
KVM: MMU: Simplify calculation of pte access
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>
Marcelo Tosatti [Fri, 7 Dec 2007 12:56:58 +0000 (07:56 -0500)]
KVM: MMU: Use cmpxchg for pte updates on walk_addr()
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>
Avi Kivity [Thu, 6 Dec 2007 17:50:00 +0000 (19:50 +0200)]
KVM: SVM: Trap access to the cr8 register
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>
Avi Kivity [Thu, 6 Dec 2007 16:14:14 +0000 (18:14 +0200)]
KVM: x86 emulator: Fix stack instructions on 64-bit mode
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>
Joerg Roedel [Thu, 6 Dec 2007 14:46:52 +0000 (15:46 +0100)]
KVM: SVM: Emulate read/write access to cr8
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>
Avi Kivity [Thu, 6 Dec 2007 14:32:45 +0000 (16:32 +0200)]
KVM: VMX: Avoid exit when setting cr8 if the local apic is in the kernel
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>
Avi Kivity [Thu, 6 Dec 2007 14:15:02 +0000 (16:15 +0200)]
KVM: x86 emulator: fix eflags preparation for emulation
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>
Avi Kivity [Sun, 25 Nov 2007 13:22:50 +0000 (15:22 +0200)]
KVM: Use generalized exception queue for injecting #UD
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Sun, 25 Nov 2007 12:12:03 +0000 (14:12 +0200)]
KVM: Replace #GP injection by the generalized exception queue
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Sun, 25 Nov 2007 12:04:58 +0000 (14:04 +0200)]
KVM: Replace page fault injection by the generalized exception queue
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Sun, 25 Nov 2007 11:41:11 +0000 (13:41 +0200)]
KVM: Generalize exception injection mechanism
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>
Marcelo Tosatti [Tue, 4 Dec 2007 18:42:16 +0000 (13:42 -0500)]
KVM: MMU: Remove unused prev_shadow_ent variable from fetch()
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
npiggin@suse.de [Wed, 5 Dec 2007 07:15:52 +0000 (18:15 +1100)]
KVM: Convert KVM from ->nopage() to ->fault()
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>
Hollis Blanchard [Mon, 3 Dec 2007 22:15:26 +0000 (16:15 -0600)]
KVM: Portability: Create kvm_arch_vcpu_runnable() function
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>
Hollis Blanchard [Mon, 3 Dec 2007 21:30:25 +0000 (15:30 -0600)]
KVM: Portability: Stop including x86-specific headers in kvm_main.c
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Hollis Blanchard [Mon, 3 Dec 2007 21:30:24 +0000 (15:30 -0600)]
KVM: Portability: Move IO device definitions to its own header file
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>
Hollis Blanchard [Mon, 3 Dec 2007 21:30:23 +0000 (15:30 -0600)]
KVM: Portability: Move address types to their own header file
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>
Zhang Xiantao [Sun, 2 Dec 2007 14:53:07 +0000 (22:53 +0800)]
KVM: Extend ioapic code to support iosapic
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>
Zhang Xiantao [Sun, 2 Dec 2007 14:49:09 +0000 (22:49 +0800)]
KVM: Replace dest_Lowest_Prio and dest_Fixed with self-defined macros
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>
Zhang Xiantao [Sun, 2 Dec 2007 14:35:57 +0000 (22:35 +0800)]
KVM: Replace kvm_lapic with kvm_vcpu in ioapic/lapic interface
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>
Carlo Marcelo Arenas Belon [Sat, 1 Dec 2007 12:17:11 +0000 (06:17 -0600)]
KVM: SVM: Remove KVM specific defines for MSR_EFER
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>
Avi Kivity [Sun, 2 Dec 2007 08:50:06 +0000 (10:50 +0200)]
KVM: Export include/linux/kvm.h only if $ARCH actually supports KVM
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>
Zhang Xiantao [Thu, 29 Nov 2007 07:35:39 +0000 (15:35 +0800)]
KVM: Correct kvm_init() error paths not freeing bad_pge.
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Zhang Xiantao [Tue, 20 Nov 2007 20:36:41 +0000 (04:36 +0800)]
KVM: Portability: Move KVM_INTERRUPT vcpu ioctl to x86.c
Other archs doesn't need it.
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Tue, 27 Nov 2007 17:30:56 +0000 (19:30 +0200)]
KVM: x86 emulator: unify four switch statements into two
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>
Avi Kivity [Tue, 27 Nov 2007 17:14:21 +0000 (19:14 +0200)]
KVM: x86 emulator: unify two switches
The rep prefix cleanup left two switch () statements next to each other.
Unify them.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Tue, 27 Nov 2007 17:05:37 +0000 (19:05 +0200)]
KVM: x86 emulator: Move rep processing before instruction execution
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>
Jerone Young [Mon, 26 Nov 2007 14:33:53 +0000 (08:33 -0600)]
KVM: Add ifdef in irqchip struct for x86 only structures
This patch fixes a small issue where sturctures:
kvm_pic_state
kvm_ioapic_state
are defined inside x86 specific code and may or may not
be defined in anyway for other architectures. The problem
caused is one cannot compile userspace apps (ex. libkvm)
for other archs since a size cannot be determined for these
structures.
Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Guillaume Thouvenin [Mon, 26 Nov 2007 12:49:09 +0000 (13:49 +0100)]
KVM: x86 emulator: cmps instruction
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>
Sheng Yang [Fri, 16 Nov 2007 08:29:15 +0000 (16:29 +0800)]
KVM: x86 emulator: Rename 'cr2' to 'memop'
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>
Izik Eidus [Mon, 26 Nov 2007 12:08:14 +0000 (14:08 +0200)]
KVM: MMU: mark pages that were inserted to the shadow pages table as accessed
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>
Avi Kivity [Sun, 25 Nov 2007 15:45:31 +0000 (17:45 +0200)]
KVM: Remove misleading check for mmio during event injection
mmio was already handled in kvm_arch_vcpu_ioctl_run(), so no need to check
again.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Thu, 22 Nov 2007 12:16:12 +0000 (14:16 +0200)]
KVM: x86 emulator: address size and operand size overrides are sticky
Current implementation is to toggle, which is incorrect. Patch ported from
corresponding Xen code.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Guillaume Thouvenin [Thu, 22 Nov 2007 10:32:09 +0000 (11:32 +0100)]
KVM: x86 emulator: Make a distinction between repeat prefixes F3 and F2
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>
Zhang Xiantao [Thu, 22 Nov 2007 03:20:33 +0000 (11:20 +0800)]
KVM: Portability: Move unalias_gfn to arch dependent file
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>
Sheng Yang [Wed, 21 Nov 2007 06:33:25 +0000 (14:33 +0800)]
KVM: VMX: Remove the secondary execute control dependency on irqchip
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>
Dan Kenigsberg [Wed, 21 Nov 2007 15:10:04 +0000 (17:10 +0200)]
KVM: Enhance guest cpuid management
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>
Avi Kivity [Wed, 21 Nov 2007 14:41:05 +0000 (16:41 +0200)]
KVM: Disallow fork() and similar games when using a VM
We don't want the meaning of guest userspace changing under our feet.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Wed, 21 Nov 2007 13:32:41 +0000 (15:32 +0200)]
KVM: MMU: Rename 'release_page'
Rename the awkwardly named variable.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Wed, 21 Nov 2007 13:28:32 +0000 (15:28 +0200)]
KVM: MMU: Rename variables of type 'struct kvm_mmu_page *'
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>
Avi Kivity [Wed, 21 Nov 2007 13:01:44 +0000 (15:01 +0200)]
KVM: Remove gpa_to_hpa()
Converting last uses along the way.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Wed, 21 Nov 2007 12:57:44 +0000 (14:57 +0200)]
KVM: MMU: Remove gva_to_hpa()
No longer used.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Wed, 21 Nov 2007 12:54:16 +0000 (14:54 +0200)]
KVM: MMU: Simplify nonpaging_map()
Instead of passing an hpa, pass a regular struct page.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Wed, 21 Nov 2007 12:44:45 +0000 (14:44 +0200)]
KVM: MMU: Introduce gfn_to_gpa()
Converting a frame number to an address is tricky since the data type changes
size. Introduce a function to do it. This fixes an actual bug when
accessing guest ptes.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Wed, 21 Nov 2007 12:20:22 +0000 (14:20 +0200)]
KVM: MMU: Adjust page_header_update_slot() to accept a gfn instead of a gpa
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Wed, 21 Nov 2007 12:16:30 +0000 (14:16 +0200)]
KVM: MMU: Merge set_pte() and set_pte_common()
Since set_pte() is now the only caller of set_pte_common(), merge the two
functions.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Wed, 21 Nov 2007 12:11:49 +0000 (14:11 +0200)]
KVM: MMU: Remove set_pde()
It is now identical to set_pte().
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Wed, 21 Nov 2007 12:08:40 +0000 (14:08 +0200)]
KVM: MMU: Remove extra gaddr parameter from set_pte_common()
Similar information is available in the gfn parameter, so use that.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Wed, 21 Nov 2007 11:54:47 +0000 (13:54 +0200)]
KVM: MMU: Move pse36 handling to the guest walker
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Wed, 21 Nov 2007 10:35:07 +0000 (12:35 +0200)]
KVM: MMU: Introduce and use gpte_to_gfn()
Instead of repretitively open-coding this.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Izik Eidus [Tue, 20 Nov 2007 10:02:12 +0000 (12:02 +0200)]
KVM: MMU: Code cleanup
Signed-off-by: Izik Eidus <izike@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Wed, 21 Nov 2007 00:57:59 +0000 (02:57 +0200)]
KVM: Don't bother the mmu if cr3 load doesn't change cr3
If the guest requests just a tlb flush, don't take the vm lock and
drop the mmu context pointlessly.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Wed, 21 Nov 2007 00:06:21 +0000 (02:06 +0200)]
KVM: MMU: Avoid unnecessary remote tlb flushes when guest updates a pte
If all we're doing is increasing permissions on a pte (typical for demand
paging), then there's not need to flush remote tlbs. Worst case they'll
get a spurious page fault.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Tue, 20 Nov 2007 21:01:14 +0000 (23:01 +0200)]
KVM: Add statistic for remote tlb flushes
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Tue, 20 Nov 2007 19:39:54 +0000 (21:39 +0200)]
KVM: MMU: Implement guest page fault bypass for nonpae
I spent an hour worrying why I see so many guest page faults on FC6 i386.
Turns out bypass wasn't implemented for nonpae. Implement it so it doesn't
happen again.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Tue, 20 Nov 2007 13:30:24 +0000 (15:30 +0200)]
KVM: Split vcpu creation to avoid vcpu_load() before preemption setup
Split kvm_arch_vcpu_create() into kvm_arch_vcpu_create() and
kvm_arch_vcpu_setup(), enabling preemption notification between the two.
This mean that we can now do vcpu_load() within kvm_arch_vcpu_setup().
Signed-off-by: Avi Kivity <avi@qumranet.com>
Zhang Xiantao [Tue, 20 Nov 2007 08:25:04 +0000 (16:25 +0800)]
KVM: Portability: Split kvm_set_memory_region() to have an arch callout
Moving !user_alloc case to kvm_arch to avoid unnecessary
code logic in non-x86 platform.
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Zhang Xiantao [Tue, 20 Nov 2007 05:11:38 +0000 (13:11 +0800)]
KVM: Recalculate mmu pages needed for every memory region change
Instead of incrementally changing the mmu cache size for every memory slot
operation, recalculate it from scratch. This is simpler and safer.
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Tue, 20 Nov 2007 11:15:52 +0000 (13:15 +0200)]
KVM: x86 emulator: prefetch up to 15 bytes of the instruction executed
Instead of fetching one byte at a time, prefetch 15 bytes (or until the next
page boundary) to avoid guest page table walks.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Tue, 20 Nov 2007 10:49:31 +0000 (12:49 +0200)]
KVM: x86 emulator: retire ->write_std()
Theoretically used to acccess memory known to be ordinary RAM, it was
never implemented. It is questionable whether it is possible to implement
it correctly.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Izik Eidus [Tue, 20 Nov 2007 09:49:33 +0000 (11:49 +0200)]
KVM: MMU: Selectively set PageDirty when releasing guest memory
Improve dirty bit setting for pages that kvm release, until now every page
that we released we marked dirty, from now only pages that have potential
to get dirty we mark dirty.
Signed-off-by: Izik Eidus <izike@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Izik Eidus [Tue, 20 Nov 2007 09:30:04 +0000 (11:30 +0200)]
KVM: MMU: Fix potential memory leak with smp real-mode
When we map a page, we check whether some other vcpu mapped it for us and if
so, bail out. But we should decrease the refcount on the page as we do so.
Signed-off-by: Izik Eidus <izike@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Tue, 20 Nov 2007 09:45:14 +0000 (11:45 +0200)]
KVM: Export include/asm-x86/kvm.h
Signed-off-by: Avi Kivity <avi@qumranet.com>
Jerone Young [Mon, 19 Nov 2007 23:06:37 +0000 (17:06 -0600)]
KVM: Portability: Move cpuid structures to <asm/kvm.h>
This patch moves structures:
kvm_cpuid_entry
kvm_cpuid
from include/linux/kvm.h to include/asm-x86/kvm.h
Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Jerone Young [Mon, 19 Nov 2007 23:06:36 +0000 (17:06 -0600)]
KVM: Portability: Move kvm_sregs and msr structures to <asm/kvm.h>
Move structures:
kvm_sregs
kvm_msr_entry
kvm_msrs
kvm_msr_list
from include/linux/kvm.h to include/asm-x86/kvm.h
Signed-off-by: Avi Kivity <avi@qumranet.com>
Jerone Young [Mon, 19 Nov 2007 23:06:35 +0000 (17:06 -0600)]
KVM: Portability: Move kvm_segment & kvm_dtable structure to <asm/kvm.h>
This patch moves structures:
kvm_segment
kvm_dtable
from include/linux/kvm.h to include/asm-x86/kvm.h
Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Jerone Young [Mon, 19 Nov 2007 23:06:34 +0000 (17:06 -0600)]
KVM: Portability: Move structure lapic_state to <asm/kvm.h>
This patch moves structure lapic_state from include/linux/kvm.h
to include/asm-x86/kvm.h
Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Jerone Young [Mon, 19 Nov 2007 23:06:33 +0000 (17:06 -0600)]
KVM: Portability: Move kvm_regs to <asm/kvm.h>
This patch moves structure kvm_regs to include/asm-x86/kvm.h.
Each architecture will need to create there own version of this
structure.
Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Jerone Young [Mon, 19 Nov 2007 23:06:32 +0000 (17:06 -0600)]
KVM: Portability: Move x86 pic strutctures
This patch moves structures:
kvm_pic_state
kvm_ioapic_state
to inclue/asm-x86/kvm.h.
Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Jerone Young [Mon, 19 Nov 2007 23:06:31 +0000 (17:06 -0600)]
KVM: Portability: Move kvm_memory_alias to asm/kvm.h
This patch moves sturct kvm_memory_alias from include/linux/kvm.h
to include/asm-x86/kvm.h. Also have include/linux/kvm.h include
include/asm/kvm.h.
Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Hollis Blanchard [Mon, 19 Nov 2007 20:04:44 +0000 (14:04 -0600)]
KVM: Move misplaced comment
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Hollis Blanchard [Mon, 19 Nov 2007 20:04:43 +0000 (14:04 -0600)]
KVM: Correct consistent typo: "destory" -> "destroy"
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Hollis Blanchard [Mon, 19 Nov 2007 20:04:45 +0000 (14:04 -0600)]
KVM: Remove unused "rmap_overflow" variable
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Mon, 19 Nov 2007 16:44:15 +0000 (18:44 +0200)]
KVM: MMU: Remove unused variable
Signed-off-by: Avi Kivity <avi@qumranet.com>
Izik Eidus [Mon, 19 Nov 2007 09:16:57 +0000 (11:16 +0200)]
KVM: Simplify kvm_clear_guest_page()
Use kvm_write_guest_page() with empty_zero_page, instead of doing
kmap and memset.
Signed-off-by: Izik Eidus <izike@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Izik Eidus [Mon, 19 Nov 2007 09:28:19 +0000 (11:28 +0200)]
KVM: MMU: Change guest pte access to kvm_{read,write}_guest()
Things are simpler and more regular this way.
Signed-off-by: Izik Eidus <izike@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Jan Kiszka [Mon, 19 Nov 2007 09:21:45 +0000 (10:21 +0100)]
KVM: VMX: Force seg.base == (seg.sel << 4) in real mode
Ensure that segment.base == segment.selector << 4 when entering the real
mode on Intel so that the CPU will not bark at us. This fixes some old
protected mode demo from http://www.x86.org/articles/pmbasics/tspec_a1_doc.htm.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Zhang Xiantao [Mon, 19 Nov 2007 07:24:28 +0000 (15:24 +0800)]
KVM: Portability: Move some function declarations to x86.h
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Zhang Xiantao [Mon, 19 Nov 2007 07:08:31 +0000 (15:08 +0800)]
KVM: Move some static inline functions out from kvm.h into x86.h
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Zhang Xiantao [Mon, 19 Nov 2007 06:56:05 +0000 (14:56 +0800)]
KVM: Portability: Move vcpu regs enumeration definition to x86.h
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>