Public Types | Public Member Functions | Data Fields | Protected Member Functions
exit_handler_intel_x64 Class Reference

Public Types

using ret_type = int64_t
 

Public Member Functions

 exit_handler_intel_x64 ()
 
virtual ~exit_handler_intel_x64 ()=default
 
virtual void dispatch ()
 
virtual void halt () noexcept
 
virtual void complete_vmcall (ret_type ret, vmcall_registers_t &regs) noexcept
 
virtual void set_vmcs (gsl::not_null< vmcs_intel_x64 *> vmcs)
 
virtual void set_state_save (gsl::not_null< state_save_intel_x64 *> state_save)
 

Data Fields

vmcs_intel_x64m_vmcs
 
state_save_intel_x64m_state_save
 

Protected Member Functions

virtual void handle_exit (intel_x64::vmcs::value_type reason)
 
void handle_cpuid ()
 
void handle_invd ()
 
void handle_vmcall ()
 
void handle_vmxoff ()
 
void handle_rdmsr ()
 
void handle_wrmsr ()
 
void advance_rip () noexcept
 
void unimplemented_handler () noexcept
 
virtual void handle_vmcall_versions (vmcall_registers_t &regs)
 
virtual void handle_vmcall_registers (vmcall_registers_t &regs)
 
virtual void handle_vmcall_data (vmcall_registers_t &regs)
 
virtual void handle_vmcall_event (vmcall_registers_t &regs)
 
virtual void handle_vmcall_start (vmcall_registers_t &regs)
 
virtual void handle_vmcall_stop (vmcall_registers_t &regs)
 
virtual void handle_vmcall_unittest (vmcall_registers_t &regs)
 
virtual void handle_vmcall_data_string_unformatted (const std::string &istr, std::string &ostr)
 
virtual void handle_vmcall_data_string_json (const json &ijson, json &ojson)
 
virtual void handle_vmcall_data_binary_unformatted (const bfn::unique_map_ptr_x64< char > &imap, const bfn::unique_map_ptr_x64< char > &omap)
 
void reply_with_string (vmcall_registers_t &regs, const std::string &str, const bfn::unique_map_ptr_x64< char > &omap)
 
void reply_with_json (vmcall_registers_t &regs, const json &str, const bfn::unique_map_ptr_x64< char > &omap)
 

Detailed Description

Exit Handler

This class is responsible for detecting why a guest exited (i.e. stopped its execution), and dispatches the appropriated handler to emulate the instruction that could not execute. Note that this class could be executed a lot, so performance is key here.

This class works with the VMCS class to provide the bare minimum exit handler needed to execute a 64bit guest, with the TRUE controls being used. In general, the only instruction that needs to be emulated is the CPUID instruction. If more functionality is needed (which is likely), the user can subclass this class, and overload the handlers that are needed. The basics are provided with this class to ease development.

Definition at line 52 of file exit_handler_intel_x64.h.

Member Typedef Documentation

◆ ret_type

Definition at line 56 of file exit_handler_intel_x64.h.

Constructor & Destructor Documentation

◆ exit_handler_intel_x64()

exit_handler_intel_x64::exit_handler_intel_x64 ( )

Default Constructor

Precondition
expects: none
Postcondition
ensures: none

Definition at line 52 of file exit_handler_intel_x64.cpp.

◆ ~exit_handler_intel_x64()

virtual exit_handler_intel_x64::~exit_handler_intel_x64 ( )
virtualdefault

Destructor

Precondition
expects: none
Postcondition
ensures: none

Member Function Documentation

◆ dispatch()

void exit_handler_intel_x64::dispatch ( )
virtual

Dispatch

Called when a VM exit needs to be handled. This function will decode the exit reason, and dispatch the correct handler.

Precondition
expects: none
Postcondition
ensures: none

Definition at line 58 of file exit_handler_intel_x64.cpp.

◆ halt()

void exit_handler_intel_x64::halt ( )
virtualnoexcept

Halt

Called when the exit handler needs to halt the CPU. This would mainly be due to an error.

Precondition
expects: none
Postcondition
ensures: none

Definition at line 62 of file exit_handler_intel_x64.cpp.

◆ complete_vmcall()

void exit_handler_intel_x64::complete_vmcall ( ret_type  ret,
vmcall_registers_t regs 
)
virtualnoexcept

Complete VMCall

Completes a VMCall given a set of previously setup registers. Note that most of the time you should not need to run this function as a vmcall will call this for you. If however your VMCall never returns and state is lost, you can complete the VMCall at a later time using this function. Special care should be taken to ensure the proper register values are maintained.

Precondition
expects: none
Postcondition
ensures: none
Parameters
retBF_VMCALL_SUCCESS on success, failure otherwise
regsthe register state to return

Definition at line 232 of file exit_handler_intel_x64.cpp.

◆ handle_exit()

void exit_handler_intel_x64::handle_exit ( intel_x64::vmcs::value_type  reason)
protectedvirtual

Definition at line 103 of file exit_handler_intel_x64.cpp.

◆ handle_cpuid()

void exit_handler_intel_x64::handle_cpuid ( )
protected

