test.cpp
Go to the documentation of this file.
1 //
2 // Bareflank Hypervisor
3 //
4 // Copyright (C) 2015 Assured Information Security, Inc.
5 // Author: Rian Quinn <quinnr@ainfosec.com>
6 // Author: Brendan Kerrigan <kerriganb@ainfosec.com>
7 // Author: Connor Davis <davisc@ainfosec.com>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 
23 #include <test.h>
24 #include <new_delete.h>
25 
26 #include <intrinsics/cpuid_x64.h>
27 
28 using namespace x64;
29 using namespace intel_x64;
30 
31 std::map<uint32_t, uint64_t> g_msrs;
32 std::map<uint64_t, uint64_t> g_vmcs_fields;
33 std::map<uint32_t, uint32_t> g_eax_cpuid;
34 
35 struct cpuid_regs g_cpuid_regs;
36 
37 bool g_vmclear_fails = false;
38 bool g_vmload_fails = false;
39 bool g_vmlaunch_fails = false;
42 
43 uint64_t g_test_addr = 0U;
44 uint64_t g_virt_apic_addr = 0U;
45 uint8_t g_virt_apic_mem[0x81] = {0U};
46 
47 uint64_t g_vmcs_link_addr = 1U;
48 uint32_t g_vmcs_link_mem[1] = {0U};
49 
50 uint64_t g_pdpt_addr = 2U;
51 uint64_t g_pdpt_mem[4] = {0U};
52 
53 std::map<uint64_t, void *> g_mock_mem
54 {
55  {
56  {g_virt_apic_addr, static_cast<void *>(&g_virt_apic_mem)},
57  {g_vmcs_link_addr, static_cast<void *>(&g_vmcs_link_mem)},
58  {g_pdpt_addr, static_cast<void *>(&g_pdpt_mem)}
59  }
60 };
61 
62 void
63 setup_mock(MockRepository &mocks, memory_manager_x64 *mm)
64 {
65  mocks.OnCallFunc(memory_manager_x64::instance).Return(mm);
67 }
68 
69 void
72 
73 void
76 
77 void
80 
81 void
84 
85 void
88 
89 void
91 { g_msrs[msrs::ia32_vmx_procbased_ctls2::addr] &= ~(mask << 32); }
92 
93 void
96 
97 void
100 
101 void
104 
105 void
108 
109 void
112 
113 void
116 
117 void
120 
121 extern "C" uint64_t
123 { return g_msrs[addr]; }
124 
125 extern "C" void
126 __write_msr(uint32_t addr, uint64_t val) noexcept
127 { g_msrs[addr] = val; }
128 
129 extern "C" uint32_t
130 __cpuid_eax(uint32_t val) noexcept
131 { return g_eax_cpuid[val]; }
132 
133 extern "C" uint32_t
134 __cpuid_ecx(uint32_t val) noexcept
135 { (void) val; return 0x04000000U; }
136 
137 extern "C" void
138 __cpuid(void *eax, void *ebx, void *ecx, void *edx) noexcept
139 {
140  *static_cast<uint32_t *>(eax) = g_cpuid_regs.eax;
141  *static_cast<uint32_t *>(ebx) = g_cpuid_regs.ebx;
142  *static_cast<uint32_t *>(ecx) = g_cpuid_regs.ecx;
143  *static_cast<uint32_t *>(edx) = g_cpuid_regs.edx;
144 }
145 
146 bool
147 __vmread(uint64_t field, uint64_t *val) noexcept
148 {
149  *val = g_vmcs_fields[field];
150  return true;
151 }
152 
153 bool
154 __vmwrite(uint64_t field, uint64_t val) noexcept
155 {
156  g_vmcs_fields[field] = val;
157  return true;
158 }
159 
160 extern "C" bool
161 __vmclear(void *ptr) noexcept
162 { (void)ptr; return !g_vmclear_fails; }
163 
164 extern "C" bool
165 __vmptrld(void *ptr) noexcept
166 { (void)ptr; return !g_vmload_fails; }
167 
168 extern "C" bool
170 { return !g_vmlaunch_fails; }
171 
172 uintptr_t
174 {
175  (void) ptr;
176 
178  throw gsl::fail_fast("");
179 
180  return 0x0000000ABCDEF0000;
181 }
182 
183 void *
184 physint_to_virtptr(uintptr_t phys)
185 {
186  (void) phys;
187 
189  return nullptr;
190 
191  return static_cast<void *>(g_mock_mem[g_test_addr]);
192 }
193 
195 {
196 }
197 
198 bool
200 {
201  return true;
202 }
203 
204 bool
206 {
207  return true;
208 }
209 
210 void
211 vmcs_ut::list_vmcs_intel_x64_cpp()
212 {
213  this->test_launch_success();
214  this->test_launch_vmlaunch_failure();
215  this->test_launch_vmlaunch_demote_failure();
216  this->test_launch_create_vmcs_region_failure();
217  this->test_launch_create_exit_handler_stack_failure();
218  this->test_launch_clear_failure();
219  this->test_launch_load_failure();
220  this->test_promote_failure();
221  this->test_resume_failure();
222 }
223 
224 void
225 vmcs_ut::list_vmcs_intel_x64_h()
226 {
227  this->test_get_vmcs_field();
228  this->test_get_vmcs_field_if_exists();
229  this->test_set_vmcs_field();
230  this->test_set_vmcs_field_if_exists();
231  this->test_set_vm_control();
232  this->test_set_vm_control_if_allowed();
233  this->test_set_vm_function_control();
234  this->test_set_vm_function_control_if_allowed();
235 }
236 
237 void
238 vmcs_ut::list_16bit_control_fields()
239 {
240  this->test_vmcs_virtual_processor_identifier();
241  this->test_vmcs_posted_interrupt_notification_vector();
242  this->test_vmcs_eptp_index();
243 }
244 
245 void
246 vmcs_ut::list_16bit_guest_state_fields()
247 {
248  this->test_vmcs_guest_es_selector();
249  this->test_vmcs_guest_es_selector_rpl();
250  this->test_vmcs_guest_es_selector_ti();
251  this->test_vmcs_guest_es_selector_index();
252  this->test_vmcs_guest_cs_selector();
253  this->test_vmcs_guest_cs_selector_rpl();
254  this->test_vmcs_guest_cs_selector_ti();
255  this->test_vmcs_guest_cs_selector_index();
256  this->test_vmcs_guest_ss_selector();
257  this->test_vmcs_guest_ss_selector_rpl();
258  this->test_vmcs_guest_ss_selector_ti();
259  this->test_vmcs_guest_ss_selector_index();
260  this->test_vmcs_guest_ds_selector();
261  this->test_vmcs_guest_ds_selector_rpl();
262  this->test_vmcs_guest_ds_selector_ti();
263  this->test_vmcs_guest_ds_selector_index();
264  this->test_vmcs_guest_fs_selector();
265  this->test_vmcs_guest_fs_selector_rpl();
266  this->test_vmcs_guest_fs_selector_ti();
267  this->test_vmcs_guest_fs_selector_index();
268  this->test_vmcs_guest_gs_selector();
269  this->test_vmcs_guest_gs_selector_rpl();
270  this->test_vmcs_guest_gs_selector_ti();
271  this->test_vmcs_guest_gs_selector_index();
272  this->test_vmcs_guest_ldtr_selector();
273  this->test_vmcs_guest_ldtr_selector_rpl();
274  this->test_vmcs_guest_ldtr_selector_ti();
275  this->test_vmcs_guest_ldtr_selector_index();
276  this->test_vmcs_guest_tr_selector();
277  this->test_vmcs_guest_tr_selector_rpl();
278  this->test_vmcs_guest_tr_selector_ti();
279  this->test_vmcs_guest_tr_selector_index();
280  this->test_vmcs_guest_interrupt_status();
281 }
282 
283 void
284 vmcs_ut::list_16bit_host_state_fields()
285 {
286  this->test_vmcs_host_es_selector();
287  this->test_vmcs_host_es_selector_rpl();
288  this->test_vmcs_host_es_selector_ti();
289  this->test_vmcs_host_es_selector_index();
290  this->test_vmcs_host_cs_selector();
291  this->test_vmcs_host_cs_selector_rpl();
292  this->test_vmcs_host_cs_selector_ti();
293  this->test_vmcs_host_cs_selector_index();
294  this->test_vmcs_host_ss_selector();
295  this->test_vmcs_host_ss_selector_rpl();
296  this->test_vmcs_host_ss_selector_ti();
297  this->test_vmcs_host_ss_selector_index();
298  this->test_vmcs_host_ds_selector();
299  this->test_vmcs_host_ds_selector_rpl();
300  this->test_vmcs_host_ds_selector_ti();
301  this->test_vmcs_host_ds_selector_index();
302  this->test_vmcs_host_fs_selector();
303  this->test_vmcs_host_fs_selector_rpl();
304  this->test_vmcs_host_fs_selector_ti();
305  this->test_vmcs_host_fs_selector_index();
306  this->test_vmcs_host_gs_selector();
307  this->test_vmcs_host_gs_selector_rpl();
308  this->test_vmcs_host_gs_selector_ti();
309  this->test_vmcs_host_gs_selector_index();
310  this->test_vmcs_host_tr_selector();
311  this->test_vmcs_host_tr_selector_rpl();
312  this->test_vmcs_host_tr_selector_ti();
313  this->test_vmcs_host_tr_selector_index();
314 }
315 
316 void
317 vmcs_ut::list_64bit_control_fields()
318 {
319  this->test_vmcs_address_of_io_bitmap_a();
320  this->test_vmcs_address_of_io_bitmap_b();
321  this->test_vmcs_address_of_msr_bitmap();
322  this->test_vmcs_vm_exit_msr_store_address();
323  this->test_vmcs_vm_exit_msr_load_address();
324  this->test_vmcs_vm_entry_msr_load_address();
325  this->test_vmcs_executive_vmcs_pointer();
326  this->test_vmcs_pml_address();
327  this->test_vmcs_tsc_offset();
328  this->test_vmcs_virtual_apic_address();
329  this->test_vmcs_apic_access_address();
330  this->test_vmcs_posted_interrupt_descriptor_address();
331  this->test_vmcs_vm_function_controls();
332  this->test_vmcs_vm_function_controls_eptp_switching();
333  this->test_vmcs_vm_function_controls_reserved();
334  this->test_vmcs_ept_pointer();
335  this->test_vmcs_ept_pointer_memory_type();
336  this->test_vmcs_ept_pointer_page_walk_length_minus_one();
337  this->test_vmcs_ept_pointer_accessed_and_dirty_flags();
338  this->test_vmcs_ept_pointer_phys_addr();
339  this->test_vmcs_ept_pointer_reserved();
340  this->test_vmcs_eoi_exit_bitmap_0();
341  this->test_vmcs_eoi_exit_bitmap_1();
342  this->test_vmcs_eoi_exit_bitmap_2();
343  this->test_vmcs_eoi_exit_bitmap_3();
344  this->test_vmcs_eptp_list_address();
345  this->test_vmcs_vmread_bitmap_address();
346  this->test_vmcs_vmwrite_bitmap_address();
347  this->test_vmcs_virtualization_exception_information_address();
348  this->test_vmcs_xss_exiting_bitmap();
349 }
350 
351 void
352 vmcs_ut::list_64bit_read_only_data_field()
353 {
354  this->test_vmcs_guest_physical_address();
355 }
356 
357 void
358 vmcs_ut::list_64bit_guest_state_fields()
359 {
360  this->test_vmcs_vmcs_link_pointer();
361  this->test_vmcs_guest_ia32_debugctl();
362  this->test_vmcs_guest_ia32_debugctl_lbr();
363  this->test_vmcs_guest_ia32_debugctl_btf();
364  this->test_vmcs_guest_ia32_debugctl_tr();
365  this->test_vmcs_guest_ia32_debugctl_bts();
366  this->test_vmcs_guest_ia32_debugctl_btint();
367  this->test_vmcs_guest_ia32_debugctl_bt_off_os();
368  this->test_vmcs_guest_ia32_debugctl_bt_off_user();
369  this->test_vmcs_guest_ia32_debugctl_freeze_lbrs_on_pmi();
370  this->test_vmcs_guest_ia32_debugctl_freeze_perfmon_on_pmi();
371  this->test_vmcs_guest_ia32_debugctl_enable_uncore_pmi();
372  this->test_vmcs_guest_ia32_debugctl_freeze_while_smm();
373  this->test_vmcs_guest_ia32_debugctl_rtm_debug();
374  this->test_vmcs_guest_ia32_debugctl_reserved();
375  this->test_vmcs_guest_ia32_pat();
376  this->test_vmcs_guest_ia32_pat_pa0();
377  this->test_vmcs_guest_ia32_pat_pa0_memory_type();
378  this->test_vmcs_guest_ia32_pat_pa0_reserved();
379  this->test_vmcs_guest_ia32_pat_pa1();
380  this->test_vmcs_guest_ia32_pat_pa1_memory_type();
381  this->test_vmcs_guest_ia32_pat_pa1_reserved();
382  this->test_vmcs_guest_ia32_pat_pa2();
383  this->test_vmcs_guest_ia32_pat_pa2_memory_type();
384  this->test_vmcs_guest_ia32_pat_pa2_reserved();
385  this->test_vmcs_guest_ia32_pat_pa3();
386  this->test_vmcs_guest_ia32_pat_pa3_memory_type();
387  this->test_vmcs_guest_ia32_pat_pa3_reserved();
388  this->test_vmcs_guest_ia32_pat_pa4();
389  this->test_vmcs_guest_ia32_pat_pa4_memory_type();
390  this->test_vmcs_guest_ia32_pat_pa4_reserved();
391  this->test_vmcs_guest_ia32_pat_pa5();
392  this->test_vmcs_guest_ia32_pat_pa5_memory_type();
393  this->test_vmcs_guest_ia32_pat_pa5_reserved();
394  this->test_vmcs_guest_ia32_pat_pa6();
395  this->test_vmcs_guest_ia32_pat_pa6_memory_type();
396  this->test_vmcs_guest_ia32_pat_pa6_reserved();
397  this->test_vmcs_guest_ia32_pat_pa7();
398  this->test_vmcs_guest_ia32_pat_pa7_memory_type();
399  this->test_vmcs_guest_ia32_pat_pa7_reserved();
400  this->test_vmcs_guest_ia32_efer();
401  this->test_vmcs_guest_ia32_efer_sce();
402  this->test_vmcs_guest_ia32_efer_lme();
403  this->test_vmcs_guest_ia32_efer_lma();
404  this->test_vmcs_guest_ia32_efer_nxe();
405  this->test_vmcs_guest_ia32_efer_reserved();
406  this->test_vmcs_guest_ia32_perf_global_ctrl();
407  this->test_vmcs_guest_ia32_perf_global_ctrl_reserved();
408  this->test_vmcs_guest_pdpte0();
409  this->test_vmcs_guest_pdpte0_present();
410  this->test_vmcs_guest_pdpte0_reserved();
411  this->test_vmcs_guest_pdpte0_pwt();
412  this->test_vmcs_guest_pdpte0_pcd();
413  this->test_vmcs_guest_pdpte0_page_directory_addr();
414  this->test_vmcs_guest_pdpte1();
415  this->test_vmcs_guest_pdpte1_present();
416  this->test_vmcs_guest_pdpte1_reserved();
417  this->test_vmcs_guest_pdpte1_pwt();
418  this->test_vmcs_guest_pdpte1_pcd();
419  this->test_vmcs_guest_pdpte1_page_directory_addr();
420  this->test_vmcs_guest_pdpte2();
421  this->test_vmcs_guest_pdpte2_present();
422  this->test_vmcs_guest_pdpte2_reserved();
423  this->test_vmcs_guest_pdpte2_pwt();
424  this->test_vmcs_guest_pdpte2_pcd();
425  this->test_vmcs_guest_pdpte2_page_directory_addr();
426  this->test_vmcs_guest_pdpte3();
427  this->test_vmcs_guest_pdpte3_present();
428  this->test_vmcs_guest_pdpte3_reserved();
429  this->test_vmcs_guest_pdpte3_pwt();
430  this->test_vmcs_guest_pdpte3_pcd();
431  this->test_vmcs_guest_pdpte3_page_directory_addr();
432  this->test_vmcs_guest_ia32_bndcfgs();
433  this->test_vmcs_guest_ia32_bndcfgs_en();
434  this->test_vmcs_guest_ia32_bndcfgs_bndpreserve();
435  this->test_vmcs_guest_ia32_bndcfgs_reserved();
436  this->test_vmcs_guest_ia32_bndcfgs_base_addr_of_bnd_directory();
437 }
438 
439 void
440 vmcs_ut::list_64bit_host_state_fields()
441 {
442  this->test_vmcs_host_ia32_pat();
443  this->test_vmcs_host_ia32_pat_pa0();
444  this->test_vmcs_host_ia32_pat_pa0_memory_type();
445  this->test_vmcs_host_ia32_pat_pa0_reserved();
446  this->test_vmcs_host_ia32_pat_pa1();
447  this->test_vmcs_host_ia32_pat_pa1_memory_type();
448  this->test_vmcs_host_ia32_pat_pa1_reserved();
449  this->test_vmcs_host_ia32_pat_pa2();
450  this->test_vmcs_host_ia32_pat_pa2_memory_type();
451  this->test_vmcs_host_ia32_pat_pa2_reserved();
452  this->test_vmcs_host_ia32_pat_pa3();
453  this->test_vmcs_host_ia32_pat_pa3_memory_type();
454  this->test_vmcs_host_ia32_pat_pa3_reserved();
455  this->test_vmcs_host_ia32_pat_pa4();
456  this->test_vmcs_host_ia32_pat_pa4_memory_type();
457  this->test_vmcs_host_ia32_pat_pa4_reserved();
458  this->test_vmcs_host_ia32_pat_pa5();
459  this->test_vmcs_host_ia32_pat_pa5_memory_type();
460  this->test_vmcs_host_ia32_pat_pa5_reserved();
461  this->test_vmcs_host_ia32_pat_pa6();
462  this->test_vmcs_host_ia32_pat_pa6_memory_type();
463  this->test_vmcs_host_ia32_pat_pa6_reserved();
464  this->test_vmcs_host_ia32_pat_pa7();
465  this->test_vmcs_host_ia32_pat_pa7_memory_type();
466  this->test_vmcs_host_ia32_pat_pa7_reserved();
467  this->test_vmcs_host_ia32_efer();
468  this->test_vmcs_host_ia32_efer_sce();
469  this->test_vmcs_host_ia32_efer_lme();
470  this->test_vmcs_host_ia32_efer_lma();
471  this->test_vmcs_host_ia32_efer_nxe();
472  this->test_vmcs_host_ia32_efer_reserved();
473  this->test_vmcs_host_ia32_perf_global_ctrl();
474  this->test_vmcs_host_ia32_perf_global_ctrl_reserved();
475 }
476 
477 void
478 vmcs_ut::list_32bit_control_fields()
479 {
480  this->test_vmcs_pin_based_vm_execution_controls();
481  this->test_vmcs_pin_based_vm_execution_controls_external_interrupt_exiting();
482  this->test_vmcs_pin_based_vm_execution_controls_nmi_exiting();
483  this->test_vmcs_pin_based_vm_execution_controls_virtual_nmis();
484  this->test_vmcs_pin_based_vm_execution_controls_activate_vmx_preemption_timer();
485  this->test_vmcs_pin_based_vm_execution_controls_process_posted_interrupts();
486  this->test_vmcs_primary_processor_based_vm_execution_controls();
487  this->test_vmcs_primary_processor_based_vm_execution_controls_interrupt_window_exiting();
488  this->test_vmcs_primary_processor_based_vm_execution_controls_use_tsc_offsetting();
489  this->test_vmcs_primary_processor_based_vm_execution_controls_hlt_exiting();
490  this->test_vmcs_primary_processor_based_vm_execution_controls_invlpg_exiting();
491  this->test_vmcs_primary_processor_based_vm_execution_controls_mwait_exiting();
492  this->test_vmcs_primary_processor_based_vm_execution_controls_rdpmc_exiting();
493  this->test_vmcs_primary_processor_based_vm_execution_controls_rdtsc_exiting();
494  this->test_vmcs_primary_processor_based_vm_execution_controls_cr3_load_exiting();
495  this->test_vmcs_primary_processor_based_vm_execution_controls_cr3_store_exiting();
496  this->test_vmcs_primary_processor_based_vm_execution_controls_cr8_load_exiting();
497  this->test_vmcs_primary_processor_based_vm_execution_controls_cr8_store_exiting();
498  this->test_vmcs_primary_processor_based_vm_execution_controls_use_tpr_shadow();
499  this->test_vmcs_primary_processor_based_vm_execution_controls_mov_dr_exiting();
500  this->test_vmcs_primary_processor_based_vm_execution_controls_unconditional_io_exiting();
501  this->test_vmcs_primary_processor_based_vm_execution_controls_nmi_window_exiting();
502  this->test_vmcs_primary_processor_based_vm_execution_controls_use_io_bitmaps();
503  this->test_vmcs_primary_processor_based_vm_execution_controls_monitor_trap_flag();
504  this->test_vmcs_primary_processor_based_vm_execution_controls_use_msr_bitmap();
505  this->test_vmcs_primary_processor_based_vm_execution_controls_monitor_exiting();
506  this->test_vmcs_primary_processor_based_vm_execution_controls_pause_exiting();
507  this->test_vmcs_primary_processor_based_vm_execution_controls_activate_secondary_controls();
508  this->test_vmcs_exception_bitmap();
509  this->test_vmcs_page_fault_error_code_mask();
510  this->test_vmcs_page_fault_error_code_match();
511  this->test_vmcs_cr3_target_count();
512  this->test_vmcs_vm_exit_controls();
513  this->test_vmcs_vm_exit_controls_save_debug_controls();
514  this->test_vmcs_vm_exit_controls_host_address_space_size();
515  this->test_vmcs_vm_exit_controls_load_ia32_perf_global_ctrl();
516  this->test_vmcs_vm_exit_controls_acknowledge_interrupt_on_exit();
517  this->test_vmcs_vm_exit_controls_save_ia32_pat();
518  this->test_vmcs_vm_exit_controls_load_ia32_pat();
519  this->test_vmcs_vm_exit_controls_save_ia32_efer();
520  this->test_vmcs_vm_exit_controls_load_ia32_efer();
521  this->test_vmcs_vm_exit_controls_save_vmx_preemption_timer_value();
522  this->test_vmcs_vm_exit_controls_clear_ia32_bndcfgs();
523  this->test_vmcs_vm_exit_msr_store_count();
524  this->test_vmcs_vm_exit_msr_load_count();
525  this->test_vmcs_vm_entry_controls();
526  this->test_vmcs_vm_entry_controls_load_debug_controls();
527  this->test_vmcs_vm_entry_controls_ia_32e_mode_guest();
528  this->test_vmcs_vm_entry_controls_entry_to_smm();
529  this->test_vmcs_vm_entry_controls_deactivate_dual_monitor_treatment();
530  this->test_vmcs_vm_entry_controls_load_ia32_perf_global_ctrl();
531  this->test_vmcs_vm_entry_controls_load_ia32_pat();
532  this->test_vmcs_vm_entry_controls_load_ia32_efer();
533  this->test_vmcs_vm_entry_controls_load_ia32_bndcfgs();
534  this->test_vmcs_vm_entry_msr_load_count();
535  this->test_vmcs_vm_entry_interruption_information_field();
536  this->test_vmcs_vm_entry_interruption_information_field_vector();
537  this->test_vmcs_vm_entry_interruption_information_field_type();
538  this->test_vmcs_vm_entry_interruption_information_field_deliver_error_code_bit();
539  this->test_vmcs_vm_entry_interruption_information_field_reserved();
540  this->test_vmcs_vm_entry_interruption_information_field_valid_bit();
541  this->test_vmcs_vm_entry_exception_error_code();
542  this->test_vmcs_vm_entry_instruction_length();
543  this->test_vmcs_tpr_threshold();
544  this->test_vmcs_secondary_processor_based_vm_execution_controls();
545  this->test_vmcs_secondary_processor_based_vm_execution_controls_virtualize_apic_accesses();
546  this->test_vmcs_secondary_processor_based_vm_execution_controls_enable_ept();
547  this->test_vmcs_secondary_processor_based_vm_execution_controls_descriptor_table_exiting();
548  this->test_vmcs_secondary_processor_based_vm_execution_controls_enable_rdtscp();
549  this->test_vmcs_secondary_processor_based_vm_execution_controls_virtualize_x2apic_mode();
550  this->test_vmcs_secondary_processor_based_vm_execution_controls_enable_vpid();
551  this->test_vmcs_secondary_processor_based_vm_execution_controls_wbinvd_exiting();
552  this->test_vmcs_secondary_processor_based_vm_execution_controls_unrestricted_guest();
553  this->test_vmcs_secondary_processor_based_vm_execution_controls_apic_register_virtualization();
554  this->test_vmcs_secondary_processor_based_vm_execution_controls_virtual_interrupt_delivery();
555  this->test_vmcs_secondary_processor_based_vm_execution_controls_pause_loop_exiting();
556  this->test_vmcs_secondary_processor_based_vm_execution_controls_rdrand_exiting();
557  this->test_vmcs_secondary_processor_based_vm_execution_controls_enable_invpcid();
558  this->test_vmcs_secondary_processor_based_vm_execution_controls_enable_vm_functions();
559  this->test_vmcs_secondary_processor_based_vm_execution_controls_vmcs_shadowing();
560  this->test_vmcs_secondary_processor_based_vm_execution_controls_rdseed_exiting();
561  this->test_vmcs_secondary_processor_based_vm_execution_controls_enable_pml();
562  this->test_vmcs_secondary_processor_based_vm_execution_controls_ept_violation_ve();
563  this->test_vmcs_secondary_processor_based_vm_execution_controls_enable_xsaves_xrstors();
564  this->test_vmcs_ple_gap();
565  this->test_vmcs_ple_window();
566 }
567 
568 
569 void
570 vmcs_ut::list_32bit_read_only_data_fields()
571 {
572  this->test_vmcs_vm_instruction_error();
573  this->test_vmcs_vm_instruction_error_description();
574  this->test_vmcs_vm_instruction_error_description_if_exists();
575  this->test_vmcs_exit_reason();
576  this->test_vmcs_exit_reason_basic_exit_reason();
577  this->test_vmcs_exit_reason_basic_exit_reason_description();
578  this->test_vmcs_exit_reason_basic_exit_reason_description_if_exists();
579  this->test_vmcs_exit_reason_reserved();
580  this->test_vmcs_exit_reason_vm_exit_incident_to_enclave_mode();
581  this->test_vmcs_exit_reason_pending_mtf_vm_exit();
582  this->test_vmcs_exit_reason_vm_exit_from_vmx_root_operation();
583  this->test_vmcs_exit_reason_vm_entry_failure();
584  this->test_vmcs_vm_exit_interruption_information();
585  this->test_vmcs_vm_exit_interruption_information_vector();
586  this->test_vmcs_vm_exit_interruption_information_interruption_type();
587  this->test_vmcs_vm_exit_interruption_information_error_code_valid();
588  this->test_vmcs_vm_exit_interruption_information_nmi_blocking_due_to_iret();
589  this->test_vmcs_vm_exit_interruption_information_reserved();
590  this->test_vmcs_vm_exit_interruption_information_valid_bit();
591  this->test_vmcs_vm_exit_interruption_error_code();
592  this->test_vmcs_idt_vectoring_information();
593  this->test_vmcs_idt_vectoring_information_vector();
594  this->test_vmcs_idt_vectoring_information_interruption_type();
595  this->test_vmcs_idt_vectoring_information_error_code_valid();
596  this->test_vmcs_idt_vectoring_information_reserved();
597  this->test_vmcs_idt_vectoring_information_valid_bit();
598  this->test_vmcs_idt_vectoring_information();
599  this->test_vmcs_idt_vectoring_error_code();
600  this->test_vmcs_vm_exit_instruction_length();
601  this->test_vmcs_vm_exit_instruction_information();
602  this->test_vmcs_vm_exit_instruction_information_ins();
603  this->test_vmcs_vm_exit_instruction_information_ins_address_size();
604  this->test_vmcs_vm_exit_instruction_information_outs();
605  this->test_vmcs_vm_exit_instruction_information_outs_address_size();
606  this->test_vmcs_vm_exit_instruction_information_outs_segment_register();
607  this->test_vmcs_vm_exit_instruction_information_invept();
608  this->test_vmcs_vm_exit_instruction_information_invept_scaling();
609  this->test_vmcs_vm_exit_instruction_information_invept_address_size();
610  this->test_vmcs_vm_exit_instruction_information_invept_segment_register();
611  this->test_vmcs_vm_exit_instruction_information_invept_index_reg();
612  this->test_vmcs_vm_exit_instruction_information_invept_index_reg_invalid();
613  this->test_vmcs_vm_exit_instruction_information_invept_base_reg();
614  this->test_vmcs_vm_exit_instruction_information_invept_base_reg_invalid();
615  this->test_vmcs_vm_exit_instruction_information_invept_reg2();
616  this->test_vmcs_vm_exit_instruction_information_invpcid();
617  this->test_vmcs_vm_exit_instruction_information_invpcid_scaling();
618  this->test_vmcs_vm_exit_instruction_information_invpcid_address_size();
619  this->test_vmcs_vm_exit_instruction_information_invpcid_segment_register();
620  this->test_vmcs_vm_exit_instruction_information_invpcid_index_reg();
621  this->test_vmcs_vm_exit_instruction_information_invpcid_index_reg_invalid();
622  this->test_vmcs_vm_exit_instruction_information_invpcid_base_reg();
623  this->test_vmcs_vm_exit_instruction_information_invpcid_base_reg_invalid();
624  this->test_vmcs_vm_exit_instruction_information_invpcid_reg2();
625  this->test_vmcs_vm_exit_instruction_information_invvpid();
626  this->test_vmcs_vm_exit_instruction_information_invvpid_scaling();
627  this->test_vmcs_vm_exit_instruction_information_invvpid_address_size();
628  this->test_vmcs_vm_exit_instruction_information_invvpid_segment_register();
629  this->test_vmcs_vm_exit_instruction_information_invvpid_index_reg();
630  this->test_vmcs_vm_exit_instruction_information_invvpid_index_reg_invalid();
631  this->test_vmcs_vm_exit_instruction_information_invvpid_base_reg();
632  this->test_vmcs_vm_exit_instruction_information_invvpid_base_reg_invalid();
633  this->test_vmcs_vm_exit_instruction_information_invvpid_reg2();
634  this->test_vmcs_vm_exit_instruction_information_lidt();
635  this->test_vmcs_vm_exit_instruction_information_lidt_scaling();
636  this->test_vmcs_vm_exit_instruction_information_lidt_address_size();
637  this->test_vmcs_vm_exit_instruction_information_lidt_operand_size();
638  this->test_vmcs_vm_exit_instruction_information_lidt_segment_register();
639  this->test_vmcs_vm_exit_instruction_information_lidt_index_reg();
640  this->test_vmcs_vm_exit_instruction_information_lidt_index_reg_invalid();
641  this->test_vmcs_vm_exit_instruction_information_lidt_base_reg();
642  this->test_vmcs_vm_exit_instruction_information_lidt_base_reg_invalid();
643  this->test_vmcs_vm_exit_instruction_information_lidt_instruction_identity();
644  this->test_vmcs_vm_exit_instruction_information_lgdt();
645  this->test_vmcs_vm_exit_instruction_information_lgdt_scaling();
646  this->test_vmcs_vm_exit_instruction_information_lgdt_address_size();
647  this->test_vmcs_vm_exit_instruction_information_lgdt_operand_size();
648  this->test_vmcs_vm_exit_instruction_information_lgdt_segment_register();
649  this->test_vmcs_vm_exit_instruction_information_lgdt_index_reg();
650  this->test_vmcs_vm_exit_instruction_information_lgdt_index_reg_invalid();
651  this->test_vmcs_vm_exit_instruction_information_lgdt_base_reg();
652  this->test_vmcs_vm_exit_instruction_information_lgdt_base_reg_invalid();
653  this->test_vmcs_vm_exit_instruction_information_lgdt_instruction_identity();
654  this->test_vmcs_vm_exit_instruction_information_sidt();
655  this->test_vmcs_vm_exit_instruction_information_sidt_scaling();
656  this->test_vmcs_vm_exit_instruction_information_sidt_address_size();
657  this->test_vmcs_vm_exit_instruction_information_sidt_operand_size();
658  this->test_vmcs_vm_exit_instruction_information_sidt_segment_register();
659  this->test_vmcs_vm_exit_instruction_information_sidt_index_reg();
660  this->test_vmcs_vm_exit_instruction_information_sidt_index_reg_invalid();
661  this->test_vmcs_vm_exit_instruction_information_sidt_base_reg();
662  this->test_vmcs_vm_exit_instruction_information_sidt_base_reg_invalid();
663  this->test_vmcs_vm_exit_instruction_information_sidt_instruction_identity();
664  this->test_vmcs_vm_exit_instruction_information_sgdt();
665  this->test_vmcs_vm_exit_instruction_information_sgdt_scaling();
666  this->test_vmcs_vm_exit_instruction_information_sgdt_address_size();
667  this->test_vmcs_vm_exit_instruction_information_sgdt_operand_size();
668  this->test_vmcs_vm_exit_instruction_information_sgdt_segment_register();
669  this->test_vmcs_vm_exit_instruction_information_sgdt_index_reg();
670  this->test_vmcs_vm_exit_instruction_information_sgdt_index_reg_invalid();
671  this->test_vmcs_vm_exit_instruction_information_sgdt_base_reg();
672  this->test_vmcs_vm_exit_instruction_information_sgdt_base_reg_invalid();
673  this->test_vmcs_vm_exit_instruction_information_sgdt_instruction_identity();
674  this->test_vmcs_vm_exit_instruction_information_lldt();
675  this->test_vmcs_vm_exit_instruction_information_lldt_scaling();
676  this->test_vmcs_vm_exit_instruction_information_lldt_reg1();
677  this->test_vmcs_vm_exit_instruction_information_lldt_address_size();
678  this->test_vmcs_vm_exit_instruction_information_lldt_mem_reg();
679  this->test_vmcs_vm_exit_instruction_information_lldt_segment_register();
680  this->test_vmcs_vm_exit_instruction_information_lldt_index_reg();
681  this->test_vmcs_vm_exit_instruction_information_lldt_index_reg_invalid();
682  this->test_vmcs_vm_exit_instruction_information_lldt_base_reg();
683  this->test_vmcs_vm_exit_instruction_information_lldt_base_reg_invalid();
684  this->test_vmcs_vm_exit_instruction_information_lldt_instruction_identity();
685  this->test_vmcs_vm_exit_instruction_information_ltr();
686  this->test_vmcs_vm_exit_instruction_information_ltr_scaling();
687  this->test_vmcs_vm_exit_instruction_information_ltr_reg1();
688  this->test_vmcs_vm_exit_instruction_information_ltr_address_size();
689  this->test_vmcs_vm_exit_instruction_information_ltr_mem_reg();
690  this->test_vmcs_vm_exit_instruction_information_ltr_segment_register();
691  this->test_vmcs_vm_exit_instruction_information_ltr_index_reg();
692  this->test_vmcs_vm_exit_instruction_information_ltr_index_reg_invalid();
693  this->test_vmcs_vm_exit_instruction_information_ltr_base_reg();
694  this->test_vmcs_vm_exit_instruction_information_ltr_base_reg_invalid();
695  this->test_vmcs_vm_exit_instruction_information_ltr_instruction_identity();
696  this->test_vmcs_vm_exit_instruction_information_sldt();
697  this->test_vmcs_vm_exit_instruction_information_sldt_scaling();
698  this->test_vmcs_vm_exit_instruction_information_sldt_reg1();
699  this->test_vmcs_vm_exit_instruction_information_sldt_address_size();
700  this->test_vmcs_vm_exit_instruction_information_sldt_mem_reg();
701  this->test_vmcs_vm_exit_instruction_information_sldt_segment_register();
702  this->test_vmcs_vm_exit_instruction_information_sldt_index_reg();
703  this->test_vmcs_vm_exit_instruction_information_sldt_index_reg_invalid();
704  this->test_vmcs_vm_exit_instruction_information_sldt_base_reg();
705  this->test_vmcs_vm_exit_instruction_information_sldt_base_reg_invalid();
706  this->test_vmcs_vm_exit_instruction_information_sldt_instruction_identity();
707  this->test_vmcs_vm_exit_instruction_information_str();
708  this->test_vmcs_vm_exit_instruction_information_str_scaling();
709  this->test_vmcs_vm_exit_instruction_information_str_reg1();
710  this->test_vmcs_vm_exit_instruction_information_str_address_size();
711  this->test_vmcs_vm_exit_instruction_information_str_mem_reg();
712  this->test_vmcs_vm_exit_instruction_information_str_segment_register();
713  this->test_vmcs_vm_exit_instruction_information_str_index_reg();
714  this->test_vmcs_vm_exit_instruction_information_str_index_reg_invalid();
715  this->test_vmcs_vm_exit_instruction_information_str_base_reg();
716  this->test_vmcs_vm_exit_instruction_information_str_base_reg_invalid();
717  this->test_vmcs_vm_exit_instruction_information_str_instruction_identity();
718  this->test_vmcs_vm_exit_instruction_information_rdrand();
719  this->test_vmcs_vm_exit_instruction_information_rdrand_destination_register();
720  this->test_vmcs_vm_exit_instruction_information_rdrand_operand_size();
721  this->test_vmcs_vm_exit_instruction_information_rdseed();
722  this->test_vmcs_vm_exit_instruction_information_rdseed_destination_register();
723  this->test_vmcs_vm_exit_instruction_information_rdseed_operand_size();
724  this->test_vmcs_vm_exit_instruction_information_vmclear();
725  this->test_vmcs_vm_exit_instruction_information_vmclear_scaling();
726  this->test_vmcs_vm_exit_instruction_information_vmclear_address_size();
727  this->test_vmcs_vm_exit_instruction_information_vmclear_segment_register();
728  this->test_vmcs_vm_exit_instruction_information_vmclear_index_reg();
729  this->test_vmcs_vm_exit_instruction_information_vmclear_index_reg_invalid();
730  this->test_vmcs_vm_exit_instruction_information_vmclear_base_reg();
731  this->test_vmcs_vm_exit_instruction_information_vmclear_base_reg_invalid();
732  this->test_vmcs_vm_exit_instruction_information_vmptrld();
733  this->test_vmcs_vm_exit_instruction_information_vmptrld_scaling();
734  this->test_vmcs_vm_exit_instruction_information_vmptrld_address_size();
735  this->test_vmcs_vm_exit_instruction_information_vmptrld_segment_register();
736  this->test_vmcs_vm_exit_instruction_information_vmptrld_index_reg();
737  this->test_vmcs_vm_exit_instruction_information_vmptrld_index_reg_invalid();
738  this->test_vmcs_vm_exit_instruction_information_vmptrld_base_reg();
739  this->test_vmcs_vm_exit_instruction_information_vmptrld_base_reg_invalid();
740  this->test_vmcs_vm_exit_instruction_information_vmptrst();
741  this->test_vmcs_vm_exit_instruction_information_vmptrst_scaling();
742  this->test_vmcs_vm_exit_instruction_information_vmptrst_address_size();
743  this->test_vmcs_vm_exit_instruction_information_vmptrst_segment_register();
744  this->test_vmcs_vm_exit_instruction_information_vmptrst_index_reg();
745  this->test_vmcs_vm_exit_instruction_information_vmptrst_index_reg_invalid();
746  this->test_vmcs_vm_exit_instruction_information_vmptrst_base_reg();
747  this->test_vmcs_vm_exit_instruction_information_vmptrst_base_reg_invalid();
748  this->test_vmcs_vm_exit_instruction_information_vmxon();
749  this->test_vmcs_vm_exit_instruction_information_vmxon_scaling();
750  this->test_vmcs_vm_exit_instruction_information_vmxon_address_size();
751  this->test_vmcs_vm_exit_instruction_information_vmxon_segment_register();
752  this->test_vmcs_vm_exit_instruction_information_vmxon_index_reg();
753  this->test_vmcs_vm_exit_instruction_information_vmxon_index_reg_invalid();
754  this->test_vmcs_vm_exit_instruction_information_vmxon_base_reg();
755  this->test_vmcs_vm_exit_instruction_information_vmxon_base_reg_invalid();
756  this->test_vmcs_vm_exit_instruction_information_xrstors();
757  this->test_vmcs_vm_exit_instruction_information_xrstors_scaling();
758  this->test_vmcs_vm_exit_instruction_information_xrstors_address_size();
759  this->test_vmcs_vm_exit_instruction_information_xrstors_segment_register();
760  this->test_vmcs_vm_exit_instruction_information_xrstors_index_reg();
761  this->test_vmcs_vm_exit_instruction_information_xrstors_index_reg_invalid();
762  this->test_vmcs_vm_exit_instruction_information_xrstors_base_reg();
763  this->test_vmcs_vm_exit_instruction_information_xrstors_base_reg_invalid();
764  this->test_vmcs_vm_exit_instruction_information_xsaves();
765  this->test_vmcs_vm_exit_instruction_information_xsaves_scaling();
766  this->test_vmcs_vm_exit_instruction_information_xsaves_address_size();
767  this->test_vmcs_vm_exit_instruction_information_xsaves_segment_register();
768  this->test_vmcs_vm_exit_instruction_information_xsaves_index_reg();
769  this->test_vmcs_vm_exit_instruction_information_xsaves_index_reg_invalid();
770  this->test_vmcs_vm_exit_instruction_information_xsaves_base_reg();
771  this->test_vmcs_vm_exit_instruction_information_xsaves_base_reg_invalid();
772  this->test_vmcs_vm_exit_instruction_information_vmread();
773  this->test_vmcs_vm_exit_instruction_information_vmread_scaling();
774  this->test_vmcs_vm_exit_instruction_information_vmread_reg1();
775  this->test_vmcs_vm_exit_instruction_information_vmread_address_size();
776  this->test_vmcs_vm_exit_instruction_information_vmread_mem_reg();
777  this->test_vmcs_vm_exit_instruction_information_vmread_segment_register();
778  this->test_vmcs_vm_exit_instruction_information_vmread_index_reg();
779  this->test_vmcs_vm_exit_instruction_information_vmread_index_reg_invalid();
780  this->test_vmcs_vm_exit_instruction_information_vmread_base_reg();
781  this->test_vmcs_vm_exit_instruction_information_vmread_base_reg_invalid();
782  this->test_vmcs_vm_exit_instruction_information_vmread_reg2();
783  this->test_vmcs_vm_exit_instruction_information_vmwrite();
784  this->test_vmcs_vm_exit_instruction_information_vmwrite_scaling();
785  this->test_vmcs_vm_exit_instruction_information_vmwrite_reg1();
786  this->test_vmcs_vm_exit_instruction_information_vmwrite_address_size();
787  this->test_vmcs_vm_exit_instruction_information_vmwrite_mem_reg();
788  this->test_vmcs_vm_exit_instruction_information_vmwrite_segment_register();
789  this->test_vmcs_vm_exit_instruction_information_vmwrite_index_reg();
790  this->test_vmcs_vm_exit_instruction_information_vmwrite_index_reg_invalid();
791  this->test_vmcs_vm_exit_instruction_information_vmwrite_base_reg();
792  this->test_vmcs_vm_exit_instruction_information_vmwrite_base_reg_invalid();
793  this->test_vmcs_vm_exit_instruction_information_vmwrite_reg2();
794 }
795 
796 void
797 vmcs_ut::list_32bit_guest_state_fields()
798 {
799  this->test_vmcs_guest_es_limit();
800  this->test_vmcs_guest_cs_limit();
801  this->test_vmcs_guest_ss_limit();
802  this->test_vmcs_guest_ds_limit();
803  this->test_vmcs_guest_fs_limit();
804  this->test_vmcs_guest_gs_limit();
805  this->test_vmcs_guest_ldtr_limit();
806  this->test_vmcs_guest_tr_limit();
807  this->test_vmcs_guest_gdtr_limit();
808  this->test_vmcs_guest_idtr_limit();
809  this->test_vmcs_guest_es_access_rights();
810  this->test_vmcs_guest_es_access_rights_type();
811  this->test_vmcs_guest_es_access_rights_s();
812  this->test_vmcs_guest_es_access_rights_dpl();
813  this->test_vmcs_guest_es_access_rights_present();
814  this->test_vmcs_guest_es_access_rights_avl();
815  this->test_vmcs_guest_es_access_rights_l();
816  this->test_vmcs_guest_es_access_rights_db();
817  this->test_vmcs_guest_es_access_rights_granularity();
818  this->test_vmcs_guest_es_access_rights_reserved();
819  this->test_vmcs_guest_es_access_rights_unusable();
820  this->test_vmcs_guest_cs_access_rights();
821  this->test_vmcs_guest_cs_access_rights_type();
822  this->test_vmcs_guest_cs_access_rights_s();
823  this->test_vmcs_guest_cs_access_rights_dpl();
824  this->test_vmcs_guest_cs_access_rights_present();
825  this->test_vmcs_guest_cs_access_rights_avl();
826  this->test_vmcs_guest_cs_access_rights_l();
827  this->test_vmcs_guest_cs_access_rights_db();
828  this->test_vmcs_guest_cs_access_rights_granularity();
829  this->test_vmcs_guest_cs_access_rights_reserved();
830  this->test_vmcs_guest_cs_access_rights_unusable();
831  this->test_vmcs_guest_ss_access_rights();
832  this->test_vmcs_guest_ss_access_rights_type();
833  this->test_vmcs_guest_ss_access_rights_s();
834  this->test_vmcs_guest_ss_access_rights_dpl();
835  this->test_vmcs_guest_ss_access_rights_present();
836  this->test_vmcs_guest_ss_access_rights_avl();
837  this->test_vmcs_guest_ss_access_rights_l();
838  this->test_vmcs_guest_ss_access_rights_db();
839  this->test_vmcs_guest_ss_access_rights_granularity();
840  this->test_vmcs_guest_ss_access_rights_reserved();
841  this->test_vmcs_guest_ss_access_rights_unusable();
842  this->test_vmcs_guest_ds_access_rights();
843  this->test_vmcs_guest_ds_access_rights_type();
844  this->test_vmcs_guest_ds_access_rights_s();
845  this->test_vmcs_guest_ds_access_rights_dpl();
846  this->test_vmcs_guest_ds_access_rights_present();
847  this->test_vmcs_guest_ds_access_rights_avl();
848  this->test_vmcs_guest_ds_access_rights_l();
849  this->test_vmcs_guest_ds_access_rights_db();
850  this->test_vmcs_guest_ds_access_rights_granularity();
851  this->test_vmcs_guest_ds_access_rights_reserved();
852  this->test_vmcs_guest_ds_access_rights_unusable();
853  this->test_vmcs_guest_fs_access_rights();
854  this->test_vmcs_guest_fs_access_rights_type();
855  this->test_vmcs_guest_fs_access_rights_s();
856  this->test_vmcs_guest_fs_access_rights_dpl();
857  this->test_vmcs_guest_fs_access_rights_present();
858  this->test_vmcs_guest_fs_access_rights_avl();
859  this->test_vmcs_guest_fs_access_rights_l();
860  this->test_vmcs_guest_fs_access_rights_db();
861  this->test_vmcs_guest_fs_access_rights_granularity();
862  this->test_vmcs_guest_fs_access_rights_reserved();
863  this->test_vmcs_guest_fs_access_rights_unusable();
864  this->test_vmcs_guest_gs_access_rights();
865  this->test_vmcs_guest_gs_access_rights_type();
866  this->test_vmcs_guest_gs_access_rights_s();
867  this->test_vmcs_guest_gs_access_rights_dpl();
868  this->test_vmcs_guest_gs_access_rights_present();
869  this->test_vmcs_guest_gs_access_rights_avl();
870  this->test_vmcs_guest_gs_access_rights_l();
871  this->test_vmcs_guest_gs_access_rights_db();
872  this->test_vmcs_guest_gs_access_rights_granularity();
873  this->test_vmcs_guest_gs_access_rights_reserved();
874  this->test_vmcs_guest_gs_access_rights_unusable();
875  this->test_vmcs_guest_ldtr_access_rights();
876  this->test_vmcs_guest_ldtr_access_rights_type();
877  this->test_vmcs_guest_ldtr_access_rights_s();
878  this->test_vmcs_guest_ldtr_access_rights_dpl();
879  this->test_vmcs_guest_ldtr_access_rights_present();
880  this->test_vmcs_guest_ldtr_access_rights_avl();
881  this->test_vmcs_guest_ldtr_access_rights_l();
882  this->test_vmcs_guest_ldtr_access_rights_db();
883  this->test_vmcs_guest_ldtr_access_rights_granularity();
884  this->test_vmcs_guest_ldtr_access_rights_reserved();
885  this->test_vmcs_guest_ldtr_access_rights_unusable();
886  this->test_vmcs_guest_tr_access_rights();
887  this->test_vmcs_guest_tr_access_rights_type();
888  this->test_vmcs_guest_tr_access_rights_s();
889  this->test_vmcs_guest_tr_access_rights_dpl();
890  this->test_vmcs_guest_tr_access_rights_present();
891  this->test_vmcs_guest_tr_access_rights_avl();
892  this->test_vmcs_guest_tr_access_rights_l();
893  this->test_vmcs_guest_tr_access_rights_db();
894  this->test_vmcs_guest_tr_access_rights_granularity();
895  this->test_vmcs_guest_tr_access_rights_reserved();
896  this->test_vmcs_guest_tr_access_rights_unusable();
897  this->test_vmcs_guest_interruptibility_state();
898  this->test_vmcs_guest_interruptibility_state_blocking_by_sti();
899  this->test_vmcs_guest_interruptibility_state_blocking_by_mov_ss();
900  this->test_vmcs_guest_interruptibility_state_blocking_by_smi();
901  this->test_vmcs_guest_interruptibility_state_blocking_by_nmi();
902  this->test_vmcs_guest_interruptibility_state_enclave_interruption();
903  this->test_vmcs_guest_interruptibility_state_reserved();
904  this->test_vmcs_guest_activity_state();
905  this->test_vmcs_guest_smbase();
906  this->test_vmcs_guest_ia32_sysenter_cs();
907  this->test_vmcs_vmx_preemption_timer_value();
908 }
909 
910 void
911 vmcs_ut::list_32bit_host_state_field()
912 {
913  this->test_vmcs_host_ia32_sysenter_cs();
914 }
915 
916 void
917 vmcs_ut::list_natural_width_control_fields()
918 {
919  this->test_vmcs_cr0_guest_host_mask();
920  this->test_vmcs_cr4_guest_host_mask();
921  this->test_vmcs_cr0_read_shadow();
922  this->test_vmcs_cr4_read_shadow();
923  this->test_vmcs_cr3_target_value_0();
924  this->test_vmcs_cr3_target_value_1();
925  this->test_vmcs_cr3_target_value_2();
926  this->test_vmcs_cr3_target_value_3();
927 }
928 
929 void
930 vmcs_ut::list_natural_width_read_only_data_fields()
931 {
932  this->test_vmcs_exit_qualification();
933  this->test_vmcs_exit_qualification_debug_exception();
934  this->test_vmcs_exit_qualification_debug_exception_b0();
935  this->test_vmcs_exit_qualification_debug_exception_b1();
936  this->test_vmcs_exit_qualification_debug_exception_b2();
937  this->test_vmcs_exit_qualification_debug_exception_b3();
938  this->test_vmcs_exit_qualification_debug_exception_reserved();
939  this->test_vmcs_exit_qualification_debug_exception_bd();
940  this->test_vmcs_exit_qualification_debug_exception_bs();
941  this->test_vmcs_exit_qualification_page_fault_exception();
942  this->test_vmcs_exit_qualification_sipi();
943  this->test_vmcs_exit_qualification_sipi_vector();
944  this->test_vmcs_exit_qualification_task_switch();
945  this->test_vmcs_exit_qualification_task_switch_tss_selector();
946  this->test_vmcs_exit_qualification_task_switch_reserved();
947  this->test_vmcs_exit_qualification_task_switch_source_of_task_switch_init();
948  this->test_vmcs_exit_qualification_invept();
949  this->test_vmcs_exit_qualification_invpcid();
950  this->test_vmcs_exit_qualification_invvpid();
951  this->test_vmcs_exit_qualification_lgdt();
952  this->test_vmcs_exit_qualification_lidt();
953  this->test_vmcs_exit_qualification_lldt();
954  this->test_vmcs_exit_qualification_ltr();
955  this->test_vmcs_exit_qualification_sgdt();
956  this->test_vmcs_exit_qualification_sidt();
957  this->test_vmcs_exit_qualification_sldt();
958  this->test_vmcs_exit_qualification_str();
959  this->test_vmcs_exit_qualification_vmclear();
960  this->test_vmcs_exit_qualification_vmptrld();
961  this->test_vmcs_exit_qualification_vmread();
962  this->test_vmcs_exit_qualification_vmwrite();
963  this->test_vmcs_exit_qualification_vmxon();
964  this->test_vmcs_exit_qualification_xrstors();
965  this->test_vmcs_exit_qualification_xsaves();
966  this->test_vmcs_exit_qualification_control_register_access();
967  this->test_vmcs_exit_qualification_control_register_access_control_register_number();
968  this->test_vmcs_exit_qualification_control_register_access_access_type();
969  this->test_vmcs_exit_qualification_control_register_access_lmsw_operand_type();
970  this->test_vmcs_exit_qualification_control_register_access_reserved();
971  this->test_vmcs_exit_qualification_control_register_access_general_purpose_register();
972  this->test_vmcs_exit_qualification_control_register_access_source_data();
973  this->test_vmcs_exit_qualification_mov_dr();
974  this->test_vmcs_exit_qualification_mov_dr_debug_register_number();
975  this->test_vmcs_exit_qualification_mov_dr_reserved();
976  this->test_vmcs_exit_qualification_mov_dr_direction_of_access();
977  this->test_vmcs_exit_qualification_mov_dr_general_purpose_register();
978  this->test_vmcs_exit_qualification_io_instruction();
979  this->test_vmcs_exit_qualification_io_instruction_size_of_access();
980  this->test_vmcs_exit_qualification_io_instruction_direction_of_access();
981  this->test_vmcs_exit_qualification_io_instruction_string_instruction();
982  this->test_vmcs_exit_qualification_io_instruction_rep_prefixed();
983  this->test_vmcs_exit_qualification_io_instruction_operand_encoding();
984  this->test_vmcs_exit_qualification_io_instruction_reserved();
985  this->test_vmcs_exit_qualification_io_instruction_port_number();
986  this->test_vmcs_exit_qualification_mwait();
987  this->test_vmcs_exit_qualification_linear_apic_access();
988  this->test_vmcs_exit_qualification_linear_apic_access_offset();
989  this->test_vmcs_exit_qualification_linear_apic_access_access_type();
990  this->test_vmcs_exit_qualification_linear_apic_access_reserved();
991  this->test_vmcs_exit_qualification_guest_physical_apic_access();
992  this->test_vmcs_exit_qualification_guest_physical_apic_access_access_type();
993  this->test_vmcs_exit_qualification_guest_physical_apic_access_reserved();
994  this->test_vmcs_exit_qualification_ept_violation();
995  this->test_vmcs_exit_qualification_ept_violation_data_read();
996  this->test_vmcs_exit_qualification_ept_violation_data_write();
997  this->test_vmcs_exit_qualification_ept_violation_instruction_fetch();
998  this->test_vmcs_exit_qualification_ept_violation_readable();
999  this->test_vmcs_exit_qualification_ept_violation_writeable();
1000  this->test_vmcs_exit_qualification_ept_violation_executable();
1001  this->test_vmcs_exit_qualification_ept_violation_reserved();
1002  this->test_vmcs_exit_qualification_ept_violation_valid_guest_linear_address();
1003  this->test_vmcs_exit_qualification_ept_violation_nmi_unblocking_due_to_iret();
1004  this->test_vmcs_exit_qualification_eoi_virtualization();
1005  this->test_vmcs_exit_qualification_eoi_virtualization_vector();
1006  this->test_vmcs_exit_qualification_apic_write();
1007  this->test_vmcs_exit_qualification_apic_write_offset();
1008  this->test_vmcs_io_rcx();
1009  this->test_vmcs_io_rsi();
1010  this->test_vmcs_io_rdi();
1011  this->test_vmcs_io_rip();
1012  this->test_vmcs_guest_linear_address();
1013 }
1014 
1015 void
1016 vmcs_ut::list_natural_width_guest_state_fields()
1017 {
1018  this->test_vmcs_guest_cr0();
1019  this->test_vmcs_guest_cr0_protection_enable();
1020  this->test_vmcs_guest_cr0_monitor_coprocessor();
1021  this->test_vmcs_guest_cr0_emulation();
1022  this->test_vmcs_guest_cr0_task_switched();
1023  this->test_vmcs_guest_cr0_extension_type();
1024  this->test_vmcs_guest_cr0_numeric_error();
1025  this->test_vmcs_guest_cr0_write_protect();
1026  this->test_vmcs_guest_cr0_alignment_mask();
1027  this->test_vmcs_guest_cr0_not_write_through();
1028  this->test_vmcs_guest_cr0_cache_disable();
1029  this->test_vmcs_guest_cr0_paging();
1030  this->test_vmcs_guest_cr3();
1031  this->test_vmcs_guest_cr4();
1032  this->test_vmcs_guest_cr4_v8086_mode_extensions();
1033  this->test_vmcs_guest_cr4_protected_mode_virtual_interrupts();
1034  this->test_vmcs_guest_cr4_time_stamp_disable();
1035  this->test_vmcs_guest_cr4_debugging_extensions();
1036  this->test_vmcs_guest_cr4_page_size_extensions();
1037  this->test_vmcs_guest_cr4_physical_address_extensions();
1038  this->test_vmcs_guest_cr4_machine_check_enable();
1039  this->test_vmcs_guest_cr4_page_global_enable();
1040  this->test_vmcs_guest_cr4_performance_monitor_counter_enable();
1041  this->test_vmcs_guest_cr4_osfxsr();
1042  this->test_vmcs_guest_cr4_osxmmexcpt();
1043  this->test_vmcs_guest_cr4_vmx_enable_bit();
1044  this->test_vmcs_guest_cr4_smx_enable_bit();
1045  this->test_vmcs_guest_cr4_fsgsbase_enable_bit();
1046  this->test_vmcs_guest_cr4_pcid_enable_bit();
1047  this->test_vmcs_guest_cr4_osxsave();
1048  this->test_vmcs_guest_cr4_smep_enable_bit();
1049  this->test_vmcs_guest_cr4_smap_enable_bit();
1050  this->test_vmcs_guest_cr4_protection_key_enable_bit();
1051  this->test_vmcs_guest_es_base();
1052  this->test_vmcs_guest_cs_base();
1053  this->test_vmcs_guest_ss_base();
1054  this->test_vmcs_guest_ds_base();
1055  this->test_vmcs_guest_fs_base();
1056  this->test_vmcs_guest_gs_base();
1057  this->test_vmcs_guest_ldtr_base();
1058  this->test_vmcs_guest_tr_base();
1059  this->test_vmcs_guest_gdtr_base();
1060  this->test_vmcs_guest_idtr_base();
1061  this->test_vmcs_guest_dr7();
1062  this->test_vmcs_guest_rsp();
1063  this->test_vmcs_guest_rip();
1064  this->test_vmcs_guest_rflags();
1065  this->test_vmcs_guest_rflags_carry_flag();
1066  this->test_vmcs_guest_rflags_parity_flag();
1067  this->test_vmcs_guest_rflags_auxiliary_carry_flag();
1068  this->test_vmcs_guest_rflags_zero_flag();
1069  this->test_vmcs_guest_rflags_sign_flag();
1070  this->test_vmcs_guest_rflags_trap_flag();
1071  this->test_vmcs_guest_rflags_interrupt_enable_flag();
1072  this->test_vmcs_guest_rflags_direction_flag();
1073  this->test_vmcs_guest_rflags_overflow_flag();
1074  this->test_vmcs_guest_rflags_privilege_level();
1075  this->test_vmcs_guest_rflags_nested_task();
1076  this->test_vmcs_guest_rflags_resume_flag();
1077  this->test_vmcs_guest_rflags_virtual_8086_mode();
1078  this->test_vmcs_guest_rflags_alignment_check_access_control();
1079  this->test_vmcs_guest_rflags_virtual_interupt_flag();
1080  this->test_vmcs_guest_rflags_virtual_interupt_pending();
1081  this->test_vmcs_guest_rflags_id_flag();
1082  this->test_vmcs_guest_rflags_reserved();
1083  this->test_vmcs_guest_rflags_always_disabled();
1084  this->test_vmcs_guest_rflags_always_enabled();
1085  this->test_vmcs_guest_pending_debug_exceptions();
1086  this->test_vmcs_guest_pending_debug_exceptions_b0();
1087  this->test_vmcs_guest_pending_debug_exceptions_b1();
1088  this->test_vmcs_guest_pending_debug_exceptions_b2();
1089  this->test_vmcs_guest_pending_debug_exceptions_b3();
1090  this->test_vmcs_guest_pending_debug_exceptions_reserved();
1091  this->test_vmcs_guest_pending_debug_exceptions_enabled_breakpoint();
1092  this->test_vmcs_guest_pending_debug_exceptions_bs();
1093  this->test_vmcs_guest_pending_debug_exceptions_rtm();
1094  this->test_vmcs_guest_ia32_sysenter_esp();
1095  this->test_vmcs_guest_ia32_sysenter_eip();
1096 }
1097 
1098 void
1099 vmcs_ut::list_natural_width_host_state_fields()
1100 {
1101  this->test_vmcs_host_cr0();
1102  this->test_vmcs_host_cr0_protection_enable();
1103  this->test_vmcs_host_cr0_monitor_coprocessor();
1104  this->test_vmcs_host_cr0_emulation();
1105  this->test_vmcs_host_cr0_task_switched();
1106  this->test_vmcs_host_cr0_extension_type();
1107  this->test_vmcs_host_cr0_numeric_error();
1108  this->test_vmcs_host_cr0_write_protect();
1109  this->test_vmcs_host_cr0_alignment_mask();
1110  this->test_vmcs_host_cr0_not_write_through();
1111  this->test_vmcs_host_cr0_cache_disable();
1112  this->test_vmcs_host_cr0_paging();
1113  this->test_vmcs_host_cr3();
1114  this->test_vmcs_host_cr4();
1115  this->test_vmcs_host_cr4_v8086_mode_extensions();
1116  this->test_vmcs_host_cr4_protected_mode_virtual_interrupts();
1117  this->test_vmcs_host_cr4_time_stamp_disable();
1118  this->test_vmcs_host_cr4_debugging_extensions();
1119  this->test_vmcs_host_cr4_page_size_extensions();
1120  this->test_vmcs_host_cr4_physical_address_extensions();
1121  this->test_vmcs_host_cr4_machine_check_enable();
1122  this->test_vmcs_host_cr4_page_global_enable();
1123  this->test_vmcs_host_cr4_performance_monitor_counter_enable();
1124  this->test_vmcs_host_cr4_osfxsr();
1125  this->test_vmcs_host_cr4_osxmmexcpt();
1126  this->test_vmcs_host_cr4_vmx_enable_bit();
1127  this->test_vmcs_host_cr4_smx_enable_bit();
1128  this->test_vmcs_host_cr4_fsgsbase_enable_bit();
1129  this->test_vmcs_host_cr4_pcid_enable_bit();
1130  this->test_vmcs_host_cr4_osxsave();
1131  this->test_vmcs_host_cr4_smep_enable_bit();
1132  this->test_vmcs_host_cr4_smap_enable_bit();
1133  this->test_vmcs_host_cr4_protection_key_enable_bit();
1134  this->test_vmcs_host_fs_base();
1135  this->test_vmcs_host_gs_base();
1136  this->test_vmcs_host_tr_base();
1137  this->test_vmcs_host_gdtr_base();
1138  this->test_vmcs_host_idtr_base();
1139  this->test_vmcs_host_ia32_sysenter_esp();
1140  this->test_vmcs_host_ia32_sysenter_eip();
1141  this->test_vmcs_host_rsp();
1142  this->test_vmcs_host_rip();
1143 }
1144 
1145 void
1146 vmcs_ut::list_checks_on_vmx_controls()
1147 {
1148  this->test_check_control_vmx_controls_all();
1149  this->test_check_control_vm_execution_control_fields_all();
1150  this->test_check_control_pin_based_ctls_reserved_properly_set();
1151  this->test_check_control_proc_based_ctls_reserved_properly_set();
1152  this->test_check_control_proc_based_ctls2_reserved_properly_set();
1153  this->test_check_control_cr3_count_less_than_4();
1154  this->test_check_control_io_bitmap_address_bits();
1155  this->test_check_control_msr_bitmap_address_bits();
1156  this->test_check_control_tpr_shadow_and_virtual_apic();
1157  this->test_check_control_nmi_exiting_and_virtual_nmi();
1158  this->test_check_control_virtual_nmi_and_nmi_window();
1159  this->test_check_control_virtual_apic_address_bits();
1160  this->test_check_control_x2apic_mode_and_virtual_apic_access();
1161  this->test_check_control_virtual_interrupt_and_external_interrupt();
1162  this->test_check_control_process_posted_interrupt_checks();
1163  this->test_check_control_vpid_checks();
1164  this->test_check_control_enable_ept_checks();
1165  this->test_check_control_unrestricted_guests();
1166  this->test_check_control_enable_vm_functions();
1167  this->test_check_control_enable_vmcs_shadowing();
1168  this->test_check_control_enable_ept_violation_checks();
1169  this->test_check_control_enable_pml_checks();
1170 
1171  this->test_check_control_vm_exit_control_fields_all();
1172  this->test_check_control_vm_exit_ctls_reserved_properly_set();
1173  this->test_check_control_activate_and_save_preemption_timer_must_be_0();
1174  this->test_check_control_exit_msr_store_address();
1175  this->test_check_control_exit_msr_load_address();
1176 
1177  this->test_check_control_vm_entry_control_fields_all();
1178  this->test_check_control_vm_entry_ctls_reserved_properly_set();
1179  this->test_check_control_event_injection_type_vector_checks();
1180  this->test_check_control_event_injection_delivery_ec_checks();
1181  this->test_check_control_event_injection_reserved_bits_checks();
1182  this->test_check_control_event_injection_ec_checks();
1183  this->test_check_control_event_injection_instr_length_checks();
1184  this->test_check_control_entry_msr_load_address();
1185 }
1186 
1187 void
1188 vmcs_ut::list_checks_on_host_state()
1189 {
1190  this->test_check_host_state_all();
1191  this->test_check_host_control_registers_and_msrs_all();
1192  this->test_check_host_cr0_for_unsupported_bits();
1193  this->test_check_host_cr4_for_unsupported_bits();
1194  this->test_check_host_cr3_for_unsupported_bits();
1195  this->test_check_host_ia32_sysenter_esp_canonical_address();
1196  this->test_check_host_ia32_sysenter_eip_canonical_address();
1197  this->test_check_host_verify_load_ia32_perf_global_ctrl();
1198  this->test_check_host_verify_load_ia32_pat();
1199  this->test_check_host_verify_load_ia32_efer();
1200 
1201  this->test_check_host_segment_and_descriptor_table_registers_all();
1202  this->test_check_host_es_selector_rpl_ti_equal_zero();
1203  this->test_check_host_cs_selector_rpl_ti_equal_zero();
1204  this->test_check_host_ss_selector_rpl_ti_equal_zero();
1205  this->test_check_host_ds_selector_rpl_ti_equal_zero();
1206  this->test_check_host_fs_selector_rpl_ti_equal_zero();
1207  this->test_check_host_gs_selector_rpl_ti_equal_zero();
1208  this->test_check_host_tr_selector_rpl_ti_equal_zero();
1209  this->test_check_host_cs_not_equal_zero();
1210  this->test_check_host_tr_not_equal_zero();
1211  this->test_check_host_ss_not_equal_zero();
1212  this->test_check_host_fs_canonical_base_address();
1213  this->test_check_host_gs_canonical_base_address();
1214  this->test_check_host_gdtr_canonical_base_address();
1215  this->test_check_host_idtr_canonical_base_address();
1216  this->test_check_host_tr_canonical_base_address();
1217 
1218  this->test_check_host_address_space_size_all();
1219  this->test_check_host_if_outside_ia32e_mode();
1220  this->test_check_host_address_space_size_exit_ctl_is_set();
1221  this->test_check_host_address_space_disabled();
1222  this->test_check_host_address_space_enabled();
1223 }
1224 
1225 void
1226 vmcs_ut::list_checks_on_guest_state()
1227 {
1228  this->test_check_guest_state_all();
1229  this->test_check_guest_control_registers_debug_registers_and_msrs_all();
1230  this->test_check_guest_cr0_for_unsupported_bits();
1231  this->test_check_guest_cr0_verify_paging_enabled();
1232  this->test_check_guest_cr4_for_unsupported_bits();
1233  this->test_check_guest_load_debug_controls_verify_reserved();
1234  this->test_check_guest_verify_ia_32e_mode_enabled();
1235  this->test_check_guest_verify_ia_32e_mode_disabled();
1236  this->test_check_guest_cr3_for_unsupported_bits();
1237  this->test_check_guest_load_debug_controls_verify_dr7();
1238  this->test_check_guest_ia32_sysenter_esp_canonical_address();
1239  this->test_check_guest_ia32_sysenter_eip_canonical_address();
1240  this->test_check_guest_verify_load_ia32_perf_global_ctrl();
1241  this->test_check_guest_verify_load_ia32_pat();
1242  this->test_check_guest_verify_load_ia32_efer();
1243  this->test_check_guest_verify_load_ia32_bndcfgs();
1244 
1245  this->test_check_guest_segment_registers_all();
1246  this->test_check_guest_tr_ti_bit_equals_0();
1247  this->test_check_guest_ldtr_ti_bit_equals_0();
1248  this->test_check_guest_ss_and_cs_rpl_are_the_same();
1249  this->test_check_guest_cs_base_is_shifted();
1250  this->test_check_guest_ss_base_is_shifted();
1251  this->test_check_guest_ds_base_is_shifted();
1252  this->test_check_guest_es_base_is_shifted();
1253  this->test_check_guest_fs_base_is_shifted();
1254  this->test_check_guest_gs_base_is_shifted();
1255  this->test_check_guest_tr_base_is_canonical();
1256  this->test_check_guest_fs_base_is_canonical();
1257  this->test_check_guest_gs_base_is_canonical();
1258  this->test_check_guest_ldtr_base_is_canonical();
1259  this->test_check_guest_cs_base_upper_dword_0();
1260  this->test_check_guest_ss_base_upper_dword_0();
1261  this->test_check_guest_ds_base_upper_dword_0();
1262  this->test_check_guest_es_base_upper_dword_0();
1263  this->test_check_guest_cs_limit();
1264  this->test_check_guest_ss_limit();
1265  this->test_check_guest_ds_limit();
1266  this->test_check_guest_es_limit();
1267  this->test_check_guest_gs_limit();
1268  this->test_check_guest_fs_limit();
1269  this->test_check_guest_v8086_cs_access_rights();
1270  this->test_check_guest_v8086_ss_access_rights();
1271  this->test_check_guest_v8086_ds_access_rights();
1272  this->test_check_guest_v8086_es_access_rights();
1273  this->test_check_guest_v8086_fs_access_rights();
1274  this->test_check_guest_v8086_gs_access_rights();
1275  this->test_check_guest_cs_access_rights_type();
1276  this->test_check_guest_ss_access_rights_type();
1277  this->test_check_guest_ds_access_rights_type();
1278  this->test_check_guest_es_access_rights_type();
1279  this->test_check_guest_fs_access_rights_type();
1280  this->test_check_guest_gs_access_rights_type();
1281  this->test_check_guest_cs_is_not_a_system_descriptor();
1282  this->test_check_guest_ss_is_not_a_system_descriptor();
1283  this->test_check_guest_ds_is_not_a_system_descriptor();
1284  this->test_check_guest_es_is_not_a_system_descriptor();
1285  this->test_check_guest_fs_is_not_a_system_descriptor();
1286  this->test_check_guest_gs_is_not_a_system_descriptor();
1287  this->test_check_guest_cs_type_not_equal_3();
1288  this->test_check_guest_cs_dpl_adheres_to_ss_dpl();
1289  this->test_check_guest_ss_dpl_must_equal_rpl();
1290  this->test_check_guest_ss_dpl_must_equal_zero();
1291  this->test_check_guest_ds_dpl();
1292  this->test_check_guest_es_dpl();
1293  this->test_check_guest_fs_dpl();
1294  this->test_check_guest_gs_dpl();
1295  this->test_check_guest_cs_must_be_present();
1296  this->test_check_guest_ss_must_be_present_if_usable();
1297  this->test_check_guest_ds_must_be_present_if_usable();
1298  this->test_check_guest_es_must_be_present_if_usable();
1299  this->test_check_guest_fs_must_be_present_if_usable();
1300  this->test_check_guest_gs_must_be_present_if_usable();
1301  this->test_check_guest_cs_access_rights_reserved_must_be_0();
1302  this->test_check_guest_ss_access_rights_reserved_must_be_0();
1303  this->test_check_guest_ds_access_rights_reserved_must_be_0();
1304  this->test_check_guest_es_access_rights_reserved_must_be_0();
1305  this->test_check_guest_fs_access_rights_reserved_must_be_0();
1306  this->test_check_guest_gs_access_rights_reserved_must_be_0();
1307  this->test_check_guest_cs_db_must_be_0_if_l_equals_1();
1308  this->test_check_guest_cs_granularity();
1309  this->test_check_guest_ss_granularity();
1310  this->test_check_guest_ds_granularity();
1311  this->test_check_guest_es_granularity();
1312  this->test_check_guest_fs_granularity();
1313  this->test_check_guest_gs_granularity();
1314  this->test_check_guest_cs_access_rights_remaining_reserved_bit_0();
1315  this->test_check_guest_ss_access_rights_remaining_reserved_bit_0();
1316  this->test_check_guest_ds_access_rights_remaining_reserved_bit_0();
1317  this->test_check_guest_es_access_rights_remaining_reserved_bit_0();
1318  this->test_check_guest_fs_access_rights_remaining_reserved_bit_0();
1319  this->test_check_guest_gs_access_rights_remaining_reserved_bit_0();
1320  this->test_check_guest_tr_type_must_be_11();
1321  this->test_check_guest_tr_must_be_a_system_descriptor();
1322  this->test_check_guest_tr_must_be_present();
1323  this->test_check_guest_tr_access_rights_reserved_must_be_0();
1324  this->test_check_guest_tr_granularity();
1325  this->test_check_guest_tr_must_be_usable();
1326  this->test_check_guest_tr_access_rights_remaining_reserved_bit_0();
1327  this->test_check_guest_ldtr_type_must_be_2();
1328  this->test_check_guest_ldtr_must_be_a_system_descriptor();
1329  this->test_check_guest_ldtr_must_be_present();
1330  this->test_check_guest_ldtr_access_rights_reserved_must_be_0();
1331  this->test_check_guest_ldtr_granularity();
1332  this->test_check_guest_ldtr_access_rights_remaining_reserved_bit_0();
1333 
1334  this->test_check_guest_descriptor_table_registers_all();
1335  this->test_check_guest_gdtr_base_must_be_canonical();
1336  this->test_check_guest_idtr_base_must_be_canonical();
1337  this->test_check_guest_gdtr_limit_reserved_bits();
1338  this->test_check_guest_idtr_limit_reserved_bits();
1339 
1340  this->test_check_guest_rip_and_rflags_all();
1341  this->test_check_guest_rip_upper_bits();
1342  this->test_check_guest_rip_valid_addr();
1343  this->test_check_guest_rflags_reserved_bits();
1344  this->test_check_guest_rflags_vm_bit();
1345  this->test_check_guest_rflag_interrupt_enable();
1346 
1347  this->test_check_guest_non_register_state_all();
1348  this->test_check_guest_valid_activity_state();
1349  this->test_check_guest_activity_state_not_hlt_when_dpl_not_0();
1350  this->test_check_guest_must_be_active_if_injecting_blocking_state();
1351  this->test_check_guest_hlt_valid_interrupts();
1352  this->test_check_guest_shutdown_valid_interrupts();
1353  this->test_check_guest_sipi_valid_interrupts();
1354  this->test_check_guest_valid_activity_state_and_smm();
1355  this->test_check_guest_interruptibility_state_reserved();
1356  this->test_check_guest_interruptibility_state_sti_mov_ss();
1357  this->test_check_guest_interruptibility_state_sti();
1358  this->test_check_guest_interruptibility_state_external_interrupt();
1359  this->test_check_guest_interruptibility_state_nmi();
1360  this->test_check_guest_interruptibility_not_in_smm();
1361  this->test_check_guest_interruptibility_entry_to_smm();
1362  this->test_check_guest_interruptibility_state_sti_and_nmi();
1363  this->test_check_guest_interruptibility_state_virtual_nmi();
1364  this->test_check_guest_interruptibility_state_enclave_interrupt();
1365  this->test_check_guest_pending_debug_exceptions_reserved();
1366  this->test_check_guest_pending_debug_exceptions_dbg_ctl();
1367  this->test_check_guest_pending_debug_exceptions_rtm();
1368  this->test_check_guest_vmcs_link_pointer_bits_11_0();
1369  this->test_check_guest_vmcs_link_pointer_valid_addr();
1370  this->test_check_guest_vmcs_link_pointer_first_word();
1371 
1372  this->test_check_guest_pdptes_all();
1373  this->test_check_guest_valid_pdpte_with_ept_disabled();
1374  this->test_check_guest_valid_pdpte_with_ept_enabled();
1375 
1376  this->test_check_control_reserved_properly_set();
1377  this->test_check_memory_type_reserved();
1378 }
1379 
1380 bool
1382 {
1383  this->list_vmcs_intel_x64_cpp();
1384  this->list_vmcs_intel_x64_h();
1385  this->list_16bit_control_fields();
1386  this->list_16bit_guest_state_fields();
1387  this->list_16bit_host_state_fields();
1388  this->list_64bit_control_fields();
1389  this->list_64bit_read_only_data_field();
1390  this->list_64bit_guest_state_fields();
1391  this->list_64bit_host_state_fields();
1392  this->list_32bit_control_fields();
1393  this->list_32bit_read_only_data_fields();
1394  this->list_32bit_guest_state_fields();
1395  this->list_32bit_host_state_field();
1396  this->list_natural_width_control_fields();
1397  this->list_natural_width_read_only_data_fields();
1398  this->list_natural_width_guest_state_fields();
1399  this->list_natural_width_host_state_fields();
1400 
1401  this->list_checks_on_vmx_controls();
1402  this->list_checks_on_host_state();
1403  this->list_checks_on_guest_state();
1404 
1405  this->test_debug_dump();
1406  this->test_debug_dump_16bit_control_fields();
1407  this->test_debug_dump_16bit_guest_state_fields();
1408  this->test_debug_dump_16bit_host_state_fields();
1409  this->test_debug_dump_64bit_control_fields();
1410  this->test_debug_dump_64bit_read_only_data_field();
1411  this->test_debug_dump_64bit_guest_state_fields();
1412  this->test_debug_dump_64bit_host_state_fields();
1413  this->test_debug_dump_32bit_control_fields();
1414  this->test_debug_dump_32bit_read_only_data_fields();
1415  this->test_debug_dump_32bit_guest_state_fields();
1416  this->test_debug_dump_32bit_host_state_field();
1417  this->test_debug_dump_natural_width_control_fields();
1418  this->test_debug_dump_natural_width_read_only_data_fields();
1419  this->test_debug_dump_natural_width_guest_state_fields();
1420  this->test_debug_dump_natural_width_host_state_fields();
1421  this->test_debug_dump_vmx_controls();
1422  this->test_debug_dump_pin_based_vm_execution_controls();
1423  this->test_debug_dump_primary_processor_based_vm_execution_controls();
1424  this->test_debug_dump_secondary_processor_based_vm_execution_controls();
1425  this->test_debug_dump_vm_exit_control_fields();
1426  this->test_debug_dump_vm_entry_control_fields();
1427  this->test_debug_dump_vmcs_field();
1428  this->test_debug_dump_vm_control();
1429 
1430  this->test_state();
1431  this->test_state_segment_registers();
1432  this->test_state_control_registers();
1433  this->test_state_debug_registers();
1434  this->test_state_rflags();
1435  this->test_state_gdt_base();
1436  this->test_state_idt_base();
1437  this->test_state_gdt_limit();
1438  this->test_state_idt_limit();
1439  this->test_state_segment_registers_limit();
1440  this->test_state_segment_registers_access_rights();
1441  this->test_state_segment_register_base();
1442  this->test_state_msrs();
1443  this->test_state_is_guest();
1444  this->test_state_dump();
1445 
1446  this->test_host_vm_state();
1447  this->test_host_vm_state_segment_registers();
1448  this->test_host_vm_state_control_registers();
1449  this->test_host_vm_state_debug_registers();
1450  this->test_host_vm_state_rflags();
1451  this->test_host_vm_state_gdt_base();
1452  this->test_host_vm_state_idt_base();
1453  this->test_host_vm_state_gdt_limit();
1454  this->test_host_vm_state_idt_limit();
1455  this->test_host_vm_state_es_limit();
1456  this->test_host_vm_state_cs_limit();
1457  this->test_host_vm_state_ss_limit();
1458  this->test_host_vm_state_ds_limit();
1459  this->test_host_vm_state_fs_limit();
1460  this->test_host_vm_state_gs_limit();
1461  this->test_host_vm_state_tr_limit();
1462  this->test_host_vm_state_ldtr_limit();
1463  this->test_host_vm_state_es_access_rights();
1464  this->test_host_vm_state_cs_access_rights();
1465  this->test_host_vm_state_ss_access_rights();
1466  this->test_host_vm_state_ds_access_rights();
1467  this->test_host_vm_state_fs_access_rights();
1468  this->test_host_vm_state_gs_access_rights();
1469  this->test_host_vm_state_tr_access_rights();
1470  this->test_host_vm_state_ldtr_access_rights();
1471  this->test_host_vm_state_es_base();
1472  this->test_host_vm_state_cs_base();
1473  this->test_host_vm_state_ss_base();
1474  this->test_host_vm_state_ds_base();
1475  this->test_host_vm_state_fs_base();
1476  this->test_host_vm_state_gs_base();
1477  this->test_host_vm_state_tr_base();
1478  this->test_host_vm_state_ldtr_base();
1479  this->test_host_vm_state_ia32_msrs_with_perf_global_ctrl();
1480  this->test_host_vm_state_ia32_msrs_without_perf_global_ctrl();
1481  this->test_host_vm_state_dump();
1482 
1483  this->test_vmm_state_gdt_not_setup();
1484  this->test_vmm_state_segment_registers();
1485  this->test_vmm_state_control_registers();
1486  this->test_vmm_state_rflags();
1487  this->test_vmm_state_gdt_base();
1488  this->test_vmm_state_idt_base();
1489  this->test_vmm_state_gdt_limit();
1490  this->test_vmm_state_idt_limit();
1491  this->test_vmm_state_segment_registers_limit();
1492  this->test_vmm_state_segment_registers_access_rights();
1493  this->test_vmm_state_segment_registers_base();
1494  this->test_vmm_state_ia32_efer_msr();
1495  this->test_vmm_state_dump();
1496 
1497  return true;
1498 }
1499 
1500 int
1501 main(int argc, char *argv[])
1502 {
1503  return RUN_ALL_TESTS(vmcs_ut);
1504 }
uint64_t g_pdpt_mem[4]
Definition: test.cpp:51
bool __vmlaunch_demote(void) noexcept
Definition: test.cpp:169
void setup_mock(MockRepository &mocks, memory_manager_x64 *mm)
Definition: test.cpp:63
uint32_t __cpuid_ecx(uint32_t val) noexcept
Definition: test.cpp:134
bool g_vmlaunch_fails
Definition: test.cpp:39
void entry_ctl_allow1(uint64_t mask)
Definition: test.cpp:110
vmcs_ut()
Definition: test.cpp:194
void proc_ctl2_allow0(uint64_t mask)
Definition: test.cpp:86
void exit_ctl_allow0(uint64_t mask)
Definition: test.cpp:106
int main(int argc, char *argv[])
Definition: test.cpp:221
bool g_vmclear_fails
Definition: test.cpp:37
void pin_ctl_allow1(uint64_t mask)
Definition: test.cpp:94
std::map< uint64_t, uint64_t > g_vmcs_fields
Definition: test.cpp:32
uint64_t __read_msr(uint32_t addr) noexcept
Definition: test.cpp:122
constexpr const auto mask
Definition: cpuid_x64.h:85
std::map< uint32_t, uint32_t > g_eax_cpuid
Definition: test.cpp:33
std::map< uint32_t, uint64_t > g_msrs
Definition: test.cpp:31
bool g_phys_to_virt_return_nullptr
Definition: test.cpp:41
bool __vmptrld(void *ptr) noexcept
Definition: test.cpp:165
bool init() override
Definition: test.cpp:199
bool __vmclear(void *ptr) noexcept
Definition: test.cpp:161
uint64_t g_test_addr
Definition: test.cpp:43
void entry_ctl_allow0(uint64_t mask)
Definition: test.cpp:114
virtual pointer physint_to_virtptr(integer_pointer phys) const
void * physint_to_virtptr(uintptr_t phys)
Definition: test.cpp:184
void uint64_t uint64_t uint64_t *rdx noexcept
void proc_ctl2_disallow1(uint64_t mask)
Definition: test.cpp:90
constexpr const auto addr
Definition: cpuid_x64.h:80
#define RUN_ALL_TESTS(ut)
Definition: unittest.h:246
uint64_t g_pdpt_addr
Definition: test.cpp:50
struct cpuid_regs g_cpuid_regs
Definition: test.cpp:35
bool __vmread(uint64_t field, uint64_t *val) noexcept
Definition: test.cpp:147
static memory_manager_x64 * instance() noexcept
bool fini() override
Definition: test.cpp:205
bool g_vmload_fails
Definition: test.cpp:38
void pin_ctl_allow0(uint64_t mask)
Definition: test.cpp:98
std::map< uint64_t, void * > g_mock_mem
Definition: test.cpp:54
uint8_t g_virt_apic_mem[0x81]
Definition: test.cpp:45
void __write_msr(uint32_t addr, uint64_t val) noexcept
Definition: test.cpp:126
bool list() override
Definition: test.cpp:1381
uint32_t __cpuid_eax(uint32_t val) noexcept
Definition: test.cpp:130
Definition: test.h:96
void proc_ctl2_allow1(uint64_t mask)
Definition: test.cpp:82
void proc_ctl_allow1(uint64_t mask)
Definition: test.cpp:70
uint64_t g_vmcs_link_addr
Definition: test.cpp:47
void proc_ctl_allow0(uint64_t mask)
Definition: test.cpp:74
void exit_ctl_allow1(uint64_t mask)
Definition: test.cpp:102
bool __vmwrite(uint64_t field, uint64_t val) noexcept
Definition: test.cpp:154
uint64_t g_virt_apic_addr
Definition: test.cpp:44
uint32_t g_vmcs_link_mem[1]
Definition: test.cpp:48
void vmfunc_ctl_allow1(uint64_t mask)
Definition: test.cpp:118
Definition: cache_x64.h:31
void __cpuid(void *eax, void *ebx, void *ecx, void *edx) noexcept
Definition: test.cpp:138
uintptr_t virtptr_to_physint(void *ptr)
Definition: test.cpp:173
bool g_virt_to_phys_return_nullptr
Definition: test.cpp:40
void proc_ctl_disallow1(uint64_t mask)
Definition: test.cpp:78