optimization and bugfix for prev commit
This commit is contained in:
parent
1b228aec32
commit
3cd11b02ee
@ -823,7 +823,6 @@ struct BxExceptionInfo exceptions_info[BX_CPU_HANDLED_EXCEPTIONS] = {
|
||||
|
||||
// vector: 0..255: vector in IDT
|
||||
// error_code: if exception generates and error, push this error code
|
||||
// trap: override exception class to TRAP
|
||||
void BX_CPU_C::exception(unsigned vector, Bit16u error_code)
|
||||
{
|
||||
BX_INSTR_EXCEPTION(BX_CPU_ID, vector, error_code);
|
||||
@ -860,34 +859,6 @@ void BX_CPU_C::exception(unsigned vector, Bit16u error_code)
|
||||
SvmInterceptException(BX_HARDWARE_EXCEPTION, vector, error_code, push_error);
|
||||
#endif
|
||||
|
||||
if (BX_CPU_THIS_PTR last_exception_type == BX_ET_DOUBLE_FAULT) {
|
||||
// restore RIP/RSP to value before error occurred
|
||||
RIP = BX_CPU_THIS_PTR prev_rip;
|
||||
if (BX_CPU_THIS_PTR speculative_rsp)
|
||||
RSP = BX_CPU_THIS_PTR prev_rsp;
|
||||
|
||||
debug(BX_CPU_THIS_PTR prev_rip); // print debug information to the log
|
||||
#if BX_SUPPORT_VMX
|
||||
VMexit_TripleFault();
|
||||
#endif
|
||||
#if BX_DEBUGGER
|
||||
// trap into debugger (similar as done when PANIC occured)
|
||||
bx_debug_break();
|
||||
#endif
|
||||
if (SIM->get_param_bool(BXPN_RESET_ON_TRIPLE_FAULT)->get()) {
|
||||
BX_ERROR(("exception(): 3rd (%d) exception with no resolution, shutdown status is %02xh, resetting", vector, DEV_cmos_get_reg(0x0f)));
|
||||
bx_pc_system.Reset(BX_RESET_HARDWARE);
|
||||
}
|
||||
else {
|
||||
BX_PANIC(("exception(): 3rd (%d) exception with no resolution", vector));
|
||||
BX_ERROR(("WARNING: Any simulation after this point is completely bogus !"));
|
||||
shutdown();
|
||||
}
|
||||
longjmp(BX_CPU_THIS_PTR jmp_buf_env, 1); // go back to main decode loop
|
||||
}
|
||||
|
||||
// note: fault-class exceptions _except_ #DB set RF in
|
||||
// eflags image.
|
||||
if (exception_class == BX_EXCEPTION_CLASS_FAULT)
|
||||
{
|
||||
// restore RIP/RSP to value before error occurred
|
||||
@ -895,6 +866,28 @@ void BX_CPU_C::exception(unsigned vector, Bit16u error_code)
|
||||
if (BX_CPU_THIS_PTR speculative_rsp)
|
||||
RSP = BX_CPU_THIS_PTR prev_rsp;
|
||||
|
||||
if (BX_CPU_THIS_PTR last_exception_type == BX_ET_DOUBLE_FAULT)
|
||||
{
|
||||
debug(BX_CPU_THIS_PTR prev_rip); // print debug information to the log
|
||||
#if BX_SUPPORT_VMX
|
||||
VMexit_TripleFault();
|
||||
#endif
|
||||
#if BX_DEBUGGER
|
||||
// trap into debugger (similar as done when PANIC occured)
|
||||
bx_debug_break();
|
||||
#endif
|
||||
if (SIM->get_param_bool(BXPN_RESET_ON_TRIPLE_FAULT)->get()) {
|
||||
BX_ERROR(("exception(): 3rd (%d) exception with no resolution, shutdown status is %02xh, resetting", vector, DEV_cmos_get_reg(0x0f)));
|
||||
bx_pc_system.Reset(BX_RESET_HARDWARE);
|
||||
}
|
||||
else {
|
||||
BX_PANIC(("exception(): 3rd (%d) exception with no resolution", vector));
|
||||
BX_ERROR(("WARNING: Any simulation after this point is completely bogus !"));
|
||||
shutdown();
|
||||
}
|
||||
longjmp(BX_CPU_THIS_PTR jmp_buf_env, 1); // go back to main decode loop
|
||||
}
|
||||
|
||||
if (vector != BX_DB_EXCEPTION) BX_CPU_THIS_PTR assert_RF();
|
||||
}
|
||||
|
||||
|
@ -630,6 +630,7 @@ void BX_CPU_C::Svm_Vmexit(int reason, Bit64u exitinfo1, Bit64u exitinfo2)
|
||||
//
|
||||
|
||||
BX_CPU_THIS_PTR EXT = 0;
|
||||
BX_CPU_THIS_PTR last_exception_type = 0;
|
||||
|
||||
#if BX_DEBUGGER
|
||||
if (BX_CPU_THIS_PTR vmexit_break) {
|
||||
@ -744,8 +745,6 @@ void BX_CPU_C::SvmInterceptException(unsigned type, unsigned vector, Bit16u errc
|
||||
BX_CPU_THIS_PTR debug_trap = 0; // clear debug_trap field
|
||||
BX_CPU_THIS_PTR inhibit_mask = 0;
|
||||
|
||||
BX_CPU_THIS_PTR last_exception_type = 0; // error resolved
|
||||
|
||||
Svm_Vmexit(SVM_VMEXIT_EXCEPTION + vector, (errcode_valid ? errcode : 0), qualification);
|
||||
}
|
||||
|
||||
|
@ -255,8 +255,6 @@ void BX_CPU_C::VMexit_Event(unsigned type, unsigned vector, Bit16u errcode, bx_b
|
||||
BX_CPU_THIS_PTR debug_trap = 0;
|
||||
BX_CPU_THIS_PTR inhibit_mask = 0;
|
||||
|
||||
BX_CPU_THIS_PTR last_exception_type = 0; // error resolved
|
||||
|
||||
Bit32u interruption_info = vector | (type << 8);
|
||||
if (errcode_valid)
|
||||
interruption_info |= (1 << 11); // error code delivered
|
||||
|
@ -2244,6 +2244,7 @@ void BX_CPU_C::VMexit(Bit32u reason, Bit64u qualification)
|
||||
mask_event(BX_EVENT_INIT); // INIT is disabled in VMX root mode
|
||||
|
||||
BX_CPU_THIS_PTR EXT = 0;
|
||||
BX_CPU_THIS_PTR last_exception_type = 0;
|
||||
|
||||
#if BX_DEBUGGER
|
||||
if (BX_CPU_THIS_PTR vmexit_break) {
|
||||
|
Loading…
Reference in New Issue
Block a user