Definition at line 140 of file exit_handler_intel_x64.cpp.

◆ handle_invd()

void exit_handler_intel_x64::handle_invd ( )
protected

Definition at line 156 of file exit_handler_intel_x64.cpp.

◆ handle_vmcall()

void exit_handler_intel_x64::handle_vmcall ( )
protected

Definition at line 163 of file exit_handler_intel_x64.cpp.

◆ handle_vmxoff()

void exit_handler_intel_x64::handle_vmxoff ( )
protected

Definition at line 261 of file exit_handler_intel_x64.cpp.

◆ handle_rdmsr()

void exit_handler_intel_x64::handle_rdmsr ( )
protected

Definition at line 265 of file exit_handler_intel_x64.cpp.

◆ handle_wrmsr()

void exit_handler_intel_x64::handle_wrmsr ( )
protected

Definition at line 337 of file exit_handler_intel_x64.cpp.

◆ advance_rip()

void exit_handler_intel_x64::advance_rip ( )
protectednoexcept

Definition at line 391 of file exit_handler_intel_x64.cpp.

◆ unimplemented_handler()

void exit_handler_intel_x64::unimplemented_handler ( )
protectednoexcept

Definition at line 395 of file exit_handler_intel_x64.cpp.

◆ handle_vmcall_versions()

void exit_handler_intel_x64::handle_vmcall_versions ( vmcall_registers_t regs)
protectedvirtual

Definition at line 439 of file exit_handler_intel_x64.cpp.

◆ handle_vmcall_registers()

void exit_handler_intel_x64::handle_vmcall_registers ( vmcall_registers_t regs)
protectedvirtual

Definition at line 467 of file exit_handler_intel_x64.cpp.

◆ handle_vmcall_data()

void exit_handler_intel_x64::handle_vmcall_data ( vmcall_registers_t regs)
protectedvirtual

Definition at line 484 of file exit_handler_intel_x64.cpp.

◆ handle_vmcall_event()

void exit_handler_intel_x64::handle_vmcall_event ( vmcall_registers_t regs)
protectedvirtual

Definition at line 529 of file exit_handler_intel_x64.cpp.

◆ handle_vmcall_start()

void exit_handler_intel_x64::handle_vmcall_start ( vmcall_registers_t regs)
protectedvirtual

Definition at line 536 of file exit_handler_intel_x64.cpp.

◆ handle_vmcall_stop()

void exit_handler_intel_x64::handle_vmcall_stop ( vmcall_registers_t regs)
protectedvirtual

Definition at line 540 of file exit_handler_intel_x64.cpp.

◆ handle_vmcall_unittest()

void exit_handler_intel_x64::handle_vmcall_unittest ( vmcall_registers_t regs)
protectedvirtual

Definition at line 27 of file exit_handler_intel_x64_unittests.cpp.

◆ handle_vmcall_data_string_unformatted()

void exit_handler_intel_x64::handle_vmcall_data_string_unformatted ( const std::string &  istr,
std::string &  ostr 
)
protectedvirtual

Definition at line 544 of file exit_handler_intel_x64.cpp.

◆ handle_vmcall_data_string_json()

void exit_handler_intel_x64::handle_vmcall_data_string_json ( const json &  ijson,
json &  ojson 
)
protectedvirtual

Definition at line 552 of file exit_handler_intel_x64.cpp.

◆ handle_vmcall_data_binary_unformatted()

void exit_handler_intel_x64::handle_vmcall_data_binary_unformatted ( const bfn::unique_map_ptr_x64< char > &  imap,
const bfn::unique_map_ptr_x64< char > &  omap 
)
protectedvirtual

Definition at line 560 of file exit_handler_intel_x64.cpp.

◆ reply_with_string()

void exit_handler_intel_x64::reply_with_string ( vmcall_registers_t regs,
const std::string &  str,
const bfn::unique_map_ptr_x64< char > &  omap 
)
protected

Definition at line 568 of file exit_handler_intel_x64.cpp.

◆ reply_with_json()

void exit_handler_intel_x64::reply_with_json ( vmcall_registers_t regs,
const json &  str,
const bfn::unique_map_ptr_x64< char > &  omap 
)
protected

Definition at line 581 of file exit_handler_intel_x64.cpp.

◆ set_vmcs()

virtual void exit_handler_intel_x64::set_vmcs ( gsl::not_null< vmcs_intel_x64 *>  vmcs)
inlinevirtual

Definition at line 158 of file exit_handler_intel_x64.h.

◆ set_state_save()

virtual void exit_handler_intel_x64::set_state_save ( gsl::not_null< state_save_intel_x64 *>  state_save)
inlinevirtual

Definition at line 161 of file exit_handler_intel_x64.h.

Field Documentation

◆ m_vmcs

vmcs_intel_x64* exit_handler_intel_x64::m_vmcs

Definition at line 155 of file exit_handler_intel_x64.h.

◆ m_state_save

state_save_intel_x64* exit_handler_intel_x64::m_state_save

Definition at line 156 of file exit_handler_intel_x64.h.


The documentation for this class was generated from the following files: