Skip to content

Commit

Permalink
improve fix for VMCS_GUEST_PENDING_DBG_EXCEPTIONS saved on VMEXIT (sh…
Browse files Browse the repository at this point in the history
…ould be cleared after most of VMEXITs)

handle some corner cases
  • Loading branch information
Stanislav Shwartsman committed Nov 14, 2023
1 parent 60cc802 commit fde226f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bochs/cpu/soft_int.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::INT1(bxInstruction_c *i)
BX_INSTR_FAR_BRANCH_ORIGIN();

#if BX_SUPPORT_VMX
VMexit_Event(BX_PRIVILEGED_SOFTWARE_INTERRUPT, 1, 0, 0);
VMexit_Event(BX_PRIVILEGED_SOFTWARE_INTERRUPT, BX_DB_EXCEPTION, 0, 0);
#endif

#if BX_SUPPORT_SVM
Expand Down
14 changes: 7 additions & 7 deletions bochs/cpu/vmexit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,15 @@ void BX_CPU_C::VMexit_Event(unsigned type, unsigned vector, Bit16u errcode, bool
if (vector == BX_DF_EXCEPTION)
BX_CPU_THIS_PTR in_event = false; // clear in_event indication on #DF

if (vector == BX_DB_EXCEPTION) {
if (vector == BX_DB_EXCEPTION) {
// qualification for debug exceptions similar to debug_trap field
qualification = BX_CPU_THIS_PTR debug_trap & 0x0000600f;
if (type == BX_PRIVILEGED_SOFTWARE_INTERRUPT)
qualification = BX_CPU_THIS_PTR debug_trap & 0xf;
else
qualification = BX_CPU_THIS_PTR debug_trap & 0x0000600f;
BX_CPU_THIS_PTR debug_trap = 0;
}

// clear debug_trap field
BX_CPU_THIS_PTR debug_trap = 0;
BX_CPU_THIS_PTR inhibit_mask = 0;

Bit32u interruption_info = vector | (type << 8);
if (errcode_valid)
interruption_info |= (1 << 11); // error code delivered
Expand Down Expand Up @@ -738,7 +738,7 @@ void BX_CPU_C::Virtualization_Exception(Bit64u qualification, Bit64u guest_physi

Bit32u magic;
access_read_physical(vm->ve_info_addr + 4, 4, &magic);
#if BX_SUPPORT_MEMTYPE
#if BX_SUPPORT_MEMTYPE && (BX_DEBUGGER || BX_INSTRUMENTATION)
BxMemtype ve_info_memtype = resolve_memtype(vm->ve_info_addr);
#endif
BX_NOTIFY_PHY_MEMORY_ACCESS(vm->ve_info_addr + 4, 4, MEMTYPE(ve_info_memtype), BX_READ, 0, (Bit8u*)(&magic));
Expand Down

0 comments on commit fde226f

Please sign in to comment.