2 * Copyright (c) 2008 Brent Stephens <brents@rice.edu>
3 * Copyright (c) 2008 Diego Ongaro <diego.ongaro@rice.edu>
4 * Copyright (c) 2008 Kaushik Kumar Ram <kaushik@rice.edu>
5 * Copyright (c) 2008 Oleg Pesok <olegpesok@gmail.com>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 #include <sys/types.h>
35 #define KVM_NR_INTERRUPTS 256
41 uint32_t nmsrs
; /* number of msrs in entries */
45 struct kvm_msr_entry
{
52 uint32_t nmsrs
; /* number of msrs in entries */
55 struct kvm_msr_entry entries
[0];
58 #if defined(_KERNEL) || defined(FKVM_INTERNAL)
60 FKVM_REGS_TYPE_REGS
=1,
61 FKVM_REGS_TYPE_SREGS
=2,
62 FKVM_REGS_TYPE_MSRS
=3,
111 kvm_regs_set(struct kvm_regs
*regs
, int idx
, uint64_t value
)
113 *(((uint64_t*) regs
) + idx
) = value
;
116 static inline uint64_t
117 kvm_regs_get(struct kvm_regs
*regs
, int idx
)
119 return *(((uint64_t*) regs
) + idx
);
128 uint8_t ftwx
; /* in fxsave format */
130 uint16_t last_opcode
;
163 struct kvm_segment cs
;
164 struct kvm_segment ds
;
165 struct kvm_segment es
;
166 struct kvm_segment fs
;
167 struct kvm_segment gs
;
168 struct kvm_segment ss
;
169 struct kvm_segment tr
;
170 struct kvm_segment ldt
;
171 struct kvm_dtable gdt
;
172 struct kvm_dtable idt
;
180 uint64_t interrupt_bitmap
[(KVM_NR_INTERRUPTS
+ 63) / 64];
185 struct kvm_breakpoint
{
191 struct kvm_debug_guest
{
194 struct kvm_breakpoint breakpoints
[4];
200 struct kvm_cpuid_entry
{
209 #if defined(_KERNEL) || defined(FKVM_INTERNAL)
212 KVM_EXIT_UNKNOWN
= 0,
213 KVM_EXIT_EXCEPTION
= 1,
215 KVM_EXIT_HYPERCALL
= 3,
219 KVM_EXIT_IRQ_WINDOW_OPEN
= 7,
220 KVM_EXIT_SHUTDOWN
= 8,
221 KVM_EXIT_FAIL_ENTRY
= 9,
223 KVM_EXIT_SET_TPR
= 11,
224 KVM_EXIT_TPR_ACCESS
= 12,
225 KVM_EXIT_S390_SIEIC
= 13,
226 KVM_EXIT_S390_RESET
= 14,
229 KVM_EXIT_NMI_WINDOW_OPEN
= 17,
231 KVM_EXIT_CONTINUE
= 19,
236 uint8_t request_interrupt_window
;
237 uint8_t request_nmi_window
;
241 uint32_t exit_reason
;
242 uint8_t ready_for_interrupt_injection
;
244 uint8_t ready_for_nmi_injection
;
247 /* in (pre_kvm_run), out (post_kvm_run) */
251 /* KVM_EXIT_UNKNOWN */
253 uint64_t hardware_exit_reason
;
255 /* KVM_EXIT_FAIL_ENTRY */
257 uint64_t hardware_entry_failure_reason
;
259 /* KVM_EXIT_EXCEPTION */
266 #define KVM_EXIT_IO_IN 0
267 #define KVM_EXIT_IO_OUT 1
268 uint8_t in
; /* 1 = in 0 = out */
269 uint8_t size
; /* bytes */
270 uint8_t string
; /* 1 = string */
271 uint8_t rep
; /* repeat boolean */
278 uint64_t fault_gpa
; /* Faulting Guest Physical Address */
282 /* KVM_EXIT_TPR_ACCESS */
298 /* Fix the size of the union. */
304 #endif /* !_FKVM_H_ */