1
0
mirror of https://github.com/momo5502/hypervisor.git synced 2025-07-05 10:41:50 +00:00

Fix watch points

This commit is contained in:
momo5502
2022-05-16 11:51:33 +02:00
parent 4d1f94d65a
commit f37a919f77
5 changed files with 70 additions and 26 deletions

View File

@ -192,7 +192,7 @@ bool hypervisor::install_ept_hook(const void* destination, const void* source, c
return failures == 0;
}
bool hypervisor::install_ept_code_watch_point(const uint64_t physical_page) const
bool hypervisor::install_ept_code_watch_point(const uint64_t physical_page, bool invalidate) const
{
try
{
@ -209,12 +209,31 @@ bool hypervisor::install_ept_code_watch_point(const uint64_t physical_page) cons
return false;
}
if (invalidate)
{
thread::dispatch_on_all_cores([&]
{
this->ept_->invalidate();
});
}
return true;
}
bool hypervisor::install_ept_code_watch_points(const uint64_t* physical_pages, const size_t count) const
{
bool success = true;
for (size_t i = 0; i < count; ++i)
{
success &= this->install_ept_code_watch_point(physical_pages[i], false);
}
thread::dispatch_on_all_cores([&]
{
this->ept_->invalidate();
});
return true;
return success;
}
void hypervisor::disable_all_ept_hooks() const
@ -534,14 +553,13 @@ extern "C" [[ noreturn ]] void vm_exit_handler(CONTEXT* context)
if (guest_context.exit_vm)
{
context->Rcx = 0x43434343;
restore_descriptor_tables(vm_state->launch_context);
__writecr3(read_vmx(VMCS_GUEST_CR3));
context->Rsp = guest_context.guest_rsp;
context->Rip = guest_context.guest_rip;
context->EFlags = static_cast<uint32_t>(guest_context.guest_e_flags);
restore_descriptor_tables(vm_state->launch_context);
__writecr3(read_vmx(VMCS_GUEST_CR3));
__vmx_off();
}
else