resolution for SF bug #1460 Incorrect "Blocking by NMI" bit when handling NMI VM-exit

as well as
resolution for Test stuck due to incorrect Virtual NMI handling #211
which appear the same problem
This commit is contained in:
Stanislav Shwartsman 2024-01-12 00:19:44 +02:00
parent 9e36971e0f
commit 6b48d6e33f
4 changed files with 17 additions and 1 deletions

View File

@ -345,11 +345,11 @@ bool BX_CPU_C::handleAsyncEvent(void)
}
#endif
clear_event(BX_EVENT_NMI);
mask_event(BX_EVENT_NMI);
BX_CPU_THIS_PTR EXT = 1; /* external event */
#if BX_SUPPORT_VMX
VMexit_Event(BX_NMI, 2, 0, 0);
#endif
mask_event(BX_EVENT_NMI);
BX_INSTR_HWINTERRUPT(BX_CPU_ID, 2, BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value, RIP);
interrupt(2, BX_NMI, 0, 0);
}

View File

@ -1912,6 +1912,8 @@ enum {
const Bit64u BX_SUPPRESS_EPT_VIOLATION_EXCEPTION = (BX_CONST64(1) << 63);
const Bit64u BX_SUB_PAGE_PROTECTED = (BX_CONST64(1) << 61);
const Bit64u BX_SUPERVISOR_SHADOW_STACK_PAGE = (BX_CONST64(1) << 60);
const Bit64u BX_PAGING_WRITE_ACCESS = (BX_CONST64(1) << 58);
const Bit64u BX_VERIFY_GUEST_PAGING = (BX_CONST64(1) << 57);
#define PAGING_EPT_RESERVED_BITS (BX_PAGING_PHY_ADDRESS_RESERVED_BITS)

View File

@ -286,6 +286,15 @@ void BX_CPU_C::VMexit_Event(unsigned type, unsigned vector, Bit16u errcode, bool
BX_CPU_THIS_PTR debug_trap = 0;
}
// interruption info:
// -----------------
// [7 : 0] vector
// [10: 8] interruption type
// [11:11] error code delivered
// [12:12] NMI unblocking due to IRET
// [30:13] reserved
// [31:31] valid
Bit32u interruption_info = vector | (type << 8);
if (errcode_valid)
interruption_info |= (1 << 11); // error code delivered

View File

@ -2886,6 +2886,11 @@ void BX_CPU_C::VMexit(Bit32u reason, Bit64u qualification)
//
mask_event(BX_EVENT_INIT); // INIT is disabled in VMX root mode
if (reason == VMX_VMEXIT_EXCEPTION_NMI) {
Bit32u vector = VMread32(VMCS_32BIT_VMEXIT_INTERRUPTION_INFO) & 0xFF;
if (vector == 2)
mask_event(BX_EVENT_NMI);
}
BX_CPU_THIS_PTR EXT = 0;
BX_CPU_THIS_PTR last_exception_type = 0;