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>
Zhang Xiantao [Mon, 19 Nov 2007 06:40:47 +0000 (14:40 +0800)]
KVM: Portability: Move struct kvm_x86_ops definition 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 06:33:37 +0000 (14:33 +0800)]
KVM: Portability: Move some macro definitions from kvm.h to x86.h
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Zhang Xiantao [Sun, 18 Nov 2007 12:43:21 +0000 (20:43 +0800)]
KVM: Portability: MMU initialization and teardown split
Move out kvm_mmu init and exit functionality from kvm_main.c
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Zhang Xiantao [Sun, 18 Nov 2007 12:29:43 +0000 (20:29 +0800)]
KVM: Portability: Move kvm_vcpu_ioctl_get_dirty_log to arch-specific file
Meanwhile keep the interface in common, and leave as more logic in common
as possible.
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Amit Shah [Thu, 15 Nov 2007 16:38:46 +0000 (18:38 +0200)]
KVM: Make unloading of FPU state when putting vcpu arch-independent
Instead of having each architecture do it individually, we
do this in the arch-independent code (just x86 as of now).
[avi: add svm to the mix, which was added to mainline during the
2.6.24-rc process]
Signed-off-by: Amit Shah <amit.shah@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Sun, 18 Nov 2007 14:37:07 +0000 (16:37 +0200)]
KVM: MMU: Add some mmu statistics
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Sun, 18 Nov 2007 14:24:12 +0000 (16:24 +0200)]
KVM: Extend stats support for VM stats
This is in addition to the current virtual cpu statistics.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Sun, 18 Nov 2007 13:17:51 +0000 (15:17 +0200)]
KVM: Add instruction emulation statistics
Avi Kivity [Sun, 18 Nov 2007 11:54:33 +0000 (13:54 +0200)]
KVM: Add fpu_reload counter
Measure the number of times we switch the fpu state.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Sun, 18 Nov 2007 11:50:24 +0000 (13:50 +0200)]
KVM: Replace 'light_exits' stat with 'host_state_reload'
This is a little more accurate (since it counts actual reloads, not potential
reloads), and reverses the sense of the statistic to measure a bad event like
most of the other stats (e.g. we want to minimize all counters).
Signed-off-by: Avi Kivity <avi@qumranet.com>
Zhang Xiantao [Sun, 18 Nov 2007 10:43:45 +0000 (18:43 +0800)]
KVM: Portability: Add two hooks to handle kvm_create and destroy vm
Add two arch hooks to handle kvm_create_vm and kvm destroy_vm. Now, just
put io_bus init and destory in common.
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Zhang Xiantao [Fri, 16 Nov 2007 06:38:21 +0000 (14:38 +0800)]
KVM: Remove __init attributes for kvm_init_debug and kvm_init_msr_list
Since their callers are not declared with __init.
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Joe Perches [Tue, 13 Nov 2007 04:06:51 +0000 (20:06 -0800)]
KVM: Remove ptr comparisons to 0
Fix sparse warnings "Using plain integer as NULL pointer"
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Zhang Xiantao [Fri, 16 Nov 2007 05:05:55 +0000 (13:05 +0800)]
KVM: Portability: Make kvm_vcpu_ioctl_translate arch dependent
Move kvm_vcpu_ioctl_translate to arch, since mmu would be put under arch.
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Thu, 15 Nov 2007 16:06:18 +0000 (18:06 +0200)]
KVM: VMX: Consolidate register usage in vmx_vcpu_run()
We pass vcpu, vmx->fail, and vmx->launched to assembly code, but all three
are fields within vmx. Consolidate by only passing in vmx and offsets for
the rest.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Zhang Xiantao [Thu, 15 Nov 2007 15:07:47 +0000 (23:07 +0800)]
KVM: Portability: move KVM_CHECK_EXTENSION
Make KVM_CHECK_EXTENSION code into a function, all archs can define its
capability independently.
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 [Thu, 15 Nov 2007 06:52:28 +0000 (14:52 +0800)]
KVM: x86 emulator: modify 'lods', and 'stos' not to depend on CR2
The current 'lods' and 'stos' is depending on incoming CR2 rather than decode
memory address from registers.
Signed-off-by: Sheng Yang <sheng.yang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Zhang Xiantao [Wed, 14 Nov 2007 12:40:21 +0000 (20:40 +0800)]
KVM: Portability: Move x86 specific code from kvm_init() to kvm_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 [Wed, 14 Nov 2007 12:39:31 +0000 (20:39 +0800)]
KVM: Portability: Combine kvm_init and kvm_init_x86
Will be called once arch module registers itself.
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 [Wed, 14 Nov 2007 12:38:21 +0000 (20:38 +0800)]
KVM: Portability: Add vcpu and hardware management arch hooks
Add the following hooks:
void decache_vcpus_on_cpu(int cpu);
int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu);
void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu);
void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu);
struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id);
void kvm_arch_vcpu_destory(struct kvm_vcpu *vcpu);
int kvm_arch_vcpu_reset(struct kvm_vcpu *vcpu);
void kvm_arch_hardware_enable(void *garbage);
void kvm_arch_hardware_disable(void *garbage);
int kvm_arch_hardware_setup(void);
void kvm_arch_hardware_unsetup(void);
void kvm_arch_check_processor_compat(void *rtn);
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Zhang Xiantao [Wed, 14 Nov 2007 12:09:30 +0000 (20:09 +0800)]
KVM: Portability: Move kvm_x86_ops to x86.c
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 [Wed, 14 Nov 2007 12:08:51 +0000 (20:08 +0800)]
KVM: Portability: Move some includes to x86.c
Move some includes to x86.c from kvm_main.c, since the related functions
have been moved to x86.c
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>
Izik Eidus [Sun, 11 Nov 2007 20:10:22 +0000 (22:10 +0200)]
KVM: Change kvm_{read,write}_guest() to use copy_{from,to}_user()
This changes kvm_write_guest_page/kvm_read_guest_page to use
copy_to_user/read_from_user, as a result we get better speed
and better dirty bit tracking.
Signed-off-by: Izik Eidus <izike@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Izik Eidus [Sun, 11 Nov 2007 20:05:04 +0000 (22:05 +0200)]
KVM: introduce gfn_to_hva()
Convert a guest frame number to the corresponding host virtual address.
Signed-off-by: Izik Eidus <izike@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Izik Eidus [Sun, 11 Nov 2007 20:02:22 +0000 (22:02 +0200)]
KVM: add kvm_is_error_hva()
Check for the "error hva", an address outside the user address space that
signals a bad gfn.
Signed-off-by: Izik Eidus <izike@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Sun, 11 Nov 2007 16:37:32 +0000 (18:37 +0200)]
KVM: Simplify CPU_TASKS_FROZEN cpu notifier handling
Signed-off-by: Avi Kivity <avi@qumranet.com>
Izik Eidus [Sun, 11 Nov 2007 12:48:17 +0000 (14:48 +0200)]
KVM: x86 emulator: remove 8 bytes operands emulator for call near instruction
it is removed beacuse it isnt supported on a real host
Signed-off-by: Izik Eidus <izike@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Eddie Dong [Sun, 11 Nov 2007 10:28:35 +0000 (12:28 +0200)]
KVM: VMX: wbinvd exiting
Add wbinvd VM Exit support to prepare for pass-through
device cache emulation and also enhance real time
responsiveness.
Signed-off-by: Yaozu (Eddie) Dong <eddie.dong@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Eddie Dong [Sun, 11 Nov 2007 10:27:20 +0000 (12:27 +0200)]
KVM: VMX: Comment VMX primary/secondary exec ctl definitions
Add comments for secondary/primary Processor-Based VM-execution controls.
Signed-off-by: Yaozu (Eddie) Dong <eddie.dong@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Thu, 22 Nov 2007 09:42:59 +0000 (11:42 +0200)]
KVM: Fix faults during injection of real-mode interrupts
If vmx fails to inject a real-mode interrupt while fetching the interrupt
redirection table, it fails to record this in the vectoring information
field. So we detect this condition and do it ourselves.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Thu, 22 Nov 2007 09:30:47 +0000 (11:30 +0200)]
KVM: VMX: Read & store IDT_VECTORING_INFO_FIELD
We'll want to write to it in order to fix real-mode irq injection problems,
but it is a read-only field. Storing it in a variable solves that issue.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Thu, 8 Nov 2007 16:19:20 +0000 (18:19 +0200)]
KVM: VMX: Use vmx to inject real-mode interrupts
Instead of injecting real-mode interrupts by writing the interrupt frame into
guest memory, abuse vmx by injecting a software interrupt. We need to
pretend the software interrupt instruction had a length > 0, so we have to
adjust rip backward.
This lets us not to mess with writing guest memory, which is complex and also
sleeps.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Dor Laor [Wed, 7 Nov 2007 14:20:06 +0000 (16:20 +0200)]
KVM: Add make_page_dirty() to kvm_clear_guest_page()
Every write access to guest pages should be tracked.
Signed-off-by: Dor Laor <dor.laor@qumranet.com>
Signed-off-by: Izik Eidus <izike@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Hollis Blanchard [Thu, 1 Nov 2007 19:16:10 +0000 (14:16 -0500)]
KVM: Portability: Move x86 vcpu ioctl handlers to x86.c
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Hollis Blanchard [Wed, 31 Oct 2007 22:24:25 +0000 (17:24 -0500)]
KVM: Portability: Move x86 FPU handling to x86.c
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Hollis Blanchard [Wed, 31 Oct 2007 22:24:24 +0000 (17:24 -0500)]
KVM: Portability: Move x86 instruction emulation code to x86.c
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Hollis Blanchard [Wed, 31 Oct 2007 22:24:23 +0000 (17:24 -0500)]
KVM: Portability: Make exported debugfs data architecture-specific
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Thu, 1 Nov 2007 04:31:28 +0000 (06:31 +0200)]
KVM: x86 emulator: Hoist modrm and abs decoding into separate functions
Signed-off-by: Avi Kivity <avi@qumranet.com>