License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 14:07:57 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.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 10:21:36 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* x86_emulate.h
|
|
|
|
*
|
|
|
|
* Generic x86 (32-bit and 64-bit) instruction decoder and emulator.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2005 Keir Fraser
|
|
|
|
*
|
|
|
|
* From: xen-unstable 10676:af9809f51f81a3c43f276f00c81a52ef558afda4
|
|
|
|
*/
|
|
|
|
|
2008-10-23 05:26:29 +00:00
|
|
|
#ifndef _ASM_X86_KVM_X86_EMULATE_H
|
|
|
|
#define _ASM_X86_KVM_X86_EMULATE_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 10:21:36 +00:00
|
|
|
|
2010-03-18 13:20:17 +00:00
|
|
|
#include <asm/desc_defs.h>
|
2021-05-26 08:56:08 +00:00
|
|
|
#include "fpu.h"
|
2010-03-18 13:20:17 +00: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 10:21:36 +00:00
|
|
|
struct x86_emulate_ctxt;
|
2011-04-04 10:39:22 +00:00
|
|
|
enum x86_intercept;
|
|
|
|
enum x86_intercept_stage;
|
[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 10:21:36 +00:00
|
|
|
|
2010-11-22 15:53:21 +00:00
|
|
|
struct x86_exception {
|
|
|
|
u8 vector;
|
|
|
|
bool error_code_valid;
|
|
|
|
u16 error_code;
|
2010-11-29 14:12:30 +00:00
|
|
|
bool nested_page_fault;
|
|
|
|
u64 address; /* cr2 or nested page fault gpa */
|
2017-07-14 01:30:41 +00:00
|
|
|
u8 async_page_fault;
|
2010-11-22 15:53:21 +00:00
|
|
|
};
|
|
|
|
|
2011-04-04 10:39:27 +00:00
|
|
|
/*
|
|
|
|
* This struct is used to carry enough information from the instruction
|
|
|
|
* decoder to main KVM so that a decision can be made whether the
|
|
|
|
* instruction needs to be intercepted or not.
|
|
|
|
*/
|
|
|
|
struct x86_instruction_info {
|
|
|
|
u8 intercept; /* which intercept */
|
|
|
|
u8 rep_prefix; /* rep prefix? */
|
|
|
|
u8 modrm_mod; /* mod part of modrm */
|
|
|
|
u8 modrm_reg; /* index of register used */
|
|
|
|
u8 modrm_rm; /* rm part of modrm */
|
|
|
|
u64 src_val; /* value of source operand */
|
2014-06-30 10:52:55 +00:00
|
|
|
u64 dst_val; /* value of destination operand */
|
2011-04-04 10:39:27 +00:00
|
|
|
u8 src_bytes; /* size of source operand */
|
|
|
|
u8 dst_bytes; /* size of destination operand */
|
|
|
|
u8 ad_bytes; /* size of src/dst address */
|
|
|
|
u64 next_rip; /* rip following the instruction */
|
|
|
|
};
|
|
|
|
|
[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 10:21:36 +00:00
|
|
|
/*
|
|
|
|
* x86_emulate_ops:
|
|
|
|
*
|
|
|
|
* These operations represent the instruction emulator's interface to memory.
|
|
|
|
* There are two categories of operation: those that act on ordinary memory
|
|
|
|
* regions (*_std), and those that act on memory regions known to require
|
|
|
|
* special treatment or emulation (*_emulated).
|
|
|
|
*
|
|
|
|
* The emulator assumes that an instruction accesses only one 'emulated memory'
|
|
|
|
* location, that this location is the given linear faulting address (cr2), and
|
|
|
|
* that this is one of the instruction's data operands. Instruction fetches and
|
|
|
|
* stack operations are assumed never to access emulated memory. The emulator
|
|
|
|
* automatically deduces which operand of a string-move operation is accessing
|
|
|
|
* emulated memory, and assumes that the other operand accesses normal memory.
|
|
|
|
*
|
|
|
|
* NOTES:
|
|
|
|
* 1. The emulator isn't very smart about emulated vs. standard memory.
|
|
|
|
* 'Emulated memory' access addresses should be checked for sanity.
|
|
|
|
* 'Normal memory' accesses may fault, and the caller must arrange to
|
|
|
|
* detect and handle reentrancy into the emulator via recursive faults.
|
|
|
|
* Accesses may be unaligned and may cross page boundaries.
|
|
|
|
* 2. If the access fails (cannot emulate, or a standard access faults) then
|
|
|
|
* it is up to the memop to propagate the fault to the guest VM via
|
|
|
|
* some out-of-band mechanism, unknown to the emulator. The memop signals
|
|
|
|
* failure by returning X86EMUL_PROPAGATE_FAULT to the emulator, which will
|
|
|
|
* then immediately bail.
|
|
|
|
* 3. Valid access sizes are 1, 2, 4 and 8 bytes. On x86/32 systems only
|
|
|
|
* cmpxchg8b_emulated need support 8-byte accesses.
|
|
|
|
* 4. The emulator cannot handle 64-bit mode emulation on an x86/32 system.
|
|
|
|
*/
|
|
|
|
/* Access completed successfully: continue emulation as normal. */
|
|
|
|
#define X86EMUL_CONTINUE 0
|
|
|
|
/* Access is unhandleable: bail from emulation and return error to caller. */
|
|
|
|
#define X86EMUL_UNHANDLEABLE 1
|
|
|
|
/* Terminate emulation but return success to the caller. */
|
|
|
|
#define X86EMUL_PROPAGATE_FAULT 2 /* propagate a generated fault to guest */
|
2010-04-28 16:15:33 +00:00
|
|
|
#define X86EMUL_RETRY_INSTR 3 /* retry the instruction for some reason */
|
|
|
|
#define X86EMUL_CMPXCHG_FAILED 4 /* cmpxchg did not see expected value */
|
2010-04-28 16:15:35 +00:00
|
|
|
#define X86EMUL_IO_NEEDED 5 /* IO is needed to complete emulation */
|
2011-04-04 10:39:22 +00:00
|
|
|
#define X86EMUL_INTERCEPTED 6 /* Intercepted by nested VMCB/VMCS */
|
2010-04-28 16:15:33 +00: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 10:21:36 +00:00
|
|
|
struct x86_emulate_ops {
|
2012-08-27 20:46:17 +00:00
|
|
|
/*
|
|
|
|
* read_gpr: read a general purpose register (rax - r15)
|
|
|
|
*
|
|
|
|
* @reg: gpr number.
|
|
|
|
*/
|
|
|
|
ulong (*read_gpr)(struct x86_emulate_ctxt *ctxt, unsigned reg);
|
|
|
|
/*
|
|
|
|
* write_gpr: write a general purpose register (rax - r15)
|
|
|
|
*
|
|
|
|
* @reg: gpr number.
|
|
|
|
* @val: value to write.
|
|
|
|
*/
|
|
|
|
void (*write_gpr)(struct x86_emulate_ctxt *ctxt, unsigned reg, ulong val);
|
[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 10:21:36 +00:00
|
|
|
/*
|
|
|
|
* read_std: Read bytes of standard (non-emulated/special) memory.
|
2010-02-10 12:21:32 +00:00
|
|
|
* Used for descriptor reading.
|
[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 10:21:36 +00:00
|
|
|
* @addr: [IN ] Linear address from which to read.
|
|
|
|
* @val: [OUT] Value read from memory, zero-extended to 'u_long'.
|
|
|
|
* @bytes: [IN ] Number of bytes to read from memory.
|
2018-06-06 15:38:09 +00:00
|
|
|
* @system:[IN ] Whether the access is forced to be at CPL0.
|
[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 10:21:36 +00:00
|
|
|
*/
|
2011-04-20 10:37:53 +00:00
|
|
|
int (*read_std)(struct x86_emulate_ctxt *ctxt,
|
|
|
|
unsigned long addr, void *val,
|
|
|
|
unsigned int bytes,
|
2018-06-06 15:38:09 +00:00
|
|
|
struct x86_exception *fault, bool system);
|
2010-02-10 12:21:32 +00:00
|
|
|
|
2015-10-30 15:36:24 +00:00
|
|
|
/*
|
|
|
|
* read_phys: Read bytes of standard (non-emulated/special) memory.
|
|
|
|
* Used for descriptor reading.
|
|
|
|
* @addr: [IN ] Physical address from which to read.
|
|
|
|
* @val: [OUT] Value read from memory.
|
|
|
|
* @bytes: [IN ] Number of bytes to read from memory.
|
|
|
|
*/
|
|
|
|
int (*read_phys)(struct x86_emulate_ctxt *ctxt, unsigned long addr,
|
|
|
|
void *val, unsigned int bytes);
|
|
|
|
|
2010-03-18 13:20:16 +00:00
|
|
|
/*
|
|
|
|
* write_std: Write bytes of standard (non-emulated/special) memory.
|
|
|
|
* Used for descriptor writing.
|
|
|
|
* @addr: [IN ] Linear address to which to write.
|
|
|
|
* @val: [OUT] Value write to memory, zero-extended to 'u_long'.
|
|
|
|
* @bytes: [IN ] Number of bytes to write to memory.
|
2018-06-06 15:38:09 +00:00
|
|
|
* @system:[IN ] Whether the access is forced to be at CPL0.
|
2010-03-18 13:20:16 +00:00
|
|
|
*/
|
2011-04-20 10:37:53 +00:00
|
|
|
int (*write_std)(struct x86_emulate_ctxt *ctxt,
|
|
|
|
unsigned long addr, void *val, unsigned int bytes,
|
2018-06-06 15:38:09 +00:00
|
|
|
struct x86_exception *fault, bool system);
|
2010-02-10 12:21:32 +00:00
|
|
|
/*
|
|
|
|
* fetch: Read bytes of standard (non-emulated/special) memory.
|
|
|
|
* Used for instruction fetch.
|
|
|
|
* @addr: [IN ] Linear address from which to read.
|
|
|
|
* @val: [OUT] Value read from memory, zero-extended to 'u_long'.
|
|
|
|
* @bytes: [IN ] Number of bytes to read from memory.
|
|
|
|
*/
|
2011-04-20 10:37:53 +00:00
|
|
|
int (*fetch)(struct x86_emulate_ctxt *ctxt,
|
|
|
|
unsigned long addr, void *val, unsigned int bytes,
|
2010-11-22 15:53:22 +00:00
|
|
|
struct x86_exception *fault);
|
[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 10:21:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* read_emulated: Read bytes from emulated/special memory area.
|
|
|
|
* @addr: [IN ] Linear address from which to read.
|
|
|
|
* @val: [OUT] Value read from memory, zero-extended to 'u_long'.
|
|
|
|
* @bytes: [IN ] Number of bytes to read from memory.
|
|
|
|
*/
|
2011-04-20 10:37:53 +00:00
|
|
|
int (*read_emulated)(struct x86_emulate_ctxt *ctxt,
|
|
|
|
unsigned long addr, void *val, unsigned int bytes,
|
|
|
|
struct x86_exception *fault);
|
[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 10:21:36 +00:00
|
|
|
|
|
|
|
/*
|
2010-01-06 08:55:23 +00:00
|
|
|
* write_emulated: Write bytes to emulated/special memory area.
|
[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 10:21:36 +00:00
|
|
|
* @addr: [IN ] Linear address to which to write.
|
|
|
|
* @val: [IN ] Value to write to memory (low-order bytes used as
|
|
|
|
* required).
|
|
|
|
* @bytes: [IN ] Number of bytes to write to memory.
|
|
|
|
*/
|
2011-04-20 10:37:53 +00:00
|
|
|
int (*write_emulated)(struct x86_emulate_ctxt *ctxt,
|
|
|
|
unsigned long addr, const void *val,
|
2008-03-23 08:02:35 +00:00
|
|
|
unsigned int bytes,
|
2011-04-20 10:37:53 +00:00
|
|
|
struct x86_exception *fault);
|
[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 10:21:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* cmpxchg_emulated: Emulate an atomic (LOCKed) CMPXCHG operation on an
|
|
|
|
* emulated/special memory area.
|
|
|
|
* @addr: [IN ] Linear address to access.
|
|
|
|
* @old: [IN ] Value expected to be current at @addr.
|
|
|
|
* @new: [IN ] Value to write to @addr.
|
|
|
|
* @bytes: [IN ] Number of bytes to access using CMPXCHG.
|
|
|
|
*/
|
2011-04-20 10:37:53 +00:00
|
|
|
int (*cmpxchg_emulated)(struct x86_emulate_ctxt *ctxt,
|
|
|
|
unsigned long addr,
|
2008-03-23 08:02:35 +00:00
|
|
|
const void *old,
|
|
|
|
const void *new,
|
|
|
|
unsigned int bytes,
|
2011-04-20 10:37:53 +00:00
|
|
|
struct x86_exception *fault);
|
2011-04-20 12:38:44 +00:00
|
|
|
void (*invlpg)(struct x86_emulate_ctxt *ctxt, ulong addr);
|
2010-03-18 13:20:23 +00:00
|
|
|
|
2011-04-20 10:37:53 +00:00
|
|
|
int (*pio_in_emulated)(struct x86_emulate_ctxt *ctxt,
|
|
|
|
int size, unsigned short port, void *val,
|
|
|
|
unsigned int count);
|
2010-03-18 13:20:23 +00:00
|
|
|
|
2011-04-20 10:37:53 +00:00
|
|
|
int (*pio_out_emulated)(struct x86_emulate_ctxt *ctxt,
|
|
|
|
int size, unsigned short port, const void *val,
|
|
|
|
unsigned int count);
|
2010-03-18 13:20:23 +00:00
|
|
|
|
2011-04-27 10:20:30 +00:00
|
|
|
bool (*get_segment)(struct x86_emulate_ctxt *ctxt, u16 *selector,
|
|
|
|
struct desc_struct *desc, u32 *base3, int seg);
|
|
|
|
void (*set_segment)(struct x86_emulate_ctxt *ctxt, u16 selector,
|
|
|
|
struct desc_struct *desc, u32 base3, int seg);
|
2011-04-20 10:37:53 +00:00
|
|
|
unsigned long (*get_cached_segment_base)(struct x86_emulate_ctxt *ctxt,
|
|
|
|
int seg);
|
|
|
|
void (*get_gdt)(struct x86_emulate_ctxt *ctxt, struct desc_ptr *dt);
|
|
|
|
void (*get_idt)(struct x86_emulate_ctxt *ctxt, struct desc_ptr *dt);
|
2011-04-20 12:12:00 +00:00
|
|
|
void (*set_gdt)(struct x86_emulate_ctxt *ctxt, struct desc_ptr *dt);
|
|
|
|
void (*set_idt)(struct x86_emulate_ctxt *ctxt, struct desc_ptr *dt);
|
2011-04-20 10:37:53 +00:00
|
|
|
ulong (*get_cr)(struct x86_emulate_ctxt *ctxt, int cr);
|
|
|
|
int (*set_cr)(struct x86_emulate_ctxt *ctxt, int cr, ulong val);
|
|
|
|
int (*cpl)(struct x86_emulate_ctxt *ctxt);
|
2021-02-03 08:42:41 +00:00
|
|
|
void (*get_dr)(struct x86_emulate_ctxt *ctxt, int dr, ulong *dest);
|
2011-04-20 10:37:53 +00:00
|
|
|
int (*set_dr)(struct x86_emulate_ctxt *ctxt, int dr, ulong value);
|
2015-05-07 09:36:11 +00:00
|
|
|
u64 (*get_smbase)(struct x86_emulate_ctxt *ctxt);
|
|
|
|
void (*set_smbase)(struct x86_emulate_ctxt *ctxt, u64 smbase);
|
2022-03-07 12:26:33 +00:00
|
|
|
int (*set_msr_with_filter)(struct x86_emulate_ctxt *ctxt, u32 msr_index, u64 data);
|
|
|
|
int (*get_msr_with_filter)(struct x86_emulate_ctxt *ctxt, u32 msr_index, u64 *pdata);
|
2011-04-20 10:37:53 +00:00
|
|
|
int (*set_msr)(struct x86_emulate_ctxt *ctxt, u32 msr_index, u64 data);
|
|
|
|
int (*get_msr)(struct x86_emulate_ctxt *ctxt, u32 msr_index, u64 *pdata);
|
2014-06-02 15:34:09 +00:00
|
|
|
int (*check_pmc)(struct x86_emulate_ctxt *ctxt, u32 pmc);
|
2011-11-10 12:57:30 +00:00
|
|
|
int (*read_pmc)(struct x86_emulate_ctxt *ctxt, u32 pmc, u64 *pdata);
|
2011-04-20 12:43:05 +00:00
|
|
|
void (*halt)(struct x86_emulate_ctxt *ctxt);
|
2011-04-20 12:53:23 +00:00
|
|
|
void (*wbinvd)(struct x86_emulate_ctxt *ctxt);
|
2011-04-20 12:47:13 +00:00
|
|
|
int (*fix_hypercall)(struct x86_emulate_ctxt *ctxt);
|
2011-04-20 10:37:53 +00:00
|
|
|
int (*intercept)(struct x86_emulate_ctxt *ctxt,
|
2011-04-04 10:39:27 +00:00
|
|
|
struct x86_instruction_info *info,
|
2011-04-04 10:39:22 +00:00
|
|
|
enum x86_intercept_stage stage);
|
2012-01-12 15:43:03 +00:00
|
|
|
|
2017-08-24 12:27:52 +00:00
|
|
|
bool (*get_cpuid)(struct x86_emulate_ctxt *ctxt, u32 *eax, u32 *ebx,
|
2020-03-05 01:34:37 +00:00
|
|
|
u32 *ecx, u32 *edx, bool exact_only);
|
2019-12-17 21:32:38 +00:00
|
|
|
bool (*guest_has_long_mode)(struct x86_emulate_ctxt *ctxt);
|
|
|
|
bool (*guest_has_movbe)(struct x86_emulate_ctxt *ctxt);
|
|
|
|
bool (*guest_has_fxsr)(struct x86_emulate_ctxt *ctxt);
|
2022-03-02 13:15:14 +00:00
|
|
|
bool (*guest_has_rdpid)(struct x86_emulate_ctxt *ctxt);
|
2019-12-17 21:32:38 +00:00
|
|
|
|
2015-01-26 07:32:23 +00:00
|
|
|
void (*set_nmi_mask)(struct x86_emulate_ctxt *ctxt, bool masked);
|
KVM: x86: fix emulation of RSM and IRET instructions
On AMD, the effect of set_nmi_mask called by emulate_iret_real and em_rsm
on hflags is reverted later on in x86_emulate_instruction where hflags are
overwritten with ctxt->emul_flags (the kvm_set_hflags call). This manifests
as a hang when rebooting Windows VMs with QEMU, OVMF, and >1 vcpu.
Instead of trying to merge ctxt->emul_flags into vcpu->arch.hflags after
an instruction is emulated, this commit deletes emul_flags altogether and
makes the emulator access vcpu->arch.hflags using two new accessors. This
way all changes, on the emulator side as well as in functions called from
the emulator and accessing vcpu state with emul_to_vcpu, are preserved.
More details on the bug and its manifestation with Windows and OVMF:
It's a KVM bug in the interaction between SMI/SMM and NMI, specific to AMD.
I believe that the SMM part explains why we started seeing this only with
OVMF.
KVM masks and unmasks NMI when entering and leaving SMM. When KVM emulates
the RSM instruction in em_rsm, the set_nmi_mask call doesn't stick because
later on in x86_emulate_instruction we overwrite arch.hflags with
ctxt->emul_flags, effectively reverting the effect of the set_nmi_mask call.
The AMD-specific hflag of interest here is HF_NMI_MASK.
When rebooting the system, Windows sends an NMI IPI to all but the current
cpu to shut them down. Only after all of them are parked in HLT will the
initiating cpu finish the restart. If NMI is masked, other cpus never get
the memo and the initiating cpu spins forever, waiting for
hal!HalpInterruptProcessorsStarted to drop. That's the symptom we observe.
Fixes: a584539b24b8 ("KVM: x86: pass the whole hflags field to emulator and back")
Signed-off-by: Ladi Prosek <lprosek@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2017-04-25 14:42:44 +00:00
|
|
|
|
|
|
|
unsigned (*get_hflags)(struct x86_emulate_ctxt *ctxt);
|
2021-06-09 18:56:13 +00:00
|
|
|
void (*exiting_smm)(struct x86_emulate_ctxt *ctxt);
|
2021-06-09 18:56:19 +00:00
|
|
|
int (*leave_smm)(struct x86_emulate_ctxt *ctxt, const char *smstate);
|
KVM: x86: Emulate triple fault shutdown if RSM emulation fails
Use the recently introduced KVM_REQ_TRIPLE_FAULT to properly emulate
shutdown if RSM from SMM fails.
Note, entering shutdown after clearing the SMM flag and restoring NMI
blocking is architecturally correct with respect to AMD's APM, which KVM
also uses for SMRAM layout and RSM NMI blocking behavior. The APM says:
An RSM causes a processor shutdown if an invalid-state condition is
found in the SMRAM state-save area. Only an external reset, external
processor-initialization, or non-maskable external interrupt (NMI) can
cause the processor to leave the shutdown state.
Of note is processor-initialization (INIT) as a valid shutdown wake
event, as INIT is blocked by SMM, implying that entering shutdown also
forces the CPU out of SMM.
For recent Intel CPUs, restoring NMI blocking is technically wrong, but
so is restoring NMI blocking in the first place, and Intel's RSM
"architecture" is such a mess that just about anything is allowed and can
be justified as micro-architectural behavior.
Per the SDM:
On Pentium 4 and later processors, shutdown will inhibit INTR and A20M
but will not change any of the other inhibits. On these processors,
NMIs will be inhibited if no action is taken in the SMI handler to
uninhibit them (see Section 34.8).
where Section 34.8 says:
When the processor enters SMM while executing an NMI handler, the
processor saves the SMRAM state save map but does not save the
attribute to keep NMI interrupts disabled. Potentially, an NMI could be
latched (while in SMM or upon exit) and serviced upon exit of SMM even
though the previous NMI handler has still not completed.
I.e. RSM unconditionally unblocks NMI, but shutdown on RSM does not,
which is in direct contradiction of KVM's behavior. But, as mentioned
above, KVM follows AMD architecture and restores NMI blocking on RSM, so
that micro-architectural detail is already lost.
And for Pentium era CPUs, SMI# can break shutdown, meaning that at least
some Intel CPUs fully leave SMM when entering shutdown:
In the shutdown state, Intel processors stop executing instructions
until a RESET#, INIT# or NMI# is asserted. While Pentium family
processors recognize the SMI# signal in shutdown state, P6 family and
Intel486 processors do not.
In other words, the fact that Intel CPUs have implemented the two
extremes gives KVM carte blanche when it comes to honoring Intel's
architecture for handling shutdown during RSM.
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210609185619.992058-3-seanjc@google.com>
[Return X86EMUL_CONTINUE after triple fault. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-06-09 18:56:12 +00:00
|
|
|
void (*triple_fault)(struct x86_emulate_ctxt *ctxt);
|
2019-08-13 13:53:32 +00:00
|
|
|
int (*set_xcr)(struct x86_emulate_ctxt *ctxt, u32 index, u64 xcr);
|
[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 10:21:36 +00:00
|
|
|
};
|
|
|
|
|
2007-09-18 09:52:50 +00:00
|
|
|
/* Type, address-of, and value of an instruction's operand. */
|
|
|
|
struct operand {
|
2012-09-03 12:24:29 +00:00
|
|
|
enum { OP_REG, OP_MEM, OP_MEM_STR, OP_IMM, OP_XMM, OP_MM, OP_NONE } type;
|
2007-09-18 09:52:50 +00:00
|
|
|
unsigned int bytes;
|
2012-09-03 12:24:29 +00:00
|
|
|
unsigned int count;
|
2010-08-26 11:31:30 +00:00
|
|
|
union {
|
|
|
|
unsigned long orig_val;
|
|
|
|
u64 orig_val64;
|
|
|
|
};
|
2010-08-01 09:35:10 +00:00
|
|
|
union {
|
|
|
|
unsigned long *reg;
|
2010-11-17 13:28:21 +00:00
|
|
|
struct segmented_address {
|
|
|
|
ulong ea;
|
|
|
|
unsigned seg;
|
|
|
|
} mem;
|
2011-03-29 09:41:27 +00:00
|
|
|
unsigned xmm;
|
2012-04-09 15:40:02 +00:00
|
|
|
unsigned mm;
|
2010-08-01 09:35:10 +00:00
|
|
|
} addr;
|
2010-04-28 16:15:26 +00:00
|
|
|
union {
|
|
|
|
unsigned long val;
|
2010-08-26 11:31:30 +00:00
|
|
|
u64 val64;
|
2014-03-27 10:36:25 +00:00
|
|
|
char valptr[sizeof(sse128_t)];
|
2011-03-29 09:41:27 +00:00
|
|
|
sse128_t vec_val;
|
2012-04-09 15:40:02 +00:00
|
|
|
u64 mm_val;
|
2012-09-03 12:24:29 +00:00
|
|
|
void *data;
|
2010-04-28 16:15:26 +00:00
|
|
|
};
|
2007-09-18 09:52:50 +00:00
|
|
|
};
|
|
|
|
|
2007-11-20 11:15:52 +00:00
|
|
|
struct fetch_cache {
|
|
|
|
u8 data[15];
|
2014-05-06 14:33:01 +00:00
|
|
|
u8 *ptr;
|
|
|
|
u8 *end;
|
2007-11-20 11:15:52 +00:00
|
|
|
};
|
|
|
|
|
2010-03-18 13:20:27 +00:00
|
|
|
struct read_cache {
|
|
|
|
u8 data[1024];
|
|
|
|
unsigned long pos;
|
|
|
|
unsigned long end;
|
|
|
|
};
|
|
|
|
|
2012-09-03 12:24:27 +00:00
|
|
|
/* Execution mode, passed to the emulator. */
|
|
|
|
enum x86emul_mode {
|
|
|
|
X86EMUL_MODE_REAL, /* Real mode. */
|
|
|
|
X86EMUL_MODE_VM86, /* Virtual 8086 mode. */
|
|
|
|
X86EMUL_MODE_PROT16, /* 16-bit protected mode. */
|
|
|
|
X86EMUL_MODE_PROT32, /* 32-bit protected mode. */
|
|
|
|
X86EMUL_MODE_PROT64, /* 64-bit (long) mode. */
|
|
|
|
};
|
|
|
|
|
2015-04-01 16:18:53 +00:00
|
|
|
/* These match some of the HF_* flags defined in kvm_host.h */
|
|
|
|
#define X86EMUL_GUEST_MASK (1 << 5) /* VCPU is in guest-mode */
|
2015-05-07 09:36:11 +00:00
|
|
|
#define X86EMUL_SMM_MASK (1 << 6)
|
|
|
|
#define X86EMUL_SMM_INSIDE_NMI_MASK (1 << 7)
|
2015-04-01 16:18:53 +00:00
|
|
|
|
2020-02-17 16:48:26 +00:00
|
|
|
/*
|
|
|
|
* fastop functions are declared as taking a never-defined fastop parameter,
|
|
|
|
* so they can't be called from C directly.
|
|
|
|
*/
|
|
|
|
struct fastop;
|
|
|
|
|
|
|
|
typedef void (*fastop_t)(struct fastop *);
|
|
|
|
|
2022-05-26 21:08:12 +00:00
|
|
|
/*
|
|
|
|
* The emulator's _regs array tracks only the GPRs, i.e. excludes RIP. RIP is
|
|
|
|
* tracked/accessed via _eip, and except for RIP relative addressing, which
|
|
|
|
* also uses _eip, RIP cannot be a register operand nor can it be an operand in
|
|
|
|
* a ModRM or SIB byte.
|
|
|
|
*
|
|
|
|
* TODO: this is technically wrong for 32-bit KVM, which only supports 8 GPRs;
|
|
|
|
* R8-R15 don't exist.
|
|
|
|
*/
|
|
|
|
#define NR_EMULATOR_GPRS 16
|
|
|
|
|
2011-06-01 12:34:25 +00:00
|
|
|
struct x86_emulate_ctxt {
|
2020-02-18 23:29:48 +00:00
|
|
|
void *vcpu;
|
2012-08-29 23:30:16 +00:00
|
|
|
const struct x86_emulate_ops *ops;
|
2011-06-01 12:34:25 +00:00
|
|
|
|
|
|
|
/* Register state before/after emulation. */
|
|
|
|
unsigned long eflags;
|
|
|
|
unsigned long eip; /* eip before instruction emulation */
|
|
|
|
/* Emulated execution mode, represented by an X86EMUL_MODE value. */
|
2012-09-03 12:24:27 +00:00
|
|
|
enum x86emul_mode mode;
|
2011-06-01 12:34:25 +00:00
|
|
|
|
|
|
|
/* interruptibility state, as a result of execution of STI or MOV SS */
|
|
|
|
int interruptibility;
|
|
|
|
|
|
|
|
bool perm_ok; /* do not check permissions if true */
|
2017-06-07 13:13:14 +00:00
|
|
|
bool tf; /* TF value before instruction (after for syscall/sysret) */
|
2011-06-01 12:34:25 +00:00
|
|
|
|
|
|
|
bool have_exception;
|
|
|
|
struct x86_exception exception;
|
|
|
|
|
2020-02-18 23:03:09 +00:00
|
|
|
/* GPA available */
|
|
|
|
bool gpa_available;
|
|
|
|
gpa_t gpa_val;
|
|
|
|
|
2013-09-22 14:44:51 +00:00
|
|
|
/*
|
|
|
|
* decode cache
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* current opcode length in bytes */
|
|
|
|
u8 opcode_len;
|
2007-09-18 09:52:50 +00:00
|
|
|
u8 b;
|
2011-04-04 10:39:22 +00:00
|
|
|
u8 intercept;
|
2007-09-18 09:52:50 +00:00
|
|
|
u8 op_bytes;
|
|
|
|
u8 ad_bytes;
|
2020-02-17 16:48:26 +00:00
|
|
|
union {
|
|
|
|
int (*execute)(struct x86_emulate_ctxt *ctxt);
|
|
|
|
fastop_t fop;
|
|
|
|
};
|
2011-04-04 10:39:25 +00:00
|
|
|
int (*check_perm)(struct x86_emulate_ctxt *ctxt);
|
2021-08-18 15:03:08 +00:00
|
|
|
|
2014-04-16 16:46:12 +00:00
|
|
|
bool rip_relative;
|
|
|
|
u8 rex_prefix;
|
|
|
|
u8 lock_prefix;
|
|
|
|
u8 rep_prefix;
|
|
|
|
/* bitmaps of registers in _regs[] that can be read */
|
|
|
|
u32 regs_valid;
|
|
|
|
/* bitmaps of registers in _regs[] that have been written */
|
|
|
|
u32 regs_dirty;
|
2007-09-18 09:52:50 +00:00
|
|
|
/* modrm */
|
|
|
|
u8 modrm;
|
|
|
|
u8 modrm_mod;
|
|
|
|
u8 modrm_reg;
|
|
|
|
u8 modrm_rm;
|
2010-08-01 09:07:29 +00:00
|
|
|
u8 modrm_seg;
|
2014-04-16 16:46:13 +00:00
|
|
|
u8 seg_override;
|
2014-04-16 16:46:12 +00:00
|
|
|
u64 d;
|
2011-06-01 12:34:24 +00:00
|
|
|
unsigned long _eip;
|
2020-02-18 23:29:50 +00:00
|
|
|
|
|
|
|
/* Here begins the usercopy section. */
|
|
|
|
struct operand src;
|
|
|
|
struct operand src2;
|
|
|
|
struct operand dst;
|
2012-06-10 14:11:00 +00:00
|
|
|
struct operand memop;
|
2022-05-26 21:08:12 +00:00
|
|
|
unsigned long _regs[NR_EMULATOR_GPRS];
|
2011-09-13 07:45:40 +00:00
|
|
|
struct operand *memopp;
|
2007-11-20 11:15:52 +00:00
|
|
|
struct fetch_cache fetch;
|
2010-03-18 13:20:27 +00:00
|
|
|
struct read_cache io_read;
|
2010-04-28 16:15:22 +00:00
|
|
|
struct read_cache mem_read;
|
2021-11-30 07:42:21 +00:00
|
|
|
bool is_branch;
|
2007-09-18 09:52:50 +00:00
|
|
|
};
|
|
|
|
|
2007-11-22 10:32:09 +00:00
|
|
|
/* Repeat String Operation Prefix */
|
2010-01-20 14:00:35 +00:00
|
|
|
#define REPE_PREFIX 0xf3
|
|
|
|
#define REPNE_PREFIX 0xf2
|
2007-11-22 10:32:09 +00:00
|
|
|
|
2012-01-12 15:43:04 +00:00
|
|
|
/* CPUID vendors */
|
|
|
|
#define X86EMUL_CPUID_VENDOR_AuthenticAMD_ebx 0x68747541
|
|
|
|
#define X86EMUL_CPUID_VENDOR_AuthenticAMD_ecx 0x444d4163
|
|
|
|
#define X86EMUL_CPUID_VENDOR_AuthenticAMD_edx 0x69746e65
|
|
|
|
|
|
|
|
#define X86EMUL_CPUID_VENDOR_AMDisbetterI_ebx 0x69444d41
|
|
|
|
#define X86EMUL_CPUID_VENDOR_AMDisbetterI_ecx 0x21726574
|
|
|
|
#define X86EMUL_CPUID_VENDOR_AMDisbetterI_edx 0x74656273
|
|
|
|
|
2018-09-23 09:36:31 +00:00
|
|
|
#define X86EMUL_CPUID_VENDOR_HygonGenuine_ebx 0x6f677948
|
|
|
|
#define X86EMUL_CPUID_VENDOR_HygonGenuine_ecx 0x656e6975
|
|
|
|
#define X86EMUL_CPUID_VENDOR_HygonGenuine_edx 0x6e65476e
|
|
|
|
|
2012-01-12 15:43:04 +00:00
|
|
|
#define X86EMUL_CPUID_VENDOR_GenuineIntel_ebx 0x756e6547
|
|
|
|
#define X86EMUL_CPUID_VENDOR_GenuineIntel_ecx 0x6c65746e
|
|
|
|
#define X86EMUL_CPUID_VENDOR_GenuineIntel_edx 0x49656e69
|
|
|
|
|
KVM: x86: Fix CPUID range checks for Hypervisor and Centaur classes
Rework the masking in the out-of-range CPUID logic to handle the
Hypervisor sub-classes, as well as the Centaur class if the guest
virtual CPU vendor is Centaur.
Masking against 0x80000000 only handles basic and extended leafs, which
results in Hypervisor range checks being performed against the basic
CPUID class, and Centuar range checks being performed against the
Extended class. E.g. if CPUID.0x40000000.EAX returns 0x4000000A and
there is no entry for CPUID.0x40000006, then function 0x40000006 would
be incorrectly reported as out of bounds.
While there is no official definition of what constitutes a class, the
convention established for Hypervisor classes effectively uses bits 31:8
as the mask by virtue of checking for different bases in increments of
0x100, e.g. KVM advertises its CPUID functions starting at 0x40000100
when HyperV features are advertised at the default base of 0x40000000.
The bad range check doesn't cause functional problems for any known VMM
because out-of-range semantics only come into play if the exact entry
isn't found, and VMMs either support a very limited Hypervisor range,
e.g. the official KVM range is 0x40000000-0x40000001 (effectively no
room for undefined leafs) or explicitly defines gaps to be zero, e.g.
Qemu explicitly creates zeroed entries up to the Centaur and Hypervisor
limits (the latter comes into play when providing HyperV features).
The bad behavior can be visually confirmed by dumping CPUID output in
the guest when running Qemu with a stable TSC, as Qemu extends the limit
of range 0x40000000 to 0x40000010 to advertise VMware's cpuid_freq,
without defining zeroed entries for 0x40000002 - 0x4000000f.
Note, documentation of Centaur/VIA CPUs is hard to come by. Designating
0xc0000000 - 0xcfffffff as the Centaur class is a best guess as to the
behavior of a real Centaur/VIA CPU.
Fixes: 43561123ab37 ("kvm: x86: Improve emulation of CPUID leaves 0BH and 1FH")
Cc: Jim Mattson <jmattson@google.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-03-05 01:34:34 +00:00
|
|
|
#define X86EMUL_CPUID_VENDOR_CentaurHauls_ebx 0x746e6543
|
|
|
|
#define X86EMUL_CPUID_VENDOR_CentaurHauls_ecx 0x736c7561
|
|
|
|
#define X86EMUL_CPUID_VENDOR_CentaurHauls_edx 0x48727561
|
|
|
|
|
2020-03-05 01:34:32 +00:00
|
|
|
static inline bool is_guest_vendor_intel(u32 ebx, u32 ecx, u32 edx)
|
|
|
|
{
|
|
|
|
return ebx == X86EMUL_CPUID_VENDOR_GenuineIntel_ebx &&
|
|
|
|
ecx == X86EMUL_CPUID_VENDOR_GenuineIntel_ecx &&
|
|
|
|
edx == X86EMUL_CPUID_VENDOR_GenuineIntel_edx;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool is_guest_vendor_amd(u32 ebx, u32 ecx, u32 edx)
|
|
|
|
{
|
|
|
|
return (ebx == X86EMUL_CPUID_VENDOR_AuthenticAMD_ebx &&
|
|
|
|
ecx == X86EMUL_CPUID_VENDOR_AuthenticAMD_ecx &&
|
|
|
|
edx == X86EMUL_CPUID_VENDOR_AuthenticAMD_edx) ||
|
|
|
|
(ebx == X86EMUL_CPUID_VENDOR_AMDisbetterI_ebx &&
|
|
|
|
ecx == X86EMUL_CPUID_VENDOR_AMDisbetterI_ecx &&
|
|
|
|
edx == X86EMUL_CPUID_VENDOR_AMDisbetterI_edx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool is_guest_vendor_hygon(u32 ebx, u32 ecx, u32 edx)
|
|
|
|
{
|
|
|
|
return ebx == X86EMUL_CPUID_VENDOR_HygonGenuine_ebx &&
|
|
|
|
ecx == X86EMUL_CPUID_VENDOR_HygonGenuine_ecx &&
|
|
|
|
edx == X86EMUL_CPUID_VENDOR_HygonGenuine_edx;
|
|
|
|
}
|
|
|
|
|
2011-04-04 10:39:22 +00:00
|
|
|
enum x86_intercept_stage {
|
2011-04-21 09:35:41 +00:00
|
|
|
X86_ICTP_NONE = 0, /* Allow zero-init to not match anything */
|
2011-04-04 10:39:22 +00:00
|
|
|
X86_ICPT_PRE_EXCEPT,
|
|
|
|
X86_ICPT_POST_EXCEPT,
|
|
|
|
X86_ICPT_POST_MEMACCESS,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum x86_intercept {
|
|
|
|
x86_intercept_none,
|
2011-04-04 10:39:28 +00:00
|
|
|
x86_intercept_cr_read,
|
|
|
|
x86_intercept_cr_write,
|
|
|
|
x86_intercept_clts,
|
2011-04-04 10:39:23 +00:00
|
|
|
x86_intercept_lmsw,
|
|
|
|
x86_intercept_smsw,
|
2011-04-04 10:39:29 +00:00
|
|
|
x86_intercept_dr_read,
|
|
|
|
x86_intercept_dr_write,
|
2011-04-04 10:39:23 +00:00
|
|
|
x86_intercept_lidt,
|
|
|
|
x86_intercept_sidt,
|
|
|
|
x86_intercept_lgdt,
|
|
|
|
x86_intercept_sgdt,
|
|
|
|
x86_intercept_lldt,
|
|
|
|
x86_intercept_sldt,
|
|
|
|
x86_intercept_ltr,
|
|
|
|
x86_intercept_str,
|
|
|
|
x86_intercept_rdtsc,
|
|
|
|
x86_intercept_rdpmc,
|
|
|
|
x86_intercept_pushf,
|
|
|
|
x86_intercept_popf,
|
|
|
|
x86_intercept_cpuid,
|
|
|
|
x86_intercept_rsm,
|
|
|
|
x86_intercept_iret,
|
|
|
|
x86_intercept_intn,
|
|
|
|
x86_intercept_invd,
|
|
|
|
x86_intercept_pause,
|
|
|
|
x86_intercept_hlt,
|
|
|
|
x86_intercept_invlpg,
|
|
|
|
x86_intercept_invlpga,
|
|
|
|
x86_intercept_vmrun,
|
|
|
|
x86_intercept_vmload,
|
|
|
|
x86_intercept_vmsave,
|
|
|
|
x86_intercept_vmmcall,
|
|
|
|
x86_intercept_stgi,
|
|
|
|
x86_intercept_clgi,
|
|
|
|
x86_intercept_skinit,
|
|
|
|
x86_intercept_rdtscp,
|
2021-05-04 17:17:23 +00:00
|
|
|
x86_intercept_rdpid,
|
2011-04-04 10:39:23 +00:00
|
|
|
x86_intercept_icebp,
|
|
|
|
x86_intercept_wbinvd,
|
|
|
|
x86_intercept_monitor,
|
|
|
|
x86_intercept_mwait,
|
2011-04-04 10:39:33 +00:00
|
|
|
x86_intercept_rdmsr,
|
|
|
|
x86_intercept_wrmsr,
|
2011-04-04 10:39:35 +00:00
|
|
|
x86_intercept_in,
|
|
|
|
x86_intercept_ins,
|
|
|
|
x86_intercept_out,
|
|
|
|
x86_intercept_outs,
|
2019-08-13 13:53:32 +00:00
|
|
|
x86_intercept_xsetbv,
|
2011-04-04 10:39:22 +00:00
|
|
|
|
|
|
|
nr_x86_intercepts
|
|
|
|
};
|
|
|
|
|
[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 10:21:36 +00:00
|
|
|
/* Host execution mode. */
|
2008-10-14 07:59:10 +00:00
|
|
|
#if defined(CONFIG_X86_32)
|
[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 10:21:36 +00:00
|
|
|
#define X86EMUL_MODE_HOST X86EMUL_MODE_PROT32
|
2006-12-13 08:33:45 +00:00
|
|
|
#elif defined(CONFIG_X86_64)
|
[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 10:21:36 +00:00
|
|
|
#define X86EMUL_MODE_HOST X86EMUL_MODE_PROT64
|
|
|
|
#endif
|
|
|
|
|
2021-05-28 00:01:37 +00:00
|
|
|
int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len, int emulation_type);
|
2011-09-22 09:02:48 +00:00
|
|
|
bool x86_page_table_writing_insn(struct x86_emulate_ctxt *ctxt);
|
2010-08-25 09:47:43 +00:00
|
|
|
#define EMULATION_FAILED -1
|
|
|
|
#define EMULATION_OK 0
|
|
|
|
#define EMULATION_RESTART 1
|
2011-04-04 10:39:24 +00:00
|
|
|
#define EMULATION_INTERCEPTED 2
|
2014-04-16 16:46:09 +00:00
|
|
|
void init_decode_cache(struct x86_emulate_ctxt *ctxt);
|
2010-07-29 12:11:50 +00:00
|
|
|
int x86_emulate_insn(struct x86_emulate_ctxt *ctxt);
|
2010-03-18 13:20:17 +00:00
|
|
|
int emulator_task_switch(struct x86_emulate_ctxt *ctxt,
|
2012-02-08 13:34:38 +00:00
|
|
|
u16 tss_selector, int idt_index, int reason,
|
2010-04-14 13:51:09 +00:00
|
|
|
bool has_error_code, u32 error_code);
|
2011-05-14 16:00:52 +00:00
|
|
|
int emulate_int_real(struct x86_emulate_ctxt *ctxt, int irq);
|
2012-08-27 20:46:17 +00:00
|
|
|
void emulator_invalidate_register_cache(struct x86_emulate_ctxt *ctxt);
|
|
|
|
void emulator_writeback_register_cache(struct x86_emulate_ctxt *ctxt);
|
2016-12-14 19:59:23 +00:00
|
|
|
bool emulator_can_use_gpa(struct x86_emulate_ctxt *ctxt);
|
2012-08-27 20:46:17 +00:00
|
|
|
|
2008-10-23 05:26:29 +00:00
|
|
|
#endif /* _ASM_X86_KVM_X86_EMULATE_H */
|