[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
/*
* Kernel - based Virtual Machine driver for Linux
*
* This module enables machines with Intel VT - x extensions to run virtual
* machines without emulation or binary translation .
*
* Copyright ( C ) 2006 Qumranet , Inc .
2010-10-06 16:23:22 +04:00
* Copyright 2010 Red Hat , Inc . and / or its affiliates .
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
*
* Authors :
* Avi Kivity < avi @ qumranet . com >
* Yaniv Kamay < yaniv @ qumranet . com >
*
* This work is licensed under the terms of the GNU GPL , version 2. See
* the COPYING file in the top - level directory .
*
*/
2015-03-26 17:39:29 +03:00
# include <kvm/iodev.h>
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
2007-12-16 12:02:48 +03:00
# include <linux/kvm_host.h>
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
# include <linux/kvm.h>
# include <linux/module.h>
# include <linux/errno.h>
# include <linux/percpu.h>
# include <linux/mm.h>
# include <linux/miscdevice.h>
# include <linux/vmalloc.h>
# include <linux/reboot.h>
# include <linux/debugfs.h>
# include <linux/highmem.h>
# include <linux/file.h>
2011-03-24 00:16:23 +03:00
# include <linux/syscore_ops.h>
2007-02-12 11:54:47 +03:00
# include <linux/cpu.h>
Detach sched.h from mm.h
First thing mm.h does is including sched.h solely for can_do_mlock() inline
function which has "current" dereference inside. By dealing with can_do_mlock()
mm.h can be detached from sched.h which is good. See below, why.
This patch
a) removes unconditional inclusion of sched.h from mm.h
b) makes can_do_mlock() normal function in mm/mlock.c
c) exports can_do_mlock() to not break compilation
d) adds sched.h inclusions back to files that were getting it indirectly.
e) adds less bloated headers to some files (asm/signal.h, jiffies.h) that were
getting them indirectly
Net result is:
a) mm.h users would get less code to open, read, preprocess, parse, ... if
they don't need sched.h
b) sched.h stops being dependency for significant number of files:
on x86_64 allmodconfig touching sched.h results in recompile of 4083 files,
after patch it's only 3744 (-8.3%).
Cross-compile tested on
all arm defconfigs, all mips defconfigs, all powerpc defconfigs,
alpha alpha-up
arm
i386 i386-up i386-defconfig i386-allnoconfig
ia64 ia64-up
m68k
mips
parisc parisc-up
powerpc powerpc-up
s390 s390-up
sparc sparc-up
sparc64 sparc64-up
um-x86_64
x86_64 x86_64-up x86_64-defconfig x86_64-allnoconfig
as well as my two usual configs.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-21 01:22:52 +04:00
# include <linux/sched.h>
2007-06-07 20:18:30 +04:00
# include <linux/cpumask.h>
# include <linux/smp.h>
2007-06-28 16:38:16 +04:00
# include <linux/anon_inodes.h>
2007-09-10 19:10:54 +04:00
# include <linux/profile.h>
2007-09-17 23:57:50 +04:00
# include <linux/kvm_para.h>
2007-10-09 21:20:39 +04:00
# include <linux/pagemap.h>
2007-10-18 18:59:34 +04:00
# include <linux/mman.h>
2008-04-02 23:46:56 +04:00
# include <linux/swap.h>
2009-03-12 16:45:39 +03:00
# include <linux/bitops.h>
2009-05-08 00:55:13 +04:00
# include <linux/spinlock.h>
2009-10-22 16:19:27 +04:00
# include <linux/compat.h>
2009-12-23 19:35:21 +03:00
# include <linux/srcu.h>
2010-01-28 14:37:56 +03:00
# include <linux/hugetlb.h>
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 11:04:11 +03:00
# include <linux/slab.h>
2011-07-27 17:00:48 +04:00
# include <linux/sort.h>
# include <linux/bsearch.h>
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
2007-06-28 22:15:57 +04:00
# include <asm/processor.h>
# include <asm/io.h>
2014-09-20 03:03:25 +04:00
# include <asm/ioctl.h>
2007-06-28 22:15:57 +04:00
# include <asm/uaccess.h>
2007-11-19 12:16:57 +03:00
# include <asm/pgtable.h>
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
2008-05-30 18:05:54 +04:00
# include "coalesced_mmio.h"
2010-10-14 13:22:46 +04:00
# include "async_pf.h"
2014-09-24 15:02:46 +04:00
# include "vfio.h"
2008-05-30 18:05:54 +04:00
2009-06-17 16:22:14 +04:00
# define CREATE_TRACE_POINTS
# include <trace/events/kvm.h>
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
MODULE_AUTHOR ( " Qumranet " ) ;
MODULE_LICENSE ( " GPL " ) ;
2015-02-27 18:50:10 +03:00
static unsigned int halt_poll_ns ;
kvm: add halt_poll_ns module parameter
This patch introduces a new module parameter for the KVM module; when it
is present, KVM attempts a bit of polling on every HLT before scheduling
itself out via kvm_vcpu_block.
This parameter helps a lot for latency-bound workloads---in particular
I tested it with O_DSYNC writes with a battery-backed disk in the host.
In this case, writes are fast (because the data doesn't have to go all
the way to the platters) but they cannot be merged by either the host or
the guest. KVM's performance here is usually around 30% of bare metal,
or 50% if you use cache=directsync or cache=writethrough (these
parameters avoid that the guest sends pointless flush requests, and
at the same time they are not slow because of the battery-backed cache).
The bad performance happens because on every halt the host CPU decides
to halt itself too. When the interrupt comes, the vCPU thread is then
migrated to a new physical CPU, and in general the latency is horrible
because the vCPU thread has to be scheduled back in.
With this patch performance reaches 60-65% of bare metal and, more
important, 99% of what you get if you use idle=poll in the guest. This
means that the tunable gets rid of this particular bottleneck, and more
work can be done to improve performance in the kernel or QEMU.
Of course there is some price to pay; every time an otherwise idle vCPUs
is interrupted by an interrupt, it will poll unnecessarily and thus
impose a little load on the host. The above results were obtained with
a mostly random value of the parameter (500000), and the load was around
1.5-2.5% CPU usage on one of the host's core for each idle guest vCPU.
The patch also adds a new stat, /sys/kernel/debug/kvm/halt_successful_poll,
that can be used to tune the parameter. It counts how many HLT
instructions received an interrupt during the polling period; each
successful poll avoids that Linux schedules the VCPU thread out and back
in, and may also avoid a likely trip to C1 and back for the physical CPU.
While the VM is idle, a Linux 4 VCPU VM halts around 10 times per second.
Of these halts, almost all are failed polls. During the benchmark,
instead, basically all halts end within the polling period, except a more
or less constant stream of 50 per second coming from vCPUs that are not
running the benchmark. The wasted time is thus very low. Things may
be slightly different for Windows VMs, which have a ~10 ms timer tick.
The effect is also visible on Marcelo's recently-introduced latency
test for the TSC deadline timer. Though of course a non-RT kernel has
awful latency bounds, the latency of the timer is around 8000-10000 clock
cycles compared to 20000-120000 without setting halt_poll_ns. For the TSC
deadline timer, thus, the effect is both a smaller average latency and
a smaller variance.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2015-02-04 20:20:58 +03:00
module_param ( halt_poll_ns , uint , S_IRUGO | S_IWUSR ) ;
2009-06-04 22:08:24 +04:00
/*
* Ordering of locks :
*
2015-02-26 09:58:24 +03:00
* kvm - > lock - - > kvm - > slots_lock - - > kvm - > irq_lock
2009-06-04 22:08:24 +04:00
*/
2013-09-25 15:53:07 +04:00
DEFINE_SPINLOCK ( kvm_lock ) ;
2013-09-10 14:58:35 +04:00
static DEFINE_RAW_SPINLOCK ( kvm_count_lock ) ;
2007-11-14 15:38:21 +03:00
LIST_HEAD ( vm_list ) ;
2007-02-12 11:54:44 +03:00
2008-12-07 13:55:45 +03:00
static cpumask_var_t cpus_hardware_enabled ;
2015-02-26 09:58:21 +03:00
static int kvm_usage_count ;
2009-09-15 13:37:46 +04:00
static atomic_t hardware_enable_failed ;
2007-05-24 14:03:52 +04:00
2007-07-30 15:12:19 +04:00
struct kmem_cache * kvm_vcpu_cache ;
EXPORT_SYMBOL_GPL ( kvm_vcpu_cache ) ;
2007-04-19 18:27:43 +04:00
2007-07-11 19:17:21 +04:00
static __read_mostly struct preempt_ops kvm_preempt_ops ;
2008-04-16 01:05:42 +04:00
struct dentry * kvm_debugfs_dir ;
2015-03-28 06:21:01 +03:00
EXPORT_SYMBOL_GPL ( kvm_debugfs_dir ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
2007-02-21 19:04:26 +03:00
static long kvm_vcpu_ioctl ( struct file * file , unsigned int ioctl ,
unsigned long arg ) ;
2015-02-03 11:35:15 +03:00
# ifdef CONFIG_KVM_COMPAT
2011-06-08 04:45:37 +04:00
static long kvm_vcpu_compat_ioctl ( struct file * file , unsigned int ioctl ,
unsigned long arg ) ;
# endif
2009-09-15 13:37:46 +04:00
static int hardware_enable_all ( void ) ;
static void hardware_disable_all ( void ) ;
2007-02-21 19:04:26 +03:00
2009-12-23 19:35:24 +03:00
static void kvm_io_bus_destroy ( struct kvm_io_bus * bus ) ;
2013-12-30 00:12:29 +04:00
static void kvm_release_pfn_dirty ( pfn_t pfn ) ;
2015-05-26 13:43:41 +03:00
static void mark_page_dirty_in_slot ( struct kvm_memory_slot * memslot , gfn_t gfn ) ;
2009-12-23 19:35:24 +03:00
2014-02-08 11:51:57 +04:00
__visible bool kvm_rebooting ;
2010-12-02 18:52:50 +03:00
EXPORT_SYMBOL_GPL ( kvm_rebooting ) ;
2008-05-13 14:23:38 +04:00
2009-06-11 19:07:44 +04:00
static bool largepages_enabled = true ;
2014-11-10 11:33:56 +03:00
bool kvm_is_reserved_pfn ( pfn_t pfn )
2008-07-28 20:26:24 +04:00
{
2013-07-25 05:04:38 +04:00
if ( pfn_valid ( pfn ) )
2014-11-10 11:33:56 +03:00
return PageReserved ( pfn_to_page ( pfn ) ) ;
2008-07-28 20:26:24 +04:00
return true ;
}
2007-02-21 19:04:26 +03:00
/*
* Switches to specified vcpu , until a matching vcpu_put ( )
*/
2012-09-16 12:50:30 +04:00
int vcpu_load ( struct kvm_vcpu * vcpu )
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
{
2007-07-11 19:17:21 +04:00
int cpu ;
2012-09-16 12:50:30 +04:00
if ( mutex_lock_killable ( & vcpu - > mutex ) )
return - EINTR ;
2007-07-11 19:17:21 +04:00
cpu = get_cpu ( ) ;
preempt_notifier_register ( & vcpu - > preempt_notifier ) ;
KVM: Portability: split kvm_vcpu_ioctl
This patch splits kvm_vcpu_ioctl into archtecture independent parts, and
x86 specific parts which go to kvm_arch_vcpu_ioctl in x86.c.
Common ioctls for all architectures are:
KVM_RUN, KVM_GET/SET_(S-)REGS, KVM_TRANSLATE, KVM_INTERRUPT,
KVM_DEBUG_GUEST, KVM_SET_SIGNAL_MASK, KVM_GET/SET_FPU
Note that some PPC chips don't have an FPU, so we might need an #ifdef
around KVM_GET/SET_FPU one day.
x86 specific ioctls are:
KVM_GET/SET_LAPIC, KVM_SET_CPUID, KVM_GET/SET_MSRS
An interresting aspect is vcpu_load/vcpu_put. We now have a common
vcpu_load/put which does the preemption stuff, and an architecture
specific kvm_arch_vcpu_load/put. In the x86 case, this one calls the
vmx/svm function defined in kvm_x86_ops.
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
2007-10-11 21:16:52 +04:00
kvm_arch_vcpu_load ( vcpu , cpu ) ;
2007-07-11 19:17:21 +04:00
put_cpu ( ) ;
2012-09-16 12:50:30 +04:00
return 0 ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
}
KVM: Portability: split kvm_vcpu_ioctl
This patch splits kvm_vcpu_ioctl into archtecture independent parts, and
x86 specific parts which go to kvm_arch_vcpu_ioctl in x86.c.
Common ioctls for all architectures are:
KVM_RUN, KVM_GET/SET_(S-)REGS, KVM_TRANSLATE, KVM_INTERRUPT,
KVM_DEBUG_GUEST, KVM_SET_SIGNAL_MASK, KVM_GET/SET_FPU
Note that some PPC chips don't have an FPU, so we might need an #ifdef
around KVM_GET/SET_FPU one day.
x86 specific ioctls are:
KVM_GET/SET_LAPIC, KVM_SET_CPUID, KVM_GET/SET_MSRS
An interresting aspect is vcpu_load/vcpu_put. We now have a common
vcpu_load/put which does the preemption stuff, and an architecture
specific kvm_arch_vcpu_load/put. In the x86 case, this one calls the
vmx/svm function defined in kvm_x86_ops.
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
2007-10-11 21:16:52 +04:00
void vcpu_put ( struct kvm_vcpu * vcpu )
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
{
2007-07-11 19:17:21 +04:00
preempt_disable ( ) ;
KVM: Portability: split kvm_vcpu_ioctl
This patch splits kvm_vcpu_ioctl into archtecture independent parts, and
x86 specific parts which go to kvm_arch_vcpu_ioctl in x86.c.
Common ioctls for all architectures are:
KVM_RUN, KVM_GET/SET_(S-)REGS, KVM_TRANSLATE, KVM_INTERRUPT,
KVM_DEBUG_GUEST, KVM_SET_SIGNAL_MASK, KVM_GET/SET_FPU
Note that some PPC chips don't have an FPU, so we might need an #ifdef
around KVM_GET/SET_FPU one day.
x86 specific ioctls are:
KVM_GET/SET_LAPIC, KVM_SET_CPUID, KVM_GET/SET_MSRS
An interresting aspect is vcpu_load/vcpu_put. We now have a common
vcpu_load/put which does the preemption stuff, and an architecture
specific kvm_arch_vcpu_load/put. In the x86 case, this one calls the
vmx/svm function defined in kvm_x86_ops.
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
2007-10-11 21:16:52 +04:00
kvm_arch_vcpu_put ( vcpu ) ;
2007-07-11 19:17:21 +04:00
preempt_notifier_unregister ( & vcpu - > preempt_notifier ) ;
preempt_enable ( ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
mutex_unlock ( & vcpu - > mutex ) ;
}
2007-06-07 20:18:30 +04:00
static void ack_flush ( void * _completed )
{
}
2014-09-24 11:57:55 +04:00
bool kvm_make_all_cpus_request ( struct kvm * kvm , unsigned int req )
2007-06-07 20:18:30 +04:00
{
2008-07-20 15:24:22 +04:00
int i , cpu , me ;
2008-12-08 12:58:04 +03:00
cpumask_var_t cpus ;
bool called = true ;
2007-06-07 20:18:30 +04:00
struct kvm_vcpu * vcpu ;
2009-06-15 10:58:26 +04:00
zalloc_cpumask_var ( & cpus , GFP_ATOMIC ) ;
2008-12-08 12:58:04 +03:00
2011-01-12 10:41:22 +03:00
me = get_cpu ( ) ;
2009-06-09 16:56:29 +04:00
kvm_for_each_vcpu ( i , vcpu , kvm ) {
2011-01-12 10:41:22 +03:00
kvm_make_request ( req , vcpu ) ;
2007-06-07 20:18:30 +04:00
cpu = vcpu - > cpu ;
2011-01-12 10:40:31 +03:00
/* Set ->requests bit before we read ->mode */
smp_mb ( ) ;
if ( cpus ! = NULL & & cpu ! = - 1 & & cpu ! = me & &
kvm_vcpu_exiting_guest_mode ( vcpu ) ! = OUTSIDE_GUEST_MODE )
2008-12-08 12:58:04 +03:00
cpumask_set_cpu ( cpu , cpus ) ;
2008-12-08 12:56:24 +03:00
}
2008-12-08 12:58:04 +03:00
if ( unlikely ( cpus = = NULL ) )
smp_call_function_many ( cpu_online_mask , ack_flush , NULL , 1 ) ;
else if ( ! cpumask_empty ( cpus ) )
smp_call_function_many ( cpus , ack_flush , NULL , 1 ) ;
else
called = false ;
2011-01-12 10:41:22 +03:00
put_cpu ( ) ;
2008-12-08 12:58:04 +03:00
free_cpumask_var ( cpus ) ;
2008-12-08 12:56:24 +03:00
return called ;
2007-06-07 20:18:30 +04:00
}
2015-01-16 02:58:52 +03:00
# ifndef CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL
2008-12-08 12:56:24 +03:00
void kvm_flush_remote_tlbs ( struct kvm * kvm )
2008-02-20 22:47:24 +03:00
{
2014-04-17 13:06:12 +04:00
long dirty_count = kvm - > tlbs_dirty ;
smp_mb ( ) ;
2014-09-24 11:57:55 +04:00
if ( kvm_make_all_cpus_request ( kvm , KVM_REQ_TLB_FLUSH ) )
2008-12-08 12:56:24 +03:00
+ + kvm - > stat . remote_tlb_flush ;
2014-04-17 13:06:12 +04:00
cmpxchg ( & kvm - > tlbs_dirty , dirty_count , 0 ) ;
2008-02-20 22:47:24 +03:00
}
2013-10-07 20:47:59 +04:00
EXPORT_SYMBOL_GPL ( kvm_flush_remote_tlbs ) ;
2015-01-16 02:58:52 +03:00
# endif
2008-02-20 22:47:24 +03:00
2008-12-08 12:56:24 +03:00
void kvm_reload_remote_mmus ( struct kvm * kvm )
{
2014-09-24 11:57:55 +04:00
kvm_make_all_cpus_request ( kvm , KVM_REQ_MMU_RELOAD ) ;
2008-12-08 12:56:24 +03:00
}
2008-02-20 22:47:24 +03:00
2012-11-28 05:29:01 +04:00
void kvm_make_mclock_inprogress_request ( struct kvm * kvm )
{
2014-09-24 11:57:55 +04:00
kvm_make_all_cpus_request ( kvm , KVM_REQ_MCLOCK_INPROGRESS ) ;
2012-11-28 05:29:01 +04:00
}
2013-04-11 15:25:13 +04:00
void kvm_make_scan_ioapic_request ( struct kvm * kvm )
2013-01-25 06:18:51 +04:00
{
2014-09-24 11:57:55 +04:00
kvm_make_all_cpus_request ( kvm , KVM_REQ_SCAN_IOAPIC ) ;
2013-01-25 06:18:51 +04:00
}
2007-07-27 11:16:56 +04:00
int kvm_vcpu_init ( struct kvm_vcpu * vcpu , struct kvm * kvm , unsigned id )
{
struct page * page ;
int r ;
mutex_init ( & vcpu - > mutex ) ;
vcpu - > cpu = - 1 ;
vcpu - > kvm = kvm ;
vcpu - > vcpu_id = id ;
2011-02-01 17:52:41 +03:00
vcpu - > pid = NULL ;
2007-07-18 13:15:21 +04:00
init_waitqueue_head ( & vcpu - > wq ) ;
2010-10-14 13:22:46 +04:00
kvm_async_pf_vcpu_init ( vcpu ) ;
2007-07-27 11:16:56 +04:00
page = alloc_page ( GFP_KERNEL | __GFP_ZERO ) ;
if ( ! page ) {
r = - ENOMEM ;
goto fail ;
}
vcpu - > run = page_address ( page ) ;
2012-07-18 17:37:46 +04:00
kvm_vcpu_set_in_spin_loop ( vcpu , false ) ;
kvm_vcpu_set_dy_eligible ( vcpu , false ) ;
2013-03-04 22:02:07 +04:00
vcpu - > preempted = false ;
2012-07-18 17:37:46 +04:00
2007-11-14 15:38:21 +03:00
r = kvm_arch_vcpu_init ( vcpu ) ;
2007-07-27 11:16:56 +04:00
if ( r < 0 )
2007-11-14 15:38:21 +03:00
goto fail_free_run ;
2007-07-27 11:16:56 +04:00
return 0 ;
fail_free_run :
free_page ( ( unsigned long ) vcpu - > run ) ;
fail :
2007-10-08 04:50:48 +04:00
return r ;
2007-07-27 11:16:56 +04:00
}
EXPORT_SYMBOL_GPL ( kvm_vcpu_init ) ;
void kvm_vcpu_uninit ( struct kvm_vcpu * vcpu )
{
2011-02-01 17:52:41 +03:00
put_pid ( vcpu - > pid ) ;
2007-11-14 15:38:21 +03:00
kvm_arch_vcpu_uninit ( vcpu ) ;
2007-07-27 11:16:56 +04:00
free_page ( ( unsigned long ) vcpu - > run ) ;
}
EXPORT_SYMBOL_GPL ( kvm_vcpu_uninit ) ;
2008-07-25 18:24:52 +04:00
# if defined(CONFIG_MMU_NOTIFIER) && defined(KVM_ARCH_WANT_MMU_NOTIFIER)
static inline struct kvm * mmu_notifier_to_kvm ( struct mmu_notifier * mn )
{
return container_of ( mn , struct kvm , mmu_notifier ) ;
}
static void kvm_mmu_notifier_invalidate_page ( struct mmu_notifier * mn ,
struct mm_struct * mm ,
unsigned long address )
{
struct kvm * kvm = mmu_notifier_to_kvm ( mn ) ;
2009-12-23 19:35:21 +03:00
int need_tlb_flush , idx ;
2008-07-25 18:24:52 +04:00
/*
* When - > invalidate_page runs , the linux pte has been zapped
* already but the page is still allocated until
* - > invalidate_page returns . So if we increase the sequence
* here the kvm page fault will notice if the spte can ' t be
* established because the page is going to be freed . If
* instead the kvm page fault establishes the spte before
* - > invalidate_page runs , kvm_unmap_hva will release it
* before returning .
*
* The sequence increase only need to be seen at spin_unlock
* time , and not at spin_lock time .
*
* Increasing the sequence after the spin_unlock would be
* unsafe because the kvm page fault could then establish the
* pte after kvm_unmap_hva returned , without noticing the page
* is going to be freed .
*/
2009-12-23 19:35:21 +03:00
idx = srcu_read_lock ( & kvm - > srcu ) ;
2008-07-25 18:24:52 +04:00
spin_lock ( & kvm - > mmu_lock ) ;
2012-02-10 10:28:31 +04:00
2008-07-25 18:24:52 +04:00
kvm - > mmu_notifier_seq + + ;
2010-11-23 06:13:00 +03:00
need_tlb_flush = kvm_unmap_hva ( kvm , address ) | kvm - > tlbs_dirty ;
2008-07-25 18:24:52 +04:00
/* we've to flush the tlb before the pages can be freed */
if ( need_tlb_flush )
kvm_flush_remote_tlbs ( kvm ) ;
2012-02-10 10:28:31 +04:00
spin_unlock ( & kvm - > mmu_lock ) ;
2014-09-24 11:57:57 +04:00
kvm_arch_mmu_notifier_invalidate_page ( kvm , address ) ;
2012-02-10 10:28:31 +04:00
srcu_read_unlock ( & kvm - > srcu , idx ) ;
2008-07-25 18:24:52 +04:00
}
2009-09-23 22:47:18 +04:00
static void kvm_mmu_notifier_change_pte ( struct mmu_notifier * mn ,
struct mm_struct * mm ,
unsigned long address ,
pte_t pte )
{
struct kvm * kvm = mmu_notifier_to_kvm ( mn ) ;
2009-12-23 19:35:21 +03:00
int idx ;
2009-09-23 22:47:18 +04:00
2009-12-23 19:35:21 +03:00
idx = srcu_read_lock ( & kvm - > srcu ) ;
2009-09-23 22:47:18 +04:00
spin_lock ( & kvm - > mmu_lock ) ;
kvm - > mmu_notifier_seq + + ;
kvm_set_spte_hva ( kvm , address , pte ) ;
spin_unlock ( & kvm - > mmu_lock ) ;
2009-12-23 19:35:21 +03:00
srcu_read_unlock ( & kvm - > srcu , idx ) ;
2009-09-23 22:47:18 +04:00
}
2008-07-25 18:24:52 +04:00
static void kvm_mmu_notifier_invalidate_range_start ( struct mmu_notifier * mn ,
struct mm_struct * mm ,
unsigned long start ,
unsigned long end )
{
struct kvm * kvm = mmu_notifier_to_kvm ( mn ) ;
2009-12-23 19:35:21 +03:00
int need_tlb_flush = 0 , idx ;
2008-07-25 18:24:52 +04:00
2009-12-23 19:35:21 +03:00
idx = srcu_read_lock ( & kvm - > srcu ) ;
2008-07-25 18:24:52 +04:00
spin_lock ( & kvm - > mmu_lock ) ;
/*
* The count increase must become visible at unlock time as no
* spte can be established without taking the mmu_lock and
* count is also read inside the mmu_lock critical section .
*/
kvm - > mmu_notifier_count + + ;
2012-07-02 12:56:33 +04:00
need_tlb_flush = kvm_unmap_hva_range ( kvm , start , end ) ;
2010-11-23 06:13:00 +03:00
need_tlb_flush | = kvm - > tlbs_dirty ;
2008-07-25 18:24:52 +04:00
/* we've to flush the tlb before the pages can be freed */
if ( need_tlb_flush )
kvm_flush_remote_tlbs ( kvm ) ;
2012-02-10 10:28:31 +04:00
spin_unlock ( & kvm - > mmu_lock ) ;
srcu_read_unlock ( & kvm - > srcu , idx ) ;
2008-07-25 18:24:52 +04:00
}
static void kvm_mmu_notifier_invalidate_range_end ( struct mmu_notifier * mn ,
struct mm_struct * mm ,
unsigned long start ,
unsigned long end )
{
struct kvm * kvm = mmu_notifier_to_kvm ( mn ) ;
spin_lock ( & kvm - > mmu_lock ) ;
/*
* This sequence increase will notify the kvm page fault that
* the page that is going to be mapped in the spte could have
* been freed .
*/
kvm - > mmu_notifier_seq + + ;
2011-12-12 16:37:21 +04:00
smp_wmb ( ) ;
2008-07-25 18:24:52 +04:00
/*
* The above sequence increase must be visible before the
2011-12-12 16:37:21 +04:00
* below count decrease , which is ensured by the smp_wmb above
* in conjunction with the smp_rmb in mmu_notifier_retry ( ) .
2008-07-25 18:24:52 +04:00
*/
kvm - > mmu_notifier_count - - ;
spin_unlock ( & kvm - > mmu_lock ) ;
BUG_ON ( kvm - > mmu_notifier_count < 0 ) ;
}
static int kvm_mmu_notifier_clear_flush_young ( struct mmu_notifier * mn ,
struct mm_struct * mm ,
2014-09-23 01:54:42 +04:00
unsigned long start ,
unsigned long end )
2008-07-25 18:24:52 +04:00
{
struct kvm * kvm = mmu_notifier_to_kvm ( mn ) ;
2009-12-23 19:35:21 +03:00
int young , idx ;
2008-07-25 18:24:52 +04:00
2009-12-23 19:35:21 +03:00
idx = srcu_read_lock ( & kvm - > srcu ) ;
2008-07-25 18:24:52 +04:00
spin_lock ( & kvm - > mmu_lock ) ;
2014-09-23 01:54:42 +04:00
young = kvm_age_hva ( kvm , start , end ) ;
2008-07-25 18:24:52 +04:00
if ( young )
kvm_flush_remote_tlbs ( kvm ) ;
2012-02-10 10:28:31 +04:00
spin_unlock ( & kvm - > mmu_lock ) ;
srcu_read_unlock ( & kvm - > srcu , idx ) ;
2008-07-25 18:24:52 +04:00
return young ;
}
2011-01-14 02:47:10 +03:00
static int kvm_mmu_notifier_test_young ( struct mmu_notifier * mn ,
struct mm_struct * mm ,
unsigned long address )
{
struct kvm * kvm = mmu_notifier_to_kvm ( mn ) ;
int young , idx ;
idx = srcu_read_lock ( & kvm - > srcu ) ;
spin_lock ( & kvm - > mmu_lock ) ;
young = kvm_test_age_hva ( kvm , address ) ;
spin_unlock ( & kvm - > mmu_lock ) ;
srcu_read_unlock ( & kvm - > srcu , idx ) ;
return young ;
}
2008-12-10 23:23:26 +03:00
static void kvm_mmu_notifier_release ( struct mmu_notifier * mn ,
struct mm_struct * mm )
{
struct kvm * kvm = mmu_notifier_to_kvm ( mn ) ;
2010-04-20 10:29:29 +04:00
int idx ;
idx = srcu_read_lock ( & kvm - > srcu ) ;
2012-08-24 22:54:57 +04:00
kvm_arch_flush_shadow_all ( kvm ) ;
2010-04-20 10:29:29 +04:00
srcu_read_unlock ( & kvm - > srcu , idx ) ;
2008-12-10 23:23:26 +03:00
}
2008-07-25 18:24:52 +04:00
static const struct mmu_notifier_ops kvm_mmu_notifier_ops = {
. invalidate_page = kvm_mmu_notifier_invalidate_page ,
. invalidate_range_start = kvm_mmu_notifier_invalidate_range_start ,
. invalidate_range_end = kvm_mmu_notifier_invalidate_range_end ,
. clear_flush_young = kvm_mmu_notifier_clear_flush_young ,
2011-01-14 02:47:10 +03:00
. test_young = kvm_mmu_notifier_test_young ,
2009-09-23 22:47:18 +04:00
. change_pte = kvm_mmu_notifier_change_pte ,
2008-12-10 23:23:26 +03:00
. release = kvm_mmu_notifier_release ,
2008-07-25 18:24:52 +04:00
} ;
2009-12-20 15:54:04 +03:00
static int kvm_init_mmu_notifier ( struct kvm * kvm )
{
kvm - > mmu_notifier . ops = & kvm_mmu_notifier_ops ;
return mmu_notifier_register ( & kvm - > mmu_notifier , current - > mm ) ;
}
# else /* !(CONFIG_MMU_NOTIFIER && KVM_ARCH_WANT_MMU_NOTIFIER) */
static int kvm_init_mmu_notifier ( struct kvm * kvm )
{
return 0 ;
}
2008-07-25 18:24:52 +04:00
# endif /* CONFIG_MMU_NOTIFIER && KVM_ARCH_WANT_MMU_NOTIFIER */
2015-05-17 12:41:37 +03:00
static struct kvm_memslots * kvm_alloc_memslots ( void )
2011-11-24 13:40:57 +04:00
{
int i ;
2015-05-17 12:41:37 +03:00
struct kvm_memslots * slots ;
2011-11-24 13:40:57 +04:00
2015-05-17 12:41:37 +03:00
slots = kvm_kvzalloc ( sizeof ( struct kvm_memslots ) ) ;
if ( ! slots )
return NULL ;
/*
* Init kvm generation close to the maximum to easily test the
* code of handling generation number wrap - around .
*/
slots - > generation = - 150 ;
2011-11-24 13:40:57 +04:00
for ( i = 0 ; i < KVM_MEM_SLOTS_NUM ; i + + )
2011-11-24 13:41:54 +04:00
slots - > id_to_index [ i ] = slots - > memslots [ i ] . id = i ;
2015-05-17 12:41:37 +03:00
return slots ;
}
static void kvm_destroy_dirty_bitmap ( struct kvm_memory_slot * memslot )
{
if ( ! memslot - > dirty_bitmap )
return ;
kvfree ( memslot - > dirty_bitmap ) ;
memslot - > dirty_bitmap = NULL ;
}
/*
* Free any memory in @ free but not in @ dont .
*/
static void kvm_free_memslot ( struct kvm * kvm , struct kvm_memory_slot * free ,
struct kvm_memory_slot * dont )
{
if ( ! dont | | free - > dirty_bitmap ! = dont - > dirty_bitmap )
kvm_destroy_dirty_bitmap ( free ) ;
kvm_arch_free_memslot ( kvm , free , dont ) ;
free - > npages = 0 ;
}
static void kvm_free_memslots ( struct kvm * kvm , struct kvm_memslots * slots )
{
struct kvm_memory_slot * memslot ;
if ( ! slots )
return ;
kvm_for_each_memslot ( memslot , slots )
kvm_free_memslot ( kvm , memslot , NULL ) ;
kvfree ( slots ) ;
2011-11-24 13:40:57 +04:00
}
2012-01-04 13:25:20 +04:00
static struct kvm * kvm_create_vm ( unsigned long type )
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
{
2010-11-09 19:02:49 +03:00
int r , i ;
struct kvm * kvm = kvm_arch_alloc_vm ( ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
2010-11-09 19:02:49 +03:00
if ( ! kvm )
return ERR_PTR ( - ENOMEM ) ;
2012-01-04 13:25:20 +04:00
r = kvm_arch_init_vm ( kvm , type ) ;
2010-11-09 19:02:49 +03:00
if ( r )
2014-01-16 16:44:20 +04:00
goto out_err_no_disable ;
2009-09-15 13:37:46 +04:00
r = hardware_enable_all ( ) ;
if ( r )
2014-01-16 16:44:20 +04:00
goto out_err_no_disable ;
2009-09-15 13:37:46 +04:00
2014-08-06 16:24:45 +04:00
# ifdef CONFIG_HAVE_KVM_IRQFD
2009-08-24 12:54:23 +04:00
INIT_HLIST_HEAD ( & kvm - > irq_ack_notifier_list ) ;
2009-01-04 18:10:50 +03:00
# endif
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
2012-12-10 21:33:32 +04:00
BUILD_BUG_ON ( KVM_MEM_SLOTS_NUM > SHRT_MAX ) ;
2009-12-23 19:35:16 +03:00
r = - ENOMEM ;
2015-05-17 18:30:37 +03:00
for ( i = 0 ; i < KVM_ADDRESS_SPACE_NUM ; i + + ) {
kvm - > memslots [ i ] = kvm_alloc_memslots ( ) ;
if ( ! kvm - > memslots [ i ] )
goto out_err_no_srcu ;
}
2014-08-20 16:29:21 +04:00
2009-12-23 19:35:21 +03:00
if ( init_srcu_struct ( & kvm - > srcu ) )
2014-01-16 16:44:20 +04:00
goto out_err_no_srcu ;
if ( init_srcu_struct ( & kvm - > irq_srcu ) )
goto out_err_no_irq_srcu ;
2009-12-23 19:35:24 +03:00
for ( i = 0 ; i < KVM_NR_BUSES ; i + + ) {
kvm - > buses [ i ] = kzalloc ( sizeof ( struct kvm_io_bus ) ,
GFP_KERNEL ) ;
2010-11-09 14:42:12 +03:00
if ( ! kvm - > buses [ i ] )
2009-12-23 19:35:24 +03:00
goto out_err ;
}
2008-07-25 18:24:52 +04:00
2011-06-04 00:04:53 +04:00
spin_lock_init ( & kvm - > mmu_lock ) ;
2007-11-21 17:41:05 +03:00
kvm - > mm = current - > mm ;
atomic_inc ( & kvm - > mm - > mm_count ) ;
KVM: add ioeventfd support
ioeventfd is a mechanism to register PIO/MMIO regions to trigger an eventfd
signal when written to by a guest. Host userspace can register any
arbitrary IO address with a corresponding eventfd and then pass the eventfd
to a specific end-point of interest for handling.
Normal IO requires a blocking round-trip since the operation may cause
side-effects in the emulated model or may return data to the caller.
Therefore, an IO in KVM traps from the guest to the host, causes a VMX/SVM
"heavy-weight" exit back to userspace, and is ultimately serviced by qemu's
device model synchronously before returning control back to the vcpu.
However, there is a subclass of IO which acts purely as a trigger for
other IO (such as to kick off an out-of-band DMA request, etc). For these
patterns, the synchronous call is particularly expensive since we really
only want to simply get our notification transmitted asychronously and
return as quickly as possible. All the sychronous infrastructure to ensure
proper data-dependencies are met in the normal IO case are just unecessary
overhead for signalling. This adds additional computational load on the
system, as well as latency to the signalling path.
Therefore, we provide a mechanism for registration of an in-kernel trigger
point that allows the VCPU to only require a very brief, lightweight
exit just long enough to signal an eventfd. This also means that any
clients compatible with the eventfd interface (which includes userspace
and kernelspace equally well) can now register to be notified. The end
result should be a more flexible and higher performance notification API
for the backend KVM hypervisor and perhipheral components.
To test this theory, we built a test-harness called "doorbell". This
module has a function called "doorbell_ring()" which simply increments a
counter for each time the doorbell is signaled. It supports signalling
from either an eventfd, or an ioctl().
We then wired up two paths to the doorbell: One via QEMU via a registered
io region and through the doorbell ioctl(). The other is direct via
ioeventfd.
You can download this test harness here:
ftp://ftp.novell.com/dev/ghaskins/doorbell.tar.bz2
The measured results are as follows:
qemu-mmio: 110000 iops, 9.09us rtt
ioeventfd-mmio: 200100 iops, 5.00us rtt
ioeventfd-pio: 367300 iops, 2.72us rtt
I didn't measure qemu-pio, because I have to figure out how to register a
PIO region with qemu's device model, and I got lazy. However, for now we
can extrapolate based on the data from the NULLIO runs of +2.56us for MMIO,
and -350ns for HC, we get:
qemu-pio: 153139 iops, 6.53us rtt
ioeventfd-hc: 412585 iops, 2.37us rtt
these are just for fun, for now, until I can gather more data.
Here is a graph for your convenience:
http://developer.novell.com/wiki/images/7/76/Iofd-chart.png
The conclusion to draw is that we save about 4us by skipping the userspace
hop.
--------------------
Signed-off-by: Gregory Haskins <ghaskins@novell.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
2009-07-08 01:08:49 +04:00
kvm_eventfd_init ( kvm ) ;
2007-07-23 10:51:37 +04:00
mutex_init ( & kvm - > lock ) ;
2009-06-04 22:08:23 +04:00
mutex_init ( & kvm - > irq_lock ) ;
2009-12-23 19:35:26 +03:00
mutex_init ( & kvm - > slots_lock ) ;
2008-03-30 17:01:25 +04:00
atomic_set ( & kvm - > users_count , 1 ) ;
2013-04-25 18:11:23 +04:00
INIT_LIST_HEAD ( & kvm - > devices ) ;
2011-06-04 00:04:53 +04:00
r = kvm_init_mmu_notifier ( kvm ) ;
if ( r )
goto out_err ;
2013-09-25 15:53:07 +04:00
spin_lock ( & kvm_lock ) ;
2007-07-23 11:08:21 +04:00
list_add ( & kvm - > vm_list , & vm_list ) ;
2013-09-25 15:53:07 +04:00
spin_unlock ( & kvm_lock ) ;
2010-11-09 19:02:49 +03:00
2015-07-03 19:53:58 +03:00
preempt_notifier_inc ( ) ;
2007-02-21 20:28:04 +03:00
return kvm ;
2009-09-15 13:37:46 +04:00
out_err :
2014-01-16 16:44:20 +04:00
cleanup_srcu_struct ( & kvm - > irq_srcu ) ;
out_err_no_irq_srcu :
2010-11-09 14:42:12 +03:00
cleanup_srcu_struct ( & kvm - > srcu ) ;
2014-01-16 16:44:20 +04:00
out_err_no_srcu :
2009-09-15 13:37:46 +04:00
hardware_disable_all ( ) ;
2014-01-16 16:44:20 +04:00
out_err_no_disable :
2009-12-23 19:35:24 +03:00
for ( i = 0 ; i < KVM_NR_BUSES ; i + + )
kfree ( kvm - > buses [ i ] ) ;
2015-05-17 18:30:37 +03:00
for ( i = 0 ; i < KVM_ADDRESS_SPACE_NUM ; i + + )
kvm_free_memslots ( kvm , kvm - > memslots [ i ] ) ;
2010-11-09 19:02:49 +03:00
kvm_arch_free_vm ( kvm ) ;
2009-09-15 13:37:46 +04:00
return ERR_PTR ( r ) ;
2007-02-21 20:28:04 +03:00
}
2012-05-20 08:13:28 +04:00
/*
* Avoid using vmalloc for a small buffer .
* Should not be used when the size is statically known .
*/
2012-05-20 08:15:07 +04:00
void * kvm_kvzalloc ( unsigned long size )
2012-05-20 08:13:28 +04:00
{
if ( size > PAGE_SIZE )
return vzalloc ( size ) ;
else
return kzalloc ( size , GFP_KERNEL ) ;
}
2013-04-25 18:11:23 +04:00
static void kvm_destroy_devices ( struct kvm * kvm )
{
struct list_head * node , * tmp ;
list_for_each_safe ( node , tmp , & kvm - > devices ) {
struct kvm_device * dev =
list_entry ( node , struct kvm_device , vm_node ) ;
list_del ( node ) ;
dev - > ops - > destroy ( dev ) ;
}
}
2007-02-21 20:28:04 +03:00
static void kvm_destroy_vm ( struct kvm * kvm )
{
2009-12-23 19:35:24 +03:00
int i ;
2007-11-21 17:41:05 +03:00
struct mm_struct * mm = kvm - > mm ;
2009-01-06 05:03:02 +03:00
kvm_arch_sync_events ( kvm ) ;
2013-09-25 15:53:07 +04:00
spin_lock ( & kvm_lock ) ;
2007-02-12 11:54:44 +03:00
list_del ( & kvm - > vm_list ) ;
2013-09-25 15:53:07 +04:00
spin_unlock ( & kvm_lock ) ;
2008-11-19 14:58:46 +03:00
kvm_free_irq_routing ( kvm ) ;
2009-12-23 19:35:24 +03:00
for ( i = 0 ; i < KVM_NR_BUSES ; i + + )
kvm_io_bus_destroy ( kvm - > buses [ i ] ) ;
2009-12-20 16:13:43 +03:00
kvm_coalesced_mmio_free ( kvm ) ;
2008-07-25 18:24:52 +04:00
# if defined(CONFIG_MMU_NOTIFIER) && defined(KVM_ARCH_WANT_MMU_NOTIFIER)
mmu_notifier_unregister ( & kvm - > mmu_notifier , kvm - > mm ) ;
2009-03-19 13:20:36 +03:00
# else
2012-08-24 22:54:57 +04:00
kvm_arch_flush_shadow_all ( kvm ) ;
2008-05-30 18:05:54 +04:00
# endif
2007-11-18 13:43:45 +03:00
kvm_arch_destroy_vm ( kvm ) ;
2013-04-25 18:11:23 +04:00
kvm_destroy_devices ( kvm ) ;
2015-05-17 18:30:37 +03:00
for ( i = 0 ; i < KVM_ADDRESS_SPACE_NUM ; i + + )
kvm_free_memslots ( kvm , kvm - > memslots [ i ] ) ;
2014-06-03 15:44:17 +04:00
cleanup_srcu_struct ( & kvm - > irq_srcu ) ;
2010-11-09 19:02:49 +03:00
cleanup_srcu_struct ( & kvm - > srcu ) ;
kvm_arch_free_vm ( kvm ) ;
2015-07-03 19:53:58 +03:00
preempt_notifier_dec ( ) ;
2009-09-15 13:37:46 +04:00
hardware_disable_all ( ) ;
2007-11-21 17:41:05 +03:00
mmdrop ( mm ) ;
2007-02-21 20:28:04 +03:00
}
2008-03-30 17:01:25 +04:00
void kvm_get_kvm ( struct kvm * kvm )
{
atomic_inc ( & kvm - > users_count ) ;
}
EXPORT_SYMBOL_GPL ( kvm_get_kvm ) ;
void kvm_put_kvm ( struct kvm * kvm )
{
if ( atomic_dec_and_test ( & kvm - > users_count ) )
kvm_destroy_vm ( kvm ) ;
}
EXPORT_SYMBOL_GPL ( kvm_put_kvm ) ;
2007-02-21 20:28:04 +03:00
static int kvm_vm_release ( struct inode * inode , struct file * filp )
{
struct kvm * kvm = filp - > private_data ;
2009-05-20 18:30:49 +04:00
kvm_irqfd_release ( kvm ) ;
2008-03-30 17:01:25 +04:00
kvm_put_kvm ( kvm ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
return 0 ;
}
2010-10-27 13:23:54 +04:00
/*
* Allocation size is twice as large as the actual dirty bitmap size .
2012-03-01 14:34:45 +04:00
* See x86 ' s kvm_vm_ioctl_get_dirty_log ( ) why this is needed .
2010-10-27 13:23:54 +04:00
*/
2010-10-27 13:22:19 +04:00
static int kvm_create_dirty_bitmap ( struct kvm_memory_slot * memslot )
{
2010-10-27 13:23:54 +04:00
unsigned long dirty_bytes = 2 * kvm_dirty_bitmap_bytes ( memslot ) ;
2010-10-27 13:22:19 +04:00
2012-05-20 08:13:28 +04:00
memslot - > dirty_bitmap = kvm_kvzalloc ( dirty_bytes ) ;
2010-10-27 13:22:19 +04:00
if ( ! memslot - > dirty_bitmap )
return - ENOMEM ;
return 0 ;
}
2011-11-24 13:40:57 +04:00
/*
2014-12-01 20:29:26 +03:00
* Insert memslot and re - sort memslots based on their GFN ,
* so binary search could be used to lookup GFN .
* Sorting algorithm takes advantage of having initially
* sorted array and known changed memslot position .
2011-11-24 13:40:57 +04:00
*/
2014-11-14 12:55:31 +03:00
static void update_memslots ( struct kvm_memslots * slots ,
struct kvm_memory_slot * new )
2011-11-24 13:40:57 +04:00
{
2014-11-14 12:22:07 +03:00
int id = new - > id ;
int i = slots - > id_to_index [ id ] ;
2014-11-14 02:00:13 +03:00
struct kvm_memory_slot * mslots = slots - > memslots ;
2011-11-24 13:41:54 +04:00
2014-11-14 12:22:07 +03:00
WARN_ON ( mslots [ i ] . id ! = id ) ;
2014-12-01 20:29:27 +03:00
if ( ! new - > npages ) {
2014-12-27 23:08:16 +03:00
WARN_ON ( ! mslots [ i ] . npages ) ;
2014-12-01 20:29:27 +03:00
if ( mslots [ i ] . npages )
slots - > used_slots - - ;
} else {
if ( ! mslots [ i ] . npages )
slots - > used_slots + + ;
}
2014-12-01 20:29:26 +03:00
2014-12-01 20:29:24 +03:00
while ( i < KVM_MEM_SLOTS_NUM - 1 & &
2014-12-01 20:29:26 +03:00
new - > base_gfn < = mslots [ i + 1 ] . base_gfn ) {
if ( ! mslots [ i + 1 ] . npages )
break ;
2014-12-01 20:29:24 +03:00
mslots [ i ] = mslots [ i + 1 ] ;
slots - > id_to_index [ mslots [ i ] . id ] = i ;
i + + ;
}
2014-12-27 20:01:00 +03:00
/*
* The " >= " is needed when creating a slot with base_gfn = = 0 ,
* so that it moves before all those with base_gfn = = npages = = 0.
*
* On the other hand , if new - > npages is zero , the above loop has
* already left i pointing to the beginning of the empty part of
* mslots , and the " >= " would move the hole backwards in this
* case - - - which is wrong . So skip the loop when deleting a slot .
*/
if ( new - > npages ) {
while ( i > 0 & &
new - > base_gfn > = mslots [ i - 1 ] . base_gfn ) {
mslots [ i ] = mslots [ i - 1 ] ;
slots - > id_to_index [ mslots [ i ] . id ] = i ;
i - - ;
}
2014-12-27 23:08:16 +03:00
} else
WARN_ON_ONCE ( i ! = slots - > used_slots ) ;
2011-11-24 13:41:54 +04:00
2014-11-14 12:22:07 +03:00
mslots [ i ] = * new ;
slots - > id_to_index [ mslots [ i ] . id ] = i ;
2011-11-24 13:40:57 +04:00
}
2015-05-18 14:59:39 +03:00
static int check_memory_region_flags ( const struct kvm_userspace_memory_region * mem )
2012-08-21 06:58:13 +04:00
{
2012-08-21 07:02:51 +04:00
u32 valid_flags = KVM_MEM_LOG_DIRTY_PAGES ;
2014-08-26 16:00:37 +04:00
# ifdef __KVM_HAVE_READONLY_MEM
2012-08-21 07:02:51 +04:00
valid_flags | = KVM_MEM_READONLY ;
# endif
if ( mem - > flags & ~ valid_flags )
2012-08-21 06:58:13 +04:00
return - EINVAL ;
return 0 ;
}
2012-12-24 19:49:30 +04:00
static struct kvm_memslots * install_new_memslots ( struct kvm * kvm ,
2015-05-17 18:30:37 +03:00
int as_id , struct kvm_memslots * slots )
2012-12-24 19:49:30 +04:00
{
2015-05-17 18:30:37 +03:00
struct kvm_memslots * old_memslots = __kvm_memslots ( kvm , as_id ) ;
2012-12-24 19:49:30 +04:00
2014-08-19 02:46:06 +04:00
/*
* Set the low bit in the generation , which disables SPTE caching
* until the end of synchronize_srcu_expedited .
*/
WARN_ON ( old_memslots - > generation & 1 ) ;
slots - > generation = old_memslots - > generation + 1 ;
2015-05-17 18:30:37 +03:00
rcu_assign_pointer ( kvm - > memslots [ as_id ] , slots ) ;
2012-12-24 19:49:30 +04:00
synchronize_srcu_expedited ( & kvm - > srcu ) ;
2013-07-04 08:40:29 +04:00
2014-08-19 02:46:06 +04:00
/*
* Increment the new memslot generation a second time . This prevents
* vm exits that race with memslot updates from caching a memslot
* generation that will ( potentially ) be valid forever .
*/
slots - > generation + + ;
2015-05-17 22:26:08 +03:00
kvm_arch_memslots_updated ( kvm , slots ) ;
2013-07-04 08:40:29 +04:00
return old_memslots ;
2012-12-24 19:49:30 +04:00
}
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
/*
* Allocate some memory and give it an address in the guest physical address
* space .
*
* Discontiguous memory is allowed , mostly for framebuffers .
2007-10-29 04:40:42 +03:00
*
2014-10-27 18:22:56 +03:00
* Must be called holding kvm - > slots_lock for write .
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
*/
2007-10-29 04:40:42 +03:00
int __kvm_set_memory_region ( struct kvm * kvm ,
2015-05-18 14:59:39 +03:00
const struct kvm_userspace_memory_region * mem )
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
{
2010-12-27 13:08:45 +03:00
int r ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
gfn_t base_gfn ;
2009-09-03 19:35:35 +04:00
unsigned long npages ;
2013-01-11 13:27:43 +04:00
struct kvm_memory_slot * slot ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
struct kvm_memory_slot old , new ;
2012-12-10 21:33:03 +04:00
struct kvm_memslots * slots = NULL , * old_memslots ;
2015-05-17 18:30:37 +03:00
int as_id , id ;
2013-01-29 06:00:07 +04:00
enum kvm_mr_change change ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
2012-08-21 06:58:13 +04:00
r = check_memory_region_flags ( mem ) ;
if ( r )
goto out ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
r = - EINVAL ;
2015-05-17 18:30:37 +03:00
as_id = mem - > slot > > 16 ;
id = ( u16 ) mem - > slot ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
/* General sanity checks */
if ( mem - > memory_size & ( PAGE_SIZE - 1 ) )
goto out ;
if ( mem - > guest_phys_addr & ( PAGE_SIZE - 1 ) )
goto out ;
2011-05-07 11:35:38 +04:00
/* We can read the guest memory with __xxx_user() later on. */
2015-05-17 18:30:37 +03:00
if ( ( id < KVM_USER_MEM_SLOTS ) & &
2011-05-07 11:35:38 +04:00
( ( mem - > userspace_addr & ( PAGE_SIZE - 1 ) ) | |
2011-05-24 09:51:27 +04:00
! access_ok ( VERIFY_WRITE ,
( void __user * ) ( unsigned long ) mem - > userspace_addr ,
mem - > memory_size ) ) )
2008-11-07 22:32:12 +03:00
goto out ;
2015-05-17 18:30:37 +03:00
if ( as_id > = KVM_ADDRESS_SPACE_NUM | | id > = KVM_MEM_SLOTS_NUM )
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
goto out ;
if ( mem - > guest_phys_addr + mem - > memory_size < mem - > guest_phys_addr )
goto out ;
2015-05-17 18:30:37 +03:00
slot = id_to_memslot ( __kvm_memslots ( kvm , as_id ) , id ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
base_gfn = mem - > guest_phys_addr > > PAGE_SHIFT ;
npages = mem - > memory_size > > PAGE_SHIFT ;
2010-04-13 17:47:24 +04:00
if ( npages > KVM_MEM_MAX_NR_PAGES )
goto out ;
2013-01-11 13:27:43 +04:00
new = old = * slot ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
2015-05-17 18:30:37 +03:00
new . id = id ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
new . base_gfn = base_gfn ;
new . npages = npages ;
new . flags = mem - > flags ;
2013-01-29 06:00:07 +04:00
if ( npages ) {
if ( ! old . npages )
change = KVM_MR_CREATE ;
else { /* Modify an existing slot. */
if ( ( mem - > userspace_addr ! = old . userspace_addr ) | |
2013-01-30 14:40:41 +04:00
( npages ! = old . npages ) | |
( ( new . flags ^ old . flags ) & KVM_MEM_READONLY ) )
2013-01-29 06:00:07 +04:00
goto out ;
if ( base_gfn ! = old . base_gfn )
change = KVM_MR_MOVE ;
else if ( new . flags ! = old . flags )
change = KVM_MR_FLAGS_ONLY ;
else { /* Nothing to change. */
r = 0 ;
goto out ;
}
}
2015-05-18 14:59:39 +03:00
} else {
if ( ! old . npages )
goto out ;
2013-01-29 06:00:07 +04:00
change = KVM_MR_DELETE ;
2015-05-18 14:59:39 +03:00
new . base_gfn = 0 ;
new . flags = 0 ;
}
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
2013-01-29 06:00:07 +04:00
if ( ( change = = KVM_MR_CREATE ) | | ( change = = KVM_MR_MOVE ) ) {
2013-01-11 13:26:55 +04:00
/* Check for overlaps */
r = - EEXIST ;
2015-05-17 18:30:37 +03:00
kvm_for_each_memslot ( slot , __kvm_memslots ( kvm , as_id ) ) {
2013-01-11 13:27:43 +04:00
if ( ( slot - > id > = KVM_USER_MEM_SLOTS ) | |
2015-05-17 18:30:37 +03:00
( slot - > id = = id ) )
2013-01-11 13:26:55 +04:00
continue ;
if ( ! ( ( base_gfn + npages < = slot - > base_gfn ) | |
( base_gfn > = slot - > base_gfn + slot - > npages ) ) )
goto out ;
}
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
}
/* Free page dirty bitmap if unneeded */
if ( ! ( new . flags & KVM_MEM_LOG_DIRTY_PAGES ) )
2007-02-09 19:38:40 +03:00
new . dirty_bitmap = NULL ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
r = - ENOMEM ;
2013-01-29 06:00:07 +04:00
if ( change = = KVM_MR_CREATE ) {
2012-02-08 08:01:09 +04:00
new . userspace_addr = mem - > userspace_addr ;
2012-08-01 13:03:28 +04:00
2013-10-07 20:48:00 +04:00
if ( kvm_arch_create_memslot ( kvm , & new , npages ) )
2012-02-08 08:02:18 +04:00
goto out_free ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
}
2009-06-19 17:16:23 +04:00
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
/* Allocate page dirty bitmap if needed */
if ( ( new . flags & KVM_MEM_LOG_DIRTY_PAGES ) & & ! new . dirty_bitmap ) {
2010-10-27 13:22:19 +04:00
if ( kvm_create_dirty_bitmap ( & new ) < 0 )
2007-10-29 04:40:42 +03:00
goto out_free ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
}
2015-03-20 15:21:37 +03:00
slots = kvm_kvzalloc ( sizeof ( struct kvm_memslots ) ) ;
2014-11-14 12:46:45 +03:00
if ( ! slots )
goto out_free ;
2015-05-17 18:30:37 +03:00
memcpy ( slots , __kvm_memslots ( kvm , as_id ) , sizeof ( struct kvm_memslots ) ) ;
2014-11-14 12:46:45 +03:00
2013-01-29 06:00:07 +04:00
if ( ( change = = KVM_MR_DELETE ) | | ( change = = KVM_MR_MOVE ) ) {
2015-05-17 18:30:37 +03:00
slot = id_to_memslot ( slots , id ) ;
2011-11-24 15:04:35 +04:00
slot - > flags | = KVM_MEMSLOT_INVALID ;
2015-05-17 18:30:37 +03:00
old_memslots = install_new_memslots ( kvm , as_id , slots ) ;
2009-12-23 19:35:21 +03:00
2012-12-10 21:32:57 +04:00
/* slot was deleted or moved, clear iommu mapping */
kvm_iommu_unmap_pages ( kvm , & old ) ;
2012-08-24 22:54:58 +04:00
/* From this point no new shadow pages pointing to a deleted,
* or moved , memslot will be created .
2009-12-23 19:35:21 +03:00
*
* validation of sp - > gfn happens in :
2015-02-26 09:58:24 +03:00
* - gfn_to_hva ( kvm_read_guest , gfn_to_pfn )
* - kvm_is_visible_gfn ( mmu_check_roots )
2009-12-23 19:35:21 +03:00
*/
2012-08-24 22:54:57 +04:00
kvm_arch_flush_shadow_memslot ( kvm , slot ) ;
2014-11-14 12:46:45 +03:00
/*
* We can re - use the old_memslots from above , the only difference
* from the currently installed memslots is the invalid flag . This
* will get overwritten by update_memslots anyway .
*/
2012-12-10 21:33:03 +04:00
slots = old_memslots ;
2009-12-23 19:35:21 +03:00
}
2008-07-11 03:49:31 +04:00
2013-02-27 14:44:34 +04:00
r = kvm_arch_prepare_memory_region ( kvm , & new , mem , change ) ;
2009-12-23 19:35:18 +03:00
if ( r )
2012-12-10 21:33:03 +04:00
goto out_slots ;
2009-12-23 19:35:18 +03:00
2015-05-17 12:41:37 +03:00
/* actual memory is freed via old in kvm_free_memslot below */
2013-01-29 06:00:07 +04:00
if ( change = = KVM_MR_DELETE ) {
2009-12-23 19:35:21 +03:00
new . dirty_bitmap = NULL ;
2012-02-08 08:02:18 +04:00
memset ( & new . arch , 0 , sizeof ( new . arch ) ) ;
2009-12-23 19:35:21 +03:00
}
2014-11-14 12:55:31 +03:00
update_memslots ( slots , & new ) ;
2015-05-17 18:30:37 +03:00
old_memslots = install_new_memslots ( kvm , as_id , slots ) ;
2007-11-20 08:11:38 +03:00
2015-05-18 14:20:23 +03:00
kvm_arch_commit_memory_region ( kvm , mem , & old , & new , change ) ;
2007-10-02 20:52:55 +04:00
2015-05-17 12:41:37 +03:00
kvm_free_memslot ( kvm , & old , & new ) ;
2015-03-20 15:21:37 +03:00
kvfree ( old_memslots ) ;
2009-12-23 19:35:21 +03:00
2013-01-25 02:04:03 +04:00
/*
* IOMMU mapping : New slots need to be mapped . Old slots need to be
2013-01-30 14:40:41 +04:00
* un - mapped and re - mapped if their base changes . Since base change
* unmapping is handled above with slot deletion , mapping alone is
* needed here . Anything else the iommu might care about for existing
* slots ( size changes , userspace addr changes and read - only flag
* changes ) is disallowed above , so any other attribute changes getting
* here can be skipped .
2013-01-25 02:04:03 +04:00
*/
2013-01-30 14:40:41 +04:00
if ( ( change = = KVM_MR_CREATE ) | | ( change = = KVM_MR_MOVE ) ) {
r = kvm_iommu_map_pages ( kvm , & new ) ;
2013-10-24 05:56:39 +04:00
return r ;
2009-12-23 19:35:21 +03:00
}
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
return 0 ;
2012-12-10 21:32:57 +04:00
out_slots :
2015-03-20 15:21:37 +03:00
kvfree ( slots ) ;
2007-10-29 04:40:42 +03:00
out_free :
2015-05-17 12:41:37 +03:00
kvm_free_memslot ( kvm , & new , & old ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
out :
return r ;
2007-10-25 01:52:57 +04:00
}
2007-10-29 04:40:42 +03:00
EXPORT_SYMBOL_GPL ( __kvm_set_memory_region ) ;
int kvm_set_memory_region ( struct kvm * kvm ,
2015-05-18 14:59:39 +03:00
const struct kvm_userspace_memory_region * mem )
2007-10-29 04:40:42 +03:00
{
int r ;
2009-12-23 19:35:26 +03:00
mutex_lock ( & kvm - > slots_lock ) ;
2013-02-27 14:43:00 +04:00
r = __kvm_set_memory_region ( kvm , mem ) ;
2009-12-23 19:35:26 +03:00
mutex_unlock ( & kvm - > slots_lock ) ;
2007-10-29 04:40:42 +03:00
return r ;
}
2007-10-25 01:52:57 +04:00
EXPORT_SYMBOL_GPL ( kvm_set_memory_region ) ;
2013-12-30 00:12:29 +04:00
static int kvm_vm_ioctl_set_memory_region ( struct kvm * kvm ,
struct kvm_userspace_memory_region * mem )
2007-10-25 01:52:57 +04:00
{
2015-05-17 18:30:37 +03:00
if ( ( u16 ) mem - > slot > = KVM_USER_MEM_SLOTS )
2007-10-25 01:57:46 +04:00
return - EINVAL ;
2015-05-18 14:59:39 +03:00
2013-02-27 14:43:00 +04:00
return kvm_set_memory_region ( kvm , mem ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
}
2007-11-18 15:29:43 +03:00
int kvm_get_dirty_log ( struct kvm * kvm ,
struct kvm_dirty_log * log , int * is_dirty )
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
{
2015-05-17 17:20:07 +03:00
struct kvm_memslots * slots ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
struct kvm_memory_slot * memslot ;
2015-05-17 18:30:37 +03:00
int r , i , as_id , id ;
2010-04-12 14:35:35 +04:00
unsigned long n ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
unsigned long any = 0 ;
r = - EINVAL ;
2015-05-17 18:30:37 +03:00
as_id = log - > slot > > 16 ;
id = ( u16 ) log - > slot ;
if ( as_id > = KVM_ADDRESS_SPACE_NUM | | id > = KVM_USER_MEM_SLOTS )
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
goto out ;
2015-05-17 18:30:37 +03:00
slots = __kvm_memslots ( kvm , as_id ) ;
memslot = id_to_memslot ( slots , id ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
r = - ENOENT ;
if ( ! memslot - > dirty_bitmap )
goto out ;
2010-04-12 14:35:35 +04:00
n = kvm_dirty_bitmap_bytes ( memslot ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
2007-02-22 17:43:09 +03:00
for ( i = 0 ; ! any & & i < n / sizeof ( long ) ; + + i )
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
any = memslot - > dirty_bitmap [ i ] ;
r = - EFAULT ;
if ( copy_to_user ( log - > dirty_bitmap , memslot - > dirty_bitmap , n ) )
goto out ;
2007-11-18 15:29:43 +03:00
if ( any )
* is_dirty = 1 ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
r = 0 ;
out :
return r ;
}
2013-10-07 20:47:59 +04:00
EXPORT_SYMBOL_GPL ( kvm_get_dirty_log ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
2015-01-16 02:58:53 +03:00
# ifdef CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT
/**
* kvm_get_dirty_log_protect - get a snapshot of dirty pages , and if any pages
* are dirty write protect them for next write .
* @ kvm : pointer to kvm instance
* @ log : slot id and address to which we copy the log
* @ is_dirty : flag set if any page is dirty
*
* We need to keep it in mind that VCPU threads can write to the bitmap
* concurrently . So , to avoid losing track of dirty pages we keep the
* following order :
*
* 1. Take a snapshot of the bit and clear it if needed .
* 2. Write protect the corresponding page .
* 3. Copy the snapshot to the userspace .
* 4. Upon return caller flushes TLB ' s if needed .
*
* Between 2 and 4 , the guest may write to the page using the remaining TLB
* entry . This is not a problem because the page is reported dirty using
* the snapshot taken before and step 4 ensures that writes done after
* exiting to userspace will be logged for the next call .
*
*/
int kvm_get_dirty_log_protect ( struct kvm * kvm ,
struct kvm_dirty_log * log , bool * is_dirty )
{
2015-05-17 17:20:07 +03:00
struct kvm_memslots * slots ;
2015-01-16 02:58:53 +03:00
struct kvm_memory_slot * memslot ;
2015-05-17 18:30:37 +03:00
int r , i , as_id , id ;
2015-01-16 02:58:53 +03:00
unsigned long n ;
unsigned long * dirty_bitmap ;
unsigned long * dirty_bitmap_buffer ;
r = - EINVAL ;
2015-05-17 18:30:37 +03:00
as_id = log - > slot > > 16 ;
id = ( u16 ) log - > slot ;
if ( as_id > = KVM_ADDRESS_SPACE_NUM | | id > = KVM_USER_MEM_SLOTS )
2015-01-16 02:58:53 +03:00
goto out ;
2015-05-17 18:30:37 +03:00
slots = __kvm_memslots ( kvm , as_id ) ;
memslot = id_to_memslot ( slots , id ) ;
2015-01-16 02:58:53 +03:00
dirty_bitmap = memslot - > dirty_bitmap ;
r = - ENOENT ;
if ( ! dirty_bitmap )
goto out ;
n = kvm_dirty_bitmap_bytes ( memslot ) ;
dirty_bitmap_buffer = dirty_bitmap + n / sizeof ( long ) ;
memset ( dirty_bitmap_buffer , 0 , n ) ;
spin_lock ( & kvm - > mmu_lock ) ;
* is_dirty = false ;
for ( i = 0 ; i < n / sizeof ( long ) ; i + + ) {
unsigned long mask ;
gfn_t offset ;
if ( ! dirty_bitmap [ i ] )
continue ;
* is_dirty = true ;
mask = xchg ( & dirty_bitmap [ i ] , 0 ) ;
dirty_bitmap_buffer [ i ] = mask ;
2015-03-17 10:19:58 +03:00
if ( mask ) {
offset = i * BITS_PER_LONG ;
kvm_arch_mmu_enable_log_dirty_pt_masked ( kvm , memslot ,
offset , mask ) ;
}
2015-01-16 02:58:53 +03:00
}
spin_unlock ( & kvm - > mmu_lock ) ;
r = - EFAULT ;
if ( copy_to_user ( log - > dirty_bitmap , dirty_bitmap_buffer , n ) )
goto out ;
r = 0 ;
out :
return r ;
}
EXPORT_SYMBOL_GPL ( kvm_get_dirty_log_protect ) ;
# endif
2012-02-08 08:02:18 +04:00
bool kvm_largepages_enabled ( void )
{
return largepages_enabled ;
}
2009-06-11 19:07:44 +04:00
void kvm_disable_largepages ( void )
{
largepages_enabled = false ;
}
EXPORT_SYMBOL_GPL ( kvm_disable_largepages ) ;
2010-10-18 17:22:23 +04:00
struct kvm_memory_slot * gfn_to_memslot ( struct kvm * kvm , gfn_t gfn )
{
return __gfn_to_memslot ( kvm_memslots ( kvm ) , gfn ) ;
}
2010-06-21 12:44:20 +04:00
EXPORT_SYMBOL_GPL ( gfn_to_memslot ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
2015-05-17 14:58:53 +03:00
struct kvm_memory_slot * kvm_vcpu_gfn_to_memslot ( struct kvm_vcpu * vcpu , gfn_t gfn )
{
return __gfn_to_memslot ( kvm_vcpu_memslots ( vcpu ) , gfn ) ;
}
2007-10-25 01:57:46 +04:00
int kvm_is_visible_gfn ( struct kvm * kvm , gfn_t gfn )
{
2011-11-24 13:40:57 +04:00
struct kvm_memory_slot * memslot = gfn_to_memslot ( kvm , gfn ) ;
2007-10-25 01:57:46 +04:00
2012-12-10 21:33:09 +04:00
if ( ! memslot | | memslot - > id > = KVM_USER_MEM_SLOTS | |
2011-11-24 13:40:57 +04:00
memslot - > flags & KVM_MEMSLOT_INVALID )
return 0 ;
2007-10-25 01:57:46 +04:00
2011-11-24 13:40:57 +04:00
return 1 ;
2007-10-25 01:57:46 +04:00
}
EXPORT_SYMBOL_GPL ( kvm_is_visible_gfn ) ;
2010-01-28 14:37:56 +03:00
unsigned long kvm_host_page_size ( struct kvm * kvm , gfn_t gfn )
{
struct vm_area_struct * vma ;
unsigned long addr , size ;
size = PAGE_SIZE ;
addr = gfn_to_hva ( kvm , gfn ) ;
if ( kvm_is_error_hva ( addr ) )
return PAGE_SIZE ;
down_read ( & current - > mm - > mmap_sem ) ;
vma = find_vma ( current - > mm , addr ) ;
if ( ! vma )
goto out ;
size = vma_kernel_pagesize ( vma ) ;
out :
up_read ( & current - > mm - > mmap_sem ) ;
return size ;
}
2012-08-21 07:02:51 +04:00
static bool memslot_is_readonly ( struct kvm_memory_slot * slot )
{
return slot - > flags & KVM_MEM_READONLY ;
}
static unsigned long __gfn_to_hva_many ( struct kvm_memory_slot * slot , gfn_t gfn ,
gfn_t * nr_pages , bool write )
2007-11-11 23:05:04 +03:00
{
2009-12-23 19:35:21 +03:00
if ( ! slot | | slot - > flags & KVM_MEMSLOT_INVALID )
2012-08-21 07:01:50 +04:00
return KVM_HVA_ERR_BAD ;
2010-08-22 15:11:43 +04:00
2012-08-21 07:02:51 +04:00
if ( memslot_is_readonly ( slot ) & & write )
return KVM_HVA_ERR_RO_BAD ;
2010-08-22 15:11:43 +04:00
if ( nr_pages )
* nr_pages = slot - > npages - ( gfn - slot - > base_gfn ) ;
2012-08-21 07:02:51 +04:00
return __gfn_to_hva_memslot ( slot , gfn ) ;
2007-11-11 23:05:04 +03:00
}
2010-08-22 15:11:43 +04:00
2012-08-21 07:02:51 +04:00
static unsigned long gfn_to_hva_many ( struct kvm_memory_slot * slot , gfn_t gfn ,
gfn_t * nr_pages )
{
return __gfn_to_hva_many ( slot , gfn , nr_pages , true ) ;
2007-11-11 23:05:04 +03:00
}
2010-08-22 15:11:43 +04:00
2012-08-21 07:02:51 +04:00
unsigned long gfn_to_hva_memslot ( struct kvm_memory_slot * slot ,
2013-12-30 00:12:29 +04:00
gfn_t gfn )
2012-08-21 07:02:51 +04:00
{
return gfn_to_hva_many ( slot , gfn , NULL ) ;
}
EXPORT_SYMBOL_GPL ( gfn_to_hva_memslot ) ;
2010-08-22 15:11:43 +04:00
unsigned long gfn_to_hva ( struct kvm * kvm , gfn_t gfn )
{
2010-10-18 17:22:23 +04:00
return gfn_to_hva_many ( gfn_to_memslot ( kvm , gfn ) , gfn , NULL ) ;
2010-08-22 15:11:43 +04:00
}
2008-04-25 17:44:50 +04:00
EXPORT_SYMBOL_GPL ( gfn_to_hva ) ;
2007-11-11 23:05:04 +03:00
2015-05-17 14:58:53 +03:00
unsigned long kvm_vcpu_gfn_to_hva ( struct kvm_vcpu * vcpu , gfn_t gfn )
{
return gfn_to_hva_many ( kvm_vcpu_gfn_to_memslot ( vcpu , gfn ) , gfn , NULL ) ;
}
EXPORT_SYMBOL_GPL ( kvm_vcpu_gfn_to_hva ) ;
2012-08-21 06:59:53 +04:00
/*
2013-09-09 15:52:33 +04:00
* If writable is set to false , the hva returned by this function is only
* allowed to be read .
2012-08-21 06:59:53 +04:00
*/
2014-08-19 14:15:00 +04:00
unsigned long gfn_to_hva_memslot_prot ( struct kvm_memory_slot * slot ,
gfn_t gfn , bool * writable )
2012-08-21 06:59:53 +04:00
{
2013-10-01 20:58:36 +04:00
unsigned long hva = __gfn_to_hva_many ( slot , gfn , NULL , false ) ;
if ( ! kvm_is_error_hva ( hva ) & & writable )
2013-09-09 15:52:33 +04:00
* writable = ! memslot_is_readonly ( slot ) ;
2013-10-01 20:58:36 +04:00
return hva ;
2012-08-21 06:59:53 +04:00
}
2014-08-19 14:15:00 +04:00
unsigned long gfn_to_hva_prot ( struct kvm * kvm , gfn_t gfn , bool * writable )
{
struct kvm_memory_slot * slot = gfn_to_memslot ( kvm , gfn ) ;
return gfn_to_hva_memslot_prot ( slot , gfn , writable ) ;
}
2015-05-17 14:58:53 +03:00
unsigned long kvm_vcpu_gfn_to_hva_prot ( struct kvm_vcpu * vcpu , gfn_t gfn , bool * writable )
{
struct kvm_memory_slot * slot = kvm_vcpu_gfn_to_memslot ( vcpu , gfn ) ;
return gfn_to_hva_memslot_prot ( slot , gfn , writable ) ;
}
2013-04-05 23:20:30 +04:00
static int get_user_page_nowait ( struct task_struct * tsk , struct mm_struct * mm ,
2011-02-01 14:21:47 +03:00
unsigned long start , int write , struct page * * page )
{
int flags = FOLL_TOUCH | FOLL_NOWAIT | FOLL_HWPOISON | FOLL_GET ;
if ( write )
flags | = FOLL_WRITE ;
return __get_user_pages ( tsk , mm , start , 1 , flags , page , NULL , NULL ) ;
}
2011-01-30 06:15:49 +03:00
static inline int check_user_page_hwpoison ( unsigned long addr )
{
int rc , flags = FOLL_TOUCH | FOLL_HWPOISON | FOLL_WRITE ;
rc = __get_user_pages ( current , current - > mm , addr , 1 ,
flags , NULL , NULL , NULL ) ;
return rc = = - EHWPOISON ;
}
2012-08-21 07:00:22 +04:00
/*
* The atomic path to get the writable pfn which will be stored in @ pfn ,
* true indicates success , otherwise false is returned .
*/
static bool hva_to_pfn_fast ( unsigned long addr , bool atomic , bool * async ,
bool write_fault , bool * writable , pfn_t * pfn )
2007-03-30 15:02:32 +04:00
{
2007-10-18 18:59:34 +04:00
struct page * page [ 1 ] ;
2012-08-21 07:00:22 +04:00
int npages ;
2007-03-30 15:02:32 +04:00
2012-08-21 07:00:22 +04:00
if ( ! ( async | | atomic ) )
return false ;
2010-10-14 13:22:46 +04:00
2012-08-21 07:00:49 +04:00
/*
* Fast pin a writable pfn only if it is a write fault request
* or the caller allows to map a writable pfn for a read fault
* request .
*/
if ( ! ( write_fault | | writable ) )
return false ;
2010-10-22 20:18:18 +04:00
2012-08-21 07:00:22 +04:00
npages = __get_user_pages_fast ( addr , 1 , 1 , page ) ;
if ( npages = = 1 ) {
* pfn = page_to_pfn ( page [ 0 ] ) ;
2010-10-22 20:18:18 +04:00
2012-08-21 07:00:22 +04:00
if ( writable )
* writable = true ;
return true ;
}
2010-10-14 13:22:46 +04:00
2012-08-21 07:00:22 +04:00
return false ;
}
2010-10-22 20:18:18 +04:00
2012-08-21 07:00:22 +04:00
/*
* The slow path to get the pfn of the specified host virtual address ,
* 1 indicates success , - errno is returned if error is detected .
*/
static int hva_to_pfn_slow ( unsigned long addr , bool * async , bool write_fault ,
bool * writable , pfn_t * pfn )
{
struct page * page [ 1 ] ;
int npages = 0 ;
2010-10-22 20:18:18 +04:00
2012-08-21 07:00:22 +04:00
might_sleep ( ) ;
if ( writable )
* writable = write_fault ;
if ( async ) {
down_read ( & current - > mm - > mmap_sem ) ;
npages = get_user_page_nowait ( current , current - > mm ,
addr , write_fault , page ) ;
up_read ( & current - > mm - > mmap_sem ) ;
2015-02-12 02:27:28 +03:00
} else
npages = __get_user_pages_unlocked ( current , current - > mm , addr , 1 ,
write_fault , 0 , page ,
FOLL_TOUCH | FOLL_HWPOISON ) ;
2012-08-21 07:00:22 +04:00
if ( npages ! = 1 )
return npages ;
/* map read fault as writable if possible */
2012-08-21 07:00:49 +04:00
if ( unlikely ( ! write_fault ) & & writable ) {
2012-08-21 07:00:22 +04:00
struct page * wpage [ 1 ] ;
npages = __get_user_pages_fast ( addr , 1 , 1 , wpage ) ;
if ( npages = = 1 ) {
* writable = true ;
put_page ( page [ 0 ] ) ;
page [ 0 ] = wpage [ 0 ] ;
2010-10-22 20:18:18 +04:00
}
2012-08-21 07:00:22 +04:00
npages = 1 ;
2010-08-22 15:10:28 +04:00
}
2012-08-21 07:00:22 +04:00
* pfn = page_to_pfn ( page [ 0 ] ) ;
return npages ;
}
2007-11-11 23:05:04 +03:00
2012-08-21 07:02:51 +04:00
static bool vma_is_valid ( struct vm_area_struct * vma , bool write_fault )
{
if ( unlikely ( ! ( vma - > vm_flags & VM_READ ) ) )
return false ;
2008-05-01 00:37:07 +04:00
2012-08-21 07:02:51 +04:00
if ( write_fault & & ( unlikely ( ! ( vma - > vm_flags & VM_WRITE ) ) ) )
return false ;
2010-08-22 15:10:28 +04:00
2012-08-21 07:02:51 +04:00
return true ;
}
2010-05-31 10:28:19 +04:00
2012-08-21 07:00:49 +04:00
/*
* Pin guest page in memory and return its pfn .
* @ addr : host virtual address which maps memory to the guest
* @ atomic : whether this function can sleep
* @ async : whether this function need to wait IO complete if the
* host page is not in the memory
* @ write_fault : whether we should get a writable host page
* @ writable : whether it allows to map a writable host page for ! @ write_fault
*
* The function will map a writable host page for these two cases :
* 1 ) : @ write_fault = true
* 2 ) : @ write_fault = false & & @ writable , @ writable will tell the caller
* whether the mapping is writable .
*/
2012-08-21 07:00:22 +04:00
static pfn_t hva_to_pfn ( unsigned long addr , bool atomic , bool * async ,
bool write_fault , bool * writable )
{
struct vm_area_struct * vma ;
pfn_t pfn = 0 ;
int npages ;
2008-05-01 00:37:07 +04:00
2012-08-21 07:00:22 +04:00
/* we can do it either atomically or asynchronously, not both */
BUG_ON ( atomic & & async ) ;
2007-10-18 18:59:34 +04:00
2012-08-21 07:00:22 +04:00
if ( hva_to_pfn_fast ( addr , atomic , async , write_fault , writable , & pfn ) )
return pfn ;
if ( atomic )
return KVM_PFN_ERR_FAULT ;
npages = hva_to_pfn_slow ( addr , async , write_fault , writable , & pfn ) ;
if ( npages = = 1 )
return pfn ;
2007-10-18 18:59:34 +04:00
2012-08-21 07:00:22 +04:00
down_read ( & current - > mm - > mmap_sem ) ;
if ( npages = = - EHWPOISON | |
( ! async & & check_user_page_hwpoison ( addr ) ) ) {
pfn = KVM_PFN_ERR_HWPOISON ;
goto exit ;
}
vma = find_vma_intersection ( current - > mm , addr , addr + 1 ) ;
if ( vma = = NULL )
pfn = KVM_PFN_ERR_FAULT ;
else if ( ( vma - > vm_flags & VM_PFNMAP ) ) {
pfn = ( ( addr - vma - > vm_start ) > > PAGE_SHIFT ) +
vma - > vm_pgoff ;
2014-11-10 11:33:56 +03:00
BUG_ON ( ! kvm_is_reserved_pfn ( pfn ) ) ;
2012-08-21 07:00:22 +04:00
} else {
2012-08-21 07:02:51 +04:00
if ( async & & vma_is_valid ( vma , write_fault ) )
2012-08-21 07:00:22 +04:00
* async = true ;
pfn = KVM_PFN_ERR_FAULT ;
}
exit :
up_read ( & current - > mm - > mmap_sem ) ;
2008-05-01 00:37:07 +04:00
return pfn ;
2008-04-02 23:46:56 +04:00
}
2015-04-02 12:20:48 +03:00
pfn_t __gfn_to_pfn_memslot ( struct kvm_memory_slot * slot , gfn_t gfn , bool atomic ,
bool * async , bool write_fault , bool * writable )
2010-08-22 15:10:28 +04:00
{
2012-08-21 07:02:51 +04:00
unsigned long addr = __gfn_to_hva_many ( slot , gfn , NULL , write_fault ) ;
if ( addr = = KVM_HVA_ERR_RO_BAD )
return KVM_PFN_ERR_RO_FAULT ;
if ( kvm_is_error_hva ( addr ) )
2012-10-16 16:10:59 +04:00
return KVM_PFN_NOSLOT ;
2012-08-21 07:02:51 +04:00
/* Do not map writable pfn in the readonly memslot. */
if ( writable & & memslot_is_readonly ( slot ) ) {
* writable = false ;
writable = NULL ;
}
return hva_to_pfn ( addr , atomic , async , write_fault ,
writable ) ;
2010-08-22 15:10:28 +04:00
}
2015-04-02 12:20:48 +03:00
EXPORT_SYMBOL_GPL ( __gfn_to_pfn_memslot ) ;
2010-08-22 15:10:28 +04:00
2010-10-22 20:18:18 +04:00
pfn_t gfn_to_pfn_prot ( struct kvm * kvm , gfn_t gfn , bool write_fault ,
bool * writable )
{
2015-05-19 17:09:04 +03:00
return __gfn_to_pfn_memslot ( gfn_to_memslot ( kvm , gfn ) , gfn , false , NULL ,
write_fault , writable ) ;
2010-10-22 20:18:18 +04:00
}
EXPORT_SYMBOL_GPL ( gfn_to_pfn_prot ) ;
2012-07-17 17:56:16 +04:00
pfn_t gfn_to_pfn_memslot ( struct kvm_memory_slot * slot , gfn_t gfn )
2009-12-23 19:35:19 +03:00
{
2012-08-21 07:02:51 +04:00
return __gfn_to_pfn_memslot ( slot , gfn , false , NULL , true , NULL ) ;
2009-12-23 19:35:19 +03:00
}
2015-05-19 17:09:04 +03:00
EXPORT_SYMBOL_GPL ( gfn_to_pfn_memslot ) ;
2009-12-23 19:35:19 +03:00
2012-08-21 06:59:12 +04:00
pfn_t gfn_to_pfn_memslot_atomic ( struct kvm_memory_slot * slot , gfn_t gfn )
2009-12-23 19:35:19 +03:00
{
2012-08-21 07:02:51 +04:00
return __gfn_to_pfn_memslot ( slot , gfn , true , NULL , true , NULL ) ;
2009-12-23 19:35:19 +03:00
}
2012-08-21 06:59:12 +04:00
EXPORT_SYMBOL_GPL ( gfn_to_pfn_memslot_atomic ) ;
2009-12-23 19:35:19 +03:00
2015-05-19 17:09:04 +03:00
pfn_t gfn_to_pfn_atomic ( struct kvm * kvm , gfn_t gfn )
{
return gfn_to_pfn_memslot_atomic ( gfn_to_memslot ( kvm , gfn ) , gfn ) ;
}
EXPORT_SYMBOL_GPL ( gfn_to_pfn_atomic ) ;
2015-05-17 14:58:53 +03:00
pfn_t kvm_vcpu_gfn_to_pfn_atomic ( struct kvm_vcpu * vcpu , gfn_t gfn )
{
return gfn_to_pfn_memslot_atomic ( kvm_vcpu_gfn_to_memslot ( vcpu , gfn ) , gfn ) ;
}
EXPORT_SYMBOL_GPL ( kvm_vcpu_gfn_to_pfn_atomic ) ;
2015-05-19 17:09:04 +03:00
pfn_t gfn_to_pfn ( struct kvm * kvm , gfn_t gfn )
{
return gfn_to_pfn_memslot ( gfn_to_memslot ( kvm , gfn ) , gfn ) ;
}
EXPORT_SYMBOL_GPL ( gfn_to_pfn ) ;
2015-05-17 14:58:53 +03:00
pfn_t kvm_vcpu_gfn_to_pfn ( struct kvm_vcpu * vcpu , gfn_t gfn )
{
return gfn_to_pfn_memslot ( kvm_vcpu_gfn_to_memslot ( vcpu , gfn ) , gfn ) ;
}
EXPORT_SYMBOL_GPL ( kvm_vcpu_gfn_to_pfn ) ;
2015-05-19 17:01:50 +03:00
int gfn_to_page_many_atomic ( struct kvm_memory_slot * slot , gfn_t gfn ,
struct page * * pages , int nr_pages )
2010-08-22 15:11:43 +04:00
{
unsigned long addr ;
gfn_t entry ;
2015-05-19 17:01:50 +03:00
addr = gfn_to_hva_many ( slot , gfn , & entry ) ;
2010-08-22 15:11:43 +04:00
if ( kvm_is_error_hva ( addr ) )
return - 1 ;
if ( entry < nr_pages )
return 0 ;
return __get_user_pages_fast ( addr , nr_pages , 1 , pages ) ;
}
EXPORT_SYMBOL_GPL ( gfn_to_page_many_atomic ) ;
2012-07-26 07:58:59 +04:00
static struct page * kvm_pfn_to_page ( pfn_t pfn )
{
2012-10-16 16:10:59 +04:00
if ( is_error_noslot_pfn ( pfn ) )
2012-08-03 11:42:10 +04:00
return KVM_ERR_PTR_BAD_PAGE ;
2012-07-26 07:58:59 +04:00
2014-11-10 11:33:56 +03:00
if ( kvm_is_reserved_pfn ( pfn ) ) {
2012-08-03 11:42:10 +04:00
WARN_ON ( 1 ) ;
2012-08-03 11:41:22 +04:00
return KVM_ERR_PTR_BAD_PAGE ;
2012-08-03 11:42:10 +04:00
}
2012-07-26 07:58:59 +04:00
return pfn_to_page ( pfn ) ;
}
2008-04-02 23:46:56 +04:00
struct page * gfn_to_page ( struct kvm * kvm , gfn_t gfn )
{
2008-05-01 00:37:07 +04:00
pfn_t pfn ;
pfn = gfn_to_pfn ( kvm , gfn ) ;
2012-07-26 07:58:59 +04:00
return kvm_pfn_to_page ( pfn ) ;
2007-03-30 15:02:32 +04:00
}
EXPORT_SYMBOL_GPL ( gfn_to_page ) ;
2015-05-17 14:58:53 +03:00
struct page * kvm_vcpu_gfn_to_page ( struct kvm_vcpu * vcpu , gfn_t gfn )
{
pfn_t pfn ;
pfn = kvm_vcpu_gfn_to_pfn ( vcpu , gfn ) ;
return kvm_pfn_to_page ( pfn ) ;
}
EXPORT_SYMBOL_GPL ( kvm_vcpu_gfn_to_page ) ;
2007-11-20 12:49:33 +03:00
void kvm_release_page_clean ( struct page * page )
{
2012-08-03 11:42:52 +04:00
WARN_ON ( is_error_page ( page ) ) ;
2008-04-02 23:46:56 +04:00
kvm_release_pfn_clean ( page_to_pfn ( page ) ) ;
2007-11-20 12:49:33 +03:00
}
EXPORT_SYMBOL_GPL ( kvm_release_page_clean ) ;
2008-04-02 23:46:56 +04:00
void kvm_release_pfn_clean ( pfn_t pfn )
{
2014-11-10 11:33:56 +03:00
if ( ! is_error_noslot_pfn ( pfn ) & & ! kvm_is_reserved_pfn ( pfn ) )
2008-05-01 00:37:07 +04:00
put_page ( pfn_to_page ( pfn ) ) ;
2008-04-02 23:46:56 +04:00
}
EXPORT_SYMBOL_GPL ( kvm_release_pfn_clean ) ;
2007-11-20 12:49:33 +03:00
void kvm_release_page_dirty ( struct page * page )
2007-10-18 13:09:33 +04:00
{
2012-07-26 07:58:59 +04:00
WARN_ON ( is_error_page ( page ) ) ;
2008-04-02 23:46:56 +04:00
kvm_release_pfn_dirty ( page_to_pfn ( page ) ) ;
}
EXPORT_SYMBOL_GPL ( kvm_release_page_dirty ) ;
2013-12-30 00:12:29 +04:00
static void kvm_release_pfn_dirty ( pfn_t pfn )
2008-04-02 23:46:56 +04:00
{
kvm_set_pfn_dirty ( pfn ) ;
kvm_release_pfn_clean ( pfn ) ;
}
void kvm_set_pfn_dirty ( pfn_t pfn )
{
2014-11-10 11:33:56 +03:00
if ( ! kvm_is_reserved_pfn ( pfn ) ) {
2008-05-01 00:37:07 +04:00
struct page * page = pfn_to_page ( pfn ) ;
2015-02-26 09:58:23 +03:00
2008-05-01 00:37:07 +04:00
if ( ! PageReserved ( page ) )
SetPageDirty ( page ) ;
}
2007-10-18 13:09:33 +04:00
}
2008-04-02 23:46:56 +04:00
EXPORT_SYMBOL_GPL ( kvm_set_pfn_dirty ) ;
void kvm_set_pfn_accessed ( pfn_t pfn )
{
2014-11-10 11:33:56 +03:00
if ( ! kvm_is_reserved_pfn ( pfn ) )
2008-05-01 00:37:07 +04:00
mark_page_accessed ( pfn_to_page ( pfn ) ) ;
2008-04-02 23:46:56 +04:00
}
EXPORT_SYMBOL_GPL ( kvm_set_pfn_accessed ) ;
void kvm_get_pfn ( pfn_t pfn )
{
2014-11-10 11:33:56 +03:00
if ( ! kvm_is_reserved_pfn ( pfn ) )
2008-05-01 00:37:07 +04:00
get_page ( pfn_to_page ( pfn ) ) ;
2008-04-02 23:46:56 +04:00
}
EXPORT_SYMBOL_GPL ( kvm_get_pfn ) ;
2007-10-18 13:09:33 +04:00
2007-10-02 00:14:18 +04:00
static int next_segment ( unsigned long len , int offset )
{
if ( len > PAGE_SIZE - offset )
return PAGE_SIZE - offset ;
else
return len ;
}
2015-05-17 14:58:53 +03:00
static int __kvm_read_guest_page ( struct kvm_memory_slot * slot , gfn_t gfn ,
void * data , int offset , int len )
2007-10-02 00:14:18 +04:00
{
2007-11-11 23:10:22 +03:00
int r ;
unsigned long addr ;
2007-10-02 00:14:18 +04:00
2015-05-17 14:58:53 +03:00
addr = gfn_to_hva_memslot_prot ( slot , gfn , NULL ) ;
2007-11-11 23:10:22 +03:00
if ( kvm_is_error_hva ( addr ) )
return - EFAULT ;
2015-04-02 15:08:20 +03:00
r = __copy_from_user ( data , ( void __user * ) addr + offset , len ) ;
2007-11-11 23:10:22 +03:00
if ( r )
2007-10-02 00:14:18 +04:00
return - EFAULT ;
return 0 ;
}
2015-05-17 14:58:53 +03:00
int kvm_read_guest_page ( struct kvm * kvm , gfn_t gfn , void * data , int offset ,
int len )
{
struct kvm_memory_slot * slot = gfn_to_memslot ( kvm , gfn ) ;
return __kvm_read_guest_page ( slot , gfn , data , offset , len ) ;
}
2007-10-02 00:14:18 +04:00
EXPORT_SYMBOL_GPL ( kvm_read_guest_page ) ;
2015-05-17 14:58:53 +03:00
int kvm_vcpu_read_guest_page ( struct kvm_vcpu * vcpu , gfn_t gfn , void * data ,
int offset , int len )
{
struct kvm_memory_slot * slot = kvm_vcpu_gfn_to_memslot ( vcpu , gfn ) ;
return __kvm_read_guest_page ( slot , gfn , data , offset , len ) ;
}
EXPORT_SYMBOL_GPL ( kvm_vcpu_read_guest_page ) ;
2007-10-02 00:14:18 +04:00
int kvm_read_guest ( struct kvm * kvm , gpa_t gpa , void * data , unsigned long len )
{
gfn_t gfn = gpa > > PAGE_SHIFT ;
int seg ;
int offset = offset_in_page ( gpa ) ;
int ret ;
while ( ( seg = next_segment ( len , offset ) ) ! = 0 ) {
ret = kvm_read_guest_page ( kvm , gfn , data , offset , seg ) ;
if ( ret < 0 )
return ret ;
offset = 0 ;
len - = seg ;
data + = seg ;
+ + gfn ;
}
return 0 ;
}
EXPORT_SYMBOL_GPL ( kvm_read_guest ) ;
2015-05-17 14:58:53 +03:00
int kvm_vcpu_read_guest ( struct kvm_vcpu * vcpu , gpa_t gpa , void * data , unsigned long len )
2007-12-21 03:18:23 +03:00
{
gfn_t gfn = gpa > > PAGE_SHIFT ;
2015-05-17 14:58:53 +03:00
int seg ;
2007-12-21 03:18:23 +03:00
int offset = offset_in_page ( gpa ) ;
2015-05-17 14:58:53 +03:00
int ret ;
while ( ( seg = next_segment ( len , offset ) ) ! = 0 ) {
ret = kvm_vcpu_read_guest_page ( vcpu , gfn , data , offset , seg ) ;
if ( ret < 0 )
return ret ;
offset = 0 ;
len - = seg ;
data + = seg ;
+ + gfn ;
}
return 0 ;
}
EXPORT_SYMBOL_GPL ( kvm_vcpu_read_guest ) ;
2007-12-21 03:18:23 +03:00
2015-05-17 14:58:53 +03:00
static int __kvm_read_guest_atomic ( struct kvm_memory_slot * slot , gfn_t gfn ,
void * data , int offset , unsigned long len )
{
int r ;
unsigned long addr ;
addr = gfn_to_hva_memslot_prot ( slot , gfn , NULL ) ;
2007-12-21 03:18:23 +03:00
if ( kvm_is_error_hva ( addr ) )
return - EFAULT ;
2008-01-30 21:57:35 +03:00
pagefault_disable ( ) ;
2015-04-02 15:08:20 +03:00
r = __copy_from_user_inatomic ( data , ( void __user * ) addr + offset , len ) ;
2008-01-30 21:57:35 +03:00
pagefault_enable ( ) ;
2007-12-21 03:18:23 +03:00
if ( r )
return - EFAULT ;
return 0 ;
}
2015-05-17 14:58:53 +03:00
int kvm_read_guest_atomic ( struct kvm * kvm , gpa_t gpa , void * data ,
unsigned long len )
{
gfn_t gfn = gpa > > PAGE_SHIFT ;
struct kvm_memory_slot * slot = gfn_to_memslot ( kvm , gfn ) ;
int offset = offset_in_page ( gpa ) ;
return __kvm_read_guest_atomic ( slot , gfn , data , offset , len ) ;
}
EXPORT_SYMBOL_GPL ( kvm_read_guest_atomic ) ;
int kvm_vcpu_read_guest_atomic ( struct kvm_vcpu * vcpu , gpa_t gpa ,
void * data , unsigned long len )
{
gfn_t gfn = gpa > > PAGE_SHIFT ;
struct kvm_memory_slot * slot = kvm_vcpu_gfn_to_memslot ( vcpu , gfn ) ;
int offset = offset_in_page ( gpa ) ;
return __kvm_read_guest_atomic ( slot , gfn , data , offset , len ) ;
}
EXPORT_SYMBOL_GPL ( kvm_vcpu_read_guest_atomic ) ;
static int __kvm_write_guest_page ( struct kvm_memory_slot * memslot , gfn_t gfn ,
const void * data , int offset , int len )
2007-10-02 00:14:18 +04:00
{
2007-11-11 23:10:22 +03:00
int r ;
unsigned long addr ;
2007-10-02 00:14:18 +04:00
2015-04-10 22:47:27 +03:00
addr = gfn_to_hva_memslot ( memslot , gfn ) ;
2007-11-11 23:10:22 +03:00
if ( kvm_is_error_hva ( addr ) )
return - EFAULT ;
2011-05-15 19:22:04 +04:00
r = __copy_to_user ( ( void __user * ) addr + offset , data , len ) ;
2007-11-11 23:10:22 +03:00
if ( r )
2007-10-02 00:14:18 +04:00
return - EFAULT ;
2015-05-26 13:43:41 +03:00
mark_page_dirty_in_slot ( memslot , gfn ) ;
2007-10-02 00:14:18 +04:00
return 0 ;
}
2015-05-17 14:58:53 +03:00
int kvm_write_guest_page ( struct kvm * kvm , gfn_t gfn ,
const void * data , int offset , int len )
{
struct kvm_memory_slot * slot = gfn_to_memslot ( kvm , gfn ) ;
return __kvm_write_guest_page ( slot , gfn , data , offset , len ) ;
}
2007-10-02 00:14:18 +04:00
EXPORT_SYMBOL_GPL ( kvm_write_guest_page ) ;
2015-05-17 14:58:53 +03:00
int kvm_vcpu_write_guest_page ( struct kvm_vcpu * vcpu , gfn_t gfn ,
const void * data , int offset , int len )
{
struct kvm_memory_slot * slot = kvm_vcpu_gfn_to_memslot ( vcpu , gfn ) ;
return __kvm_write_guest_page ( slot , gfn , data , offset , len ) ;
}
EXPORT_SYMBOL_GPL ( kvm_vcpu_write_guest_page ) ;
2007-10-02 00:14:18 +04:00
int kvm_write_guest ( struct kvm * kvm , gpa_t gpa , const void * data ,
unsigned long len )
{
gfn_t gfn = gpa > > PAGE_SHIFT ;
int seg ;
int offset = offset_in_page ( gpa ) ;
int ret ;
while ( ( seg = next_segment ( len , offset ) ) ! = 0 ) {
ret = kvm_write_guest_page ( kvm , gfn , data , offset , seg ) ;
if ( ret < 0 )
return ret ;
offset = 0 ;
len - = seg ;
data + = seg ;
+ + gfn ;
}
return 0 ;
}
2014-12-11 08:52:58 +03:00
EXPORT_SYMBOL_GPL ( kvm_write_guest ) ;
2007-10-02 00:14:18 +04:00
2015-05-17 14:58:53 +03:00
int kvm_vcpu_write_guest ( struct kvm_vcpu * vcpu , gpa_t gpa , const void * data ,
unsigned long len )
{
gfn_t gfn = gpa > > PAGE_SHIFT ;
int seg ;
int offset = offset_in_page ( gpa ) ;
int ret ;
while ( ( seg = next_segment ( len , offset ) ) ! = 0 ) {
ret = kvm_vcpu_write_guest_page ( vcpu , gfn , data , offset , seg ) ;
if ( ret < 0 )
return ret ;
offset = 0 ;
len - = seg ;
data + = seg ;
+ + gfn ;
}
return 0 ;
}
EXPORT_SYMBOL_GPL ( kvm_vcpu_write_guest ) ;
2010-10-18 17:22:23 +04:00
int kvm_gfn_to_hva_cache_init ( struct kvm * kvm , struct gfn_to_hva_cache * ghc ,
2013-03-29 20:35:21 +04:00
gpa_t gpa , unsigned long len )
2010-10-18 17:22:23 +04:00
{
struct kvm_memslots * slots = kvm_memslots ( kvm ) ;
int offset = offset_in_page ( gpa ) ;
2013-03-29 20:35:21 +04:00
gfn_t start_gfn = gpa > > PAGE_SHIFT ;
gfn_t end_gfn = ( gpa + len - 1 ) > > PAGE_SHIFT ;
gfn_t nr_pages_needed = end_gfn - start_gfn + 1 ;
gfn_t nr_pages_avail ;
2010-10-18 17:22:23 +04:00
ghc - > gpa = gpa ;
ghc - > generation = slots - > generation ;
2013-03-29 20:35:21 +04:00
ghc - > len = len ;
ghc - > memslot = gfn_to_memslot ( kvm , start_gfn ) ;
2015-04-08 15:16:48 +03:00
ghc - > hva = gfn_to_hva_many ( ghc - > memslot , start_gfn , NULL ) ;
if ( ! kvm_is_error_hva ( ghc - > hva ) & & nr_pages_needed < = 1 ) {
2010-10-18 17:22:23 +04:00
ghc - > hva + = offset ;
2013-03-29 20:35:21 +04:00
} else {
/*
* If the requested region crosses two memslots , we still
* verify that the entire region is valid here .
*/
while ( start_gfn < = end_gfn ) {
ghc - > memslot = gfn_to_memslot ( kvm , start_gfn ) ;
ghc - > hva = gfn_to_hva_many ( ghc - > memslot , start_gfn ,
& nr_pages_avail ) ;
if ( kvm_is_error_hva ( ghc - > hva ) )
return - EFAULT ;
start_gfn + = nr_pages_avail ;
}
/* Use the slow path for cross page reads and writes. */
ghc - > memslot = NULL ;
}
2010-10-18 17:22:23 +04:00
return 0 ;
}
EXPORT_SYMBOL_GPL ( kvm_gfn_to_hva_cache_init ) ;
int kvm_write_guest_cached ( struct kvm * kvm , struct gfn_to_hva_cache * ghc ,
void * data , unsigned long len )
{
struct kvm_memslots * slots = kvm_memslots ( kvm ) ;
int r ;
2013-03-29 20:35:21 +04:00
BUG_ON ( len > ghc - > len ) ;
2010-10-18 17:22:23 +04:00
if ( slots - > generation ! = ghc - > generation )
2013-03-29 20:35:21 +04:00
kvm_gfn_to_hva_cache_init ( kvm , ghc , ghc - > gpa , ghc - > len ) ;
if ( unlikely ( ! ghc - > memslot ) )
return kvm_write_guest ( kvm , ghc - > gpa , data , len ) ;
2010-10-18 17:22:23 +04:00
if ( kvm_is_error_hva ( ghc - > hva ) )
return - EFAULT ;
2011-05-15 19:22:04 +04:00
r = __copy_to_user ( ( void __user * ) ghc - > hva , data , len ) ;
2010-10-18 17:22:23 +04:00
if ( r )
return - EFAULT ;
2015-05-26 13:43:41 +03:00
mark_page_dirty_in_slot ( ghc - > memslot , ghc - > gpa > > PAGE_SHIFT ) ;
2010-10-18 17:22:23 +04:00
return 0 ;
}
EXPORT_SYMBOL_GPL ( kvm_write_guest_cached ) ;
2011-07-11 23:28:11 +04:00
int kvm_read_guest_cached ( struct kvm * kvm , struct gfn_to_hva_cache * ghc ,
void * data , unsigned long len )
{
struct kvm_memslots * slots = kvm_memslots ( kvm ) ;
int r ;
2013-03-29 20:35:21 +04:00
BUG_ON ( len > ghc - > len ) ;
2011-07-11 23:28:11 +04:00
if ( slots - > generation ! = ghc - > generation )
2013-03-29 20:35:21 +04:00
kvm_gfn_to_hva_cache_init ( kvm , ghc , ghc - > gpa , ghc - > len ) ;
if ( unlikely ( ! ghc - > memslot ) )
return kvm_read_guest ( kvm , ghc - > gpa , data , len ) ;
2011-07-11 23:28:11 +04:00
if ( kvm_is_error_hva ( ghc - > hva ) )
return - EFAULT ;
r = __copy_from_user ( data , ( void __user * ) ghc - > hva , len ) ;
if ( r )
return - EFAULT ;
return 0 ;
}
EXPORT_SYMBOL_GPL ( kvm_read_guest_cached ) ;
2007-10-02 00:14:18 +04:00
int kvm_clear_guest_page ( struct kvm * kvm , gfn_t gfn , int offset , int len )
{
2013-11-18 13:35:55 +04:00
const void * zero_page = ( const void * ) __va ( page_to_phys ( ZERO_PAGE ( 0 ) ) ) ;
return kvm_write_guest_page ( kvm , gfn , zero_page , offset , len ) ;
2007-10-02 00:14:18 +04:00
}
EXPORT_SYMBOL_GPL ( kvm_clear_guest_page ) ;
int kvm_clear_guest ( struct kvm * kvm , gpa_t gpa , unsigned long len )
{
gfn_t gfn = gpa > > PAGE_SHIFT ;
int seg ;
int offset = offset_in_page ( gpa ) ;
int ret ;
2015-02-20 16:21:36 +03:00
while ( ( seg = next_segment ( len , offset ) ) ! = 0 ) {
2007-10-02 00:14:18 +04:00
ret = kvm_clear_guest_page ( kvm , gfn , offset , seg ) ;
if ( ret < 0 )
return ret ;
offset = 0 ;
len - = seg ;
+ + gfn ;
}
return 0 ;
}
EXPORT_SYMBOL_GPL ( kvm_clear_guest ) ;
2015-05-26 13:43:41 +03:00
static void mark_page_dirty_in_slot ( struct kvm_memory_slot * memslot ,
2013-12-30 00:12:29 +04:00
gfn_t gfn )
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
{
2007-07-31 14:41:14 +04:00
if ( memslot & & memslot - > dirty_bitmap ) {
unsigned long rel_gfn = gfn - memslot - > base_gfn ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
2012-10-05 04:13:12 +04:00
set_bit_le ( rel_gfn , memslot - > dirty_bitmap ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
}
}
2010-10-18 17:22:23 +04:00
void mark_page_dirty ( struct kvm * kvm , gfn_t gfn )
{
struct kvm_memory_slot * memslot ;
memslot = gfn_to_memslot ( kvm , gfn ) ;
2015-05-26 13:43:41 +03:00
mark_page_dirty_in_slot ( memslot , gfn ) ;
2010-10-18 17:22:23 +04:00
}
2013-10-07 20:47:59 +04:00
EXPORT_SYMBOL_GPL ( mark_page_dirty ) ;
2010-10-18 17:22:23 +04:00
2015-05-17 14:58:53 +03:00
void kvm_vcpu_mark_page_dirty ( struct kvm_vcpu * vcpu , gfn_t gfn )
{
struct kvm_memory_slot * memslot ;
memslot = kvm_vcpu_gfn_to_memslot ( vcpu , gfn ) ;
mark_page_dirty_in_slot ( memslot , gfn ) ;
}
EXPORT_SYMBOL_GPL ( kvm_vcpu_mark_page_dirty ) ;
kvm: add halt_poll_ns module parameter
This patch introduces a new module parameter for the KVM module; when it
is present, KVM attempts a bit of polling on every HLT before scheduling
itself out via kvm_vcpu_block.
This parameter helps a lot for latency-bound workloads---in particular
I tested it with O_DSYNC writes with a battery-backed disk in the host.
In this case, writes are fast (because the data doesn't have to go all
the way to the platters) but they cannot be merged by either the host or
the guest. KVM's performance here is usually around 30% of bare metal,
or 50% if you use cache=directsync or cache=writethrough (these
parameters avoid that the guest sends pointless flush requests, and
at the same time they are not slow because of the battery-backed cache).
The bad performance happens because on every halt the host CPU decides
to halt itself too. When the interrupt comes, the vCPU thread is then
migrated to a new physical CPU, and in general the latency is horrible
because the vCPU thread has to be scheduled back in.
With this patch performance reaches 60-65% of bare metal and, more
important, 99% of what you get if you use idle=poll in the guest. This
means that the tunable gets rid of this particular bottleneck, and more
work can be done to improve performance in the kernel or QEMU.
Of course there is some price to pay; every time an otherwise idle vCPUs
is interrupted by an interrupt, it will poll unnecessarily and thus
impose a little load on the host. The above results were obtained with
a mostly random value of the parameter (500000), and the load was around
1.5-2.5% CPU usage on one of the host's core for each idle guest vCPU.
The patch also adds a new stat, /sys/kernel/debug/kvm/halt_successful_poll,
that can be used to tune the parameter. It counts how many HLT
instructions received an interrupt during the polling period; each
successful poll avoids that Linux schedules the VCPU thread out and back
in, and may also avoid a likely trip to C1 and back for the physical CPU.
While the VM is idle, a Linux 4 VCPU VM halts around 10 times per second.
Of these halts, almost all are failed polls. During the benchmark,
instead, basically all halts end within the polling period, except a more
or less constant stream of 50 per second coming from vCPUs that are not
running the benchmark. The wasted time is thus very low. Things may
be slightly different for Windows VMs, which have a ~10 ms timer tick.
The effect is also visible on Marcelo's recently-introduced latency
test for the TSC deadline timer. Though of course a non-RT kernel has
awful latency bounds, the latency of the timer is around 8000-10000 clock
cycles compared to 20000-120000 without setting halt_poll_ns. For the TSC
deadline timer, thus, the effect is both a smaller average latency and
a smaller variance.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2015-02-04 20:20:58 +03:00
static int kvm_vcpu_check_block ( struct kvm_vcpu * vcpu )
{
if ( kvm_arch_vcpu_runnable ( vcpu ) ) {
kvm_make_request ( KVM_REQ_UNHALT , vcpu ) ;
return - EINTR ;
}
if ( kvm_cpu_has_pending_timer ( vcpu ) )
return - EINTR ;
if ( signal_pending ( current ) )
return - EINTR ;
return 0 ;
}
2007-07-18 13:15:21 +04:00
/*
* The vCPU has executed a HLT instruction with in - kernel mode enabled .
*/
2007-11-01 01:24:24 +03:00
void kvm_vcpu_block ( struct kvm_vcpu * vcpu )
2007-06-05 16:53:05 +04:00
{
kvm: add halt_poll_ns module parameter
This patch introduces a new module parameter for the KVM module; when it
is present, KVM attempts a bit of polling on every HLT before scheduling
itself out via kvm_vcpu_block.
This parameter helps a lot for latency-bound workloads---in particular
I tested it with O_DSYNC writes with a battery-backed disk in the host.
In this case, writes are fast (because the data doesn't have to go all
the way to the platters) but they cannot be merged by either the host or
the guest. KVM's performance here is usually around 30% of bare metal,
or 50% if you use cache=directsync or cache=writethrough (these
parameters avoid that the guest sends pointless flush requests, and
at the same time they are not slow because of the battery-backed cache).
The bad performance happens because on every halt the host CPU decides
to halt itself too. When the interrupt comes, the vCPU thread is then
migrated to a new physical CPU, and in general the latency is horrible
because the vCPU thread has to be scheduled back in.
With this patch performance reaches 60-65% of bare metal and, more
important, 99% of what you get if you use idle=poll in the guest. This
means that the tunable gets rid of this particular bottleneck, and more
work can be done to improve performance in the kernel or QEMU.
Of course there is some price to pay; every time an otherwise idle vCPUs
is interrupted by an interrupt, it will poll unnecessarily and thus
impose a little load on the host. The above results were obtained with
a mostly random value of the parameter (500000), and the load was around
1.5-2.5% CPU usage on one of the host's core for each idle guest vCPU.
The patch also adds a new stat, /sys/kernel/debug/kvm/halt_successful_poll,
that can be used to tune the parameter. It counts how many HLT
instructions received an interrupt during the polling period; each
successful poll avoids that Linux schedules the VCPU thread out and back
in, and may also avoid a likely trip to C1 and back for the physical CPU.
While the VM is idle, a Linux 4 VCPU VM halts around 10 times per second.
Of these halts, almost all are failed polls. During the benchmark,
instead, basically all halts end within the polling period, except a more
or less constant stream of 50 per second coming from vCPUs that are not
running the benchmark. The wasted time is thus very low. Things may
be slightly different for Windows VMs, which have a ~10 ms timer tick.
The effect is also visible on Marcelo's recently-introduced latency
test for the TSC deadline timer. Though of course a non-RT kernel has
awful latency bounds, the latency of the timer is around 8000-10000 clock
cycles compared to 20000-120000 without setting halt_poll_ns. For the TSC
deadline timer, thus, the effect is both a smaller average latency and
a smaller variance.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2015-02-04 20:20:58 +03:00
ktime_t start , cur ;
2008-05-09 02:47:01 +04:00
DEFINE_WAIT ( wait ) ;
kvm: add halt_poll_ns module parameter
This patch introduces a new module parameter for the KVM module; when it
is present, KVM attempts a bit of polling on every HLT before scheduling
itself out via kvm_vcpu_block.
This parameter helps a lot for latency-bound workloads---in particular
I tested it with O_DSYNC writes with a battery-backed disk in the host.
In this case, writes are fast (because the data doesn't have to go all
the way to the platters) but they cannot be merged by either the host or
the guest. KVM's performance here is usually around 30% of bare metal,
or 50% if you use cache=directsync or cache=writethrough (these
parameters avoid that the guest sends pointless flush requests, and
at the same time they are not slow because of the battery-backed cache).
The bad performance happens because on every halt the host CPU decides
to halt itself too. When the interrupt comes, the vCPU thread is then
migrated to a new physical CPU, and in general the latency is horrible
because the vCPU thread has to be scheduled back in.
With this patch performance reaches 60-65% of bare metal and, more
important, 99% of what you get if you use idle=poll in the guest. This
means that the tunable gets rid of this particular bottleneck, and more
work can be done to improve performance in the kernel or QEMU.
Of course there is some price to pay; every time an otherwise idle vCPUs
is interrupted by an interrupt, it will poll unnecessarily and thus
impose a little load on the host. The above results were obtained with
a mostly random value of the parameter (500000), and the load was around
1.5-2.5% CPU usage on one of the host's core for each idle guest vCPU.
The patch also adds a new stat, /sys/kernel/debug/kvm/halt_successful_poll,
that can be used to tune the parameter. It counts how many HLT
instructions received an interrupt during the polling period; each
successful poll avoids that Linux schedules the VCPU thread out and back
in, and may also avoid a likely trip to C1 and back for the physical CPU.
While the VM is idle, a Linux 4 VCPU VM halts around 10 times per second.
Of these halts, almost all are failed polls. During the benchmark,
instead, basically all halts end within the polling period, except a more
or less constant stream of 50 per second coming from vCPUs that are not
running the benchmark. The wasted time is thus very low. Things may
be slightly different for Windows VMs, which have a ~10 ms timer tick.
The effect is also visible on Marcelo's recently-introduced latency
test for the TSC deadline timer. Though of course a non-RT kernel has
awful latency bounds, the latency of the timer is around 8000-10000 clock
cycles compared to 20000-120000 without setting halt_poll_ns. For the TSC
deadline timer, thus, the effect is both a smaller average latency and
a smaller variance.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2015-02-04 20:20:58 +03:00
bool waited = false ;
start = cur = ktime_get ( ) ;
if ( halt_poll_ns ) {
ktime_t stop = ktime_add_ns ( ktime_get ( ) , halt_poll_ns ) ;
2015-02-26 09:58:23 +03:00
kvm: add halt_poll_ns module parameter
This patch introduces a new module parameter for the KVM module; when it
is present, KVM attempts a bit of polling on every HLT before scheduling
itself out via kvm_vcpu_block.
This parameter helps a lot for latency-bound workloads---in particular
I tested it with O_DSYNC writes with a battery-backed disk in the host.
In this case, writes are fast (because the data doesn't have to go all
the way to the platters) but they cannot be merged by either the host or
the guest. KVM's performance here is usually around 30% of bare metal,
or 50% if you use cache=directsync or cache=writethrough (these
parameters avoid that the guest sends pointless flush requests, and
at the same time they are not slow because of the battery-backed cache).
The bad performance happens because on every halt the host CPU decides
to halt itself too. When the interrupt comes, the vCPU thread is then
migrated to a new physical CPU, and in general the latency is horrible
because the vCPU thread has to be scheduled back in.
With this patch performance reaches 60-65% of bare metal and, more
important, 99% of what you get if you use idle=poll in the guest. This
means that the tunable gets rid of this particular bottleneck, and more
work can be done to improve performance in the kernel or QEMU.
Of course there is some price to pay; every time an otherwise idle vCPUs
is interrupted by an interrupt, it will poll unnecessarily and thus
impose a little load on the host. The above results were obtained with
a mostly random value of the parameter (500000), and the load was around
1.5-2.5% CPU usage on one of the host's core for each idle guest vCPU.
The patch also adds a new stat, /sys/kernel/debug/kvm/halt_successful_poll,
that can be used to tune the parameter. It counts how many HLT
instructions received an interrupt during the polling period; each
successful poll avoids that Linux schedules the VCPU thread out and back
in, and may also avoid a likely trip to C1 and back for the physical CPU.
While the VM is idle, a Linux 4 VCPU VM halts around 10 times per second.
Of these halts, almost all are failed polls. During the benchmark,
instead, basically all halts end within the polling period, except a more
or less constant stream of 50 per second coming from vCPUs that are not
running the benchmark. The wasted time is thus very low. Things may
be slightly different for Windows VMs, which have a ~10 ms timer tick.
The effect is also visible on Marcelo's recently-introduced latency
test for the TSC deadline timer. Though of course a non-RT kernel has
awful latency bounds, the latency of the timer is around 8000-10000 clock
cycles compared to 20000-120000 without setting halt_poll_ns. For the TSC
deadline timer, thus, the effect is both a smaller average latency and
a smaller variance.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2015-02-04 20:20:58 +03:00
do {
/*
* This sets KVM_REQ_UNHALT if an interrupt
* arrives .
*/
if ( kvm_vcpu_check_block ( vcpu ) < 0 ) {
+ + vcpu - > stat . halt_successful_poll ;
goto out ;
}
cur = ktime_get ( ) ;
} while ( single_task_running ( ) & & ktime_before ( cur , stop ) ) ;
}
2008-05-09 02:47:01 +04:00
for ( ; ; ) {
prepare_to_wait ( & vcpu - > wq , & wait , TASK_INTERRUPTIBLE ) ;
kvm: add halt_poll_ns module parameter
This patch introduces a new module parameter for the KVM module; when it
is present, KVM attempts a bit of polling on every HLT before scheduling
itself out via kvm_vcpu_block.
This parameter helps a lot for latency-bound workloads---in particular
I tested it with O_DSYNC writes with a battery-backed disk in the host.
In this case, writes are fast (because the data doesn't have to go all
the way to the platters) but they cannot be merged by either the host or
the guest. KVM's performance here is usually around 30% of bare metal,
or 50% if you use cache=directsync or cache=writethrough (these
parameters avoid that the guest sends pointless flush requests, and
at the same time they are not slow because of the battery-backed cache).
The bad performance happens because on every halt the host CPU decides
to halt itself too. When the interrupt comes, the vCPU thread is then
migrated to a new physical CPU, and in general the latency is horrible
because the vCPU thread has to be scheduled back in.
With this patch performance reaches 60-65% of bare metal and, more
important, 99% of what you get if you use idle=poll in the guest. This
means that the tunable gets rid of this particular bottleneck, and more
work can be done to improve performance in the kernel or QEMU.
Of course there is some price to pay; every time an otherwise idle vCPUs
is interrupted by an interrupt, it will poll unnecessarily and thus
impose a little load on the host. The above results were obtained with
a mostly random value of the parameter (500000), and the load was around
1.5-2.5% CPU usage on one of the host's core for each idle guest vCPU.
The patch also adds a new stat, /sys/kernel/debug/kvm/halt_successful_poll,
that can be used to tune the parameter. It counts how many HLT
instructions received an interrupt during the polling period; each
successful poll avoids that Linux schedules the VCPU thread out and back
in, and may also avoid a likely trip to C1 and back for the physical CPU.
While the VM is idle, a Linux 4 VCPU VM halts around 10 times per second.
Of these halts, almost all are failed polls. During the benchmark,
instead, basically all halts end within the polling period, except a more
or less constant stream of 50 per second coming from vCPUs that are not
running the benchmark. The wasted time is thus very low. Things may
be slightly different for Windows VMs, which have a ~10 ms timer tick.
The effect is also visible on Marcelo's recently-introduced latency
test for the TSC deadline timer. Though of course a non-RT kernel has
awful latency bounds, the latency of the timer is around 8000-10000 clock
cycles compared to 20000-120000 without setting halt_poll_ns. For the TSC
deadline timer, thus, the effect is both a smaller average latency and
a smaller variance.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2015-02-04 20:20:58 +03:00
if ( kvm_vcpu_check_block ( vcpu ) < 0 )
2008-05-09 02:47:01 +04:00
break ;
kvm: add halt_poll_ns module parameter
This patch introduces a new module parameter for the KVM module; when it
is present, KVM attempts a bit of polling on every HLT before scheduling
itself out via kvm_vcpu_block.
This parameter helps a lot for latency-bound workloads---in particular
I tested it with O_DSYNC writes with a battery-backed disk in the host.
In this case, writes are fast (because the data doesn't have to go all
the way to the platters) but they cannot be merged by either the host or
the guest. KVM's performance here is usually around 30% of bare metal,
or 50% if you use cache=directsync or cache=writethrough (these
parameters avoid that the guest sends pointless flush requests, and
at the same time they are not slow because of the battery-backed cache).
The bad performance happens because on every halt the host CPU decides
to halt itself too. When the interrupt comes, the vCPU thread is then
migrated to a new physical CPU, and in general the latency is horrible
because the vCPU thread has to be scheduled back in.
With this patch performance reaches 60-65% of bare metal and, more
important, 99% of what you get if you use idle=poll in the guest. This
means that the tunable gets rid of this particular bottleneck, and more
work can be done to improve performance in the kernel or QEMU.
Of course there is some price to pay; every time an otherwise idle vCPUs
is interrupted by an interrupt, it will poll unnecessarily and thus
impose a little load on the host. The above results were obtained with
a mostly random value of the parameter (500000), and the load was around
1.5-2.5% CPU usage on one of the host's core for each idle guest vCPU.
The patch also adds a new stat, /sys/kernel/debug/kvm/halt_successful_poll,
that can be used to tune the parameter. It counts how many HLT
instructions received an interrupt during the polling period; each
successful poll avoids that Linux schedules the VCPU thread out and back
in, and may also avoid a likely trip to C1 and back for the physical CPU.
While the VM is idle, a Linux 4 VCPU VM halts around 10 times per second.
Of these halts, almost all are failed polls. During the benchmark,
instead, basically all halts end within the polling period, except a more
or less constant stream of 50 per second coming from vCPUs that are not
running the benchmark. The wasted time is thus very low. Things may
be slightly different for Windows VMs, which have a ~10 ms timer tick.
The effect is also visible on Marcelo's recently-introduced latency
test for the TSC deadline timer. Though of course a non-RT kernel has
awful latency bounds, the latency of the timer is around 8000-10000 clock
cycles compared to 20000-120000 without setting halt_poll_ns. For the TSC
deadline timer, thus, the effect is both a smaller average latency and
a smaller variance.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2015-02-04 20:20:58 +03:00
waited = true ;
2007-07-18 13:15:21 +04:00
schedule ( ) ;
}
2007-06-05 16:53:05 +04:00
2008-05-09 02:47:01 +04:00
finish_wait ( & vcpu - > wq , & wait ) ;
kvm: add halt_poll_ns module parameter
This patch introduces a new module parameter for the KVM module; when it
is present, KVM attempts a bit of polling on every HLT before scheduling
itself out via kvm_vcpu_block.
This parameter helps a lot for latency-bound workloads---in particular
I tested it with O_DSYNC writes with a battery-backed disk in the host.
In this case, writes are fast (because the data doesn't have to go all
the way to the platters) but they cannot be merged by either the host or
the guest. KVM's performance here is usually around 30% of bare metal,
or 50% if you use cache=directsync or cache=writethrough (these
parameters avoid that the guest sends pointless flush requests, and
at the same time they are not slow because of the battery-backed cache).
The bad performance happens because on every halt the host CPU decides
to halt itself too. When the interrupt comes, the vCPU thread is then
migrated to a new physical CPU, and in general the latency is horrible
because the vCPU thread has to be scheduled back in.
With this patch performance reaches 60-65% of bare metal and, more
important, 99% of what you get if you use idle=poll in the guest. This
means that the tunable gets rid of this particular bottleneck, and more
work can be done to improve performance in the kernel or QEMU.
Of course there is some price to pay; every time an otherwise idle vCPUs
is interrupted by an interrupt, it will poll unnecessarily and thus
impose a little load on the host. The above results were obtained with
a mostly random value of the parameter (500000), and the load was around
1.5-2.5% CPU usage on one of the host's core for each idle guest vCPU.
The patch also adds a new stat, /sys/kernel/debug/kvm/halt_successful_poll,
that can be used to tune the parameter. It counts how many HLT
instructions received an interrupt during the polling period; each
successful poll avoids that Linux schedules the VCPU thread out and back
in, and may also avoid a likely trip to C1 and back for the physical CPU.
While the VM is idle, a Linux 4 VCPU VM halts around 10 times per second.
Of these halts, almost all are failed polls. During the benchmark,
instead, basically all halts end within the polling period, except a more
or less constant stream of 50 per second coming from vCPUs that are not
running the benchmark. The wasted time is thus very low. Things may
be slightly different for Windows VMs, which have a ~10 ms timer tick.
The effect is also visible on Marcelo's recently-introduced latency
test for the TSC deadline timer. Though of course a non-RT kernel has
awful latency bounds, the latency of the timer is around 8000-10000 clock
cycles compared to 20000-120000 without setting halt_poll_ns. For the TSC
deadline timer, thus, the effect is both a smaller average latency and
a smaller variance.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2015-02-04 20:20:58 +03:00
cur = ktime_get ( ) ;
out :
trace_kvm_vcpu_wakeup ( ktime_to_ns ( cur ) - ktime_to_ns ( start ) , waited ) ;
2007-07-18 13:15:21 +04:00
}
2013-10-07 20:47:59 +04:00
EXPORT_SYMBOL_GPL ( kvm_vcpu_block ) ;
2007-07-18 13:15:21 +04:00
2012-03-15 00:58:48 +04:00
# ifndef CONFIG_S390
2012-03-09 01:44:24 +04:00
/*
* Kick a sleeping VCPU , or a guest VCPU in guest mode , into host kernel mode .
*/
void kvm_vcpu_kick ( struct kvm_vcpu * vcpu )
{
int me ;
int cpu = vcpu - > cpu ;
wait_queue_head_t * wqp ;
wqp = kvm_arch_vcpu_wq ( vcpu ) ;
if ( waitqueue_active ( wqp ) ) {
wake_up_interruptible ( wqp ) ;
+ + vcpu - > stat . halt_wakeup ;
}
me = get_cpu ( ) ;
if ( cpu ! = me & & ( unsigned ) cpu < nr_cpu_ids & & cpu_online ( cpu ) )
if ( kvm_arch_vcpu_should_kick ( vcpu ) )
smp_send_reschedule ( cpu ) ;
put_cpu ( ) ;
}
2013-04-11 15:25:15 +04:00
EXPORT_SYMBOL_GPL ( kvm_vcpu_kick ) ;
2012-03-15 00:58:48 +04:00
# endif /* !CONFIG_S390 */
2012-03-09 01:44:24 +04:00
2014-05-23 14:20:42 +04:00
int kvm_vcpu_yield_to ( struct kvm_vcpu * target )
2012-04-25 17:30:38 +04:00
{
struct pid * pid ;
struct task_struct * task = NULL ;
2014-05-23 14:20:42 +04:00
int ret = 0 ;
2012-04-25 17:30:38 +04:00
rcu_read_lock ( ) ;
pid = rcu_dereference ( target - > pid ) ;
if ( pid )
2014-09-19 03:40:41 +04:00
task = get_pid_task ( pid , PIDTYPE_PID ) ;
2012-04-25 17:30:38 +04:00
rcu_read_unlock ( ) ;
if ( ! task )
2013-01-22 11:39:24 +04:00
return ret ;
ret = yield_to ( task , 1 ) ;
2012-04-25 17:30:38 +04:00
put_task_struct ( task ) ;
2013-01-22 11:39:24 +04:00
return ret ;
2012-04-25 17:30:38 +04:00
}
EXPORT_SYMBOL_GPL ( kvm_vcpu_yield_to ) ;
2012-07-19 13:47:52 +04:00
/*
* Helper that checks whether a VCPU is eligible for directed yield .
* Most eligible candidate to yield is decided by following heuristics :
*
* ( a ) VCPU which has not done pl - exit or cpu relax intercepted recently
* ( preempted lock holder ) , indicated by @ in_spin_loop .
* Set at the beiginning and cleared at the end of interception / PLE handler .
*
* ( b ) VCPU which has done pl - exit / cpu relax intercepted but did not get
* chance last time ( mostly it has become eligible now since we have probably
* yielded to lockholder in last iteration . This is done by toggling
* @ dy_eligible each time a VCPU checked for eligibility . )
*
* Yielding to a recently pl - exited / cpu relax intercepted VCPU before yielding
* to preempted lock - holder could result in wrong VCPU selection and CPU
* burning . Giving priority for a potential lock - holder increases lock
* progress .
*
* Since algorithm is based on heuristics , accessing another VCPU data without
* locking does not harm . It may result in trying to yield to same VCPU , fail
* and continue with next VCPU and so on .
*/
2013-12-30 00:12:29 +04:00
static bool kvm_vcpu_eligible_for_directed_yield ( struct kvm_vcpu * vcpu )
2012-07-19 13:47:52 +04:00
{
2014-01-10 04:43:16 +04:00
# ifdef CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT
2012-07-19 13:47:52 +04:00
bool eligible ;
eligible = ! vcpu - > spin_loop . in_spin_loop | |
2014-09-04 23:13:31 +04:00
vcpu - > spin_loop . dy_eligible ;
2012-07-19 13:47:52 +04:00
if ( vcpu - > spin_loop . in_spin_loop )
kvm_vcpu_set_dy_eligible ( vcpu , ! vcpu - > spin_loop . dy_eligible ) ;
return eligible ;
2014-01-10 04:43:16 +04:00
# else
return true ;
2012-07-19 13:47:52 +04:00
# endif
2014-01-10 04:43:16 +04:00
}
2013-01-22 11:39:24 +04:00
2011-02-01 17:53:28 +03:00
void kvm_vcpu_on_spin ( struct kvm_vcpu * me )
2009-10-09 14:03:20 +04:00
{
2011-02-01 17:53:28 +03:00
struct kvm * kvm = me - > kvm ;
struct kvm_vcpu * vcpu ;
int last_boosted_vcpu = me - > kvm - > last_boosted_vcpu ;
int yielded = 0 ;
2013-01-22 11:39:24 +04:00
int try = 3 ;
2011-02-01 17:53:28 +03:00
int pass ;
int i ;
2009-10-09 14:03:20 +04:00
2012-07-18 17:37:46 +04:00
kvm_vcpu_set_in_spin_loop ( me , true ) ;
2011-02-01 17:53:28 +03:00
/*
* We boost the priority of a VCPU that is runnable but not
* currently running , because it got preempted by something
* else and called schedule in __vcpu_run . Hopefully that
* VCPU is holding the lock that we need and will release it .
* We approximate round - robin by starting at the last boosted VCPU .
*/
2013-01-22 11:39:24 +04:00
for ( pass = 0 ; pass < 2 & & ! yielded & & try ; pass + + ) {
2011-02-01 17:53:28 +03:00
kvm_for_each_vcpu ( i , vcpu , kvm ) {
2012-06-20 00:51:04 +04:00
if ( ! pass & & i < = last_boosted_vcpu ) {
2011-02-01 17:53:28 +03:00
i = last_boosted_vcpu ;
continue ;
} else if ( pass & & i > last_boosted_vcpu )
break ;
2013-03-04 22:02:27 +04:00
if ( ! ACCESS_ONCE ( vcpu - > preempted ) )
continue ;
2011-02-01 17:53:28 +03:00
if ( vcpu = = me )
continue ;
2014-02-26 19:14:18 +04:00
if ( waitqueue_active ( & vcpu - > wq ) & & ! kvm_arch_vcpu_runnable ( vcpu ) )
2011-02-01 17:53:28 +03:00
continue ;
2012-07-19 13:47:52 +04:00
if ( ! kvm_vcpu_eligible_for_directed_yield ( vcpu ) )
continue ;
2013-01-22 11:39:24 +04:00
yielded = kvm_vcpu_yield_to ( vcpu ) ;
if ( yielded > 0 ) {
2011-02-01 17:53:28 +03:00
kvm - > last_boosted_vcpu = i ;
break ;
2013-01-22 11:39:24 +04:00
} else if ( yielded < 0 ) {
try - - ;
if ( ! try )
break ;
2011-02-01 17:53:28 +03:00
}
}
}
2012-07-18 17:37:46 +04:00
kvm_vcpu_set_in_spin_loop ( me , false ) ;
2012-07-19 13:47:52 +04:00
/* Ensure vcpu is not eligible during next spinloop */
kvm_vcpu_set_dy_eligible ( me , false ) ;
2009-10-09 14:03:20 +04:00
}
EXPORT_SYMBOL_GPL ( kvm_vcpu_on_spin ) ;
2007-12-05 10:15:52 +03:00
static int kvm_vcpu_fault ( struct vm_area_struct * vma , struct vm_fault * vmf )
2007-02-22 13:58:31 +03:00
{
struct kvm_vcpu * vcpu = vma - > vm_file - > private_data ;
struct page * page ;
2007-12-05 10:15:52 +03:00
if ( vmf - > pgoff = = 0 )
2007-03-20 13:46:50 +03:00
page = virt_to_page ( vcpu - > run ) ;
2008-01-23 19:14:23 +03:00
# ifdef CONFIG_X86
2007-12-05 10:15:52 +03:00
else if ( vmf - > pgoff = = KVM_PIO_PAGE_OFFSET )
2007-12-13 18:50:52 +03:00
page = virt_to_page ( vcpu - > arch . pio_data ) ;
2008-05-30 18:05:54 +04:00
# endif
# ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
else if ( vmf - > pgoff = = KVM_COALESCED_MMIO_PAGE_OFFSET )
page = virt_to_page ( vcpu - > kvm - > coalesced_mmio_ring ) ;
2008-01-23 19:14:23 +03:00
# endif
2007-03-20 13:46:50 +03:00
else
2012-01-04 13:25:23 +04:00
return kvm_arch_vcpu_fault ( vcpu , vmf ) ;
2007-02-22 13:58:31 +03:00
get_page ( page ) ;
2007-12-05 10:15:52 +03:00
vmf - > page = page ;
return 0 ;
2007-02-22 13:58:31 +03:00
}
2009-09-27 22:29:37 +04:00
static const struct vm_operations_struct kvm_vcpu_vm_ops = {
2007-12-05 10:15:52 +03:00
. fault = kvm_vcpu_fault ,
2007-02-22 13:58:31 +03:00
} ;
static int kvm_vcpu_mmap ( struct file * file , struct vm_area_struct * vma )
{
vma - > vm_ops = & kvm_vcpu_vm_ops ;
return 0 ;
}
2007-02-21 19:04:26 +03:00
static int kvm_vcpu_release ( struct inode * inode , struct file * filp )
{
struct kvm_vcpu * vcpu = filp - > private_data ;
2008-04-19 23:33:56 +04:00
kvm_put_kvm ( vcpu - > kvm ) ;
2007-02-21 19:04:26 +03:00
return 0 ;
}
2008-12-02 13:17:32 +03:00
static struct file_operations kvm_vcpu_fops = {
2007-02-21 19:04:26 +03:00
. release = kvm_vcpu_release ,
. unlocked_ioctl = kvm_vcpu_ioctl ,
2015-02-03 11:35:15 +03:00
# ifdef CONFIG_KVM_COMPAT
2011-06-08 04:45:37 +04:00
. compat_ioctl = kvm_vcpu_compat_ioctl ,
# endif
2007-02-22 13:58:31 +03:00
. mmap = kvm_vcpu_mmap ,
llseek: automatically add .llseek fop
All file_operations should get a .llseek operation so we can make
nonseekable_open the default for future file operations without a
.llseek pointer.
The three cases that we can automatically detect are no_llseek, seq_lseek
and default_llseek. For cases where we can we can automatically prove that
the file offset is always ignored, we use noop_llseek, which maintains
the current behavior of not returning an error from a seek.
New drivers should normally not use noop_llseek but instead use no_llseek
and call nonseekable_open at open time. Existing drivers can be converted
to do the same when the maintainer knows for certain that no user code
relies on calling seek on the device file.
The generated code is often incorrectly indented and right now contains
comments that clarify for each added line why a specific variant was
chosen. In the version that gets submitted upstream, the comments will
be gone and I will manually fix the indentation, because there does not
seem to be a way to do that using coccinelle.
Some amount of new code is currently sitting in linux-next that should get
the same modifications, which I will do at the end of the merge window.
Many thanks to Julia Lawall for helping me learn to write a semantic
patch that does all this.
===== begin semantic patch =====
// This adds an llseek= method to all file operations,
// as a preparation for making no_llseek the default.
//
// The rules are
// - use no_llseek explicitly if we do nonseekable_open
// - use seq_lseek for sequential files
// - use default_llseek if we know we access f_pos
// - use noop_llseek if we know we don't access f_pos,
// but we still want to allow users to call lseek
//
@ open1 exists @
identifier nested_open;
@@
nested_open(...)
{
<+...
nonseekable_open(...)
...+>
}
@ open exists@
identifier open_f;
identifier i, f;
identifier open1.nested_open;
@@
int open_f(struct inode *i, struct file *f)
{
<+...
(
nonseekable_open(...)
|
nested_open(...)
)
...+>
}
@ read disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ read_no_fpos disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
... when != off
}
@ write @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ write_no_fpos @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
... when != off
}
@ fops0 @
identifier fops;
@@
struct file_operations fops = {
...
};
@ has_llseek depends on fops0 @
identifier fops0.fops;
identifier llseek_f;
@@
struct file_operations fops = {
...
.llseek = llseek_f,
...
};
@ has_read depends on fops0 @
identifier fops0.fops;
identifier read_f;
@@
struct file_operations fops = {
...
.read = read_f,
...
};
@ has_write depends on fops0 @
identifier fops0.fops;
identifier write_f;
@@
struct file_operations fops = {
...
.write = write_f,
...
};
@ has_open depends on fops0 @
identifier fops0.fops;
identifier open_f;
@@
struct file_operations fops = {
...
.open = open_f,
...
};
// use no_llseek if we call nonseekable_open
////////////////////////////////////////////
@ nonseekable1 depends on !has_llseek && has_open @
identifier fops0.fops;
identifier nso ~= "nonseekable_open";
@@
struct file_operations fops = {
... .open = nso, ...
+.llseek = no_llseek, /* nonseekable */
};
@ nonseekable2 depends on !has_llseek @
identifier fops0.fops;
identifier open.open_f;
@@
struct file_operations fops = {
... .open = open_f, ...
+.llseek = no_llseek, /* open uses nonseekable */
};
// use seq_lseek for sequential files
/////////////////////////////////////
@ seq depends on !has_llseek @
identifier fops0.fops;
identifier sr ~= "seq_read";
@@
struct file_operations fops = {
... .read = sr, ...
+.llseek = seq_lseek, /* we have seq_read */
};
// use default_llseek if there is a readdir
///////////////////////////////////////////
@ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier readdir_e;
@@
// any other fop is used that changes pos
struct file_operations fops = {
... .readdir = readdir_e, ...
+.llseek = default_llseek, /* readdir is present */
};
// use default_llseek if at least one of read/write touches f_pos
/////////////////////////////////////////////////////////////////
@ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read.read_f;
@@
// read fops use offset
struct file_operations fops = {
... .read = read_f, ...
+.llseek = default_llseek, /* read accesses f_pos */
};
@ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write.write_f;
@@
// write fops use offset
struct file_operations fops = {
... .write = write_f, ...
+ .llseek = default_llseek, /* write accesses f_pos */
};
// Use noop_llseek if neither read nor write accesses f_pos
///////////////////////////////////////////////////////////
@ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
identifier write_no_fpos.write_f;
@@
// write fops use offset
struct file_operations fops = {
...
.write = write_f,
.read = read_f,
...
+.llseek = noop_llseek, /* read and write both use no f_pos */
};
@ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write_no_fpos.write_f;
@@
struct file_operations fops = {
... .write = write_f, ...
+.llseek = noop_llseek, /* write uses no f_pos */
};
@ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
@@
struct file_operations fops = {
... .read = read_f, ...
+.llseek = noop_llseek, /* read uses no f_pos */
};
@ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
@@
struct file_operations fops = {
...
+.llseek = noop_llseek, /* no read or write fn */
};
===== End semantic patch =====
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Julia Lawall <julia@diku.dk>
Cc: Christoph Hellwig <hch@infradead.org>
2010-08-15 20:52:59 +04:00
. llseek = noop_llseek ,
2007-02-21 19:04:26 +03:00
} ;
/*
* Allocates an inode for the vcpu .
*/
static int create_vcpu_fd ( struct kvm_vcpu * vcpu )
{
2013-08-25 00:14:07 +04:00
return anon_inode_getfd ( " kvm-vcpu " , & kvm_vcpu_fops , vcpu , O_RDWR | O_CLOEXEC ) ;
2007-02-21 19:04:26 +03:00
}
2007-02-20 19:41:05 +03:00
/*
* Creates some virtual cpus . Good luck creating more than one .
*/
2009-06-09 16:56:28 +04:00
static int kvm_vm_ioctl_create_vcpu ( struct kvm * kvm , u32 id )
2007-02-20 19:41:05 +03:00
{
int r ;
2009-06-09 16:56:29 +04:00
struct kvm_vcpu * vcpu , * v ;
2007-02-20 19:41:05 +03:00
2013-11-19 04:09:22 +04:00
if ( id > = KVM_MAX_VCPUS )
return - EINVAL ;
2009-06-09 16:56:28 +04:00
vcpu = kvm_arch_vcpu_create ( kvm , id ) ;
2007-07-27 11:16:56 +04:00
if ( IS_ERR ( vcpu ) )
return PTR_ERR ( vcpu ) ;
2007-02-20 19:41:05 +03:00
2007-07-11 19:17:21 +04:00
preempt_notifier_init ( & vcpu - > preempt_notifier , & kvm_preempt_ops ) ;
2007-11-20 16:30:24 +03:00
r = kvm_arch_vcpu_setup ( vcpu ) ;
if ( r )
2011-05-23 12:33:05 +04:00
goto vcpu_destroy ;
2007-11-20 16:30:24 +03:00
2007-07-23 10:51:37 +04:00
mutex_lock ( & kvm - > lock ) ;
2012-03-05 16:23:29 +04:00
if ( ! kvm_vcpu_compatible ( vcpu ) ) {
r = - EINVAL ;
goto unlock_vcpu_destroy ;
}
2009-06-09 16:56:28 +04:00
if ( atomic_read ( & kvm - > online_vcpus ) = = KVM_MAX_VCPUS ) {
r = - EINVAL ;
2011-05-23 12:33:05 +04:00
goto unlock_vcpu_destroy ;
2007-07-27 11:16:56 +04:00
}
2009-06-09 16:56:28 +04:00
2009-06-09 16:56:29 +04:00
kvm_for_each_vcpu ( r , v , kvm )
if ( v - > vcpu_id = = id ) {
2009-06-09 16:56:28 +04:00
r = - EEXIST ;
2011-05-23 12:33:05 +04:00
goto unlock_vcpu_destroy ;
2009-06-09 16:56:28 +04:00
}
BUG_ON ( kvm - > vcpus [ atomic_read ( & kvm - > online_vcpus ) ] ) ;
2007-02-20 19:41:05 +03:00
2007-07-27 11:16:56 +04:00
/* Now it's all set up, let userspace reach it */
2008-04-19 23:33:56 +04:00
kvm_get_kvm ( kvm ) ;
2007-02-21 19:04:26 +03:00
r = create_vcpu_fd ( vcpu ) ;
2009-06-09 16:56:28 +04:00
if ( r < 0 ) {
kvm_put_kvm ( kvm ) ;
2011-05-23 12:33:05 +04:00
goto unlock_vcpu_destroy ;
2009-06-09 16:56:28 +04:00
}
kvm - > vcpus [ atomic_read ( & kvm - > online_vcpus ) ] = vcpu ;
2015-07-29 12:32:20 +03:00
/*
* Pairs with smp_rmb ( ) in kvm_get_vcpu . Write kvm - > vcpus
* before kvm - > online_vcpu ' s incremented value .
*/
2009-06-09 16:56:28 +04:00
smp_wmb ( ) ;
atomic_inc ( & kvm - > online_vcpus ) ;
mutex_unlock ( & kvm - > lock ) ;
2012-11-28 05:29:02 +04:00
kvm_arch_vcpu_postcreate ( vcpu ) ;
2007-07-27 11:16:56 +04:00
return r ;
2007-06-07 20:11:53 +04:00
2011-05-23 12:33:05 +04:00
unlock_vcpu_destroy :
2008-09-18 06:16:59 +04:00
mutex_unlock ( & kvm - > lock ) ;
2011-05-23 12:33:05 +04:00
vcpu_destroy :
2007-11-19 23:04:43 +03:00
kvm_arch_vcpu_destroy ( vcpu ) ;
2007-02-20 19:41:05 +03:00
return r ;
}
2007-03-05 20:46:05 +03:00
static int kvm_vcpu_ioctl_set_sigmask ( struct kvm_vcpu * vcpu , sigset_t * sigset )
{
if ( sigset ) {
sigdelsetmask ( sigset , sigmask ( SIGKILL ) | sigmask ( SIGSTOP ) ) ;
vcpu - > sigset_active = 1 ;
vcpu - > sigset = * sigset ;
} else
vcpu - > sigset_active = 0 ;
return 0 ;
}
2007-02-21 19:04:26 +03:00
static long kvm_vcpu_ioctl ( struct file * filp ,
unsigned int ioctl , unsigned long arg )
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
{
2007-02-21 19:04:26 +03:00
struct kvm_vcpu * vcpu = filp - > private_data ;
2007-02-09 19:38:35 +03:00
void __user * argp = ( void __user * ) arg ;
KVM: Portability: split kvm_vcpu_ioctl
This patch splits kvm_vcpu_ioctl into archtecture independent parts, and
x86 specific parts which go to kvm_arch_vcpu_ioctl in x86.c.
Common ioctls for all architectures are:
KVM_RUN, KVM_GET/SET_(S-)REGS, KVM_TRANSLATE, KVM_INTERRUPT,
KVM_DEBUG_GUEST, KVM_SET_SIGNAL_MASK, KVM_GET/SET_FPU
Note that some PPC chips don't have an FPU, so we might need an #ifdef
around KVM_GET/SET_FPU one day.
x86 specific ioctls are:
KVM_GET/SET_LAPIC, KVM_SET_CPUID, KVM_GET/SET_MSRS
An interresting aspect is vcpu_load/vcpu_put. We now have a common
vcpu_load/put which does the preemption stuff, and an architecture
specific kvm_arch_vcpu_load/put. In the x86 case, this one calls the
vmx/svm function defined in kvm_x86_ops.
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
2007-10-11 21:16:52 +04:00
int r ;
2008-08-11 21:01:46 +04:00
struct kvm_fpu * fpu = NULL ;
struct kvm_sregs * kvm_sregs = NULL ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
2007-11-21 17:41:05 +03:00
if ( vcpu - > kvm - > mm ! = current - > mm )
return - EIO ;
2010-05-13 12:25:04 +04:00
2014-09-20 03:03:25 +04:00
if ( unlikely ( _IOC_TYPE ( ioctl ) ! = KVMIO ) )
return - EINVAL ;
2012-11-22 06:34:15 +04:00
# if defined(CONFIG_S390) || defined(CONFIG_PPC) || defined(CONFIG_MIPS)
2010-05-13 12:25:04 +04:00
/*
* Special cases : vcpu ioctls that are asynchronous to vcpu execution ,
* so vcpu_load ( ) would break it .
*/
2014-11-11 22:57:06 +03:00
if ( ioctl = = KVM_S390_INTERRUPT | | ioctl = = KVM_S390_IRQ | | ioctl = = KVM_INTERRUPT )
2010-05-13 12:25:04 +04:00
return kvm_arch_vcpu_ioctl ( filp , ioctl , arg ) ;
# endif
2012-09-16 12:50:30 +04:00
r = vcpu_load ( vcpu ) ;
if ( r )
return r ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
switch ( ioctl ) {
2007-02-22 13:58:31 +03:00
case KVM_RUN :
2007-03-07 14:11:17 +03:00
r = - EINVAL ;
if ( arg )
goto out ;
2014-08-05 18:44:14 +04:00
if ( unlikely ( vcpu - > pid ! = current - > pids [ PIDTYPE_PID ] . pid ) ) {
/* The thread running this VCPU changed. */
struct pid * oldpid = vcpu - > pid ;
struct pid * newpid = get_task_pid ( current , PIDTYPE_PID ) ;
2015-02-26 09:58:23 +03:00
2014-08-05 18:44:14 +04:00
rcu_assign_pointer ( vcpu - > pid , newpid ) ;
if ( oldpid )
synchronize_rcu ( ) ;
put_pid ( oldpid ) ;
}
2007-11-01 22:16:10 +03:00
r = kvm_arch_vcpu_ioctl_run ( vcpu , vcpu - > run ) ;
2010-10-24 18:49:08 +04:00
trace_kvm_userspace_exit ( vcpu - > run - > exit_reason , r ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
break ;
case KVM_GET_REGS : {
2008-02-25 13:52:20 +03:00
struct kvm_regs * kvm_regs ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
2008-02-25 13:52:20 +03:00
r = - ENOMEM ;
kvm_regs = kzalloc ( sizeof ( struct kvm_regs ) , GFP_KERNEL ) ;
if ( ! kvm_regs )
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
goto out ;
2008-02-25 13:52:20 +03:00
r = kvm_arch_vcpu_ioctl_get_regs ( vcpu , kvm_regs ) ;
if ( r )
goto out_free1 ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
r = - EFAULT ;
2008-02-25 13:52:20 +03:00
if ( copy_to_user ( argp , kvm_regs , sizeof ( struct kvm_regs ) ) )
goto out_free1 ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
r = 0 ;
2008-02-25 13:52:20 +03:00
out_free1 :
kfree ( kvm_regs ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
break ;
}
case KVM_SET_REGS : {
2008-02-25 13:52:20 +03:00
struct kvm_regs * kvm_regs ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
2008-02-25 13:52:20 +03:00
r = - ENOMEM ;
2011-12-04 21:36:29 +04:00
kvm_regs = memdup_user ( argp , sizeof ( * kvm_regs ) ) ;
if ( IS_ERR ( kvm_regs ) ) {
r = PTR_ERR ( kvm_regs ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
goto out ;
2011-12-04 21:36:29 +04:00
}
2008-02-25 13:52:20 +03:00
r = kvm_arch_vcpu_ioctl_set_regs ( vcpu , kvm_regs ) ;
kfree ( kvm_regs ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
break ;
}
case KVM_GET_SREGS : {
2008-08-11 21:01:46 +04:00
kvm_sregs = kzalloc ( sizeof ( struct kvm_sregs ) , GFP_KERNEL ) ;
r = - ENOMEM ;
if ( ! kvm_sregs )
goto out ;
r = kvm_arch_vcpu_ioctl_get_sregs ( vcpu , kvm_sregs ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
if ( r )
goto out ;
r = - EFAULT ;
2008-08-11 21:01:46 +04:00
if ( copy_to_user ( argp , kvm_sregs , sizeof ( struct kvm_sregs ) ) )
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
goto out ;
r = 0 ;
break ;
}
case KVM_SET_SREGS : {
2011-12-04 21:36:29 +04:00
kvm_sregs = memdup_user ( argp , sizeof ( * kvm_sregs ) ) ;
if ( IS_ERR ( kvm_sregs ) ) {
r = PTR_ERR ( kvm_sregs ) ;
2012-11-02 14:33:21 +04:00
kvm_sregs = NULL ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
goto out ;
2011-12-04 21:36:29 +04:00
}
2008-08-11 21:01:46 +04:00
r = kvm_arch_vcpu_ioctl_set_sregs ( vcpu , kvm_sregs ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
break ;
}
2008-04-11 20:24:45 +04:00
case KVM_GET_MP_STATE : {
struct kvm_mp_state mp_state ;
r = kvm_arch_vcpu_ioctl_get_mpstate ( vcpu , & mp_state ) ;
if ( r )
goto out ;
r = - EFAULT ;
2015-02-26 09:58:19 +03:00
if ( copy_to_user ( argp , & mp_state , sizeof ( mp_state ) ) )
2008-04-11 20:24:45 +04:00
goto out ;
r = 0 ;
break ;
}
case KVM_SET_MP_STATE : {
struct kvm_mp_state mp_state ;
r = - EFAULT ;
2015-02-26 09:58:19 +03:00
if ( copy_from_user ( & mp_state , argp , sizeof ( mp_state ) ) )
2008-04-11 20:24:45 +04:00
goto out ;
r = kvm_arch_vcpu_ioctl_set_mpstate ( vcpu , & mp_state ) ;
break ;
}
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
case KVM_TRANSLATE : {
struct kvm_translation tr ;
r = - EFAULT ;
2015-02-26 09:58:19 +03:00
if ( copy_from_user ( & tr , argp , sizeof ( tr ) ) )
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
goto out ;
2007-11-16 08:05:55 +03:00
r = kvm_arch_vcpu_ioctl_translate ( vcpu , & tr ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
if ( r )
goto out ;
r = - EFAULT ;
2015-02-26 09:58:19 +03:00
if ( copy_to_user ( argp , & tr , sizeof ( tr ) ) )
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
goto out ;
r = 0 ;
break ;
}
2008-12-15 15:52:10 +03:00
case KVM_SET_GUEST_DEBUG : {
struct kvm_guest_debug dbg ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
r = - EFAULT ;
2015-02-26 09:58:19 +03:00
if ( copy_from_user ( & dbg , argp , sizeof ( dbg ) ) )
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
goto out ;
2008-12-15 15:52:10 +03:00
r = kvm_arch_vcpu_ioctl_set_guest_debug ( vcpu , & dbg ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
break ;
}
2007-03-05 20:46:05 +03:00
case KVM_SET_SIGNAL_MASK : {
struct kvm_signal_mask __user * sigmask_arg = argp ;
struct kvm_signal_mask kvm_sigmask ;
sigset_t sigset , * p ;
p = NULL ;
if ( argp ) {
r = - EFAULT ;
if ( copy_from_user ( & kvm_sigmask , argp ,
2015-02-26 09:58:19 +03:00
sizeof ( kvm_sigmask ) ) )
2007-03-05 20:46:05 +03:00
goto out ;
r = - EINVAL ;
2015-02-26 09:58:19 +03:00
if ( kvm_sigmask . len ! = sizeof ( sigset ) )
2007-03-05 20:46:05 +03:00
goto out ;
r = - EFAULT ;
if ( copy_from_user ( & sigset , sigmask_arg - > sigset ,
2015-02-26 09:58:19 +03:00
sizeof ( sigset ) ) )
2007-03-05 20:46:05 +03:00
goto out ;
p = & sigset ;
}
2010-06-10 15:10:47 +04:00
r = kvm_vcpu_ioctl_set_sigmask ( vcpu , p ) ;
2007-03-05 20:46:05 +03:00
break ;
}
2007-04-01 17:34:31 +04:00
case KVM_GET_FPU : {
2008-08-11 21:01:46 +04:00
fpu = kzalloc ( sizeof ( struct kvm_fpu ) , GFP_KERNEL ) ;
r = - ENOMEM ;
if ( ! fpu )
goto out ;
r = kvm_arch_vcpu_ioctl_get_fpu ( vcpu , fpu ) ;
2007-04-01 17:34:31 +04:00
if ( r )
goto out ;
r = - EFAULT ;
2008-08-11 21:01:46 +04:00
if ( copy_to_user ( argp , fpu , sizeof ( struct kvm_fpu ) ) )
2007-04-01 17:34:31 +04:00
goto out ;
r = 0 ;
break ;
}
case KVM_SET_FPU : {
2011-12-04 21:36:29 +04:00
fpu = memdup_user ( argp , sizeof ( * fpu ) ) ;
if ( IS_ERR ( fpu ) ) {
r = PTR_ERR ( fpu ) ;
2012-11-02 14:33:21 +04:00
fpu = NULL ;
2007-04-01 17:34:31 +04:00
goto out ;
2011-12-04 21:36:29 +04:00
}
2008-08-11 21:01:46 +04:00
r = kvm_arch_vcpu_ioctl_set_fpu ( vcpu , fpu ) ;
2007-04-01 17:34:31 +04:00
break ;
}
2007-02-21 19:04:26 +03:00
default :
KVM: Portability: split kvm_vcpu_ioctl
This patch splits kvm_vcpu_ioctl into archtecture independent parts, and
x86 specific parts which go to kvm_arch_vcpu_ioctl in x86.c.
Common ioctls for all architectures are:
KVM_RUN, KVM_GET/SET_(S-)REGS, KVM_TRANSLATE, KVM_INTERRUPT,
KVM_DEBUG_GUEST, KVM_SET_SIGNAL_MASK, KVM_GET/SET_FPU
Note that some PPC chips don't have an FPU, so we might need an #ifdef
around KVM_GET/SET_FPU one day.
x86 specific ioctls are:
KVM_GET/SET_LAPIC, KVM_SET_CPUID, KVM_GET/SET_MSRS
An interresting aspect is vcpu_load/vcpu_put. We now have a common
vcpu_load/put which does the preemption stuff, and an architecture
specific kvm_arch_vcpu_load/put. In the x86 case, this one calls the
vmx/svm function defined in kvm_x86_ops.
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
2007-10-11 21:16:52 +04:00
r = kvm_arch_vcpu_ioctl ( filp , ioctl , arg ) ;
2007-02-21 19:04:26 +03:00
}
out :
2010-05-13 12:25:04 +04:00
vcpu_put ( vcpu ) ;
2008-08-11 21:01:46 +04:00
kfree ( fpu ) ;
kfree ( kvm_sregs ) ;
2007-02-21 19:04:26 +03:00
return r ;
}
2015-02-03 11:35:15 +03:00
# ifdef CONFIG_KVM_COMPAT
2011-06-08 04:45:37 +04:00
static long kvm_vcpu_compat_ioctl ( struct file * filp ,
unsigned int ioctl , unsigned long arg )
{
struct kvm_vcpu * vcpu = filp - > private_data ;
void __user * argp = compat_ptr ( arg ) ;
int r ;
if ( vcpu - > kvm - > mm ! = current - > mm )
return - EIO ;
switch ( ioctl ) {
case KVM_SET_SIGNAL_MASK : {
struct kvm_signal_mask __user * sigmask_arg = argp ;
struct kvm_signal_mask kvm_sigmask ;
compat_sigset_t csigset ;
sigset_t sigset ;
if ( argp ) {
r = - EFAULT ;
if ( copy_from_user ( & kvm_sigmask , argp ,
2015-02-26 09:58:19 +03:00
sizeof ( kvm_sigmask ) ) )
2011-06-08 04:45:37 +04:00
goto out ;
r = - EINVAL ;
2015-02-26 09:58:19 +03:00
if ( kvm_sigmask . len ! = sizeof ( csigset ) )
2011-06-08 04:45:37 +04:00
goto out ;
r = - EFAULT ;
if ( copy_from_user ( & csigset , sigmask_arg - > sigset ,
2015-02-26 09:58:19 +03:00
sizeof ( csigset ) ) )
2011-06-08 04:45:37 +04:00
goto out ;
2012-08-22 17:34:11 +04:00
sigset_from_compat ( & sigset , & csigset ) ;
r = kvm_vcpu_ioctl_set_sigmask ( vcpu , & sigset ) ;
} else
r = kvm_vcpu_ioctl_set_sigmask ( vcpu , NULL ) ;
2011-06-08 04:45:37 +04:00
break ;
}
default :
r = kvm_vcpu_ioctl ( filp , ioctl , arg ) ;
}
out :
return r ;
}
# endif
2013-04-12 18:08:42 +04:00
static int kvm_device_ioctl_attr ( struct kvm_device * dev ,
int ( * accessor ) ( struct kvm_device * dev ,
struct kvm_device_attr * attr ) ,
unsigned long arg )
{
struct kvm_device_attr attr ;
if ( ! accessor )
return - EPERM ;
if ( copy_from_user ( & attr , ( void __user * ) arg , sizeof ( attr ) ) )
return - EFAULT ;
return accessor ( dev , & attr ) ;
}
static long kvm_device_ioctl ( struct file * filp , unsigned int ioctl ,
unsigned long arg )
{
struct kvm_device * dev = filp - > private_data ;
switch ( ioctl ) {
case KVM_SET_DEVICE_ATTR :
return kvm_device_ioctl_attr ( dev , dev - > ops - > set_attr , arg ) ;
case KVM_GET_DEVICE_ATTR :
return kvm_device_ioctl_attr ( dev , dev - > ops - > get_attr , arg ) ;
case KVM_HAS_DEVICE_ATTR :
return kvm_device_ioctl_attr ( dev , dev - > ops - > has_attr , arg ) ;
default :
if ( dev - > ops - > ioctl )
return dev - > ops - > ioctl ( dev , ioctl , arg ) ;
return - ENOTTY ;
}
}
static int kvm_device_release ( struct inode * inode , struct file * filp )
{
struct kvm_device * dev = filp - > private_data ;
struct kvm * kvm = dev - > kvm ;
kvm_put_kvm ( kvm ) ;
return 0 ;
}
static const struct file_operations kvm_device_fops = {
. unlocked_ioctl = kvm_device_ioctl ,
2015-02-03 11:35:15 +03:00
# ifdef CONFIG_KVM_COMPAT
2013-05-01 05:00:45 +04:00
. compat_ioctl = kvm_device_ioctl ,
# endif
2013-04-12 18:08:42 +04:00
. release = kvm_device_release ,
} ;
struct kvm_device * kvm_device_from_filp ( struct file * filp )
{
if ( filp - > f_op ! = & kvm_device_fops )
return NULL ;
return filp - > private_data ;
}
2014-09-02 13:27:33 +04:00
static struct kvm_device_ops * kvm_device_ops_table [ KVM_DEV_TYPE_MAX ] = {
2013-04-12 18:08:46 +04:00
# ifdef CONFIG_KVM_MPIC
2014-09-02 13:27:33 +04:00
[ KVM_DEV_TYPE_FSL_MPIC_20 ] = & kvm_mpic_ops ,
[ KVM_DEV_TYPE_FSL_MPIC_42 ] = & kvm_mpic_ops ,
2013-04-27 04:28:37 +04:00
# endif
2014-09-02 13:27:33 +04:00
2013-04-27 04:28:37 +04:00
# ifdef CONFIG_KVM_XICS
2014-09-02 13:27:33 +04:00
[ KVM_DEV_TYPE_XICS ] = & kvm_xics_ops ,
2013-10-30 21:02:17 +04:00
# endif
2014-09-02 13:27:33 +04:00
} ;
int kvm_register_device_ops ( struct kvm_device_ops * ops , u32 type )
{
if ( type > = ARRAY_SIZE ( kvm_device_ops_table ) )
return - ENOSPC ;
if ( kvm_device_ops_table [ type ] ! = NULL )
return - EEXIST ;
kvm_device_ops_table [ type ] = ops ;
return 0 ;
}
2014-10-09 14:30:08 +04:00
void kvm_unregister_device_ops ( u32 type )
{
if ( kvm_device_ops_table [ type ] ! = NULL )
kvm_device_ops_table [ type ] = NULL ;
}
2013-04-12 18:08:42 +04:00
static int kvm_ioctl_create_device ( struct kvm * kvm ,
struct kvm_create_device * cd )
{
struct kvm_device_ops * ops = NULL ;
struct kvm_device * dev ;
bool test = cd - > flags & KVM_CREATE_DEVICE_TEST ;
int ret ;
2014-09-02 13:27:33 +04:00
if ( cd - > type > = ARRAY_SIZE ( kvm_device_ops_table ) )
return - ENODEV ;
ops = kvm_device_ops_table [ cd - > type ] ;
if ( ops = = NULL )
2013-04-12 18:08:42 +04:00
return - ENODEV ;
if ( test )
return 0 ;
dev = kzalloc ( sizeof ( * dev ) , GFP_KERNEL ) ;
if ( ! dev )
return - ENOMEM ;
dev - > ops = ops ;
dev - > kvm = kvm ;
ret = ops - > create ( dev , cd - > type ) ;
if ( ret < 0 ) {
kfree ( dev ) ;
return ret ;
}
2013-08-25 00:14:07 +04:00
ret = anon_inode_getfd ( ops - > name , & kvm_device_fops , dev , O_RDWR | O_CLOEXEC ) ;
2013-04-12 18:08:42 +04:00
if ( ret < 0 ) {
ops - > destroy ( dev ) ;
return ret ;
}
2013-04-25 18:11:23 +04:00
list_add ( & dev - > vm_node , & kvm - > devices ) ;
2013-04-12 18:08:42 +04:00
kvm_get_kvm ( kvm ) ;
cd - > fd = ret ;
return 0 ;
}
2014-07-14 20:33:08 +04:00
static long kvm_vm_ioctl_check_extension_generic ( struct kvm * kvm , long arg )
{
switch ( arg ) {
case KVM_CAP_USER_MEMORY :
case KVM_CAP_DESTROY_MEMORY_REGION_WORKS :
case KVM_CAP_JOIN_MEMORY_REGIONS_WORKS :
case KVM_CAP_INTERNAL_ERROR_DATA :
# ifdef CONFIG_HAVE_KVM_MSI
case KVM_CAP_SIGNAL_MSI :
# endif
2014-06-30 14:51:13 +04:00
# ifdef CONFIG_HAVE_KVM_IRQFD
2015-03-05 13:54:46 +03:00
case KVM_CAP_IRQFD :
2014-07-14 20:33:08 +04:00
case KVM_CAP_IRQFD_RESAMPLE :
# endif
case KVM_CAP_CHECK_EXTENSION_VM :
return 1 ;
# ifdef CONFIG_HAVE_KVM_IRQ_ROUTING
case KVM_CAP_IRQ_ROUTING :
return KVM_MAX_IRQ_ROUTES ;
2015-05-17 18:30:37 +03:00
# endif
# if KVM_ADDRESS_SPACE_NUM > 1
case KVM_CAP_MULTI_ADDRESS_SPACE :
return KVM_ADDRESS_SPACE_NUM ;
2014-07-14 20:33:08 +04:00
# endif
default :
break ;
}
return kvm_vm_ioctl_check_extension ( kvm , arg ) ;
}
2007-02-21 19:04:26 +03:00
static long kvm_vm_ioctl ( struct file * filp ,
unsigned int ioctl , unsigned long arg )
{
struct kvm * kvm = filp - > private_data ;
void __user * argp = ( void __user * ) arg ;
2007-10-29 18:08:35 +03:00
int r ;
2007-02-21 19:04:26 +03:00
2007-11-21 17:41:05 +03:00
if ( kvm - > mm ! = current - > mm )
return - EIO ;
2007-02-21 19:04:26 +03:00
switch ( ioctl ) {
case KVM_CREATE_VCPU :
r = kvm_vm_ioctl_create_vcpu ( kvm , arg ) ;
break ;
2007-10-09 21:20:39 +04:00
case KVM_SET_USER_MEMORY_REGION : {
struct kvm_userspace_memory_region kvm_userspace_mem ;
r = - EFAULT ;
if ( copy_from_user ( & kvm_userspace_mem , argp ,
2015-02-26 09:58:19 +03:00
sizeof ( kvm_userspace_mem ) ) )
2007-10-09 21:20:39 +04:00
goto out ;
2013-02-27 14:43:00 +04:00
r = kvm_vm_ioctl_set_memory_region ( kvm , & kvm_userspace_mem ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
break ;
}
case KVM_GET_DIRTY_LOG : {
struct kvm_dirty_log log ;
r = - EFAULT ;
2015-02-26 09:58:19 +03:00
if ( copy_from_user ( & log , argp , sizeof ( log ) ) )
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
goto out ;
2007-02-20 19:27:58 +03:00
r = kvm_vm_ioctl_get_dirty_log ( kvm , & log ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
break ;
}
2008-05-30 18:05:54 +04:00
# ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
case KVM_REGISTER_COALESCED_MMIO : {
struct kvm_coalesced_mmio_zone zone ;
2015-02-26 09:58:23 +03:00
2008-05-30 18:05:54 +04:00
r = - EFAULT ;
2015-02-26 09:58:19 +03:00
if ( copy_from_user ( & zone , argp , sizeof ( zone ) ) )
2008-05-30 18:05:54 +04:00
goto out ;
r = kvm_vm_ioctl_register_coalesced_mmio ( kvm , & zone ) ;
break ;
}
case KVM_UNREGISTER_COALESCED_MMIO : {
struct kvm_coalesced_mmio_zone zone ;
2015-02-26 09:58:23 +03:00
2008-05-30 18:05:54 +04:00
r = - EFAULT ;
2015-02-26 09:58:19 +03:00
if ( copy_from_user ( & zone , argp , sizeof ( zone ) ) )
2008-05-30 18:05:54 +04:00
goto out ;
r = kvm_vm_ioctl_unregister_coalesced_mmio ( kvm , & zone ) ;
break ;
}
# endif
2009-05-20 18:30:49 +04:00
case KVM_IRQFD : {
struct kvm_irqfd data ;
r = - EFAULT ;
2015-02-26 09:58:19 +03:00
if ( copy_from_user ( & data , argp , sizeof ( data ) ) )
2009-05-20 18:30:49 +04:00
goto out ;
2012-06-29 19:56:08 +04:00
r = kvm_irqfd ( kvm , & data ) ;
2009-05-20 18:30:49 +04:00
break ;
}
KVM: add ioeventfd support
ioeventfd is a mechanism to register PIO/MMIO regions to trigger an eventfd
signal when written to by a guest. Host userspace can register any
arbitrary IO address with a corresponding eventfd and then pass the eventfd
to a specific end-point of interest for handling.
Normal IO requires a blocking round-trip since the operation may cause
side-effects in the emulated model or may return data to the caller.
Therefore, an IO in KVM traps from the guest to the host, causes a VMX/SVM
"heavy-weight" exit back to userspace, and is ultimately serviced by qemu's
device model synchronously before returning control back to the vcpu.
However, there is a subclass of IO which acts purely as a trigger for
other IO (such as to kick off an out-of-band DMA request, etc). For these
patterns, the synchronous call is particularly expensive since we really
only want to simply get our notification transmitted asychronously and
return as quickly as possible. All the sychronous infrastructure to ensure
proper data-dependencies are met in the normal IO case are just unecessary
overhead for signalling. This adds additional computational load on the
system, as well as latency to the signalling path.
Therefore, we provide a mechanism for registration of an in-kernel trigger
point that allows the VCPU to only require a very brief, lightweight
exit just long enough to signal an eventfd. This also means that any
clients compatible with the eventfd interface (which includes userspace
and kernelspace equally well) can now register to be notified. The end
result should be a more flexible and higher performance notification API
for the backend KVM hypervisor and perhipheral components.
To test this theory, we built a test-harness called "doorbell". This
module has a function called "doorbell_ring()" which simply increments a
counter for each time the doorbell is signaled. It supports signalling
from either an eventfd, or an ioctl().
We then wired up two paths to the doorbell: One via QEMU via a registered
io region and through the doorbell ioctl(). The other is direct via
ioeventfd.
You can download this test harness here:
ftp://ftp.novell.com/dev/ghaskins/doorbell.tar.bz2
The measured results are as follows:
qemu-mmio: 110000 iops, 9.09us rtt
ioeventfd-mmio: 200100 iops, 5.00us rtt
ioeventfd-pio: 367300 iops, 2.72us rtt
I didn't measure qemu-pio, because I have to figure out how to register a
PIO region with qemu's device model, and I got lazy. However, for now we
can extrapolate based on the data from the NULLIO runs of +2.56us for MMIO,
and -350ns for HC, we get:
qemu-pio: 153139 iops, 6.53us rtt
ioeventfd-hc: 412585 iops, 2.37us rtt
these are just for fun, for now, until I can gather more data.
Here is a graph for your convenience:
http://developer.novell.com/wiki/images/7/76/Iofd-chart.png
The conclusion to draw is that we save about 4us by skipping the userspace
hop.
--------------------
Signed-off-by: Gregory Haskins <ghaskins@novell.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
2009-07-08 01:08:49 +04:00
case KVM_IOEVENTFD : {
struct kvm_ioeventfd data ;
r = - EFAULT ;
2015-02-26 09:58:19 +03:00
if ( copy_from_user ( & data , argp , sizeof ( data ) ) )
KVM: add ioeventfd support
ioeventfd is a mechanism to register PIO/MMIO regions to trigger an eventfd
signal when written to by a guest. Host userspace can register any
arbitrary IO address with a corresponding eventfd and then pass the eventfd
to a specific end-point of interest for handling.
Normal IO requires a blocking round-trip since the operation may cause
side-effects in the emulated model or may return data to the caller.
Therefore, an IO in KVM traps from the guest to the host, causes a VMX/SVM
"heavy-weight" exit back to userspace, and is ultimately serviced by qemu's
device model synchronously before returning control back to the vcpu.
However, there is a subclass of IO which acts purely as a trigger for
other IO (such as to kick off an out-of-band DMA request, etc). For these
patterns, the synchronous call is particularly expensive since we really
only want to simply get our notification transmitted asychronously and
return as quickly as possible. All the sychronous infrastructure to ensure
proper data-dependencies are met in the normal IO case are just unecessary
overhead for signalling. This adds additional computational load on the
system, as well as latency to the signalling path.
Therefore, we provide a mechanism for registration of an in-kernel trigger
point that allows the VCPU to only require a very brief, lightweight
exit just long enough to signal an eventfd. This also means that any
clients compatible with the eventfd interface (which includes userspace
and kernelspace equally well) can now register to be notified. The end
result should be a more flexible and higher performance notification API
for the backend KVM hypervisor and perhipheral components.
To test this theory, we built a test-harness called "doorbell". This
module has a function called "doorbell_ring()" which simply increments a
counter for each time the doorbell is signaled. It supports signalling
from either an eventfd, or an ioctl().
We then wired up two paths to the doorbell: One via QEMU via a registered
io region and through the doorbell ioctl(). The other is direct via
ioeventfd.
You can download this test harness here:
ftp://ftp.novell.com/dev/ghaskins/doorbell.tar.bz2
The measured results are as follows:
qemu-mmio: 110000 iops, 9.09us rtt
ioeventfd-mmio: 200100 iops, 5.00us rtt
ioeventfd-pio: 367300 iops, 2.72us rtt
I didn't measure qemu-pio, because I have to figure out how to register a
PIO region with qemu's device model, and I got lazy. However, for now we
can extrapolate based on the data from the NULLIO runs of +2.56us for MMIO,
and -350ns for HC, we get:
qemu-pio: 153139 iops, 6.53us rtt
ioeventfd-hc: 412585 iops, 2.37us rtt
these are just for fun, for now, until I can gather more data.
Here is a graph for your convenience:
http://developer.novell.com/wiki/images/7/76/Iofd-chart.png
The conclusion to draw is that we save about 4us by skipping the userspace
hop.
--------------------
Signed-off-by: Gregory Haskins <ghaskins@novell.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
2009-07-08 01:08:49 +04:00
goto out ;
r = kvm_ioeventfd ( kvm , & data ) ;
break ;
}
2012-03-29 23:14:12 +04:00
# ifdef CONFIG_HAVE_KVM_MSI
case KVM_SIGNAL_MSI : {
struct kvm_msi msi ;
r = - EFAULT ;
2015-02-26 09:58:19 +03:00
if ( copy_from_user ( & msi , argp , sizeof ( msi ) ) )
2012-03-29 23:14:12 +04:00
goto out ;
r = kvm_send_userspace_msi ( kvm , & msi ) ;
break ;
}
2012-07-24 16:51:20 +04:00
# endif
# ifdef __KVM_HAVE_IRQ_LINE
case KVM_IRQ_LINE_STATUS :
case KVM_IRQ_LINE : {
struct kvm_irq_level irq_event ;
r = - EFAULT ;
2015-02-26 09:58:19 +03:00
if ( copy_from_user ( & irq_event , argp , sizeof ( irq_event ) ) )
2012-07-24 16:51:20 +04:00
goto out ;
2013-04-11 15:21:40 +04:00
r = kvm_vm_ioctl_irq_line ( kvm , & irq_event ,
ioctl = = KVM_IRQ_LINE_STATUS ) ;
2012-07-24 16:51:20 +04:00
if ( r )
goto out ;
r = - EFAULT ;
if ( ioctl = = KVM_IRQ_LINE_STATUS ) {
2015-02-26 09:58:19 +03:00
if ( copy_to_user ( argp , & irq_event , sizeof ( irq_event ) ) )
2012-07-24 16:51:20 +04:00
goto out ;
}
r = 0 ;
break ;
}
2009-06-09 16:56:28 +04:00
# endif
2013-04-15 23:12:53 +04:00
# ifdef CONFIG_HAVE_KVM_IRQ_ROUTING
case KVM_SET_GSI_ROUTING : {
struct kvm_irq_routing routing ;
struct kvm_irq_routing __user * urouting ;
struct kvm_irq_routing_entry * entries ;
r = - EFAULT ;
if ( copy_from_user ( & routing , argp , sizeof ( routing ) ) )
goto out ;
r = - EINVAL ;
if ( routing . nr > = KVM_MAX_IRQ_ROUTES )
goto out ;
if ( routing . flags )
goto out ;
r = - ENOMEM ;
entries = vmalloc ( routing . nr * sizeof ( * entries ) ) ;
if ( ! entries )
goto out ;
r = - EFAULT ;
urouting = argp ;
if ( copy_from_user ( entries , urouting - > entries ,
routing . nr * sizeof ( * entries ) ) )
goto out_free_irq_routing ;
r = kvm_set_irq_routing ( kvm , entries , routing . nr ,
routing . flags ) ;
2015-02-26 09:58:20 +03:00
out_free_irq_routing :
2013-04-15 23:12:53 +04:00
vfree ( entries ) ;
break ;
}
# endif /* CONFIG_HAVE_KVM_IRQ_ROUTING */
2013-04-12 18:08:42 +04:00
case KVM_CREATE_DEVICE : {
struct kvm_create_device cd ;
r = - EFAULT ;
if ( copy_from_user ( & cd , argp , sizeof ( cd ) ) )
goto out ;
r = kvm_ioctl_create_device ( kvm , & cd ) ;
if ( r )
goto out ;
r = - EFAULT ;
if ( copy_to_user ( argp , & cd , sizeof ( cd ) ) )
goto out ;
r = 0 ;
break ;
}
2014-07-14 20:33:08 +04:00
case KVM_CHECK_EXTENSION :
r = kvm_vm_ioctl_check_extension_generic ( kvm , arg ) ;
break ;
2007-02-21 20:28:04 +03:00
default :
2007-10-29 18:08:35 +03:00
r = kvm_arch_vm_ioctl ( filp , ioctl , arg ) ;
2007-02-21 20:28:04 +03:00
}
out :
return r ;
}
2015-02-03 11:35:15 +03:00
# ifdef CONFIG_KVM_COMPAT
2009-10-22 16:19:27 +04:00
struct compat_kvm_dirty_log {
__u32 slot ;
__u32 padding1 ;
union {
compat_uptr_t dirty_bitmap ; /* one bit per page */
__u64 padding2 ;
} ;
} ;
static long kvm_vm_compat_ioctl ( struct file * filp ,
unsigned int ioctl , unsigned long arg )
{
struct kvm * kvm = filp - > private_data ;
int r ;
if ( kvm - > mm ! = current - > mm )
return - EIO ;
switch ( ioctl ) {
case KVM_GET_DIRTY_LOG : {
struct compat_kvm_dirty_log compat_log ;
struct kvm_dirty_log log ;
r = - EFAULT ;
if ( copy_from_user ( & compat_log , ( void __user * ) arg ,
sizeof ( compat_log ) ) )
goto out ;
log . slot = compat_log . slot ;
log . padding1 = compat_log . padding1 ;
log . padding2 = compat_log . padding2 ;
log . dirty_bitmap = compat_ptr ( compat_log . dirty_bitmap ) ;
r = kvm_vm_ioctl_get_dirty_log ( kvm , & log ) ;
break ;
}
default :
r = kvm_vm_ioctl ( filp , ioctl , arg ) ;
}
out :
return r ;
}
# endif
2008-12-02 13:17:32 +03:00
static struct file_operations kvm_vm_fops = {
2007-02-21 20:28:04 +03:00
. release = kvm_vm_release ,
. unlocked_ioctl = kvm_vm_ioctl ,
2015-02-03 11:35:15 +03:00
# ifdef CONFIG_KVM_COMPAT
2009-10-22 16:19:27 +04:00
. compat_ioctl = kvm_vm_compat_ioctl ,
# endif
llseek: automatically add .llseek fop
All file_operations should get a .llseek operation so we can make
nonseekable_open the default for future file operations without a
.llseek pointer.
The three cases that we can automatically detect are no_llseek, seq_lseek
and default_llseek. For cases where we can we can automatically prove that
the file offset is always ignored, we use noop_llseek, which maintains
the current behavior of not returning an error from a seek.
New drivers should normally not use noop_llseek but instead use no_llseek
and call nonseekable_open at open time. Existing drivers can be converted
to do the same when the maintainer knows for certain that no user code
relies on calling seek on the device file.
The generated code is often incorrectly indented and right now contains
comments that clarify for each added line why a specific variant was
chosen. In the version that gets submitted upstream, the comments will
be gone and I will manually fix the indentation, because there does not
seem to be a way to do that using coccinelle.
Some amount of new code is currently sitting in linux-next that should get
the same modifications, which I will do at the end of the merge window.
Many thanks to Julia Lawall for helping me learn to write a semantic
patch that does all this.
===== begin semantic patch =====
// This adds an llseek= method to all file operations,
// as a preparation for making no_llseek the default.
//
// The rules are
// - use no_llseek explicitly if we do nonseekable_open
// - use seq_lseek for sequential files
// - use default_llseek if we know we access f_pos
// - use noop_llseek if we know we don't access f_pos,
// but we still want to allow users to call lseek
//
@ open1 exists @
identifier nested_open;
@@
nested_open(...)
{
<+...
nonseekable_open(...)
...+>
}
@ open exists@
identifier open_f;
identifier i, f;
identifier open1.nested_open;
@@
int open_f(struct inode *i, struct file *f)
{
<+...
(
nonseekable_open(...)
|
nested_open(...)
)
...+>
}
@ read disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ read_no_fpos disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
... when != off
}
@ write @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ write_no_fpos @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
... when != off
}
@ fops0 @
identifier fops;
@@
struct file_operations fops = {
...
};
@ has_llseek depends on fops0 @
identifier fops0.fops;
identifier llseek_f;
@@
struct file_operations fops = {
...
.llseek = llseek_f,
...
};
@ has_read depends on fops0 @
identifier fops0.fops;
identifier read_f;
@@
struct file_operations fops = {
...
.read = read_f,
...
};
@ has_write depends on fops0 @
identifier fops0.fops;
identifier write_f;
@@
struct file_operations fops = {
...
.write = write_f,
...
};
@ has_open depends on fops0 @
identifier fops0.fops;
identifier open_f;
@@
struct file_operations fops = {
...
.open = open_f,
...
};
// use no_llseek if we call nonseekable_open
////////////////////////////////////////////
@ nonseekable1 depends on !has_llseek && has_open @
identifier fops0.fops;
identifier nso ~= "nonseekable_open";
@@
struct file_operations fops = {
... .open = nso, ...
+.llseek = no_llseek, /* nonseekable */
};
@ nonseekable2 depends on !has_llseek @
identifier fops0.fops;
identifier open.open_f;
@@
struct file_operations fops = {
... .open = open_f, ...
+.llseek = no_llseek, /* open uses nonseekable */
};
// use seq_lseek for sequential files
/////////////////////////////////////
@ seq depends on !has_llseek @
identifier fops0.fops;
identifier sr ~= "seq_read";
@@
struct file_operations fops = {
... .read = sr, ...
+.llseek = seq_lseek, /* we have seq_read */
};
// use default_llseek if there is a readdir
///////////////////////////////////////////
@ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier readdir_e;
@@
// any other fop is used that changes pos
struct file_operations fops = {
... .readdir = readdir_e, ...
+.llseek = default_llseek, /* readdir is present */
};
// use default_llseek if at least one of read/write touches f_pos
/////////////////////////////////////////////////////////////////
@ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read.read_f;
@@
// read fops use offset
struct file_operations fops = {
... .read = read_f, ...
+.llseek = default_llseek, /* read accesses f_pos */
};
@ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write.write_f;
@@
// write fops use offset
struct file_operations fops = {
... .write = write_f, ...
+ .llseek = default_llseek, /* write accesses f_pos */
};
// Use noop_llseek if neither read nor write accesses f_pos
///////////////////////////////////////////////////////////
@ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
identifier write_no_fpos.write_f;
@@
// write fops use offset
struct file_operations fops = {
...
.write = write_f,
.read = read_f,
...
+.llseek = noop_llseek, /* read and write both use no f_pos */
};
@ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write_no_fpos.write_f;
@@
struct file_operations fops = {
... .write = write_f, ...
+.llseek = noop_llseek, /* write uses no f_pos */
};
@ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
@@
struct file_operations fops = {
... .read = read_f, ...
+.llseek = noop_llseek, /* read uses no f_pos */
};
@ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
@@
struct file_operations fops = {
...
+.llseek = noop_llseek, /* no read or write fn */
};
===== End semantic patch =====
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Julia Lawall <julia@diku.dk>
Cc: Christoph Hellwig <hch@infradead.org>
2010-08-15 20:52:59 +04:00
. llseek = noop_llseek ,
2007-02-21 20:28:04 +03:00
} ;
2012-01-04 13:25:20 +04:00
static int kvm_dev_ioctl_create_vm ( unsigned long type )
2007-02-21 20:28:04 +03:00
{
2010-10-27 19:22:10 +04:00
int r ;
2007-02-21 20:28:04 +03:00
struct kvm * kvm ;
2012-01-04 13:25:20 +04:00
kvm = kvm_create_vm ( type ) ;
2007-06-28 16:38:16 +04:00
if ( IS_ERR ( kvm ) )
return PTR_ERR ( kvm ) ;
2010-03-15 16:13:30 +03:00
# ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
r = kvm_coalesced_mmio_init ( kvm ) ;
if ( r < 0 ) {
kvm_put_kvm ( kvm ) ;
return r ;
}
# endif
2013-08-25 00:14:07 +04:00
r = anon_inode_getfd ( " kvm-vm " , & kvm_vm_fops , kvm , O_RDWR | O_CLOEXEC ) ;
2010-10-27 19:22:10 +04:00
if ( r < 0 )
2008-04-19 23:33:56 +04:00
kvm_put_kvm ( kvm ) ;
2007-02-21 20:28:04 +03:00
2010-10-27 19:22:10 +04:00
return r ;
2007-02-21 20:28:04 +03:00
}
static long kvm_dev_ioctl ( struct file * filp ,
unsigned int ioctl , unsigned long arg )
{
2007-03-07 14:05:38 +03:00
long r = - EINVAL ;
2007-02-21 20:28:04 +03:00
switch ( ioctl ) {
case KVM_GET_API_VERSION :
2007-03-07 14:11:17 +03:00
if ( arg )
goto out ;
2007-02-21 20:28:04 +03:00
r = KVM_API_VERSION ;
break ;
case KVM_CREATE_VM :
2012-01-04 13:25:20 +04:00
r = kvm_dev_ioctl_create_vm ( arg ) ;
2007-02-21 20:28:04 +03:00
break ;
2007-11-15 18:07:47 +03:00
case KVM_CHECK_EXTENSION :
2014-07-14 20:27:35 +04:00
r = kvm_vm_ioctl_check_extension_generic ( NULL , arg ) ;
2007-03-01 18:56:20 +03:00
break ;
2007-03-07 14:05:38 +03:00
case KVM_GET_VCPU_MMAP_SIZE :
if ( arg )
goto out ;
2008-01-24 16:13:08 +03:00
r = PAGE_SIZE ; /* struct kvm_run */
# ifdef CONFIG_X86
r + = PAGE_SIZE ; /* pio data page */
2008-05-30 18:05:54 +04:00
# endif
# ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
r + = PAGE_SIZE ; /* coalesced mmio ring page */
2008-01-24 16:13:08 +03:00
# endif
2007-03-07 14:05:38 +03:00
break ;
2008-04-10 16:47:53 +04:00
case KVM_TRACE_ENABLE :
case KVM_TRACE_PAUSE :
case KVM_TRACE_DISABLE :
2009-06-18 18:47:28 +04:00
r = - EOPNOTSUPP ;
2008-04-10 16:47:53 +04:00
break ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
default :
2007-10-10 19:16:19 +04:00
return kvm_arch_dev_ioctl ( filp , ioctl , arg ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
}
out :
return r ;
}
static struct file_operations kvm_chardev_ops = {
. unlocked_ioctl = kvm_dev_ioctl ,
. compat_ioctl = kvm_dev_ioctl ,
llseek: automatically add .llseek fop
All file_operations should get a .llseek operation so we can make
nonseekable_open the default for future file operations without a
.llseek pointer.
The three cases that we can automatically detect are no_llseek, seq_lseek
and default_llseek. For cases where we can we can automatically prove that
the file offset is always ignored, we use noop_llseek, which maintains
the current behavior of not returning an error from a seek.
New drivers should normally not use noop_llseek but instead use no_llseek
and call nonseekable_open at open time. Existing drivers can be converted
to do the same when the maintainer knows for certain that no user code
relies on calling seek on the device file.
The generated code is often incorrectly indented and right now contains
comments that clarify for each added line why a specific variant was
chosen. In the version that gets submitted upstream, the comments will
be gone and I will manually fix the indentation, because there does not
seem to be a way to do that using coccinelle.
Some amount of new code is currently sitting in linux-next that should get
the same modifications, which I will do at the end of the merge window.
Many thanks to Julia Lawall for helping me learn to write a semantic
patch that does all this.
===== begin semantic patch =====
// This adds an llseek= method to all file operations,
// as a preparation for making no_llseek the default.
//
// The rules are
// - use no_llseek explicitly if we do nonseekable_open
// - use seq_lseek for sequential files
// - use default_llseek if we know we access f_pos
// - use noop_llseek if we know we don't access f_pos,
// but we still want to allow users to call lseek
//
@ open1 exists @
identifier nested_open;
@@
nested_open(...)
{
<+...
nonseekable_open(...)
...+>
}
@ open exists@
identifier open_f;
identifier i, f;
identifier open1.nested_open;
@@
int open_f(struct inode *i, struct file *f)
{
<+...
(
nonseekable_open(...)
|
nested_open(...)
)
...+>
}
@ read disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ read_no_fpos disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
... when != off
}
@ write @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ write_no_fpos @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
... when != off
}
@ fops0 @
identifier fops;
@@
struct file_operations fops = {
...
};
@ has_llseek depends on fops0 @
identifier fops0.fops;
identifier llseek_f;
@@
struct file_operations fops = {
...
.llseek = llseek_f,
...
};
@ has_read depends on fops0 @
identifier fops0.fops;
identifier read_f;
@@
struct file_operations fops = {
...
.read = read_f,
...
};
@ has_write depends on fops0 @
identifier fops0.fops;
identifier write_f;
@@
struct file_operations fops = {
...
.write = write_f,
...
};
@ has_open depends on fops0 @
identifier fops0.fops;
identifier open_f;
@@
struct file_operations fops = {
...
.open = open_f,
...
};
// use no_llseek if we call nonseekable_open
////////////////////////////////////////////
@ nonseekable1 depends on !has_llseek && has_open @
identifier fops0.fops;
identifier nso ~= "nonseekable_open";
@@
struct file_operations fops = {
... .open = nso, ...
+.llseek = no_llseek, /* nonseekable */
};
@ nonseekable2 depends on !has_llseek @
identifier fops0.fops;
identifier open.open_f;
@@
struct file_operations fops = {
... .open = open_f, ...
+.llseek = no_llseek, /* open uses nonseekable */
};
// use seq_lseek for sequential files
/////////////////////////////////////
@ seq depends on !has_llseek @
identifier fops0.fops;
identifier sr ~= "seq_read";
@@
struct file_operations fops = {
... .read = sr, ...
+.llseek = seq_lseek, /* we have seq_read */
};
// use default_llseek if there is a readdir
///////////////////////////////////////////
@ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier readdir_e;
@@
// any other fop is used that changes pos
struct file_operations fops = {
... .readdir = readdir_e, ...
+.llseek = default_llseek, /* readdir is present */
};
// use default_llseek if at least one of read/write touches f_pos
/////////////////////////////////////////////////////////////////
@ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read.read_f;
@@
// read fops use offset
struct file_operations fops = {
... .read = read_f, ...
+.llseek = default_llseek, /* read accesses f_pos */
};
@ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write.write_f;
@@
// write fops use offset
struct file_operations fops = {
... .write = write_f, ...
+ .llseek = default_llseek, /* write accesses f_pos */
};
// Use noop_llseek if neither read nor write accesses f_pos
///////////////////////////////////////////////////////////
@ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
identifier write_no_fpos.write_f;
@@
// write fops use offset
struct file_operations fops = {
...
.write = write_f,
.read = read_f,
...
+.llseek = noop_llseek, /* read and write both use no f_pos */
};
@ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write_no_fpos.write_f;
@@
struct file_operations fops = {
... .write = write_f, ...
+.llseek = noop_llseek, /* write uses no f_pos */
};
@ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
@@
struct file_operations fops = {
... .read = read_f, ...
+.llseek = noop_llseek, /* read uses no f_pos */
};
@ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
@@
struct file_operations fops = {
...
+.llseek = noop_llseek, /* no read or write fn */
};
===== End semantic patch =====
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Julia Lawall <julia@diku.dk>
Cc: Christoph Hellwig <hch@infradead.org>
2010-08-15 20:52:59 +04:00
. llseek = noop_llseek ,
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
} ;
static struct miscdevice kvm_dev = {
2007-03-04 14:27:36 +03:00
KVM_MINOR ,
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
" kvm " ,
& kvm_chardev_ops ,
} ;
2010-11-16 11:37:41 +03:00
static void hardware_enable_nolock ( void * junk )
2007-05-24 14:03:52 +04:00
{
int cpu = raw_smp_processor_id ( ) ;
2009-09-15 13:37:46 +04:00
int r ;
2007-05-24 14:03:52 +04:00
2008-12-07 13:55:45 +03:00
if ( cpumask_test_cpu ( cpu , cpus_hardware_enabled ) )
2007-05-24 14:03:52 +04:00
return ;
2009-09-15 13:37:46 +04:00
2008-12-07 13:55:45 +03:00
cpumask_set_cpu ( cpu , cpus_hardware_enabled ) ;
2009-09-15 13:37:46 +04:00
2014-08-28 17:13:03 +04:00
r = kvm_arch_hardware_enable ( ) ;
2009-09-15 13:37:46 +04:00
if ( r ) {
cpumask_clear_cpu ( cpu , cpus_hardware_enabled ) ;
atomic_inc ( & hardware_enable_failed ) ;
2015-02-26 09:58:26 +03:00
pr_info ( " kvm: enabling virtualization on CPU%d failed \n " , cpu ) ;
2009-09-15 13:37:46 +04:00
}
2007-05-24 14:03:52 +04:00
}
2013-09-10 14:57:17 +04:00
static void hardware_enable ( void )
2010-11-16 11:37:41 +03:00
{
2013-09-10 14:58:35 +04:00
raw_spin_lock ( & kvm_count_lock ) ;
2013-09-10 14:57:17 +04:00
if ( kvm_usage_count )
hardware_enable_nolock ( NULL ) ;
2013-09-10 14:58:35 +04:00
raw_spin_unlock ( & kvm_count_lock ) ;
2010-11-16 11:37:41 +03:00
}
static void hardware_disable_nolock ( void * junk )
2007-05-24 14:03:52 +04:00
{
int cpu = raw_smp_processor_id ( ) ;
2008-12-07 13:55:45 +03:00
if ( ! cpumask_test_cpu ( cpu , cpus_hardware_enabled ) )
2007-05-24 14:03:52 +04:00
return ;
2008-12-07 13:55:45 +03:00
cpumask_clear_cpu ( cpu , cpus_hardware_enabled ) ;
2014-08-28 17:13:03 +04:00
kvm_arch_hardware_disable ( ) ;
2007-05-24 14:03:52 +04:00
}
2013-09-10 14:57:17 +04:00
static void hardware_disable ( void )
2010-11-16 11:37:41 +03:00
{
2013-09-10 14:58:35 +04:00
raw_spin_lock ( & kvm_count_lock ) ;
2013-09-10 14:57:17 +04:00
if ( kvm_usage_count )
hardware_disable_nolock ( NULL ) ;
2013-09-10 14:58:35 +04:00
raw_spin_unlock ( & kvm_count_lock ) ;
2010-11-16 11:37:41 +03:00
}
2009-09-15 13:37:46 +04:00
static void hardware_disable_all_nolock ( void )
{
BUG_ON ( ! kvm_usage_count ) ;
kvm_usage_count - - ;
if ( ! kvm_usage_count )
2010-11-16 11:37:41 +03:00
on_each_cpu ( hardware_disable_nolock , NULL , 1 ) ;
2009-09-15 13:37:46 +04:00
}
static void hardware_disable_all ( void )
{
2013-09-10 14:58:35 +04:00
raw_spin_lock ( & kvm_count_lock ) ;
2009-09-15 13:37:46 +04:00
hardware_disable_all_nolock ( ) ;
2013-09-10 14:58:35 +04:00
raw_spin_unlock ( & kvm_count_lock ) ;
2009-09-15 13:37:46 +04:00
}
static int hardware_enable_all ( void )
{
int r = 0 ;
2013-09-10 14:58:35 +04:00
raw_spin_lock ( & kvm_count_lock ) ;
2009-09-15 13:37:46 +04:00
kvm_usage_count + + ;
if ( kvm_usage_count = = 1 ) {
atomic_set ( & hardware_enable_failed , 0 ) ;
2010-11-16 11:37:41 +03:00
on_each_cpu ( hardware_enable_nolock , NULL , 1 ) ;
2009-09-15 13:37:46 +04:00
if ( atomic_read ( & hardware_enable_failed ) ) {
hardware_disable_all_nolock ( ) ;
r = - EBUSY ;
}
}
2013-09-10 14:58:35 +04:00
raw_spin_unlock ( & kvm_count_lock ) ;
2009-09-15 13:37:46 +04:00
return r ;
}
2007-02-12 11:54:47 +03:00
static int kvm_cpu_hotplug ( struct notifier_block * notifier , unsigned long val ,
void * v )
{
2007-11-11 19:37:32 +03:00
val & = ~ CPU_TASKS_FROZEN ;
2007-02-12 11:54:47 +03:00
switch ( val ) {
2007-05-24 14:11:41 +04:00
case CPU_DYING :
2013-09-10 14:57:17 +04:00
hardware_disable ( ) ;
2007-08-19 16:57:26 +04:00
break ;
2010-08-20 12:07:27 +04:00
case CPU_STARTING :
2013-09-10 14:57:17 +04:00
hardware_enable ( ) ;
2007-02-12 11:54:47 +03:00
break ;
}
return NOTIFY_OK ;
}
2007-07-17 17:17:55 +04:00
static int kvm_reboot ( struct notifier_block * notifier , unsigned long val ,
2007-10-08 17:02:08 +04:00
void * v )
2007-07-17 17:17:55 +04:00
{
2009-04-29 07:09:04 +04:00
/*
* Some ( well , at least mine ) BIOSes hang on reboot if
* in vmx root mode .
*
* And Intel TXT required VMX off for all cpu when system shutdown .
*/
2015-02-26 09:58:26 +03:00
pr_info ( " kvm: exiting hardware virtualization \n " ) ;
2009-04-29 07:09:04 +04:00
kvm_rebooting = true ;
2010-11-16 11:37:41 +03:00
on_each_cpu ( hardware_disable_nolock , NULL , 1 ) ;
2007-07-17 17:17:55 +04:00
return NOTIFY_OK ;
}
static struct notifier_block kvm_reboot_notifier = {
. notifier_call = kvm_reboot ,
. priority = 0 ,
} ;
2009-12-23 19:35:24 +03:00
static void kvm_io_bus_destroy ( struct kvm_io_bus * bus )
2007-05-31 22:08:53 +04:00
{
int i ;
for ( i = 0 ; i < bus - > dev_count ; i + + ) {
2011-07-27 17:00:48 +04:00
struct kvm_io_device * pos = bus - > range [ i ] . dev ;
2007-05-31 22:08:53 +04:00
kvm_iodevice_destructor ( pos ) ;
}
2009-12-23 19:35:24 +03:00
kfree ( bus ) ;
2007-05-31 22:08:53 +04:00
}
2013-08-27 17:41:41 +04:00
static inline int kvm_io_bus_cmp ( const struct kvm_io_range * r1 ,
2015-02-26 09:58:25 +03:00
const struct kvm_io_range * r2 )
2011-07-27 17:00:48 +04:00
{
if ( r1 - > addr < r2 - > addr )
return - 1 ;
if ( r1 - > addr + r1 - > len > r2 - > addr + r2 - > len )
return 1 ;
return 0 ;
}
2013-07-16 15:03:29 +04:00
static int kvm_io_bus_sort_cmp ( const void * p1 , const void * p2 )
{
2013-08-27 17:41:41 +04:00
return kvm_io_bus_cmp ( p1 , p2 ) ;
2013-07-16 15:03:29 +04:00
}
2013-04-05 23:20:30 +04:00
static int kvm_io_bus_insert_dev ( struct kvm_io_bus * bus , struct kvm_io_device * dev ,
2011-07-27 17:00:48 +04:00
gpa_t addr , int len )
{
bus - > range [ bus - > dev_count + + ] = ( struct kvm_io_range ) {
. addr = addr ,
. len = len ,
. dev = dev ,
} ;
sort ( bus - > range , bus - > dev_count , sizeof ( struct kvm_io_range ) ,
kvm_io_bus_sort_cmp , NULL ) ;
return 0 ;
}
2013-04-05 23:20:30 +04:00
static int kvm_io_bus_get_first_dev ( struct kvm_io_bus * bus ,
2011-07-27 17:00:48 +04:00
gpa_t addr , int len )
{
struct kvm_io_range * range , key ;
int off ;
key = ( struct kvm_io_range ) {
. addr = addr ,
. len = len ,
} ;
range = bsearch ( & key , bus - > range , bus - > dev_count ,
sizeof ( struct kvm_io_range ) , kvm_io_bus_sort_cmp ) ;
if ( range = = NULL )
return - ENOENT ;
off = range - bus - > range ;
2013-08-27 17:41:41 +04:00
while ( off > 0 & & kvm_io_bus_cmp ( & key , & bus - > range [ off - 1 ] ) = = 0 )
2011-07-27 17:00:48 +04:00
off - - ;
return off ;
}
2015-03-26 17:39:28 +03:00
static int __kvm_io_bus_write ( struct kvm_vcpu * vcpu , struct kvm_io_bus * bus ,
2013-07-03 18:30:53 +04:00
struct kvm_io_range * range , const void * val )
{
int idx ;
idx = kvm_io_bus_get_first_dev ( bus , range - > addr , range - > len ) ;
if ( idx < 0 )
return - EOPNOTSUPP ;
while ( idx < bus - > dev_count & &
2013-08-27 17:41:41 +04:00
kvm_io_bus_cmp ( range , & bus - > range [ idx ] ) = = 0 ) {
2015-03-26 17:39:28 +03:00
if ( ! kvm_iodevice_write ( vcpu , bus - > range [ idx ] . dev , range - > addr ,
2013-07-03 18:30:53 +04:00
range - > len , val ) )
return idx ;
idx + + ;
}
return - EOPNOTSUPP ;
}
2009-06-29 23:24:32 +04:00
/* kvm_io_bus_write - called under kvm->slots_lock */
2015-03-26 17:39:28 +03:00
int kvm_io_bus_write ( struct kvm_vcpu * vcpu , enum kvm_bus bus_idx , gpa_t addr ,
2009-06-29 23:24:32 +04:00
int len , const void * val )
2007-05-31 22:08:53 +04:00
{
2010-04-19 13:41:23 +04:00
struct kvm_io_bus * bus ;
2011-07-27 17:00:48 +04:00
struct kvm_io_range range ;
2013-07-03 18:30:53 +04:00
int r ;
2011-07-27 17:00:48 +04:00
range = ( struct kvm_io_range ) {
. addr = addr ,
. len = len ,
} ;
2010-04-19 13:41:23 +04:00
2015-03-26 17:39:28 +03:00
bus = srcu_dereference ( vcpu - > kvm - > buses [ bus_idx ] , & vcpu - > kvm - > srcu ) ;
r = __kvm_io_bus_write ( vcpu , bus , & range , val ) ;
2013-07-03 18:30:53 +04:00
return r < 0 ? r : 0 ;
}
/* kvm_io_bus_write_cookie - called under kvm->slots_lock */
2015-03-26 17:39:28 +03:00
int kvm_io_bus_write_cookie ( struct kvm_vcpu * vcpu , enum kvm_bus bus_idx ,
gpa_t addr , int len , const void * val , long cookie )
2013-07-03 18:30:53 +04:00
{
struct kvm_io_bus * bus ;
struct kvm_io_range range ;
range = ( struct kvm_io_range ) {
. addr = addr ,
. len = len ,
} ;
2015-03-26 17:39:28 +03:00
bus = srcu_dereference ( vcpu - > kvm - > buses [ bus_idx ] , & vcpu - > kvm - > srcu ) ;
2013-07-03 18:30:53 +04:00
/* First try the device referenced by cookie. */
if ( ( cookie > = 0 ) & & ( cookie < bus - > dev_count ) & &
2013-08-27 17:41:41 +04:00
( kvm_io_bus_cmp ( & range , & bus - > range [ cookie ] ) = = 0 ) )
2015-03-26 17:39:28 +03:00
if ( ! kvm_iodevice_write ( vcpu , bus - > range [ cookie ] . dev , addr , len ,
2013-07-03 18:30:53 +04:00
val ) )
return cookie ;
/*
* cookie contained garbage ; fall back to search and return the
* correct cookie value .
*/
2015-03-26 17:39:28 +03:00
return __kvm_io_bus_write ( vcpu , bus , & range , val ) ;
2013-07-03 18:30:53 +04:00
}
2015-03-26 17:39:28 +03:00
static int __kvm_io_bus_read ( struct kvm_vcpu * vcpu , struct kvm_io_bus * bus ,
struct kvm_io_range * range , void * val )
2013-07-03 18:30:53 +04:00
{
int idx ;
idx = kvm_io_bus_get_first_dev ( bus , range - > addr , range - > len ) ;
2011-07-27 17:00:48 +04:00
if ( idx < 0 )
return - EOPNOTSUPP ;
while ( idx < bus - > dev_count & &
2013-08-27 17:41:41 +04:00
kvm_io_bus_cmp ( range , & bus - > range [ idx ] ) = = 0 ) {
2015-03-26 17:39:28 +03:00
if ( ! kvm_iodevice_read ( vcpu , bus - > range [ idx ] . dev , range - > addr ,
2013-07-03 18:30:53 +04:00
range - > len , val ) )
return idx ;
2011-07-27 17:00:48 +04:00
idx + + ;
}
2009-06-29 23:24:32 +04:00
return - EOPNOTSUPP ;
}
KVM: VMX: speed up wildcard MMIO EVENTFD
With KVM, MMIO is much slower than PIO, due to the need to
do page walk and emulation. But with EPT, it does not have to be: we
know the address from the VMCS so if the address is unique, we can look
up the eventfd directly, bypassing emulation.
Unfortunately, this only works if userspace does not need to match on
access length and data. The implementation adds a separate FAST_MMIO
bus internally. This serves two purposes:
- minimize overhead for old userspace that does not use eventfd with lengtth = 0
- minimize disruption in other code (since we don't know the length,
devices on the MMIO bus only get a valid address in write, this
way we don't need to touch all devices to teach them to handle
an invalid length)
At the moment, this optimization only has effect for EPT on x86.
It will be possible to speed up MMIO for NPT and MMU using the same
idea in the future.
With this patch applied, on VMX MMIO EVENTFD is essentially as fast as PIO.
I was unable to detect any measureable slowdown to non-eventfd MMIO.
Making MMIO faster is important for the upcoming virtio 1.0 which
includes an MMIO signalling capability.
The idea was suggested by Peter Anvin. Lots of thanks to Gleb for
pre-review and suggestions.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2014-03-31 22:50:44 +04:00
EXPORT_SYMBOL_GPL ( kvm_io_bus_write ) ;
2007-05-31 22:08:53 +04:00
2009-06-29 23:24:32 +04:00
/* kvm_io_bus_read - called under kvm->slots_lock */
2015-03-26 17:39:28 +03:00
int kvm_io_bus_read ( struct kvm_vcpu * vcpu , enum kvm_bus bus_idx , gpa_t addr ,
2009-12-23 19:35:24 +03:00
int len , void * val )
2009-06-29 23:24:32 +04:00
{
2010-04-19 13:41:23 +04:00
struct kvm_io_bus * bus ;
2011-07-27 17:00:48 +04:00
struct kvm_io_range range ;
2013-07-03 18:30:53 +04:00
int r ;
2011-07-27 17:00:48 +04:00
range = ( struct kvm_io_range ) {
. addr = addr ,
. len = len ,
} ;
2009-12-23 19:35:24 +03:00
2015-03-26 17:39:28 +03:00
bus = srcu_dereference ( vcpu - > kvm - > buses [ bus_idx ] , & vcpu - > kvm - > srcu ) ;
r = __kvm_io_bus_read ( vcpu , bus , & range , val ) ;
2013-07-03 18:30:53 +04:00
return r < 0 ? r : 0 ;
}
2011-07-27 17:00:48 +04:00
2007-05-31 22:08:53 +04:00
2009-12-23 19:35:26 +03:00
/* Caller must hold slots_lock. */
2011-07-27 17:00:48 +04:00
int kvm_io_bus_register_dev ( struct kvm * kvm , enum kvm_bus bus_idx , gpa_t addr ,
int len , struct kvm_io_device * dev )
2009-06-29 23:24:26 +04:00
{
2009-12-23 19:35:24 +03:00
struct kvm_io_bus * new_bus , * bus ;
2009-07-08 01:08:44 +04:00
2009-12-23 19:35:24 +03:00
bus = kvm - > buses [ bus_idx ] ;
2013-05-25 02:44:15 +04:00
/* exclude ioeventfd which is limited by maximum fd */
if ( bus - > dev_count - bus - > ioeventfd_count > NR_IOBUS_DEVS - 1 )
2009-07-08 01:08:44 +04:00
return - ENOSPC ;
2007-05-31 22:08:53 +04:00
2012-03-09 08:17:32 +04:00
new_bus = kzalloc ( sizeof ( * bus ) + ( ( bus - > dev_count + 1 ) *
sizeof ( struct kvm_io_range ) ) , GFP_KERNEL ) ;
2009-12-23 19:35:24 +03:00
if ( ! new_bus )
return - ENOMEM ;
2012-03-09 08:17:32 +04:00
memcpy ( new_bus , bus , sizeof ( * bus ) + ( bus - > dev_count *
sizeof ( struct kvm_io_range ) ) ) ;
2011-07-27 17:00:48 +04:00
kvm_io_bus_insert_dev ( new_bus , dev , addr , len ) ;
2009-12-23 19:35:24 +03:00
rcu_assign_pointer ( kvm - > buses [ bus_idx ] , new_bus ) ;
synchronize_srcu_expedited ( & kvm - > srcu ) ;
kfree ( bus ) ;
2009-07-08 01:08:44 +04:00
return 0 ;
}
2009-12-23 19:35:26 +03:00
/* Caller must hold slots_lock. */
2009-12-23 19:35:24 +03:00
int kvm_io_bus_unregister_dev ( struct kvm * kvm , enum kvm_bus bus_idx ,
struct kvm_io_device * dev )
2009-07-08 01:08:44 +04:00
{
2009-12-23 19:35:24 +03:00
int i , r ;
struct kvm_io_bus * new_bus , * bus ;
2009-07-08 01:08:44 +04:00
2011-12-04 21:36:28 +04:00
bus = kvm - > buses [ bus_idx ] ;
2009-12-23 19:35:24 +03:00
r = - ENOENT ;
2012-03-09 08:17:32 +04:00
for ( i = 0 ; i < bus - > dev_count ; i + + )
if ( bus - > range [ i ] . dev = = dev ) {
2009-12-23 19:35:24 +03:00
r = 0 ;
2009-07-08 01:08:44 +04:00
break ;
}
2009-12-23 19:35:24 +03:00
2012-03-09 08:17:32 +04:00
if ( r )
2009-12-23 19:35:24 +03:00
return r ;
2012-03-09 08:17:32 +04:00
new_bus = kzalloc ( sizeof ( * bus ) + ( ( bus - > dev_count - 1 ) *
sizeof ( struct kvm_io_range ) ) , GFP_KERNEL ) ;
if ( ! new_bus )
return - ENOMEM ;
memcpy ( new_bus , bus , sizeof ( * bus ) + i * sizeof ( struct kvm_io_range ) ) ;
new_bus - > dev_count - - ;
memcpy ( new_bus - > range + i , bus - > range + i + 1 ,
( new_bus - > dev_count - i ) * sizeof ( struct kvm_io_range ) ) ;
2009-12-23 19:35:24 +03:00
rcu_assign_pointer ( kvm - > buses [ bus_idx ] , new_bus ) ;
synchronize_srcu_expedited ( & kvm - > srcu ) ;
kfree ( bus ) ;
return r ;
2007-05-31 22:08:53 +04:00
}
2007-02-12 11:54:47 +03:00
static struct notifier_block kvm_cpu_notifier = {
. notifier_call = kvm_cpu_hotplug ,
} ;
2008-02-08 15:20:26 +03:00
static int vm_stat_get ( void * _offset , u64 * val )
2007-11-18 17:24:12 +03:00
{
unsigned offset = ( long ) _offset ;
struct kvm * kvm ;
2008-02-08 15:20:26 +03:00
* val = 0 ;
2013-09-25 15:53:07 +04:00
spin_lock ( & kvm_lock ) ;
2007-11-18 17:24:12 +03:00
list_for_each_entry ( kvm , & vm_list , vm_list )
2008-02-08 15:20:26 +03:00
* val + = * ( u32 * ) ( ( void * ) kvm + offset ) ;
2013-09-25 15:53:07 +04:00
spin_unlock ( & kvm_lock ) ;
2008-02-08 15:20:26 +03:00
return 0 ;
2007-11-18 17:24:12 +03:00
}
DEFINE_SIMPLE_ATTRIBUTE ( vm_stat_fops , vm_stat_get , NULL , " %llu \n " ) ;
2008-02-08 15:20:26 +03:00
static int vcpu_stat_get ( void * _offset , u64 * val )
2007-04-19 18:27:43 +04:00
{
unsigned offset = ( long ) _offset ;
struct kvm * kvm ;
struct kvm_vcpu * vcpu ;
int i ;
2008-02-08 15:20:26 +03:00
* val = 0 ;
2013-09-25 15:53:07 +04:00
spin_lock ( & kvm_lock ) ;
2007-04-19 18:27:43 +04:00
list_for_each_entry ( kvm , & vm_list , vm_list )
2009-06-09 16:56:29 +04:00
kvm_for_each_vcpu ( i , vcpu , kvm )
* val + = * ( u32 * ) ( ( void * ) vcpu + offset ) ;
2013-09-25 15:53:07 +04:00
spin_unlock ( & kvm_lock ) ;
2008-02-08 15:20:26 +03:00
return 0 ;
2007-04-19 18:27:43 +04:00
}
2007-11-18 17:24:12 +03:00
DEFINE_SIMPLE_ATTRIBUTE ( vcpu_stat_fops , vcpu_stat_get , NULL , " %llu \n " ) ;
2009-10-02 02:43:56 +04:00
static const struct file_operations * stat_fops [ ] = {
2007-11-18 17:24:12 +03:00
[ KVM_STAT_VCPU ] = & vcpu_stat_fops ,
[ KVM_STAT_VM ] = & vm_stat_fops ,
} ;
2007-04-19 18:27:43 +04:00
2011-12-15 10:23:16 +04:00
static int kvm_init_debug ( void )
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
{
2013-10-30 15:12:13 +04:00
int r = - EEXIST ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
struct kvm_stats_debugfs_item * p ;
2008-04-16 01:05:42 +04:00
kvm_debugfs_dir = debugfs_create_dir ( " kvm " , NULL ) ;
2011-12-15 10:23:16 +04:00
if ( kvm_debugfs_dir = = NULL )
goto out ;
for ( p = debugfs_entries ; p - > name ; + + p ) {
2008-04-16 01:05:42 +04:00
p - > dentry = debugfs_create_file ( p - > name , 0444 , kvm_debugfs_dir ,
2007-04-19 18:27:43 +04:00
( void * ) ( long ) p - > offset ,
2007-11-18 17:24:12 +03:00
stat_fops [ p - > kind ] ) ;
2011-12-15 10:23:16 +04:00
if ( p - > dentry = = NULL )
goto out_dir ;
}
return 0 ;
out_dir :
debugfs_remove_recursive ( kvm_debugfs_dir ) ;
out :
return r ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
}
static void kvm_exit_debug ( void )
{
struct kvm_stats_debugfs_item * p ;
for ( p = debugfs_entries ; p - > name ; + + p )
debugfs_remove ( p - > dentry ) ;
2008-04-16 01:05:42 +04:00
debugfs_remove ( kvm_debugfs_dir ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
}
2011-03-24 00:16:23 +03:00
static int kvm_suspend ( void )
2007-02-12 11:54:48 +03:00
{
2009-09-15 13:37:46 +04:00
if ( kvm_usage_count )
2010-11-16 11:37:41 +03:00
hardware_disable_nolock ( NULL ) ;
2007-02-12 11:54:48 +03:00
return 0 ;
}
2011-03-24 00:16:23 +03:00
static void kvm_resume ( void )
2007-02-12 11:54:48 +03:00
{
2010-08-20 12:07:28 +04:00
if ( kvm_usage_count ) {
2013-09-10 14:58:35 +04:00
WARN_ON ( raw_spin_is_locked ( & kvm_count_lock ) ) ;
2010-11-16 11:37:41 +03:00
hardware_enable_nolock ( NULL ) ;
2010-08-20 12:07:28 +04:00
}
2007-02-12 11:54:48 +03:00
}
2011-03-24 00:16:23 +03:00
static struct syscore_ops kvm_syscore_ops = {
2007-02-12 11:54:48 +03:00
. suspend = kvm_suspend ,
. resume = kvm_resume ,
} ;
2007-07-11 19:17:21 +04:00
static inline
struct kvm_vcpu * preempt_notifier_to_vcpu ( struct preempt_notifier * pn )
{
return container_of ( pn , struct kvm_vcpu , preempt_notifier ) ;
}
static void kvm_sched_in ( struct preempt_notifier * pn , int cpu )
{
struct kvm_vcpu * vcpu = preempt_notifier_to_vcpu ( pn ) ;
2015-02-26 09:58:23 +03:00
2013-03-04 22:02:07 +04:00
if ( vcpu - > preempted )
vcpu - > preempted = false ;
2007-07-11 19:17:21 +04:00
2014-08-21 20:08:05 +04:00
kvm_arch_sched_in ( vcpu , cpu ) ;
2007-11-14 15:38:21 +03:00
kvm_arch_vcpu_load ( vcpu , cpu ) ;
2007-07-11 19:17:21 +04:00
}
static void kvm_sched_out ( struct preempt_notifier * pn ,
struct task_struct * next )
{
struct kvm_vcpu * vcpu = preempt_notifier_to_vcpu ( pn ) ;
2013-03-04 22:02:07 +04:00
if ( current - > state = = TASK_RUNNING )
vcpu - > preempted = true ;
2007-11-14 15:38:21 +03:00
kvm_arch_vcpu_put ( vcpu ) ;
2007-07-11 19:17:21 +04:00
}
2010-04-28 16:39:01 +04:00
int kvm_init ( void * opaque , unsigned vcpu_size , unsigned vcpu_align ,
2007-07-30 15:12:19 +04:00
struct module * module )
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
{
int r ;
2007-07-31 15:23:01 +04:00
int cpu ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
2007-11-14 15:40:21 +03:00
r = kvm_arch_init ( opaque ) ;
if ( r )
2007-11-29 10:35:39 +03:00
goto out_fail ;
2007-11-14 15:39:31 +03:00
2013-05-08 06:57:29 +04:00
/*
* kvm_arch_init makes sure there ' s at most one caller
* for architectures that support multiple implementations ,
* like intel and amd on x86 .
* kvm_arch_init must be called before kvm_irqfd_init to avoid creating
* conflicts in case kvm is already setup for another implementation .
*/
r = kvm_irqfd_init ( ) ;
if ( r )
goto out_irqfd ;
2009-06-07 01:52:35 +04:00
if ( ! zalloc_cpumask_var ( & cpus_hardware_enabled , GFP_KERNEL ) ) {
2008-12-07 13:55:45 +03:00
r = - ENOMEM ;
goto out_free_0 ;
}
2007-11-14 15:38:21 +03:00
r = kvm_arch_hardware_setup ( ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
if ( r < 0 )
2008-12-07 13:55:45 +03:00
goto out_free_0a ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
2007-07-31 15:23:01 +04:00
for_each_online_cpu ( cpu ) {
smp_call_function_single ( cpu ,
2007-11-14 15:38:21 +03:00
kvm_arch_check_processor_compat ,
2008-06-06 13:18:06 +04:00
& r , 1 ) ;
2007-07-31 15:23:01 +04:00
if ( r < 0 )
2007-11-29 10:35:39 +03:00
goto out_free_1 ;
2007-07-31 15:23:01 +04:00
}
2007-02-12 11:54:47 +03:00
r = register_cpu_notifier ( & kvm_cpu_notifier ) ;
if ( r )
2007-11-29 10:35:39 +03:00
goto out_free_2 ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
register_reboot_notifier ( & kvm_reboot_notifier ) ;
2007-07-30 15:12:19 +04:00
/* A kmem cache lets us meet the alignment requirements of fx_save. */
2010-04-28 16:39:01 +04:00
if ( ! vcpu_align )
vcpu_align = __alignof__ ( struct kvm_vcpu ) ;
kvm_vcpu_cache = kmem_cache_create ( " kvm_vcpu " , vcpu_size , vcpu_align ,
2007-11-13 07:06:51 +03:00
0 , NULL ) ;
2007-07-30 15:12:19 +04:00
if ( ! kvm_vcpu_cache ) {
r = - ENOMEM ;
2011-03-24 00:16:23 +03:00
goto out_free_3 ;
2007-07-30 15:12:19 +04:00
}
2010-10-14 13:22:46 +04:00
r = kvm_async_pf_init ( ) ;
if ( r )
goto out_free ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
kvm_chardev_ops . owner = module ;
2008-12-02 13:17:32 +03:00
kvm_vm_fops . owner = module ;
kvm_vcpu_fops . owner = module ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
r = misc_register ( & kvm_dev ) ;
if ( r ) {
2015-02-26 09:58:26 +03:00
pr_err ( " kvm: misc device register failed \n " ) ;
2010-10-14 13:22:46 +04:00
goto out_unreg ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
}
2011-03-24 00:16:23 +03:00
register_syscore_ops ( & kvm_syscore_ops ) ;
2007-07-11 19:17:21 +04:00
kvm_preempt_ops . sched_in = kvm_sched_in ;
kvm_preempt_ops . sched_out = kvm_sched_out ;
2011-12-15 10:23:16 +04:00
r = kvm_init_debug ( ) ;
if ( r ) {
2015-02-26 09:58:26 +03:00
pr_err ( " kvm: create debugfs files failed \n " ) ;
2011-12-15 10:23:16 +04:00
goto out_undebugfs ;
}
2009-10-15 03:21:00 +04:00
2014-09-24 15:02:46 +04:00
r = kvm_vfio_ops_init ( ) ;
WARN_ON ( r ) ;
KVM: Allow not-present guest page faults to bypass kvm
There are two classes of page faults trapped by kvm:
- host page faults, where the fault is needed to allow kvm to install
the shadow pte or update the guest accessed and dirty bits
- guest page faults, where the guest has faulted and kvm simply injects
the fault back into the guest to handle
The second class, guest page faults, is pure overhead. We can eliminate
some of it on vmx using the following evil trick:
- when we set up a shadow page table entry, if the corresponding guest pte
is not present, set up the shadow pte as not present
- if the guest pte _is_ present, mark the shadow pte as present but also
set one of the reserved bits in the shadow pte
- tell the vmx hardware not to trap faults which have the present bit clear
With this, normal page-not-present faults go directly to the guest,
bypassing kvm entirely.
Unfortunately, this trick only works on Intel hardware, as AMD lacks a
way to discriminate among page faults based on error code. It is also
a little risky since it uses reserved bits which might become unreserved
in the future, so a module parameter is provided to disable it.
Signed-off-by: Avi Kivity <avi@qumranet.com>
2007-09-16 20:58:32 +04:00
return 0 ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
2011-12-15 10:23:16 +04:00
out_undebugfs :
unregister_syscore_ops ( & kvm_syscore_ops ) ;
2013-05-05 16:03:40 +04:00
misc_deregister ( & kvm_dev ) ;
2010-10-14 13:22:46 +04:00
out_unreg :
kvm_async_pf_deinit ( ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
out_free :
2007-07-30 15:12:19 +04:00
kmem_cache_destroy ( kvm_vcpu_cache ) ;
2007-11-29 10:35:39 +03:00
out_free_3 :
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
unregister_reboot_notifier ( & kvm_reboot_notifier ) ;
2007-02-12 11:54:47 +03:00
unregister_cpu_notifier ( & kvm_cpu_notifier ) ;
2007-11-29 10:35:39 +03:00
out_free_2 :
out_free_1 :
2007-11-14 15:38:21 +03:00
kvm_arch_hardware_unsetup ( ) ;
2008-12-07 13:55:45 +03:00
out_free_0a :
free_cpumask_var ( cpus_hardware_enabled ) ;
2007-11-29 10:35:39 +03:00
out_free_0 :
2013-02-28 15:33:18 +04:00
kvm_irqfd_exit ( ) ;
out_irqfd :
2013-05-08 06:57:29 +04:00
kvm_arch_exit ( ) ;
out_fail :
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
return r ;
}
2007-11-14 15:39:31 +03:00
EXPORT_SYMBOL_GPL ( kvm_init ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
2007-11-14 15:39:31 +03:00
void kvm_exit ( void )
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
{
2009-10-15 03:21:00 +04:00
kvm_exit_debug ( ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
misc_deregister ( & kvm_dev ) ;
2007-07-30 15:12:19 +04:00
kmem_cache_destroy ( kvm_vcpu_cache ) ;
2010-10-14 13:22:46 +04:00
kvm_async_pf_deinit ( ) ;
2011-03-24 00:16:23 +03:00
unregister_syscore_ops ( & kvm_syscore_ops ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
unregister_reboot_notifier ( & kvm_reboot_notifier ) ;
2007-02-12 11:54:48 +03:00
unregister_cpu_notifier ( & kvm_cpu_notifier ) ;
2010-11-16 11:37:41 +03:00
on_each_cpu ( hardware_disable_nolock , NULL , 1 ) ;
2007-11-14 15:38:21 +03:00
kvm_arch_hardware_unsetup ( ) ;
2007-11-14 15:40:21 +03:00
kvm_arch_exit ( ) ;
2013-02-28 15:33:18 +04:00
kvm_irqfd_exit ( ) ;
2008-12-07 13:55:45 +03:00
free_cpumask_var ( cpus_hardware_enabled ) ;
2014-10-09 14:30:08 +04:00
kvm_vfio_ops_exit ( ) ;
[PATCH] kvm: userspace interface
web site: http://kvm.sourceforge.net
mailing list: kvm-devel@lists.sourceforge.net
(http://lists.sourceforge.net/lists/listinfo/kvm-devel)
The following patchset adds a driver for Intel's hardware virtualization
extensions to the x86 architecture. The driver adds a character device
(/dev/kvm) that exposes the virtualization capabilities to userspace. Using
this driver, a process can run a virtual machine (a "guest") in a fully
virtualized PC containing its own virtual hard disks, network adapters, and
display.
Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread in
that process. kill(1), nice(1), top(1) work as expected. In effect, the
driver adds a third execution mode to the existing two: we now have kernel
mode, user mode, and guest mode. Guest mode has its own address space mapping
guest physical memory (which is accessible to user mode by mmap()ing
/dev/kvm). Guest mode has no access to any I/O devices; any such access is
intercepted and directed to user mode for emulation.
The driver supports i386 and x86_64 hosts and guests. All combinations are
allowed except x86_64 guest on i386 host. For i386 guests and hosts, both pae
and non-pae paging modes are supported.
SMP hosts and UP guests are supported. At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.
Performance currently is non-stellar due to the naive implementation of the
mmu virtualization, which throws away most of the shadow page table entries
every context switch. We plan to address this in two ways:
- cache shadow page tables across tlb flushes
- wait until AMD and Intel release processors with nested page tables
Currently a virtual desktop is responsive but consumes a lot of CPU. Under
Windows I tried playing pinball and watching a few flash movies; with a recent
CPU one can hardly feel the virtualization. Linux/X is slower, probably due
to X being in a separate process.
In addition to the driver, you need a slightly modified qemu to provide I/O
device emulation and the BIOS.
Caveats (akpm: might no longer be true):
- The Windows install currently bluescreens due to a problem with the
virtual APIC. We are working on a fix. A temporary workaround is to
use an existing image or install through qemu
- Windows 64-bit does not work. That's also true for qemu, so it's
probably a problem with the device model.
[bero@arklinux.org: build fix]
[simon.kagstrom@bth.se: build fix, other fixes]
[uril@qumranet.com: KVM: Expose interrupt bitmap]
[akpm@osdl.org: i386 build fix]
[mingo@elte.hu: i386 fixes]
[rdreier@cisco.com: add log levels to all printks]
[randy.dunlap@oracle.com: Fix sparse NULL and C99 struct init warnings]
[anthony@codemonkey.ws: KVM: AMD SVM: 32-bit host support]
Signed-off-by: Yaniv Kamay <yaniv@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: Bernhard Rosenkraenzer <bero@arklinux.org>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 13:21:36 +03:00
}
2007-11-14 15:39:31 +03:00
EXPORT_SYMBOL_GPL ( kvm_exit ) ;