59 {
handle_exit(vmcs::exit_reason::basic_exit_reason::get()); }
68 bferror <<
"Guest register state: " << bfendl;
69 bferror <<
"----------------------------------------------------" << bfendl;
90 bferror <<
"CPU Halted: " << bfendl;
91 bferror <<
"----------------------------------------------------" << bfendl;
195 case VMCALL_VERSIONS:
196 handle_vmcall_versions(regs);
199 case VMCALL_REGISTERS:
200 handle_vmcall_registers(regs);
204 handle_vmcall_data(regs);
208 handle_vmcall_event(regs);
212 handle_vmcall_start(regs);
216 handle_vmcall_stop(regs);
219 case VMCALL_UNITTEST:
220 handle_vmcall_unittest(regs);
224 throw std::runtime_error(
"unknown vmcall opcode");
235 switch (m_state_save->rax)
238 m_state_save->rcx = regs.r02;
242 m_state_save->r15 = regs.r12;
243 m_state_save->r14 = regs.r11;
244 m_state_save->r13 = regs.r10;
245 m_state_save->r12 = regs.r09;
246 m_state_save->r11 = regs.r08;
247 m_state_save->r10 = regs.r07;
248 m_state_save->r09 = regs.r06;
249 m_state_save->r08 = regs.r05;
250 m_state_save->rsi = regs.r04;
251 m_state_save->rbx = regs.r03;
252 m_state_save->rcx = regs.r02;
256 m_state_save->rdx = static_cast < decltype(m_state_save->rdx) > (ret);
272 msr = vmcs::guest_ia32_debugctl::get();
276 msr = vmcs::guest_ia32_pat::get();
280 msr = vmcs::guest_ia32_efer::get();
284 msr = vmcs::guest_ia32_perf_global_ctrl::get();
288 msr = vmcs::guest_ia32_sysenter_cs::get();
292 msr = vmcs::guest_ia32_sysenter_esp::get();
296 msr = vmcs::guest_ia32_sysenter_eip::get();
300 msr = vmcs::guest_fs_base::get();
304 msr = vmcs::guest_gs_base::get();
401 bferror <<
"Unimplemented Exit Handler: " << bfendl;
402 bferror <<
"----------------------------------------------------" << bfendl;
403 bferror <<
"- exit reason: " 405 bferror <<
"- exit reason string: " 407 bferror <<
"- exit qualification: " 409 bferror <<
"- exit interrupt information: " 410 <<
view_as_pointer(vmcs::vm_exit_interruption_information::get()) << bfendl;
411 bferror <<
"- instruction length: " 413 bferror <<
"- instruction information: " 414 <<
view_as_pointer(vmcs::vm_exit_instruction_information::get()) << bfendl;
415 bferror <<
"- guest linear address: " 417 bferror <<
"- guest physical address: " 423 bferror <<
"VM-entry failure detected!!!" << bfendl;
462 throw std::runtime_error(
"unknown vmcall version index");
469 bfdebug <<
"vmcall registers:" << bfendl;
494 auto &&imap = bfn::make_unique_map_x64<char>(regs.
r05, vmcs::guest_cr3::get(), regs.
r06, vmcs::guest_ia32_pat::get());
495 auto &&omap = bfn::make_unique_map_x64<char>(regs.
r08, vmcs::guest_cr3::get(), regs.
r09, vmcs::guest_ia32_pat::get());
524 throw std::runtime_error(
"unknown vmcall data type");
531 bfdebug <<
"vmcall event:" << bfendl;
547 bfdebug <<
"received in vmm: " << istr << bfendl;
553 const json &ijson, json &ojson)
555 bfdebug <<
"received in vmm: " << ijson << bfendl;
564 bfdebug <<
"received binary data" << bfendl;
565 __builtin_memcpy(omap.
get(), imap.
get(), imap.
size());
572 auto &&len = str.length();
574 __builtin_memcpy(omap.
get(), str.data(), len);
585 auto &&dmp = str.dump();
586 auto &&len = dmp.length();
588 __builtin_memcpy(omap.
get(), dmp.data(), len);
constexpr const auto cpuid
virtual void handle_vmcall_data_binary_unformatted(const bfn::unique_map_ptr_x64< char > &imap, const bfn::unique_map_ptr_x64< char > &omap)
#define USER_VERSION_MAJOR
#define BF_VMCALL_FAILURE
virtual size_type size() const noexcept
void reply_with_string(vmcall_registers_t ®s, const std::string &str, const bfn::unique_map_ptr_x64< char > &omap)
std::mutex g_unimplemented_handler_mutex
#define VMCALL_IN_BUFFER_SIZE
virtual void handle_exit(intel_x64::vmcs::value_type reason)
constexpr const auto addr
void unimplemented_handler() noexcept
virtual void handle_vmcall_registers(vmcall_registers_t ®s)
void reply_with_json(vmcall_registers_t ®s, const json &str, const bfn::unique_map_ptr_x64< char > &omap)
#define USER_VERSION_PATCH
virtual void handle_vmcall_start(vmcall_registers_t ®s)
constexpr const auto addr
void advance_rip() noexcept
#define VMCALL_OUT_BUFFER_SIZE
constexpr const auto addr
#define BAREFLANK_VERSION_PATCH
virtual void handle_vmcall_data(vmcall_registers_t ®s)
#define BAREFLANK_VERSION_MINOR
constexpr const auto invd
virtual void handle_vmcall_event(vmcall_registers_t ®s)
constexpr const auto rdmsr
void uint64_t uint64_t uint64_t *rdx noexcept
virtual void handle_vmcall_stop(vmcall_registers_t ®s)
constexpr const auto addr
constexpr const auto string
#define USER_VERSION_MINOR
constexpr const auto wbinvd
virtual void handle_vmcall_data_string_json(const json &ijson, json &ojson)
auto get(A addr) noexcept
void set(A addr, T val) noexcept
virtual void complete_vmcall(ret_type ret, vmcall_registers_t ®s) noexcept
const void * view_as_pointer(const T val)
constexpr const auto addr
constexpr const auto addr
virtual void halt() noexcept
virtual pointer get() const noexcept
virtual void handle_vmcall_data_string_unformatted(const std::string &istr, std::string &ostr)
E guard_exceptions(E error_code, T func)
#define BAREFLANK_VERSION_MAJOR
constexpr const auto addr
constexpr const auto wrmsr
virtual void handle_vmcall_versions(vmcall_registers_t ®s)
state_save_intel_x64 * m_state_save
constexpr const auto addr
constexpr const auto addr
constexpr const auto vmxoff
#define VMCALL_MAGIC_NUMBER