]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4sys/include/__vm-svm.h
5cb81da25bd05f5ec07aaa9efa6d49c9525b2692
[l4.git] / l4 / pkg / l4sys / include / __vm-svm.h
1 /**
2  * \internal
3  * \file
4  * \brief X86 virtualization interface.
5  */
6 /*
7  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
8  *               Alexander Warg <warg@os.inf.tu-dresden.de>
9  *     economic rights: Technische Universität Dresden (Germany)
10  *
11  * This file is part of TUD:OS and distributed under the terms of the
12  * GNU General Public License 2.
13  * Please see the COPYING-GPL-2 file for details.
14  *
15  * As a special exception, you may use this file as part of a free software
16  * library without restriction.  Specifically, if other files instantiate
17  * templates or use macros or inline functions from this file, or you compile
18  * this file and link it with other files to produce an executable, this
19  * file does not by itself cause the resulting executable to be covered by
20  * the GNU General Public License.  This exception does not however
21  * invalidate any other reasons why the executable file might be covered by
22  * the GNU General Public License.
23  */
24 #pragma once
25
26 #include <l4/sys/ipc.h>
27 #include <l4/sys/task.h>
28
29 /**
30  * \defgroup l4_vm_svm_api VM API for SVM
31  * \brief Virtual machine API for SVM.
32  * \ingroup l4_vm_api
33  */
34
35
36 /**
37  * \brief VMCB structure for SVM VMs
38  * \ingroup l4_vm_svm_api
39  */
40 typedef struct l4_vm_svm_vmcb_control_area
41 {
42   l4_uint16_t intercept_rd_crX;
43   l4_uint16_t intercept_wr_crX;
44
45   l4_uint16_t intercept_rd_drX;
46   l4_uint16_t intercept_wr_drX;
47
48   l4_uint32_t intercept_exceptions;
49
50   l4_uint32_t intercept_instruction0;
51   l4_uint32_t intercept_instruction1;
52
53   l4_uint8_t _reserved0[44];
54
55   l4_uint64_t iopm_base_pa;
56   l4_uint64_t msrpm_base_pa;
57   l4_uint64_t tsc_offset;
58   l4_uint64_t guest_asid_tlb_ctl;
59   l4_uint64_t interrupt_ctl;
60   l4_uint64_t interrupt_shadow;
61   l4_uint64_t exitcode;
62   l4_uint64_t exitinfo1;
63   l4_uint64_t exitinfo2;
64   l4_uint64_t exitintinfo;
65   l4_uint64_t np_enable;
66
67   l4_uint8_t _reserved1[16];
68
69   l4_uint64_t eventinj;
70   l4_uint64_t n_cr3;
71   l4_uint64_t lbr_virtualization_enable;
72
73   l4_uint8_t _reserved2[832];
74 } __attribute__((packed)) l4_vm_svm_vmcb_control_area_t;
75
76 /**
77  * \brief State save area segment selector struct
78  * \ingroup l4_vm_svm_api
79  */
80 typedef struct l4_vm_svm_vmcb_state_save_area_seg
81 {
82   l4_uint16_t selector;
83   l4_uint16_t attrib;
84   l4_uint32_t limit;
85   l4_uint64_t base;
86 } __attribute__((packed)) l4_vm_svm_vmcb_state_save_area_seg_t;
87
88 /**
89  * \brief State save area structure for SVM VMs
90  * \ingroup l4_vm_svm_api
91  */
92 typedef struct l4_vm_svm_vmcb_state_save_area
93 {
94   struct l4_vm_svm_vmcb_state_save_area_seg es;
95   struct l4_vm_svm_vmcb_state_save_area_seg cs;
96   struct l4_vm_svm_vmcb_state_save_area_seg ss;
97   struct l4_vm_svm_vmcb_state_save_area_seg ds;
98   struct l4_vm_svm_vmcb_state_save_area_seg fs;
99   struct l4_vm_svm_vmcb_state_save_area_seg gs;
100   struct l4_vm_svm_vmcb_state_save_area_seg gdtr;
101   struct l4_vm_svm_vmcb_state_save_area_seg ldtr;
102   struct l4_vm_svm_vmcb_state_save_area_seg idtr;
103   struct l4_vm_svm_vmcb_state_save_area_seg tr;
104
105   l4_uint8_t _reserved0[43];
106
107   l4_uint8_t cpl;
108
109   l4_uint32_t _reserved1;
110
111   l4_uint64_t efer;
112
113   l4_uint8_t _reserved2[112];
114
115   l4_uint64_t cr4;
116   l4_uint64_t cr3;
117   l4_uint64_t cr0;
118   l4_uint64_t dr7;
119   l4_uint64_t dr6;
120   l4_uint64_t rflags;
121   l4_uint64_t rip;
122
123   l4_uint8_t _reserved3[88];
124
125   l4_uint64_t rsp;
126
127   l4_uint8_t _reserved4[24];
128
129   l4_uint64_t rax;
130   l4_uint64_t star;
131   l4_uint64_t lstar;
132   l4_uint64_t cstar;
133   l4_uint64_t sfmask;
134   l4_uint64_t kernelgsbase;
135   l4_uint64_t sysenter_cs;
136   l4_uint64_t sysenter_esp;
137   l4_uint64_t sysenter_eip;
138   l4_uint64_t cr2;
139
140   l4_uint8_t _reserved5[32];
141
142   l4_uint64_t g_pat;
143   l4_uint64_t dbgctl;
144   l4_uint64_t br_from;
145   l4_uint64_t br_to;
146   l4_uint64_t lastexcpfrom;
147   l4_uint64_t last_excpto;
148
149   l4_uint8_t _reserved6[2408];
150 } __attribute__((packed)) l4_vm_svm_vmcb_state_save_area_t;
151
152
153 /**
154  * \brief Control structure for SVM VMs
155  * \ingroup l4_vm_svm_api
156  */
157 typedef struct l4_vm_svm_vmcb_t
158 {
159   l4_vm_svm_vmcb_control_area_t    control_area;
160   l4_vm_svm_vmcb_state_save_area_t state_save_area;
161 } l4_vm_svm_vmcb_t;