Add debug prints before any #GP excepion which only possible to be generated

This commit is contained in:
Stanislav Shwartsman 2006-06-09 22:29:07 +00:00
parent 3cb38b3c45
commit 6c3420a18b
20 changed files with 169 additions and 122 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: access.cc,v 1.65 2006-03-06 22:02:50 sshwarts Exp $
// $Id: access.cc,v 1.66 2006-06-09 22:29:06 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -54,6 +54,7 @@ BX_CPU_C::write_virtual_checks(bx_segment_reg_t *seg, bx_address offset,
#endif
if (protected_mode()) {
if (seg->cache.valid==0) {
BX_DEBUG(("write_virtual_checks(): segment descriptor not valid"));
exception(BX_GP_EXCEPTION, 0, 0);
return;
}
@ -117,6 +118,7 @@ BX_CPU_C::write_virtual_checks(bx_segment_reg_t *seg, bx_address offset,
if (offset > (seg->cache.u.segment.limit_scaled - length + 1)
|| (length-1 > seg->cache.u.segment.limit_scaled))
{
BX_DEBUG(("write_virtual_checks(): write beyond limit (real mode)"));
exception(int_number(seg), 0, 0);
}
if (seg->cache.u.segment.limit_scaled >= 7) {
@ -145,6 +147,7 @@ BX_CPU_C::read_virtual_checks(bx_segment_reg_t *seg, bx_address offset,
#endif
if (protected_mode()) {
if (seg->cache.valid==0) {
BX_DEBUG(("read_virtual_checks(): segment descriptor not valid"));
exception(BX_GP_EXCEPTION, 0, 0);
return;
}
@ -230,6 +233,7 @@ BX_CPU_C::read_virtual_checks(bx_segment_reg_t *seg, bx_address offset,
if (offset > (seg->cache.u.segment.limit_scaled - length + 1)
|| (length-1 > seg->cache.u.segment.limit_scaled))
{
BX_DEBUG(("read_virtual_checks(): read beyond limit (real mode)"));
exception(int_number(seg), 0, 0);
}
if (seg->cache.u.segment.limit_scaled >= 7) {
@ -993,6 +997,7 @@ BX_CPU_C::read_virtual_dqword_aligned(unsigned s, bx_address offset, Bit8u *data
{
// If double quadword access is unaligned, #GP(0).
if (offset & 0xf) {
BX_DEBUG(("read_virtual_dqword_aligned: access not aligned to 16-byte"));
exception(BX_GP_EXCEPTION, 0, 0);
}
@ -1014,6 +1019,7 @@ BX_CPU_C::write_virtual_dqword_aligned(unsigned s, bx_address offset, Bit8u *dat
{
// If double quadword access is unaligned, #GP(0).
if (offset & 0xf) {
BX_DEBUG(("write_virtual_dqword_aligned: access not aligned to 16-byte"));
exception(BX_GP_EXCEPTION, 0, 0);
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: arith64.cc,v 1.29 2006-03-26 18:58:00 sshwarts Exp $
// $Id: arith64.cc,v 1.30 2006-06-09 22:29:06 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -622,12 +622,12 @@ void BX_CPU_C::CMPXCHG16B(bxInstruction_c *i)
Bit64u op1_64_lo, op1_64_hi, diff;
if (i->modC0()) {
BX_INFO(("CMPXCHG16B: dest is not memory location (#UD)"));
BX_ERROR(("CMPXCHG16B: dest is not memory location (#UD)"));
UndefinedOpcode(i);
}
if (RMAddr(i) & 0xf) {
BX_INFO(("CMPXCHG16B: not aligned memory location (#GP)"));
BX_ERROR(("CMPXCHG16B: not aligned memory location (#GP)"));
exception(BX_GP_EXCEPTION, 0, 0);
}

View File

@ -1,5 +1,5 @@
////////////////////////////////////////////////////////////////////////
// $Id: call_far.cc,v 1.10 2006-03-22 20:47:11 sshwarts Exp $
// $Id: call_far.cc,v 1.11 2006-06-09 22:29:06 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -285,7 +285,7 @@ BX_CPU_C::call_protected(bxInstruction_c *i, Bit16u cs_raw, bx_address disp)
// selector's RPL must equal DPL of code segment,
// else #TS(SS selector)
if (ss_selector.rpl != cs_descriptor.dpl) {
BX_DEBUG(("call_protected: SS selector.rpl != CS descr.dpl"));
BX_ERROR(("call_protected: SS selector.rpl != CS descr.dpl"));
exception(BX_TS_EXCEPTION, SS_for_cpl_x & 0xfffc, 0);
}
@ -333,7 +333,7 @@ BX_CPU_C::call_protected(bxInstruction_c *i, Bit16u cs_raw, bx_address disp)
// new stack must have room for parameters plus return info
// else #SS(SS selector)
if (!can_push(&ss_descriptor, ESP_for_cpl_x, room_needed)) {
BX_INFO(("call_protected: stack doesn't have room"));
BX_ERROR(("call_protected: stack doesn't have room"));
exception(BX_SS_EXCEPTION, SS_for_cpl_x & 0xfffc, 0);
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: cpu.h,v 1.297 2006-05-28 17:07:57 sshwarts Exp $
// $Id: cpu.h,v 1.298 2006-06-09 22:29:06 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -1407,10 +1407,10 @@ public: // for now...
BX_SMF void PUSH_Iw(bxInstruction_c *);
BX_SMF void INSB_YbDX(bxInstruction_c *);
BX_SMF void INSW_YwDX(bxInstruction_c *);
BX_SMF void INSW_YdDX(bxInstruction_c *);
BX_SMF void INSD_YdDX(bxInstruction_c *);
BX_SMF void OUTSB_DXXb(bxInstruction_c *);
BX_SMF void OUTSW_DXXw(bxInstruction_c *);
BX_SMF void OUTSW_DXXd(bxInstruction_c *);
BX_SMF void OUTSD_DXXd(bxInstruction_c *);
BX_SMF void BOUND_GwMa(bxInstruction_c *);
BX_SMF void BOUND_GdMa(bxInstruction_c *);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: ctrl_xfer16.cc,v 1.35 2006-05-12 17:04:19 sshwarts Exp $
// $Id: ctrl_xfer16.cc,v 1.36 2006-06-09 22:29:06 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -416,7 +416,7 @@ void BX_CPU_C::IRET16(bxInstruction_c *i)
#endif
if (! can_pop(6)) {
BX_PANIC(("IRET: top 6 bytes of stack not within stack limits"));
BX_ERROR(("IRET: top 6 bytes of stack not within stack limits"));
exception(BX_SS_EXCEPTION, 0, 0);
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: ctrl_xfer32.cc,v 1.48 2006-05-12 17:04:19 sshwarts Exp $
// $Id: ctrl_xfer32.cc,v 1.49 2006-06-09 22:29:06 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -411,7 +411,7 @@ void BX_CPU_C::IRET32(bxInstruction_c *i)
Bit32u eip, ecs, eflags;
if (! can_pop(12)) {
BX_PANIC(("IRETD: to 12 bytes of stack not within stack limits"));
BX_ERROR(("IRETD: to 12 bytes of stack not within stack limits"));
exception(BX_SS_EXCEPTION, 0, 0);
}
@ -419,7 +419,7 @@ void BX_CPU_C::IRET32(bxInstruction_c *i)
// CS.LIMIT in real mode is 0xffff
if (eip > 0xffff) {
BX_PANIC(("IRETD: instruction pointer not within code segment limits"));
BX_ERROR(("IRETD: instruction pointer not within code segment limits"));
exception(BX_GP_EXCEPTION, 0, 0);
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: ctrl_xfer64.cc,v 1.46 2006-05-12 17:04:19 sshwarts Exp $
// $Id: ctrl_xfer64.cc,v 1.47 2006-06-09 22:29:06 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -122,7 +122,7 @@ void BX_CPU_C::CALL_Aq(bxInstruction_c *i)
#endif
if (! IsCanonical(new_RIP)) {
BX_INFO(("CALL_Aq: canonical RIP violation"));
BX_ERROR(("CALL_Aq: canonical RIP violation"));
exception(BX_GP_EXCEPTION, 0, 0);
}
@ -150,7 +150,7 @@ void BX_CPU_C::CALL_Eq(bxInstruction_c *i)
if (! IsCanonical(op1_64))
{
BX_INFO(("CALL_Eq: canonical RIP violation"));
BX_ERROR(("CALL_Eq: canonical RIP violation"));
exception(BX_GP_EXCEPTION, 0, 0);
}
@ -249,7 +249,7 @@ void BX_CPU_C::JMP_Eq(bxInstruction_c *i)
}
if (! IsCanonical(op1_64)) {
BX_INFO(("JMP_Eq: canonical RIP violation"));
BX_ERROR(("JMP_Eq: canonical RIP violation"));
exception(BX_GP_EXCEPTION, 0, 0);
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: exception.cc,v 1.78 2006-06-05 16:38:43 sshwarts Exp $
// $Id: exception.cc,v 1.79 2006-06-09 22:29:06 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -316,7 +316,7 @@ void BX_CPU_C::protected_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error
parse_descriptor(dword1, dword2, &gate_descriptor);
if ((gate_descriptor.valid==0) || gate_descriptor.segment) {
BX_DEBUG(("interrupt(): gate descriptor is not valid sys seg"));
BX_ERROR(("interrupt(): gate descriptor is not valid sys seg"));
exception(BX_GP_EXCEPTION, vector*8 + 2, 0);
}
@ -328,7 +328,7 @@ void BX_CPU_C::protected_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error
case BX_386_TRAP_GATE:
break;
default:
BX_DEBUG(("interrupt(): gate.type(%u) != {5,6,7,14,15}",
BX_ERROR(("interrupt(): gate.type(%u) != {5,6,7,14,15}",
(unsigned) gate_descriptor.type));
exception(BX_GP_EXCEPTION, vector*8 + 2, 0);
}
@ -342,7 +342,7 @@ void BX_CPU_C::protected_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error
// Gate must be present, else #NP(vector * 8 + 2 + EXT)
if (! IS_PRESENT(gate_descriptor)) {
BX_DEBUG(("interrupt(): gate not present"));
BX_ERROR(("interrupt(): gate not present"));
exception(BX_NP_EXCEPTION, vector*8 + 2, 0);
}
@ -367,11 +367,11 @@ void BX_CPU_C::protected_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error
// AR byte must specify available TSS,
// else #GP(TSS selector)
if (tss_descriptor.valid==0 || tss_descriptor.segment) {
BX_PANIC(("exception: TSS selector points to bad TSS"));
BX_ERROR(("exception: TSS selector points to bad TSS"));
exception(BX_GP_EXCEPTION, raw_tss_selector & 0xfffc, 0);
}
if (tss_descriptor.type!=9 && tss_descriptor.type!=1) {
BX_INFO(("exception: TSS selector points to bad TSS"));
BX_ERROR(("exception: TSS selector points to bad TSS"));
exception(BX_GP_EXCEPTION, raw_tss_selector & 0xfffc, 0);
}
@ -438,19 +438,19 @@ void BX_CPU_C::protected_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error
cs_descriptor.u.segment.executable==0 ||
cs_descriptor.dpl>CPL )
{
BX_DEBUG(("interrupt(): not code segment"));
BX_ERROR(("interrupt(): not code segment"));
exception(BX_GP_EXCEPTION, cs_selector.value & 0xfffc, 0);
}
// segment must be present, else #NP(selector + EXT)
if (! IS_PRESENT(cs_descriptor)) {
BX_DEBUG(("interrupt(): segment not present"));
BX_ERROR(("interrupt(): segment not present"));
exception(BX_NP_EXCEPTION, cs_selector.value & 0xfffc, 0);
}
// if code segment is non-conforming and DPL < CPL then
// INTERRUPT TO INNER PRIVILEGE:
if ( cs_descriptor.u.segment.c_ed==0 && cs_descriptor.dpl<CPL )
if (cs_descriptor.u.segment.c_ed==0 && cs_descriptor.dpl<CPL)
{
Bit16u old_SS, old_CS, SS_for_cpl_x;
Bit32u ESP_for_cpl_x, old_EIP, old_ESP;
@ -463,6 +463,7 @@ void BX_CPU_C::protected_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error
if (is_v8086_mode && cs_descriptor.dpl != 0) {
// if code segment DPL != 0 then #GP(new code segment selector)
BX_ERROR(("interrupt(): code segment DPL != 0 in v8086 mode"));
exception(BX_GP_EXCEPTION, cs_selector.value & 0xfffc, 0);
}
@ -517,7 +518,7 @@ void BX_CPU_C::protected_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error
if (gate_descriptor.type>=14) {
// 386 int/trap gate
// new stack must have room for 20|24 bytes, else #SS(0)
if ( is_error_code )
if (is_error_code)
bytes = 24;
else
bytes = 20;
@ -526,7 +527,7 @@ void BX_CPU_C::protected_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error
}
else {
// new stack must have room for 10|12 bytes, else #SS(0)
if ( is_error_code )
if (is_error_code)
bytes = 12;
else
bytes = 10;
@ -639,6 +640,7 @@ void BX_CPU_C::protected_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error
if (v8086_mode()) {
// if code segment DPL != 0 then #GP(new code segment selector)
BX_ERROR(("interrupt(): code seg DPL != 0 in v8086 mode"));
exception(BX_GP_EXCEPTION, cs_selector.value & 0xfffc, 0);
}
@ -658,13 +660,13 @@ void BX_CPU_C::protected_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error
// Current stack limits must allow pushing 6|8 bytes, else #SS(0)
if (gate_descriptor.type >= 14) { // 386 gate
if ( is_error_code )
if (is_error_code)
bytes = 16;
else
bytes = 12;
}
else { // 286 gate
if ( is_error_code )
if (is_error_code)
bytes = 8;
else
bytes = 6;
@ -768,7 +770,7 @@ void BX_CPU_C::interrupt(Bit8u vector, bx_bool is_INT, bx_bool is_error_code, Bi
{
#if BX_DEBUGGER
if (bx_guard.special_unwind_stack) {
BX_INFO (("interrupt() returning early because special_unwind_stack is set"));
BX_INFO(("interrupt() returning early because special_unwind_stack is set"));
return;
}
BX_CPU_THIS_PTR show_flag |= Flag_intsig;
@ -822,7 +824,7 @@ void BX_CPU_C::exception(unsigned vector, Bit16u error_code, bx_bool is_INT)
#if BX_DEBUGGER
if (bx_guard.special_unwind_stack) {
BX_INFO (("exception() returning early because special_unwind_stack is set"));
BX_INFO(("exception() returning early because special_unwind_stack is set"));
longjmp(BX_CPU_THIS_PTR jmp_buf_env, 1); // go back to main decode loop
}
#endif

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: fetchdecode.cc,v 1.97 2006-05-24 20:57:37 sshwarts Exp $
// $Id: fetchdecode.cc,v 1.98 2006-06-09 22:29:07 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -1067,9 +1067,9 @@ static const BxOpcodeInfo_t BxOpcodeInfo[512*2] = {
/* 6A */ { BxImmediate_Ib_SE, &BX_CPU_C::PUSH_Id },
/* 6B */ { BxAnother | BxImmediate_Ib_SE, &BX_CPU_C::IMUL_GdEdId },
/* 6C */ { BxRepeatable, &BX_CPU_C::INSB_YbDX },
/* 6D */ { BxRepeatable, &BX_CPU_C::INSW_YdDX },
/* 6D */ { BxRepeatable, &BX_CPU_C::INSD_YdDX },
/* 6E */ { BxRepeatable, &BX_CPU_C::OUTSB_DXXb },
/* 6F */ { BxRepeatable, &BX_CPU_C::OUTSW_DXXd },
/* 6F */ { BxRepeatable, &BX_CPU_C::OUTSD_DXXd },
/* 70 */ { BxImmediate_BrOff8, &BX_CPU_C::JCC_Jd },
/* 71 */ { BxImmediate_BrOff8, &BX_CPU_C::JCC_Jd },
/* 72 */ { BxImmediate_BrOff8, &BX_CPU_C::JCC_Jd },

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: fetchdecode64.cc,v 1.97 2006-05-24 20:57:37 sshwarts Exp $
// $Id: fetchdecode64.cc,v 1.98 2006-06-09 22:29:07 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -1190,9 +1190,9 @@ static const BxOpcodeInfo_t BxOpcodeInfo64[512*3] = {
/* 6A */ { BxImmediate_Ib_SE, &BX_CPU_C::PUSH64_Id },
/* 6B */ { BxAnother | BxImmediate_Ib_SE, &BX_CPU_C::IMUL_GdEdId },
/* 6C */ { BxRepeatable, &BX_CPU_C::INSB_YbDX },
/* 6D */ { BxRepeatable, &BX_CPU_C::INSW_YdDX },
/* 6D */ { BxRepeatable, &BX_CPU_C::INSD_YdDX },
/* 6E */ { BxRepeatable, &BX_CPU_C::OUTSB_DXXb },
/* 6F */ { BxRepeatable, &BX_CPU_C::OUTSW_DXXd },
/* 6F */ { BxRepeatable, &BX_CPU_C::OUTSD_DXXd },
/* 70 */ { BxImmediate_BrOff8, &BX_CPU_C::JCC_Jq },
/* 71 */ { BxImmediate_BrOff8, &BX_CPU_C::JCC_Jq },
/* 72 */ { BxImmediate_BrOff8, &BX_CPU_C::JCC_Jq },
@ -1719,9 +1719,9 @@ static const BxOpcodeInfo_t BxOpcodeInfo64[512*3] = {
/* 6A */ { BxImmediate_Ib_SE, &BX_CPU_C::PUSH64_Id },
/* 6B */ { BxAnother | BxImmediate_Ib_SE, &BX_CPU_C::IMUL_GqEqId },
/* 6C */ { BxRepeatable, &BX_CPU_C::INSB_YbDX },
/* 6D */ { BxRepeatable, &BX_CPU_C::INSW_YdDX },
/* 6D */ { BxRepeatable, &BX_CPU_C::INSD_YdDX },
/* 6E */ { BxRepeatable, &BX_CPU_C::OUTSB_DXXb },
/* 6F */ { BxRepeatable, &BX_CPU_C::OUTSW_DXXd },
/* 6F */ { BxRepeatable, &BX_CPU_C::OUTSD_DXXd },
/* 70 */ { BxImmediate_BrOff8, &BX_CPU_C::JCC_Jq },
/* 71 */ { BxImmediate_BrOff8, &BX_CPU_C::JCC_Jq },
/* 72 */ { BxImmediate_BrOff8, &BX_CPU_C::JCC_Jq },

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: flag_ctrl.cc,v 1.25 2006-03-06 22:02:59 sshwarts Exp $
// $Id: flag_ctrl.cc,v 1.26 2006-06-09 22:29:07 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -53,7 +53,7 @@ void BX_CPU_C::LAHF(bxInstruction_c *i)
void BX_CPU_C::CLC(bxInstruction_c *i)
{
clear_CF ();
clear_CF();
}
void BX_CPU_C::STC(bxInstruction_c *i)
@ -80,8 +80,10 @@ void BX_CPU_C::CLI(bxInstruction_c *i)
else
#endif
{
if (IOPL < cpl)
if (IOPL < cpl) {
BX_DEBUG(("CLI: IOPL < CPL in protected mode"));
exception(BX_GP_EXCEPTION, 0, 0);
}
}
}
#if BX_CPU_LEVEL >= 3
@ -94,13 +96,14 @@ void BX_CPU_C::CLI(bxInstruction_c *i)
return;
}
#endif
BX_DEBUG(("CLI: IOPL != 3 in v8086 mode"));
exception(BX_GP_EXCEPTION, 0, 0);
}
}
#endif
#endif
BX_CPU_THIS_PTR clear_IF ();
BX_CPU_THIS_PTR clear_IF();
}
void BX_CPU_C::STI(bxInstruction_c *i)
@ -121,12 +124,15 @@ void BX_CPU_C::STI(bxInstruction_c *i)
return;
}
BX_DEBUG(("STI: #GP(0) in VME mode"));
exception(BX_GP_EXCEPTION, 0, 0);
}
}
#endif
if (cpl > IOPL)
if (cpl > IOPL) {
BX_DEBUG(("STI: CPL > IOPL in protected mode"));
exception(BX_GP_EXCEPTION, 0, 0);
}
}
#if BX_CPU_LEVEL >= 3
else if (v8086_mode())
@ -139,14 +145,15 @@ void BX_CPU_C::STI(bxInstruction_c *i)
return;
}
#endif
BX_DEBUG(("STI: IOPL != 3 in v8086 mode"));
exception(BX_GP_EXCEPTION, 0, 0);
}
}
#endif
#endif
if (!BX_CPU_THIS_PTR get_IF ()) {
BX_CPU_THIS_PTR assert_IF ();
if (!BX_CPU_THIS_PTR get_IF()) {
BX_CPU_THIS_PTR assert_IF();
BX_CPU_THIS_PTR inhibit_mask |= BX_INHIBIT_INTERRUPTS;
BX_CPU_THIS_PTR async_event = 1;
}
@ -154,17 +161,17 @@ void BX_CPU_C::STI(bxInstruction_c *i)
void BX_CPU_C::CLD(bxInstruction_c *i)
{
BX_CPU_THIS_PTR clear_DF ();
BX_CPU_THIS_PTR clear_DF();
}
void BX_CPU_C::STD(bxInstruction_c *i)
{
BX_CPU_THIS_PTR assert_DF ();
BX_CPU_THIS_PTR assert_DF();
}
void BX_CPU_C::CMC(bxInstruction_c *i)
{
set_CF( !get_CF() );
set_CF(! get_CF());
}
void BX_CPU_C::PUSHF_Fw(bxInstruction_c *i)
@ -172,7 +179,8 @@ void BX_CPU_C::PUSHF_Fw(bxInstruction_c *i)
Bit16u flags = read_flags();
if (v8086_mode()) {
if ((BX_CPU_THIS_PTR get_IOPL () < 3) && (CR4_VME_ENABLED == 0)) {
if ((BX_CPU_THIS_PTR get_IOPL() < 3) && (CR4_VME_ENABLED == 0)) {
BX_DEBUG(("PUSHFW: #GP(0) in v8086 (no VME) mode"));
exception(BX_GP_EXCEPTION, 0, 0);
return;
}
@ -208,7 +216,8 @@ void BX_CPU_C::POPF_Fw(bxInstruction_c *i)
changeMask |= EFlagsIFMask;
}
else if (v8086_mode()) {
if ((BX_CPU_THIS_PTR get_IOPL () < 3) && (CR4_VME_ENABLED == 0)) {
if ((BX_CPU_THIS_PTR get_IOPL() < 3) && (CR4_VME_ENABLED == 0)) {
BX_DEBUG(("POPFW: #GP(0) in v8086 (no VME) mode"));
exception(BX_GP_EXCEPTION, 0, 0);
return;
}
@ -245,7 +254,8 @@ void BX_CPU_C::POPF_Fw(bxInstruction_c *i)
void BX_CPU_C::PUSHF_Fd(bxInstruction_c *i)
{
if (v8086_mode() && (BX_CPU_THIS_PTR get_IOPL ()<3)) {
if (v8086_mode() && (BX_CPU_THIS_PTR get_IOPL()<3)) {
BX_DEBUG(("PUSHFD: #GP(0) in v8086 mode"));
exception(BX_GP_EXCEPTION, 0, 0);
return;
}
@ -277,6 +287,7 @@ void BX_CPU_C::POPF_Fd(bxInstruction_c *i)
}
else if (v8086_mode()) {
if (BX_CPU_THIS_PTR get_IOPL() < 3) {
BX_DEBUG(("POPFD: #GP(0) in v8086 mode"));
exception(BX_GP_EXCEPTION, 0, 0);
return;
}
@ -327,7 +338,7 @@ void BX_CPU_C::POPF_Fq(bxInstruction_c *i)
void BX_CPU_C::SALC(bxInstruction_c *i)
{
if ( get_CF() ) {
if (get_CF()) {
AL = 0xff;
}
else {

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: io.cc,v 1.34 2006-05-27 15:54:48 sshwarts Exp $
// $Id: io.cc,v 1.35 2006-06-09 22:29:07 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -277,8 +277,9 @@ void BX_CPU_C::INSB_YbDX(bxInstruction_c *i)
{
Bit8u value8=0;
if (BX_CPU_THIS_PTR cr0.pe && (BX_CPU_THIS_PTR get_VM () || (CPL>BX_CPU_THIS_PTR get_IOPL ()))) {
if ( !BX_CPU_THIS_PTR allow_io(DX, 1) ) {
if (BX_CPU_THIS_PTR cr0.pe && (BX_CPU_THIS_PTR get_VM() || (CPL>BX_CPU_THIS_PTR get_IOPL()))) {
if (! BX_CPU_THIS_PTR allow_io(DX, 1)) {
BX_DEBUG(("INSB_YbDX: I/O access not allowed !"));
exception(BX_GP_EXCEPTION, 0, 0);
}
}
@ -438,10 +439,11 @@ doIncr:
}
// input doubleword from port to string
void BX_CPU_C::INSW_YdDX(bxInstruction_c *i)
void BX_CPU_C::INSD_YdDX(bxInstruction_c *i)
{
if (BX_CPU_THIS_PTR cr0.pe && (BX_CPU_THIS_PTR get_VM() || (CPL>BX_CPU_THIS_PTR get_IOPL()))) {
if (! BX_CPU_THIS_PTR allow_io(DX, 4)) {
BX_DEBUG(("INSD_YdDX: I/O access not allowed !"));
exception(BX_GP_EXCEPTION, 0, 0);
}
}
@ -499,6 +501,7 @@ void BX_CPU_C::OUTSB_DXXb(bxInstruction_c *i)
if (BX_CPU_THIS_PTR cr0.pe && (BX_CPU_THIS_PTR get_VM() || (CPL>BX_CPU_THIS_PTR get_IOPL()))) {
if (! BX_CPU_THIS_PTR allow_io(DX, 1)) {
BX_DEBUG(("OUTSB_DXXb: I/O access not allowed !"));
exception(BX_GP_EXCEPTION, 0, 0);
}
}
@ -547,8 +550,10 @@ void BX_CPU_C::OUTSW_DXXw(bxInstruction_c *i)
unsigned incr = 2;
if (BX_CPU_THIS_PTR cr0.pe && (BX_CPU_THIS_PTR get_VM() || (CPL>BX_CPU_THIS_PTR get_IOPL()))) {
if (! BX_CPU_THIS_PTR allow_io(DX, 2))
if (! BX_CPU_THIS_PTR allow_io(DX, 2)) {
BX_DEBUG(("OUTSW_DXXw: I/O access not allowed !"));
exception(BX_GP_EXCEPTION, 0, 0);
}
}
#if BX_SUPPORT_X86_64
@ -640,11 +645,13 @@ doIncr:
}
// output doubleword string to port
void BX_CPU_C::OUTSW_DXXd(bxInstruction_c *i)
void BX_CPU_C::OUTSD_DXXd(bxInstruction_c *i)
{
if (BX_CPU_THIS_PTR cr0.pe && (BX_CPU_THIS_PTR get_VM() || (CPL>BX_CPU_THIS_PTR get_IOPL()))) {
if (! BX_CPU_THIS_PTR allow_io(DX, 4))
if (! BX_CPU_THIS_PTR allow_io(DX, 4)) {
BX_DEBUG(("OUTSD_DXXd: I/O access not allowed !"));
exception(BX_GP_EXCEPTION, 0, 0);
}
}
bx_address esi;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: io_pro.cc,v 1.19 2006-05-21 20:41:48 sshwarts Exp $
// $Id: io_pro.cc,v 1.20 2006-06-09 22:29:07 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -37,15 +37,16 @@ BX_CPU_C::inp16(Bit16u addr)
{
Bit16u ret16;
if (BX_CPU_THIS_PTR cr0.pe && (BX_CPU_THIS_PTR get_VM () || (CPL>BX_CPU_THIS_PTR get_IOPL ()))) {
if ( !BX_CPU_THIS_PTR allow_io(addr, 2) ) {
if (BX_CPU_THIS_PTR cr0.pe && (BX_CPU_THIS_PTR get_VM() || (CPL>BX_CPU_THIS_PTR get_IOPL()))) {
if (! BX_CPU_THIS_PTR allow_io(addr, 2)) {
BX_DEBUG(("inp16(): I/O access not allowed !"));
exception(BX_GP_EXCEPTION, 0, 0);
return(0);
}
}
ret16 = BX_INP(addr, 2);
return( ret16 );
return ret16;
}
void BX_CPP_AttrRegparmN(2)
@ -56,7 +57,8 @@ BX_CPU_C::outp16(Bit16u addr, Bit16u value)
* On the 286, there is no IO permissions map */
if (BX_CPU_THIS_PTR cr0.pe && (BX_CPU_THIS_PTR get_VM() || (CPL>BX_CPU_THIS_PTR get_IOPL()))) {
if ( !BX_CPU_THIS_PTR allow_io(addr, 2) ) {
if (! BX_CPU_THIS_PTR allow_io(addr, 2)) {
BX_DEBUG(("outp16(): I/O access not allowed !"));
exception(BX_GP_EXCEPTION, 0, 0);
return;
}
@ -71,14 +73,15 @@ BX_CPU_C::inp32(Bit16u addr)
Bit32u ret32;
if (BX_CPU_THIS_PTR cr0.pe && (BX_CPU_THIS_PTR get_VM() || (CPL>BX_CPU_THIS_PTR get_IOPL()))) {
if ( !BX_CPU_THIS_PTR allow_io(addr, 4) ) {
if (! BX_CPU_THIS_PTR allow_io(addr, 4)) {
BX_DEBUG(("inp32(): I/O access not allowed !"));
exception(BX_GP_EXCEPTION, 0, 0);
return(0);
}
}
ret32 = BX_INP(addr, 4);
return( ret32 );
return ret32;
}
void BX_CPP_AttrRegparmN(2)
@ -89,7 +92,8 @@ BX_CPU_C::outp32(Bit16u addr, Bit32u value)
* On the 286, there is no IO permissions map */
if (BX_CPU_THIS_PTR cr0.pe && (BX_CPU_THIS_PTR get_VM() || (CPL>BX_CPU_THIS_PTR get_IOPL()))) {
if ( !BX_CPU_THIS_PTR allow_io(addr, 4) ) {
if (! BX_CPU_THIS_PTR allow_io(addr, 4)) {
BX_DEBUG(("outp32(): I/O access not allowed !"));
exception(BX_GP_EXCEPTION, 0, 0);
return;
}
@ -104,14 +108,15 @@ BX_CPU_C::inp8(Bit16u addr)
Bit8u ret8;
if (BX_CPU_THIS_PTR cr0.pe && (BX_CPU_THIS_PTR get_VM() || (CPL>BX_CPU_THIS_PTR get_IOPL()))) {
if ( !BX_CPU_THIS_PTR allow_io(addr, 1) ) {
if (! BX_CPU_THIS_PTR allow_io(addr, 1)) {
BX_DEBUG(("inp8(): I/O access not allowed !"));
exception(BX_GP_EXCEPTION, 0, 0);
return(0);
}
}
ret8 = BX_INP(addr, 1);
return( ret8 );
return ret8;
}
@ -123,7 +128,8 @@ BX_CPU_C::outp8(Bit16u addr, Bit8u value)
* On the 286, there is no IO permissions map */
if (BX_CPU_THIS_PTR cr0.pe && (BX_CPU_THIS_PTR get_VM() || (CPL>BX_CPU_THIS_PTR get_IOPL()))) {
if ( !BX_CPU_THIS_PTR allow_io(addr, 1) ) {
if (! BX_CPU_THIS_PTR allow_io(addr, 1)) {
BX_DEBUG(("outp8(): I/O access not allowed !"));
exception(BX_GP_EXCEPTION, 0, 0);
return;
}

View File

@ -1,5 +1,5 @@
////////////////////////////////////////////////////////////////////////
// $Id: iret.cc,v 1.13 2006-06-05 17:33:25 sshwarts Exp $
// $Id: iret.cc,v 1.14 2006-06-09 22:29:07 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -89,11 +89,11 @@ BX_CPU_C::iret_protected(bxInstruction_c *i)
// new TSS must be busy, else #TS(new TSS selector)
parse_descriptor(dword1, dword2, &tss_descriptor);
if (tss_descriptor.valid==0 || tss_descriptor.segment) {
BX_INFO(("iret: TSS selector points to bad TSS"));
BX_ERROR(("iret: TSS selector points to bad TSS"));
exception(BX_TS_EXCEPTION, raw_link_selector & 0xfffc, 0);
}
if ((tss_descriptor.type!=11) && (tss_descriptor.type!=3)) {
BX_INFO(("iret: TSS selector points to bad TSS"));
BX_ERROR(("iret: TSS selector points to bad TSS"));
exception(BX_TS_EXCEPTION, raw_link_selector & 0xfffc, 0);
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: paging.cc,v 1.73 2006-04-29 17:21:49 sshwarts Exp $
// $Id: paging.cc,v 1.74 2006-06-09 22:29:07 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -571,12 +571,15 @@ void BX_CPU_C::INVLPG(bxInstruction_c* i)
}
// Can not be executed in v8086 mode
if (v8086_mode())
if (v8086_mode()) {
BX_ERROR(("INVLPG: cannot be executed in v8086 mode"));
exception(BX_GP_EXCEPTION, 0, 0);
}
// Protected instruction: CPL0 only
if (BX_CPU_THIS_PTR cr0.pe) {
if (CPL!=0) {
BX_ERROR(("INVLPG: #GP(0) in protected mode with CPL != 0"));
exception(BX_GP_EXCEPTION, 0, 0);
}
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: proc_ctrl.cc,v 1.150 2006-05-21 20:41:48 sshwarts Exp $
// $Id: proc_ctrl.cc,v 1.151 2006-06-09 22:29:07 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -95,6 +95,7 @@ void BX_CPU_C::HLT(bxInstruction_c *i)
BX_PANIC(("HALT instruction encountered in the BIOS ROM"));
if (!real_mode() && CPL!=0) {
BX_ERROR(("HLT: priveledge check failed, generate #GP(0)"));
exception(BX_GP_EXCEPTION, 0, 0);
return;
}
@ -127,7 +128,7 @@ void BX_CPU_C::CLTS(bxInstruction_c *i)
{
// #GP(0) if CPL is not 0
if (!real_mode() && CPL!=0) {
BX_INFO(("CLTS: #GP(0) if CPL is not 0"));
BX_ERROR(("CLTS: priveledge check failed, generate #GP(0)"));
exception(BX_GP_EXCEPTION, 0, 0);
return;
}
@ -144,7 +145,7 @@ void BX_CPU_C::INVD(bxInstruction_c *i)
// protected or v8086 mode
if (BX_CPU_THIS_PTR cr0.pe) {
if (CPL!=0) {
BX_INFO(("INVD: #GP(0) if CPL is not 0"));
BX_ERROR(("INVD: priveledge check failed, generate #GP(0)"));
exception(BX_GP_EXCEPTION, 0, 0);
}
}
@ -169,7 +170,7 @@ void BX_CPU_C::WBINVD(bxInstruction_c *i)
if (BX_CPU_THIS_PTR cr0.pe) {
if (CPL!=0) {
BX_INFO(("WBINVD: #GP(0) if CPL is not 0"));
BX_ERROR(("WBINVD: priveledge check failed, generate #GP(0)"));
exception(BX_GP_EXCEPTION, 0, 0);
}
}
@ -1460,6 +1461,7 @@ bx_bool BX_CPU_C::SetCR4(Bit32u val_32)
&& (!(val_32 >> 5) & 1)
&& (BX_CPU_THIS_PTR cr4.get_PAE()))
{
BX_ERROR(("SetCR4: attempt to change PAE when LMA=1"));
return 0;
}
#endif
@ -1493,10 +1495,10 @@ void BX_CPU_C::RDPMC(bxInstruction_c *i)
#if (BX_CPU_LEVEL == 6 && BX_SUPPORT_SSE >= 2) // Pentium 4 processor (see cpuid.cc)
if ((ECX & 0x7fffffff) >= 18)
exception (BX_GP_EXCEPTION, 0, 0);
exception(BX_GP_EXCEPTION, 0, 0);
#else //
if ((ECX & 0xffffffff) >= 2)
exception (BX_GP_EXCEPTION, 0, 0);
exception(BX_GP_EXCEPTION, 0, 0);
#endif
// Most counters are for hardware specific details, which
// we anyhow do not emulate (like pipeline stalls etc)
@ -1511,7 +1513,7 @@ void BX_CPU_C::RDPMC(bxInstruction_c *i)
BX_ERROR(("RDPMC: Performance Counters Support not reasonably implemented yet"));
} else {
// not allowed to use RDPMC!
exception (BX_GP_EXCEPTION, 0, 0);
exception(BX_GP_EXCEPTION, 0, 0);
}
#else
UndefinedOpcode(i);
@ -1548,7 +1550,7 @@ void BX_CPU_C::RDTSC(bxInstruction_c *i)
} else {
// not allowed to use RDTSC!
BX_ERROR(("RDTSC: incorrect usage of RDTSC instruction !"));
exception (BX_GP_EXCEPTION, 0, 0);
exception(BX_GP_EXCEPTION, 0, 0);
}
#else
BX_INFO(("RDTSC: Pentium CPU required, use --enable-cpu=5"));
@ -1804,6 +1806,7 @@ void BX_CPU_C::WRMSR(bxInstruction_c *i)
if ((BX_CPU_THIS_PTR msr.lme != ((EAX >> 8) & 1)) &&
(BX_CPU_THIS_PTR cr0.pg == 1))
{
BX_ERROR(("WRMSR: attempt to change LME when CR0.PG=1"));
exception(BX_GP_EXCEPTION, 0, 0);
}
BX_CPU_THIS_PTR msr.sce = (EAX >> 0) & 1;
@ -1865,13 +1868,13 @@ void BX_CPU_C::SYSENTER (bxInstruction_c *i)
{
#if BX_SUPPORT_SEP
if (!protected_mode ()) {
BX_INFO (("sysenter not from protected mode"));
exception (BX_GP_EXCEPTION, 0, 0);
BX_INFO(("sysenter not from protected mode !"));
exception(BX_GP_EXCEPTION, 0, 0);
return;
}
if ((BX_CPU_THIS_PTR msr.sysenter_cs_msr & BX_SELECTOR_RPL_MASK) == 0) {
BX_INFO (("sysenter with zero sysenter_cs_msr"));
exception (BX_GP_EXCEPTION, 0, 0);
BX_INFO(("sysenter with zero sysenter_cs_msr !"));
exception(BX_GP_EXCEPTION, 0, 0);
return;
}
@ -1927,16 +1930,16 @@ void BX_CPU_C::SYSEXIT (bxInstruction_c *i)
{
#if BX_SUPPORT_SEP
if (!protected_mode ()) {
BX_INFO (("sysexit not from protected mode"));
exception (BX_GP_EXCEPTION, 0, 0);
BX_INFO(("sysexit not from protected mode !"));
exception(BX_GP_EXCEPTION, 0, 0);
}
if ((BX_CPU_THIS_PTR msr.sysenter_cs_msr & BX_SELECTOR_RPL_MASK) == 0) {
BX_INFO (("sysexit with zero sysenter_cs_msr"));
exception (BX_GP_EXCEPTION, 0, 0);
BX_INFO(("sysexit with zero sysenter_cs_msr !"));
exception(BX_GP_EXCEPTION, 0, 0);
}
if (CPL != 0) {
BX_INFO (("sysexit at non-zero cpl %u", CPL));
exception (BX_GP_EXCEPTION, 0, 0);
BX_INFO(("sysexit at non-zero cpl %u !", CPL));
exception(BX_GP_EXCEPTION, 0, 0);
}
invalidate_prefetch_q();
@ -2058,6 +2061,8 @@ SYSCALL_LEGACY_MODE:
bx_selector_t cs_selector,ss_selector;
Bit32u dword1, dword2;
BX_DEBUG(("Execute SYSCALL instruction"));
if (!BX_CPU_THIS_PTR msr.sce) {
exception(BX_UD_EXCEPTION, 0, 0);
}
@ -2174,11 +2179,14 @@ SYSRET_NON_64BIT_MODE:
bx_selector_t cs_selector,ss_selector;
Bit32u dword1, dword2;
BX_DEBUG(("Execute SYSRET instruction"));
if (!BX_CPU_THIS_PTR msr.sce) {
exception(BX_UD_EXCEPTION, 0, 0);
}
if(real_mode() || CPL != 0) {
BX_ERROR(("SYSRET: priveledge check failed, generate #GP(0)"));
exception(BX_GP_EXCEPTION, 0, 0);
}

View File

@ -1,5 +1,5 @@
////////////////////////////////////////////////////////////////////////
// $Id: ret_far.cc,v 1.5 2006-03-06 22:03:02 sshwarts Exp $
// $Id: ret_far.cc,v 1.6 2006-06-09 22:29:07 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -67,7 +67,7 @@ BX_CPU_C::return_protected(bxInstruction_c *i, Bit16u pop_bytes)
}
#if BX_SUPPORT_X86_64
if ( i->os64L() ) {
if (i->os64L()) {
/* operand size=64: 2nd qword on stack must be within stack limits,
* else #SS(0); */
if (!can_pop(16))
@ -85,10 +85,10 @@ BX_CPU_C::return_protected(bxInstruction_c *i, Bit16u pop_bytes)
}
else
#endif
if ( i->os32L() ) {
if (i->os32L()) {
/* operand size=32: 2nd dword on stack must be within stack limits,
* else #SS(0); */
if (!can_pop(8))
if (! can_pop(8))
{
BX_ERROR(("return_protected: 2rd dword not in stack limits"));
exception(BX_SS_EXCEPTION, 0, 0);
@ -106,7 +106,7 @@ BX_CPU_C::return_protected(bxInstruction_c *i, Bit16u pop_bytes)
else {
/* operand size=16: second word on stack must be within stack limits,
* else #SS(0); */
if ( !can_pop(4) )
if (! can_pop(4))
{
BX_ERROR(("return_protected: 2nd word not in stack limits"));
exception(BX_SS_EXCEPTION, 0, 0);
@ -123,8 +123,8 @@ BX_CPU_C::return_protected(bxInstruction_c *i, Bit16u pop_bytes)
}
// selector must be non-null else #GP(0)
if ( (raw_cs_selector & 0xfffc) == 0 ) {
BX_INFO(("return_protected: CS selector null"));
if ((raw_cs_selector & 0xfffc) == 0) {
BX_ERROR(("return_protected: CS selector null"));
exception(BX_GP_EXCEPTION, 0, 0);
}
@ -187,7 +187,7 @@ BX_CPU_C::return_protected(bxInstruction_c *i, Bit16u pop_bytes)
#if BX_SUPPORT_X86_64
if (i->os64L()) {
/* top 32+immediate bytes on stack must be within stack limits, else #SS(0) */
if ( !can_pop(32 + pop_bytes) ) {
if (! can_pop(32 + pop_bytes)) {
BX_ERROR(("return_protected: 32 bytes not within stack limits"));
exception(BX_SS_EXCEPTION, 0, 0);
}
@ -201,7 +201,7 @@ BX_CPU_C::return_protected(bxInstruction_c *i, Bit16u pop_bytes)
#endif
if (i->os32L()) {
/* top 16+immediate bytes on stack must be within stack limits, else #SS(0) */
if ( !can_pop(16 + pop_bytes) ) {
if (! can_pop(16 + pop_bytes)) {
BX_ERROR(("return_protected: 16 bytes not within stack limits"));
exception(BX_SS_EXCEPTION, 0, 0);
}
@ -215,7 +215,7 @@ BX_CPU_C::return_protected(bxInstruction_c *i, Bit16u pop_bytes)
}
else {
/* top 8+immediate bytes on stack must be within stack limits, else #SS(0) */
if ( !can_pop(8 + pop_bytes) ) {
if (! can_pop(8 + pop_bytes)) {
BX_ERROR(("return_protected: 8 bytes not within stack limits"));
exception(BX_SS_EXCEPTION, 0, 0);
}
@ -262,7 +262,7 @@ BX_CPU_C::return_protected(bxInstruction_c *i, Bit16u pop_bytes)
ss_descriptor.u.segment.executable ||
ss_descriptor.u.segment.r_w==0)
{
BX_PANIC(("return_protected: SS.AR byte not writable data"));
BX_ERROR(("return_protected: SS.AR byte not writable data"));
exception(BX_GP_EXCEPTION, raw_ss_selector & 0xfffc, 0);
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: segment_ctrl_pro.cc,v 1.62 2006-05-27 14:02:34 sshwarts Exp $
// $Id: segment_ctrl_pro.cc,v 1.63 2006-06-09 22:29:07 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -154,8 +154,8 @@ BX_CPU_C::load_seg_reg(bx_segment_reg_t *seg, Bit16u new_value)
/* If data or non-conforming code, then both the RPL and the CPL
* must be less than or equal to DPL in AR byte else #GP(selector) */
if ( descriptor.u.segment.executable==0 ||
descriptor.u.segment.c_ed==0 )
if (descriptor.u.segment.executable==0 ||
descriptor.u.segment.c_ed==0)
{
if ((selector.rpl > descriptor.dpl) || (CPL > descriptor.dpl)) {
BX_ERROR(("load_seg_reg(%s): RPL & CPL must be <= DPL", strseg(seg)));

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: soft_int.cc,v 1.29 2006-05-21 20:41:48 sshwarts Exp $
// $Id: soft_int.cc,v 1.30 2006-06-09 22:29:07 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -133,6 +133,7 @@ void BX_CPU_C::INT_Ib(bxInstruction_c *i)
// interrupt is not redirected or VME is OFF
if (BX_CPU_THIS_PTR get_IOPL() < 3)
{
BX_DEBUG(("INT_Ib(): Interrupt cannot be redirected, generate #GP(0)"));
exception(BX_GP_EXCEPTION, 0, 0);
}
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: tasking.cc,v 1.33 2006-05-21 20:41:48 sshwarts Exp $
// $Id: tasking.cc,v 1.34 2006-06-09 22:29:07 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -135,7 +135,7 @@ void BX_CPU_C::task_switch(bx_selector_t *tss_selector,
unsigned exception_no = 256; // no exception
Bit16u error_code = 0;
BX_DEBUG(( "TASKING: ENTER" ));
BX_DEBUG(("TASKING: ENTER"));
invalidate_prefetch_q();
@ -749,9 +749,10 @@ void BX_CPU_C::get_SS_ESP_from_TSS(unsigned pl, Bit16u *ss, Bit32u *esp)
if (BX_CPU_THIS_PTR tr.cache.type==BX_SYS_SEGMENT_AVAIL_386_TSS) {
// 32-bit TSS
Bit32u TSSstackaddr = 8*pl + 4;
if ((TSSstackaddr+7) > BX_CPU_THIS_PTR tr.cache.u.tss.limit_scaled)
if ((TSSstackaddr+7) > BX_CPU_THIS_PTR tr.cache.u.tss.limit_scaled) {
BX_DEBUG(("get_SS_ESP_from_TSS(386): TSSstackaddr > TSS.LIMIT"));
exception(BX_TS_EXCEPTION, BX_CPU_THIS_PTR tr.selector.value & 0xfffc, 0);
}
access_linear(BX_CPU_THIS_PTR tr.cache.u.tss.base +
TSSstackaddr+4, 2, 0, BX_READ, ss);
access_linear(BX_CPU_THIS_PTR tr.cache.u.tss.base +
@ -761,9 +762,10 @@ void BX_CPU_C::get_SS_ESP_from_TSS(unsigned pl, Bit16u *ss, Bit32u *esp)
// 16-bit TSS
Bit16u temp16;
Bit32u TSSstackaddr = 4*pl + 2;
if ((TSSstackaddr+4) > BX_CPU_THIS_PTR tr.cache.u.tss.limit_scaled)
if ((TSSstackaddr+4) > BX_CPU_THIS_PTR tr.cache.u.tss.limit_scaled) {
BX_DEBUG(("get_SS_ESP_from_TSS(286): TSSstackaddr > TSS.LIMIT"));
exception(BX_TS_EXCEPTION, BX_CPU_THIS_PTR tr.selector.value & 0xfffc, 0);
}
access_linear(BX_CPU_THIS_PTR tr.cache.u.tss.base +
TSSstackaddr+2, 2, 0, BX_READ, ss);
access_linear(BX_CPU_THIS_PTR tr.cache.u.tss.base +
@ -784,12 +786,13 @@ void BX_CPU_C::get_RSP_from_TSS(unsigned pl, Bit64u *rsp)
// 32-bit TSS
Bit32u TSSstackaddr = 8*pl + 4;
if ((TSSstackaddr+7) > BX_CPU_THIS_PTR tr.cache.u.tss.limit_scaled)
exception(BX_TS_EXCEPTION,
BX_CPU_THIS_PTR tr.selector.value & 0xfffc, 0);
if ((TSSstackaddr+7) > BX_CPU_THIS_PTR tr.cache.u.tss.limit_scaled) {
BX_DEBUG(("get_RSP_from_TSS(): TSSstackaddr > TSS.LIMIT"));
exception(BX_TS_EXCEPTION, BX_CPU_THIS_PTR tr.selector.value & 0xfffc, 0);
}
access_linear(BX_CPU_THIS_PTR tr.cache.u.tss.base +
TSSstackaddr, 8, 0, BX_READ, rsp);
TSSstackaddr, 8, 0, BX_READ, rsp);
}
#endif // #if BX_SUPPORT_X86_64