-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvmcs.h
330 lines (312 loc) · 9.96 KB
/
vmcs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
#ifndef __LKM_VMCS_H__
#define __LKM_VMCS_H__
#include "common.h"
#define VMCS_HOST_SELECTOR_MASK 0xF8
#define TSS_AVAILABLE 0x9
#define TSS_BUSY 0xB
_warn_unused_result_ int vmcs_init_all (cpu_ctx *_cpu_ctx, guest_init guest);
typedef union
{
u32 ctl;
struct
{
u32 external_interrupt_exiting : 1;
u32 reserved_0 : 2;
u32 nmi_exiting : 1;
u32 reserved_1 : 1;
u32 virtual_nmis : 1;
u32 activate_vmx_preemption_timer : 1;
u32 process_posted_interrupts : 1;
u32 reserved_2 : 24;
};
} vmx_pinbased_ctls;
size_assert (vmx_pinbased_ctls, BITS (32));
typedef union
{
u32 ctl;
struct
{
u32 reserved_0 : 2;
u32 interrupt_window_exiting : 1;
u32 use_tsc_offsetting : 1;
u32 reserved_1 : 3;
u32 hlt_exiting : 1;
u32 reserved_2 : 1;
u32 invlpg_exiting : 1;
u32 mwait_exiting : 1;
u32 rdpmc_exiting : 1;
u32 rdtsc_exiting : 1;
u32 reserved_3 : 2;
u32 cr3_load_exiting : 1;
u32 cr3_store_exiting : 1;
u32 activate_tertiary_controls : 1;
u32 reserved_4 : 1;
u32 cr8_load_exiting : 1;
u32 cr8_store_exiting : 1;
u32 use_tpr_shadow : 1;
u32 nmi_window_exiting : 1;
u32 mov_dr_exiting : 1;
u32 unconditional_io_exiting : 1;
u32 use_io_bitmaps : 1;
u32 reserved_5 : 1;
u32 monitor_trap_flag : 1;
u32 use_msr_bitmaps : 1;
u32 monitor_exiting : 1;
u32 pause_exiting : 1;
u32 activate_secondary_controls : 1;
};
} vmx_procbased_ctls;
size_assert (vmx_procbased_ctls, BITS (32));
typedef union
{
u32 ctl;
struct
{
u32 virtualize_apic_accesses : 1;
u32 enable_ept : 1;
u32 descriptor_table_exiting : 1;
u32 enable_rdtscp : 1;
u32 virtualize_x2apic_mode : 1;
u32 enable_vpid : 1;
u32 wbinvd_exiting : 1;
u32 unrestricted_guest : 1;
u32 apic_register_virtualization : 1;
u32 virtual_interrupt_delivery : 1;
u32 pause_loop_exiting : 1;
u32 rdrand_exiting : 1;
u32 enable_invpcid : 1;
u32 enable_vm_functions : 1;
u32 vmcs_shadowing : 1;
u32 enable_encls_exiting : 1;
u32 rdseed_exiting : 1;
u32 enable_pml : 1;
u32 ept_violation_ve : 1;
u32 conceal_vmx_from_pt : 1;
u32 enable_xsaves_xrstors : 1;
u32 pasid_translation : 1;
u32 mode_based_ept_execute : 1;
u32 ept_sub_page_write_permissions : 1;
u32 intel_pt_use_guest_phys_addr : 1;
u32 use_tsc_scaling : 1;
u32 enable_user_wait_and_pause : 1;
u32 enable_pconfig : 1;
u32 enable_enclv_exiting : 1;
u32 reserved_0 : 1;
u32 vmm_bus_lock_detection : 1;
u32 instruction_timeout : 1;
};
} vmx_procbased_ctls2;
size_assert (vmx_procbased_ctls2, BITS (32));
typedef union
{
u64 ctl;
struct
{
u64 loadiwkey_exiting : 1;
u64 enable_hlat : 1;
u64 ept_paging_write_control : 1;
u64 guest_paging_verification : 1;
u64 ipi_virtualization : 1;
u64 reserved_0 : 1;
u64 enable_msr_list_instructions : 1;
u64 virtualize_ia32_spec_ctrl : 1;
u64 reserved_1 : 56;
};
} vmx_procbased_ctls3;
size_assert (vmx_procbased_ctls3, BITS (64));
typedef union
{
u32 ctl;
struct
{
u32 reserved_0 : 2;
u32 save_debug_controls : 1;
u32 reserved_1 : 6;
u32 host_address_space_size : 1;
u32 reserved_2 : 2;
u32 load_ia32_perf_global_ctrl : 1;
u32 reserved_3 : 2;
u32 acknowledge_interrupt_on_exit : 1;
u32 reserved_4 : 2;
u32 save_ia32_pat : 1;
u32 load_ia32_pat : 1;
u32 save_ia32_efer : 1;
u32 load_ia32_efer : 1;
u32 save_vmx_preemption_timer_value : 1;
u32 clear_ia32_bndcfgs : 1;
u32 conceal_vmx_from_pt : 1;
u32 clear_ia32_rtit_ctl : 1;
u32 clear_ia32_lbr_ctl : 1;
u32 clear_uinv : 1;
u32 load_cet_state : 1;
u32 load_pkrs : 1;
u32 save_ia32_perf_global_ctl : 1;
u32 activate_secondary_controls : 1;
};
} vmx_exit_ctls;
size_assert (vmx_exit_ctls, BITS (32));
typedef union
{
u32 ctl;
struct
{
u32 reserved_0 : 3;
u32 prematurely_busy_shadow_stack : 1;
u32 reserved_1 : 28;
};
} vmx_exit_ctls2;
size_assert (vmx_exit_ctls2, BITS (32));
typedef union
{
u32 ctl;
struct
{
u32 reserved_0 : 2;
u32 load_debug_controls : 1;
u32 reserved_1 : 6;
u32 ia32e_mode_guest : 1;
u32 entry_to_smm : 1;
u32 deactivate_dual_monitor_treatment : 1;
u32 reserved_2 : 1;
u32 load_ia32_perf_global_ctrl : 1;
u32 load_ia32_pat : 1;
u32 load_ia32_efer : 1;
u32 load_ia32_bndcfgs : 1;
u32 conceal_vmx_from_pt : 1;
u32 load_ia32_rtit_ctl : 1;
u32 load_uinv : 1;
u32 load_cet_state : 1;
u32 load_guest_ia32_lbr_ctl : 1;
u32 load_pkrs : 1;
u32 reserved_3 : 9;
};
} vmx_entry_ctls;
size_assert (vmx_entry_ctls, BITS (32));
typedef union
{
u32 ctl;
struct
{
u32 divide_error : 1;
u32 debug : 1;
u32 nmi_interrupt : 1;
u32 breakpoint : 1;
u32 overflow : 1;
u32 bound_range_exceeded : 1;
u32 invalid_opcode : 1;
u32 device_not_available : 1;
u32 double_fault : 1;
u32 coprocessor_segment_overrun : 1;
u32 invalid_tss : 1;
u32 segment_not_present : 1;
u32 stack_segment_fault : 1;
u32 general_protection : 1;
u32 page_fault : 1;
u32 reserved_1 : 1;
u32 floating_point_error : 1;
u32 alignment_check : 1;
u32 machine_check : 1;
u32 simd_floating_point_exception : 1;
u32 virtualization_exception : 1;
u32 control_protection_exception : 1;
u32 reserved_2 : 10;
};
} vmx_exception_bitmap;
size_assert (vmx_exception_bitmap, BITS (32));
typedef union
{
u16 ctl;
struct
{
u16 RPL : 2;
u16 table_indicator : 1;
u16 index : 13;
};
} segment_selector;
size_assert (segment_selector, BITS (16));
typedef struct
{
u16 limit_low;
u16 base_low;
union
{
u32 ctl;
struct
{
u32 base_mid : 8;
u32 segment_type : 4;
u32 descriptor_type : 1;
u32 DPL : 2;
u32 present : 1;
u32 limit_high : 4;
u32 available_for_system : 1;
u32 long_mode : 1;
u32 DB : 1;
u32 granularity : 1;
u32 base_high : 8;
};
};
} segment_descriptor_32;
size_assert (segment_descriptor_32, BITS (64));
typedef struct
{
u16 limit_low;
u16 base_low;
union
{
u32 ctl0;
struct
{
u32 base_mid : 8;
u32 segment_type : 4;
u32 reserved_0 : 1;
u32 DPL : 2;
u32 present : 1;
u32 limit_high : 4;
u32 available_for_system : 1;
u32 reserved_1 : 1;
u32 reserved_2 : 1;
u32 granularity : 1;
u32 base_high : 8;
};
};
u32 base_upper;
union
{
u32 ctl1;
struct
{
u32 reserved_3 : 8;
u32 reserved_4 : 5;
u32 reserved_5 : 19;
};
};
} segment_descriptor_64;
size_assert (segment_descriptor_64, BITS (128));
typedef union
{
u32 ctl;
struct
{
u32 segment_type : 4;
u32 descriptor_type : 1;
u32 DPL : 2;
u32 segment_present : 1;
u32 reserved_0 : 4;
u32 AVL : 1;
u32 long_mode : 1;
u32 DB : 1;
u32 granularity : 1;
u32 segment_unusable : 1;
u32 reserved_1 : 15;
};
} segment_access_rights;
size_assert (segment_access_rights, BITS (32));
typedef struct _pseudo_descriptor pseudo_descriptor;
struct _packed_ _pseudo_descriptor
{
u16 limit;
u64 base;
};
size_assert (pseudo_descriptor, BITS (80));
#endif // __LKM_VMCS_H__