35 { (void)
addr;
return 0; }
99 { (void) val;
return 0x04000000U; }
103 { (void) val;
return 0x2U; }
115 setup_mm(MockRepository &mocks)
125 setup_pt(MockRepository &mocks)
135 vcpu_ut::test_vcpu_intel_x64_invalid_id()
141 vcpu_ut::test_vcpu_intel_x64_valid()
143 MockRepository mocks;
144 auto &&
dr = bfn::mock_unique<debug_ring>(mocks);
145 auto &&
on = bfn::mock_unique<vmxon_intel_x64>(mocks);
146 auto &&
cs = bfn::mock_unique<vmcs_intel_x64>(mocks);
147 auto &&eh = bfn::mock_unique<exit_handler_intel_x64>(mocks);
148 auto &&vs = bfn::mock_unique<vmcs_intel_x64_vmm_state>(mocks);
149 auto &&
gs = bfn::mock_unique<vmcs_intel_x64_host_vm_state>(mocks);
154 std::make_unique<vcpu_intel_x64>(
155 0, std::move(
dr), std::move(on), std::move(cs), std::move(eh), std::move(vs), std::move(gs));
161 vcpu_ut::test_vcpu_intel_x64_init_null_params()
163 MockRepository mocks;
169 auto vc = std::make_unique<vcpu_intel_x64>(0,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr);
176 vcpu_ut::test_vcpu_intel_x64_init_valid_params()
178 MockRepository mocks;
182 auto &&
dr = bfn::mock_unique<debug_ring>(mocks);
183 auto &&on = bfn::mock_unique<vmxon_intel_x64>(mocks);
184 auto &&cs = bfn::mock_unique<vmcs_intel_x64>(mocks);
185 auto &&eh = bfn::mock_unique<exit_handler_intel_x64>(mocks);
186 auto &&vs = bfn::mock_unique<vmcs_intel_x64_vmm_state>(mocks);
187 auto &&gs = bfn::mock_unique<vmcs_intel_x64_host_vm_state>(mocks);
189 mocks.OnCall(cs.get(), vmcs_intel_x64::set_state_save);
196 auto vc = std::make_unique<vcpu_intel_x64>(
197 0, std::move(
dr), std::move(on), std::move(cs), std::move(eh), std::move(vs), std::move(gs));
204 vcpu_ut::test_vcpu_intel_x64_init_valid()
206 MockRepository mocks;
210 auto &&
dr = bfn::mock_unique<debug_ring>(mocks);
211 auto &&on = bfn::mock_unique<vmxon_intel_x64>(mocks);
212 auto &&cs = bfn::mock_unique<vmcs_intel_x64>(mocks);
213 auto &&eh = bfn::mock_unique<exit_handler_intel_x64>(mocks);
214 auto &&vs = bfn::mock_unique<vmcs_intel_x64_vmm_state>(mocks);
215 auto &&gs = bfn::mock_unique<vmcs_intel_x64_host_vm_state>(mocks);
217 mocks.OnCall(cs.get(), vmcs_intel_x64::set_state_save);
224 auto vc = std::make_unique<vcpu_intel_x64>(
225 0, std::move(
dr), std::move(on), std::move(cs), std::move(eh), std::move(vs), std::move(gs));
232 vcpu_ut::test_vcpu_intel_x64_init_vmcs_throws()
234 MockRepository mocks;
238 auto &&
dr = bfn::mock_unique<debug_ring>(mocks);
239 auto &&on = bfn::mock_unique<vmxon_intel_x64>(mocks);
240 auto &&cs = bfn::mock_unique<vmcs_intel_x64>(mocks);
241 auto &&eh = bfn::mock_unique<exit_handler_intel_x64>(mocks);
242 auto &&vs = bfn::mock_unique<vmcs_intel_x64_vmm_state>(mocks);
243 auto &&gs = bfn::mock_unique<vmcs_intel_x64_host_vm_state>(mocks);
245 mocks.OnCall(cs.get(), vmcs_intel_x64::set_state_save).Throw(std::logic_error(
"error"));
252 auto vc = std::make_unique<vcpu_intel_x64>(
253 0, std::move(
dr), std::move(on), std::move(cs), std::move(eh), std::move(vs), std::move(gs));
260 vcpu_ut::test_vcpu_intel_x64_fini_null_params()
262 MockRepository mocks;
268 auto vc = std::make_unique<vcpu_intel_x64>(0,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr);
276 vcpu_ut::test_vcpu_intel_x64_fini_valid_params()
278 MockRepository mocks;
282 auto &&
dr = bfn::mock_unique<debug_ring>(mocks);
283 auto &&on = bfn::mock_unique<vmxon_intel_x64>(mocks);
284 auto &&cs = bfn::mock_unique<vmcs_intel_x64>(mocks);
285 auto &&eh = bfn::mock_unique<exit_handler_intel_x64>(mocks);
286 auto &&vs = bfn::mock_unique<vmcs_intel_x64_vmm_state>(mocks);
287 auto &&gs = bfn::mock_unique<vmcs_intel_x64_host_vm_state>(mocks);
289 mocks.OnCall(cs.get(), vmcs_intel_x64::set_state_save);
296 auto vc = std::make_unique<vcpu_intel_x64>(
297 0, std::move(
dr), std::move(on), std::move(cs), std::move(eh), std::move(vs), std::move(gs));
305 vcpu_ut::test_vcpu_intel_x64_fini_valid()
307 MockRepository mocks;
311 auto &&
dr = bfn::mock_unique<debug_ring>(mocks);
312 auto &&on = bfn::mock_unique<vmxon_intel_x64>(mocks);
313 auto &&cs = bfn::mock_unique<vmcs_intel_x64>(mocks);
314 auto &&eh = bfn::mock_unique<exit_handler_intel_x64>(mocks);
315 auto &&vs = bfn::mock_unique<vmcs_intel_x64_vmm_state>(mocks);
316 auto &&gs = bfn::mock_unique<vmcs_intel_x64_host_vm_state>(mocks);
318 mocks.OnCall(cs.get(), vmcs_intel_x64::set_state_save);
325 auto vc = std::make_unique<vcpu_intel_x64>(
326 0, std::move(
dr), std::move(on), std::move(cs), std::move(eh), std::move(vs), std::move(gs));
334 vcpu_ut::test_vcpu_intel_x64_fini_no_init()
336 MockRepository mocks;
340 auto &&
dr = bfn::mock_unique<debug_ring>(mocks);
341 auto &&on = bfn::mock_unique<vmxon_intel_x64>(mocks);
342 auto &&cs = bfn::mock_unique<vmcs_intel_x64>(mocks);
343 auto &&eh = bfn::mock_unique<exit_handler_intel_x64>(mocks);
344 auto &&vs = bfn::mock_unique<vmcs_intel_x64_vmm_state>(mocks);
345 auto &&gs = bfn::mock_unique<vmcs_intel_x64_host_vm_state>(mocks);
349 auto vc = std::make_unique<vcpu_intel_x64>(
350 0, std::move(
dr), std::move(on), std::move(cs), std::move(eh), std::move(vs), std::move(gs));
357 vcpu_ut::test_vcpu_intel_x64_run_launch()
359 MockRepository mocks;
363 auto &&
dr = bfn::mock_unique<debug_ring>(mocks);
364 auto &&on = bfn::mock_unique<vmxon_intel_x64>(mocks);
365 auto &&cs = bfn::mock_unique<vmcs_intel_x64>(mocks);
366 auto &&eh = bfn::mock_unique<exit_handler_intel_x64>(mocks);
367 auto &&vs = bfn::mock_unique<vmcs_intel_x64_vmm_state>(mocks);
368 auto &&gs = bfn::mock_unique<vmcs_intel_x64_host_vm_state>(mocks);
370 mocks.OnCall(cs.get(), vmcs_intel_x64::set_state_save);
383 auto vc = std::make_unique<vcpu_intel_x64>(
384 0x0001000000000000, std::move(
dr), std::move(on), std::move(cs), std::move(eh), std::move(vs), std::move(gs));
392 vcpu_ut::test_vcpu_intel_x64_run_launch_is_host_vcpu()
394 MockRepository mocks;
398 auto &&
dr = bfn::mock_unique<debug_ring>(mocks);
399 auto &&on = bfn::mock_unique<vmxon_intel_x64>(mocks);
400 auto &&cs = bfn::mock_unique<vmcs_intel_x64>(mocks);
401 auto &&eh = bfn::mock_unique<exit_handler_intel_x64>(mocks);
402 auto &&vs = bfn::mock_unique<vmcs_intel_x64_vmm_state>(mocks);
403 auto &&gs = bfn::mock_unique<vmcs_intel_x64_host_vm_state>(mocks);
405 mocks.OnCall(cs.get(), vmcs_intel_x64::set_state_save);
418 auto vc = std::make_unique<vcpu_intel_x64>(
419 0, std::move(
dr), std::move(on), std::move(cs), std::move(eh), std::move(vs), std::move(gs));
427 vcpu_ut::test_vcpu_intel_x64_run_resume()
429 MockRepository mocks;
433 auto &&
dr = bfn::mock_unique<debug_ring>(mocks);
434 auto &&on = bfn::mock_unique<vmxon_intel_x64>(mocks);
435 auto &&cs = bfn::mock_unique<vmcs_intel_x64>(mocks);
436 auto &&eh = bfn::mock_unique<exit_handler_intel_x64>(mocks);
437 auto &&vs = bfn::mock_unique<vmcs_intel_x64_vmm_state>(mocks);
438 auto &&gs = bfn::mock_unique<vmcs_intel_x64_host_vm_state>(mocks);
440 mocks.OnCall(cs.get(), vmcs_intel_x64::set_state_save);
453 auto vc = std::make_unique<vcpu_intel_x64>(
454 0, std::move(
dr), std::move(on), std::move(cs), std::move(eh), std::move(vs), std::move(gs));
463 vcpu_ut::test_vcpu_intel_x64_run_no_init()
465 MockRepository mocks;
469 auto &&
dr = bfn::mock_unique<debug_ring>(mocks);
470 auto &&on = bfn::mock_unique<vmxon_intel_x64>(mocks);
471 auto &&cs = bfn::mock_unique<vmcs_intel_x64>(mocks);
472 auto &&eh = bfn::mock_unique<exit_handler_intel_x64>(mocks);
473 auto &&vs = bfn::mock_unique<vmcs_intel_x64_vmm_state>(mocks);
474 auto &&gs = bfn::mock_unique<vmcs_intel_x64_host_vm_state>(mocks);
476 mocks.OnCall(cs.get(), vmcs_intel_x64::set_state_save);
489 auto vc = std::make_unique<vcpu_intel_x64>(
490 0, std::move(
dr), std::move(on), std::move(cs), std::move(eh), std::move(vs), std::move(gs));
497 vcpu_ut::test_vcpu_intel_x64_run_vmxon_throws()
499 MockRepository mocks;
503 auto &&
dr = bfn::mock_unique<debug_ring>(mocks);
504 auto &&on = bfn::mock_unique<vmxon_intel_x64>(mocks);
505 auto &&cs = bfn::mock_unique<vmcs_intel_x64>(mocks);
506 auto &&eh = bfn::mock_unique<exit_handler_intel_x64>(mocks);
507 auto &&vs = bfn::mock_unique<vmcs_intel_x64_vmm_state>(mocks);
508 auto &&gs = bfn::mock_unique<vmcs_intel_x64_host_vm_state>(mocks);
510 mocks.OnCall(cs.get(), vmcs_intel_x64::set_state_save);
523 auto vc = std::make_unique<vcpu_intel_x64>(
524 0, std::move(
dr), std::move(on), std::move(cs), std::move(eh), std::move(vs), std::move(gs));
532 vcpu_ut::test_vcpu_intel_x64_run_vmcs_throws()
534 MockRepository mocks;
538 auto &&
dr = bfn::mock_unique<debug_ring>(mocks);
539 auto &&on = bfn::mock_unique<vmxon_intel_x64>(mocks);
540 auto &&cs = bfn::mock_unique<vmcs_intel_x64>(mocks);
541 auto &&eh = bfn::mock_unique<exit_handler_intel_x64>(mocks);
542 auto &&vs = bfn::mock_unique<vmcs_intel_x64_vmm_state>(mocks);
543 auto &&gs = bfn::mock_unique<vmcs_intel_x64_host_vm_state>(mocks);
545 mocks.OnCall(cs.get(), vmcs_intel_x64::set_state_save);
558 auto vc = std::make_unique<vcpu_intel_x64>(
559 0, std::move(
dr), std::move(on), std::move(cs), std::move(eh), std::move(vs), std::move(gs));
567 vcpu_ut::test_vcpu_intel_x64_hlt_no_init()
569 MockRepository mocks;
573 auto &&
dr = bfn::mock_unique<debug_ring>(mocks);
574 auto &&on = bfn::mock_unique<vmxon_intel_x64>(mocks);
575 auto &&cs = bfn::mock_unique<vmcs_intel_x64>(mocks);
576 auto &&eh = bfn::mock_unique<exit_handler_intel_x64>(mocks);
577 auto &&vs = bfn::mock_unique<vmcs_intel_x64_vmm_state>(mocks);
578 auto &&gs = bfn::mock_unique<vmcs_intel_x64_host_vm_state>(mocks);
580 mocks.OnCall(cs.get(), vmcs_intel_x64::set_state_save);
593 auto vc = std::make_unique<vcpu_intel_x64>(
594 0x0001000000000000, std::move(
dr), std::move(on), std::move(cs), std::move(eh), std::move(vs), std::move(gs));
601 vcpu_ut::test_vcpu_intel_x64_hlt_no_run()
603 MockRepository mocks;
607 auto &&
dr = bfn::mock_unique<debug_ring>(mocks);
608 auto &&on = bfn::mock_unique<vmxon_intel_x64>(mocks);
609 auto &&cs = bfn::mock_unique<vmcs_intel_x64>(mocks);
610 auto &&eh = bfn::mock_unique<exit_handler_intel_x64>(mocks);
611 auto &&vs = bfn::mock_unique<vmcs_intel_x64_vmm_state>(mocks);
612 auto &&gs = bfn::mock_unique<vmcs_intel_x64_host_vm_state>(mocks);
614 mocks.OnCall(cs.get(), vmcs_intel_x64::set_state_save);
627 auto vc = std::make_unique<vcpu_intel_x64>(
628 0x0001000000000000, std::move(
dr), std::move(on), std::move(cs), std::move(eh), std::move(vs), std::move(gs));
635 vcpu_ut::test_vcpu_intel_x64_hlt_valid()
637 MockRepository mocks;
641 auto &&
dr = bfn::mock_unique<debug_ring>(mocks);
642 auto &&on = bfn::mock_unique<vmxon_intel_x64>(mocks);
643 auto &&cs = bfn::mock_unique<vmcs_intel_x64>(mocks);
644 auto &&eh = bfn::mock_unique<exit_handler_intel_x64>(mocks);
645 auto &&vs = bfn::mock_unique<vmcs_intel_x64_vmm_state>(mocks);
646 auto &&gs = bfn::mock_unique<vmcs_intel_x64_host_vm_state>(mocks);
648 mocks.OnCall(cs.get(), vmcs_intel_x64::set_state_save);
661 auto vc = std::make_unique<vcpu_intel_x64>(
662 0x0001000000000000, std::move(
dr), std::move(on), std::move(cs), std::move(eh), std::move(vs), std::move(gs));
671 vcpu_ut::test_vcpu_intel_x64_hlt_valid_is_host_vcpu()
673 MockRepository mocks;
677 auto &&
dr = bfn::mock_unique<debug_ring>(mocks);
678 auto &&on = bfn::mock_unique<vmxon_intel_x64>(mocks);
679 auto &&cs = bfn::mock_unique<vmcs_intel_x64>(mocks);
680 auto &&eh = bfn::mock_unique<exit_handler_intel_x64>(mocks);
681 auto &&vs = bfn::mock_unique<vmcs_intel_x64_vmm_state>(mocks);
682 auto &&gs = bfn::mock_unique<vmcs_intel_x64_host_vm_state>(mocks);
684 mocks.OnCall(cs.get(), vmcs_intel_x64::set_state_save);
697 auto vc = std::make_unique<vcpu_intel_x64>(
698 0, std::move(
dr), std::move(on), std::move(cs), std::move(eh), std::move(vs), std::move(gs));
707 vcpu_ut::test_vcpu_intel_x64_hlt_vmxon_throws()
709 MockRepository mocks;
713 auto &&
dr = bfn::mock_unique<debug_ring>(mocks);
714 auto &&on = bfn::mock_unique<vmxon_intel_x64>(mocks);
715 auto &&cs = bfn::mock_unique<vmcs_intel_x64>(mocks);
716 auto &&eh = bfn::mock_unique<exit_handler_intel_x64>(mocks);
717 auto &&vs = bfn::mock_unique<vmcs_intel_x64_vmm_state>(mocks);
718 auto &&gs = bfn::mock_unique<vmcs_intel_x64_host_vm_state>(mocks);
720 mocks.OnCall(cs.get(), vmcs_intel_x64::set_state_save);
733 auto vc = std::make_unique<vcpu_intel_x64>(
734 0, std::move(
dr), std::move(on), std::move(cs), std::move(eh), std::move(vs), std::move(gs));
virtual void set_vmcs(gsl::not_null< vmcs_intel_x64 *> vmcs)
virtual void launch(gsl::not_null< vmcs_intel_x64_state *> host_state, gsl::not_null< vmcs_intel_x64_state *> guest_state)
#define expect_exception(f, e)
uint64_t __read_cr0(void) noexcept
void __read_idt(idt_reg_x64_t *idt_reg) noexcept
void __read_gdt(gdt_reg_x64_t *gdt_reg) noexcept
#define RUN_UNITTEST_WITH_MOCKS(a, b)
uint16_t __read_ds(void) noexcept
#define expect_no_exception(f)
uint16_t __read_ss(void) noexcept
uint64_t __read_cr3(void) noexcept
void __cpuid(void *eax, void *ebx, void *ecx, void *edx) noexcept
virtual integer_pointer virtptr_to_physint(pointer virt) const
void uint64_t uint64_t uint64_t *rdx noexcept
uint16_t __read_tr(void) noexcept
constexpr const auto addr
virtual void set_state_save(gsl::not_null< state_save_intel_x64 *> state_save)
uint64_t __read_cr4(void) noexcept
uint32_t __cpuid_ecx(uint32_t val) noexcept
uint64_t __read_msr(uint32_t addr) noexcept
static memory_manager_x64 * instance() noexcept
uint16_t __read_es(void) noexcept
uint64_t __read_rflags(void) noexcept
constexpr const auto reserved
uint16_t __read_fs(void) noexcept
uint32_t __cpuid_eax(uint32_t val) noexcept
void on(gsl::not_null< void *> ptr)
uint16_t __read_ldtr(void) noexcept
uint16_t __read_gs(void) noexcept
uint16_t __read_cs(void) noexcept
uint64_t __read_dr7(void) noexcept
root_page_table_x64 * root_pt() noexcept