From 6fe6da5f2585c4807603530e773eb594c3d706f3 Mon Sep 17 00:00:00 2001 From: Stanislav Shwartsman Date: Thu, 7 May 2009 12:00:02 +0000 Subject: [PATCH] small fixes --- bochs/cpu/cpu.cc | 15 ++++++++++----- bochs/cpu/proc_ctrl.cc | 30 +++++++++++++++++++++++------- bochs/cpu/tasking.cc | 18 ++++++++++++++---- 3 files changed, 47 insertions(+), 16 deletions(-) diff --git a/bochs/cpu/cpu.cc b/bochs/cpu/cpu.cc index a53303fbf..8cda172dc 100644 --- a/bochs/cpu/cpu.cc +++ b/bochs/cpu/cpu.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: cpu.cc,v 1.289 2009-04-18 21:09:50 sshwarts Exp $ +// $Id: cpu.cc,v 1.290 2009-05-07 12:00:02 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -656,11 +656,16 @@ unsigned BX_CPU_C::handleAsyncEvent(void) BX_CPU_THIS_PTR debug_trap || BX_HRQ || BX_CPU_THIS_PTR get_TF() -#if BX_X86_DEBUGGER - || (BX_CPU_THIS_PTR dr7 & 0xff) -#endif #if BX_SUPPORT_VMX - || (BX_CPU_THIS_PTR vmx_interrupt_window) + || BX_CPU_THIS_PTR vmx_interrupt_window +#endif +#if BX_X86_DEBUGGER + // any debug code breakpoint is set + || ((BX_CPU_THIS_PTR dr7 & 0xff) && + (((BX_CPU_THIS_PTR dr7 >> 16) & 3) == 0 || + ((BX_CPU_THIS_PTR dr7 >> 20) & 3) == 0 || + ((BX_CPU_THIS_PTR dr7 >> 24) & 3) == 0 || + ((BX_CPU_THIS_PTR dr7 >> 28) & 3) == 0)) #endif )) BX_CPU_THIS_PTR async_event = 0; diff --git a/bochs/cpu/proc_ctrl.cc b/bochs/cpu/proc_ctrl.cc index 5dddf4b5d..521071065 100644 --- a/bochs/cpu/proc_ctrl.cc +++ b/bochs/cpu/proc_ctrl.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: proc_ctrl.cc,v 1.295 2009-04-07 16:12:19 sshwarts Exp $ +// $Id: proc_ctrl.cc,v 1.296 2009-05-07 12:00:02 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -345,10 +345,18 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_DdRd(bxInstruction_c *i) BX_CPU_THIS_PTR dr7 = (val_32 & 0xffff2fff) | 0x00000400; #endif #if BX_X86_DEBUGGER - // if we have breakpoints enabled then we must check + // if we have code breakpoints enabled then we must check // breakpoints condition in cpu loop - if(BX_CPU_THIS_PTR dr7 & 0xff) - BX_CPU_THIS_PTR async_event = 1; + if (BX_CPU_THIS_PTR dr7 & 0xff) { + if (((BX_CPU_THIS_PTR dr7 >> 16) & 3) == 0 || + ((BX_CPU_THIS_PTR dr7 >> 20) & 3) == 0 || + ((BX_CPU_THIS_PTR dr7 >> 24) & 3) == 0 || + ((BX_CPU_THIS_PTR dr7 >> 28) & 3) == 0) + { + BX_INFO(("MOV_DdRd(): code breakpoint is set")); + BX_CPU_THIS_PTR async_event = 1; + } + } #endif break; @@ -519,10 +527,18 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_DqRq(bxInstruction_c *i) BX_CPU_THIS_PTR dr7 = (val_64 & 0xffff2fff) | 0x00000400; #if BX_X86_DEBUGGER - // if we have breakpoints enabled then we must check + // if we have code breakpoints enabled then we must check // breakpoints condition in cpu loop - if(BX_CPU_THIS_PTR dr7 & 0xff) - BX_CPU_THIS_PTR async_event = 1; + if (BX_CPU_THIS_PTR dr7 & 0xff) { + if (((BX_CPU_THIS_PTR dr7 >> 16) & 3) == 0 || + ((BX_CPU_THIS_PTR dr7 >> 20) & 3) == 0 || + ((BX_CPU_THIS_PTR dr7 >> 24) & 3) == 0 || + ((BX_CPU_THIS_PTR dr7 >> 28) & 3) == 0) + { + BX_INFO(("MOV_DdRd(): code breakpoint is set")); + BX_CPU_THIS_PTR async_event = 1; + } + } #endif break; diff --git a/bochs/cpu/tasking.cc b/bochs/cpu/tasking.cc index 65b71d64b..76a8880a0 100644 --- a/bochs/cpu/tasking.cc +++ b/bochs/cpu/tasking.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: tasking.cc,v 1.71 2009-05-01 14:59:21 sshwarts Exp $ +// $Id: tasking.cc,v 1.72 2009-05-07 12:00:02 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -78,7 +78,7 @@ // | EBP | 3c 60 dynamic // | ESP | 38 56 dynamic // | EBX | 34 52 dynamic - // | EDX | 30 48 dynamic + // | EDX | 30 48 dyn amic // | ECX | 2c 44 dynamic // | EAX | 28 40 dynamic // | EFLAGS | 24 36 dynamic @@ -205,8 +205,6 @@ void BX_CPU_C::task_switch(bxInstruction_c *i, bx_selector_t *tss_selector, // used in the task switch are paged in. if (BX_CPU_THIS_PTR cr0.get_PG()) { - dtranslate_linear(obase32, 0, BX_WRITE); // new TSS - dtranslate_linear(obase32 + old_TSS_max, 0, BX_WRITE); dtranslate_linear(nbase32, 0, BX_READ); // old TSS dtranslate_linear(nbase32 + new_TSS_max, 0, BX_READ); @@ -242,6 +240,12 @@ void BX_CPU_C::task_switch(bxInstruction_c *i, bx_selector_t *tss_selector, } if (BX_CPU_THIS_PTR tr.cache.type <= 3) { + // check that we won't page fault while writing + if (BX_CPU_THIS_PTR cr0.get_PG()) { + dtranslate_linear(Bit32u(obase32 + 14), 0, BX_WRITE); + dtranslate_linear(Bit32u(obase32 + 41), 0, BX_WRITE); + } + temp16 = IP; access_write_linear(Bit32u(obase32 + 14), 2, 0, &temp16); temp16 = oldEFLAGS; access_write_linear(Bit32u(obase32 + 16), 2, 0, &temp16); temp16 = AX; access_write_linear(Bit32u(obase32 + 18), 2, 0, &temp16); @@ -262,6 +266,12 @@ void BX_CPU_C::task_switch(bxInstruction_c *i, bx_selector_t *tss_selector, access_write_linear(Bit32u(obase32 + 40), 2, 0, &temp16); } else { + // check that we won't page fault while writing + if (BX_CPU_THIS_PTR cr0.get_PG()) { + dtranslate_linear(Bit32u(obase32 + 0x20), 0, BX_WRITE); + dtranslate_linear(Bit32u(obase32 + 0x5d), 0, BX_WRITE); + } + temp32 = EIP; access_write_linear(Bit32u(obase32 + 0x20), 4, 0, &temp32); temp32 = oldEFLAGS; access_write_linear(Bit32u(obase32 + 0x24), 4, 0, &temp32); temp32 = EAX; access_write_linear(Bit32u(obase32 + 0x28), 4, 0, &temp32);