The register_vmx_mode_leave_cb registers a callback of type
vmx_mode_switch_cb_t
that will be called before the processor
leaves a particular VMX mode.
The register_vmx_mode_enter_cb registers a callback of type
vmx_mode_switch_cb_t
that will be called after the processor
enters a particular VMX mode.
The callback in both cases looks like this:
This callback type is used by the
vmx_instrumentation_subscribe
to implements VMX mode switch
instrumentation.
typedef void (*vmx_mode_switch_cb_t)( conf_object_t *obj, conf_object_t *cpu, vmx_mode_t mode, physical_address_t vmcs_address, lang_void *user_data);
The obj argument is the user object that registered the callback, or NULL if no such object exists.
The cpu argument is the processor that switches VMX mode.
The mode that will be left or entered is passed in the mode argument in the callback.
The different VMX modes are defined in the following type:
This enum is used to distinguish VMX modes. It is
used by the vmx_mode_switch_cb_t
.
typedef enum { Vmx_Off = 0, Vmx_Root = 1, Vmx_Non_Root = 2 } vmx_mode_t;
The vmcs_address argument specifies the Virtual Machine Control Structure address that is currently being used. If not available, it will be passed as (physical_address_t)(-1).
When leaving a mode and then entering another mode, the mode can actually be reported as to be the same in certain situations. This is not a bug, it is a consequent of how Simics is implemented. It would require a lot of extra code to filter those out.
The user_data argument is the callback user data, passed to the register methods.
SIM_INTERFACE(vmx_instrumentation_subscribe) { cpu_cb_handle_t *(*register_vmx_mode_leave_cb)( conf_object_t *cpu, conf_object_t *connection, vmx_mode_switch_cb_t cb, lang_void *user_data); cpu_cb_handle_t *(*register_vmx_mode_enter_cb)( conf_object_t *cpu, conf_object_t *connection, vmx_mode_switch_cb_t cb, lang_void *user_data); }; #define VMX_INSTRUMENTATION_SUBSCRIBE_INTERFACE \ "vmx_instrumentation_subscribe"