bfvmm/src/hve/arch/intel_x64/vmexit/nmi_window.cpp
nmi_window_handler::nmi_window_handler(
    gsl::not_null<vcpu *> vcpu
) :
    m_vcpu{vcpu}
{
    using namespace vmcs_n;

    vcpu->add_handler(
        exit_reason::basic_exit_reason::nmi_window,
        ::handler_delegate_t::create<nmi_window_handler, &nmi_window_handler::handle>(this)
    );
}
// TODO
//
// The NMI logic is not safe, and it could result in corruption (although the
// chances of this a very low). There is no clean way to disable NMIs which
// means that at any given time, an NMI could fire. If the enable CTL is
// being modified when an NMI fires, this code could corrupt said operation.
//
// The only real way to prevent this is to ensure that both this code, and any
// code that touches this CTL only uses atomic bit sets which can be done:
// https://stackoverflow.com/questions/30467638/cheapest-least-intrusive-way-to-atomically-update-a-bit
//
// If atomic bit setting is done for this field, we can ensure that at no time,
// the CTL becomes corrupt if an NMI happens to fire.
//




If atomic bit setting is done for this field, we can ensure that at no time,
the CTL becomes corrupt if an NMI happens to fire.
If atomic bit setting is done for this field we can ensure that at no time the CTL becomes corrupt if an NMI happens to fire .
nmi_window_handler::nmi_window_handler(
    gsl::not_null<vcpu *> vcpu
) :
    m_vcpu{vcpu}
{
    using namespace vmcs_n;
    vcpu->add_handler(
        exit_reason::basic_exit_reason::nmi_window,
        ::handler_delegate_t::create<nmi_window_handler, &nmi_window_handler::handle>(this)
    );
}
nmi_window_handler :: nmi_window_handler ( gsl :: not_null < vcpu * > vcpu ) : m_vcpu { vcpu } { using namespace vmcs_n ; vcpu -> add_handler ( exit_reason :: basic_exit_reason :: nmi_window , :: handler_delegate_t :: create < nmi_window_handler , & nmi_window_handler :: handle > ( this ) ) ; }
TODO
The NMI logic is not safe, and it could result in corruption (although the
chances of this a very low).
TODO The NMI logic is not safe and it could result in corruption ( although the chances of this a very low ) .