]> git.lizzy.rs Git - plan9front.git/blob - sys/man/3/vmx
devvga: removing #v/vgabios, use /dev/realmodemem instead
[plan9front.git] / sys / man / 3 / vmx
1 .TH VMX 3
2 .SH NAME
3 vmx \- x86 virtualization interface
4 .SH SYNOPSIS
5 .nf
6 .B #X/clone
7 .B #X/n
8 .B #X/n/ctl
9 .B #X/n/fpregs
10 .B #X/n/map
11 .B #X/n/regs
12 .B #X/n/status
13 .B #X/n/wait
14 .fi
15 .SH DESCRIPTION
16 The
17 .I vmx
18 device supports "virtual CPUs" using the Intel VT-x extension (a.k.a. VMX instruction set).
19 This is used by
20 .IR vmx (3)
21 to implement virtual machines.
22 Access to the
23 .I vmx
24 device is restricted to the hostowner.
25 .PP
26 The top level directory contains a
27 .B clone
28 file and numbered subdirectories representing the
29 allocated virtual CPUs.
30 Opening the clone file allocates a new virtual CPU
31 and returns the file descriptor to its
32 .B ctl
33 file.
34 The
35 .B ctl
36 file provides the main control interface. See below for
37 a list of commands. Reading returns the subdirectory number.
38 Removing the
39 .B ctl
40 file marks the virtual CPU as moribund.
41 The
42 .B status
43 file contains the current status of the virtual CPU, which is one of
44 .TF \fLrunning\fR
45 .TP
46 \fLinit\fR
47 The virtual CPU is being initialized.
48 .TP
49 \fLready\fR
50 The virtual CPU is idle.
51 .TP
52 \fLrunning\fR
53 The virtual CPU is executing code.
54 .TP
55 \fLdead\fR
56 The virtual CPU suffered a fatal error.
57 This state may be followed by an error message.
58 .TP
59 \fLending\fR
60 The virtual CPU is shutting down.
61
62 .LP
63 The
64 .B map
65 file contains the memory map that the virtual CPU will see.
66 It consists of lines of the form
67 .IP
68 \fIaccess\fR \fIcache\fR \fIlowaddr\fR \fIhighaddr\fR \fIsegment\fR \fIoffset\fR
69 .LP
70 \fILowaddr\fR specifies the lowest address in the region and \fIhighaddr\fR one past the highest address.
71 The region is mapped to a region of the same size in the global segment \fIsegment\fR (see
72 .IR segment (3)),
73 starting at \fIoffset\fR.
74 The \fIaccess\fR field specifies the permitted types of access using the characters \fLr\fR (read), \fLw\fR (write), \fLx\fR (execute) and \fL-\fR (padding character).
75 The \fIcache\fR field specifies the cacheability of the region, it must be one of \fLuc\fR, \fLwc\fR, \fLwt\fR, \fLwp\fR and \fLwb\fR (as defined in the Intel SDM).
76
77 .PP
78 Writes to the
79 .B map
80 file append lines to the end.
81 Multiple lines can be written at once but all lines written must be newline terminated.
82 Regions can be overlapping, in which case later definitions always override earlier ones.
83 The map can be cleared by opening the file with
84 .B OTRUNC
85 (see 
86 .IB open
87 (2)).
88
89 .PP
90 The
91 .B regs
92 file contains the registers of the virtual CPU in the format \fIname value\fR.
93 Writes to the file (in the same format) write to the referenced registers (if possible).
94 Multiple lines can be written at once but all lines written must be newline terminated.
95
96 .PP
97 Some registers (\fLCR0\fR and \fLCR4\fR) are split into three registers, suffixed \fLreal\fR, \fLfake\fR and \fLmask\fR.
98 In this case, \fLreal\fR corresponds to the bits that affect actual CPU execution, \fLfake\fR corresponds to the bits read back by the guest and the bits set in \fLmask\fR are those "owned" by the host.
99 The guest is free to modify the bits that it owns (in which case it always has the same value in both \fLreal\fR and \fLfake\fR), but attempting to change a host-owned bit from the status in \fLfake\fR causes a VM exit.
100 Certain bits are owned by the kernel, which means they are fixed in both \fLmask\fR and \fLreal\fR.
101
102 .PP
103 Reading the
104 .B wait
105 file will stall the reading process until the virtual CPU reaches a point where it cannot continue (a "VM exit").
106 This may be due to the an access to hardware or a software exception.
107 Each exit is indicated by a single line in a format compatible with
108 .IR tokenize (2).
109 The first column contains the cause of the exit and the second column contains the "exit qualification" field that may contain more details on the exit (see Intel SDM).
110 The remaining columns come in pairs and contain further info and the values of relevant registers.
111
112 .LP
113 Some notable exit causes are (see kernel source code for a complete list)
114 .TF ".\fL#\fR\fIexception\fR"
115 .TP
116 \fL#\fR\fIexception\fR
117 Exception of the specified type (e.g. \fL#gp\fR for general protection fault).
118 Currently only debug exceptions are configured to cause VM exits.
119 .TP
120 \fLtriplef\fR
121 Triple fault.
122 .TP
123 \fLeptfault\fR
124 The virtual CPU attempted a memory access that does not match any entry in the \fLmap\fR file.
125 .TP
126 \fLmovcr\fR
127 Illegal access to a control register (see above).
128 .IP "\fL.\fR\fIinstr\fR"
129 The virtual CPU attempted to execute the instruction \fIinstr\fR.
130 .TP
131 \fL*ack\fR
132 Not an actual exit, but acknowledgement that an interrupt request (IRQ) was posted.
133
134 .PP
135 The
136 .B fpregs
137 file contains the virtual CPU's floating point registers, in the same binary format used by
138 .IR proc (3).
139
140 .SS Control messages
141 .TF "\fLextrap\fR [ \fIexcep\fR ]"
142 .TP
143 .B quit
144 Destroy the current virtual CPU.
145 .TP
146 \fLgo\fR [ \fIregs\fR ]
147 Launch the virtual CPU.
148 \fIRegs\fR is an optional list of register changes in the format \fIname\fL=\fIvalue\fL;\fR that will be applied before launching.
149 .TP
150 .B stop
151 Stop the virtual CPU.
152 .TP
153 \fLstep\fR [ \fIregs\fR ]
154 Executes a single instruction with the virtual CPU.
155 \fIRegs\fR is optinal, same as \fLgo\fR.
156 .TP
157 \fLexc\fR \fIexcep\fR
158 The exception \fIexcep\fR is triggered in the virtual CPU.
159 \fIExcep\fR can either be a named exception (such as \fL#gp\fR, in lower case) or an exception number.
160 A number may be preeded by \fL#\fR to mark it as an exception, otherwise it is delivered as an interrupt (but always disregarding whether interrupts are enabled).
161 .TP
162 \fLirq\fR [ \fIexcep\fR ]
163 An Interrupt is posted, i.e. the exception \fIexcep\fR will be triggered the next time interrupts are enabled in the virtual CPU, at which point a
164 .B *ack
165 message is sent to
166 .BR wait.
167 .IExcep\fR uses the same format as the argument of \fBexc\fR.
168 .B Irq
169 cancels any interrupts that have been previously posted but not yet delivered and it can be called with no argument to cancel an interrupt.
170 .TP
171 \fLextrap\fR \fIbitmap\fR
172 Changes the exception bitmap. Set bits cause a VM exits.
173 .SH SOURCE
174 .B /sys/src/9/pc/devvmx.c
175 .SH "SEE ALSO"
176 .IR vmx (1),
177 .IR cpuid (8)
178
179 Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3B, Chapters 23-33.
180 .SH BUGS
181 .I Devvmx
182 can and will crash your kernel.
183 .SH HISTORY
184 .I Devvmx
185 first appeared in 9front (June, 2017).