Fixed compatability mode execution bug, compatability mode and long mode should be treated as protected for all protected_mode() checks

This commit is contained in:
Stanislav Shwartsman 2005-03-29 21:37:06 +00:00
parent e1aee85d19
commit da9091f04a
3 changed files with 11 additions and 10 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: cpu.h,v 1.210 2005-03-25 21:33:47 kevinlawton Exp $
// $Id: cpu.h,v 1.211 2005-03-29 21:37:06 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -329,10 +329,10 @@
#endif
#define BX_MODE_IA32_REAL 0x0 // CR0.PE=0
#define BX_MODE_IA32_PROTECTED 0x1 // CR0.PE=1, EFLAGS.VM=0
#define BX_MODE_IA32_V8086 0x2 // CR0.PE=1, EFLAGS.VM=1
#define BX_MODE_LONG_COMPAT 0x3 // EFER.LMA = 0, EFER.LME = 1
#define BX_MODE_LONG_64 0x4 // EFER.LMA = 1, EFER.LME = 1
#define BX_MODE_IA32_V8086 0x1 // CR0.PE=1, EFLAGS.VM=1
#define BX_MODE_IA32_PROTECTED 0x2 // CR0.PE=1, EFLAGS.VM=0
#define BX_MODE_LONG_COMPAT 0x3 // EFER.LMA = 0, EFER.LME = 1, CR0.PE=1
#define BX_MODE_LONG_64 0x4 // EFER.LMA = 1, EFER.LME = 1, CR0.PE=1
#if BX_SUPPORT_X86_64
#define IsLongMode() (BX_CPU_THIS_PTR cpu_mode == BX_MODE_LONG_64)
@ -2941,7 +2941,7 @@ BX_CPP_INLINE bx_bool BX_CPU_C::v8086_mode(void)
BX_CPP_INLINE bx_bool BX_CPU_C::protected_mode(void)
{
return (BX_CPU_THIS_PTR cpu_mode == BX_MODE_IA32_PROTECTED);
return (BX_CPU_THIS_PTR cpu_mode >= BX_MODE_IA32_PROTECTED);
}
BX_CPP_INLINE void

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: protect_ctrl.cc,v 1.37 2005-03-22 18:19:55 kevinlawton Exp $
// $Id: protect_ctrl.cc,v 1.38 2005-03-29 21:37:06 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -469,7 +469,7 @@ void BX_CPU_C::LTR_Ew(bxInstruction_c *i)
access_linear(BX_CPU_THIS_PTR gdtr.base + selector.index*8 + 8, 4, 0,
BX_READ, &dword3);
descriptor.u.tss386.base |= ((Bit64u)dword3 << 32);
BX_INFO(("64 bit tss base = %08x%08x\n",(Bit32u)(descriptor.u.tss386.base >> 32),(Bit32u)descriptor.u.tss386.base));
BX_INFO(("64 bit tss base = 0x%08x%08x",(Bit32u)(descriptor.u.tss386.base >> 32),(Bit32u)descriptor.u.tss386.base));
}
#endif

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: segment_ctrl_pro.cc,v 1.32 2005-03-12 18:38:56 sshwarts Exp $
// $Id: segment_ctrl_pro.cc,v 1.33 2005-03-29 21:37:06 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -560,8 +560,9 @@ BX_CPU_C::load_cs(bx_selector_t *selector, bx_descriptor_t *descriptor,
if (BX_CPU_THIS_PTR msr.lma) {
if (descriptor->u.segment.l) {
BX_CPU_THIS_PTR cpu_mode = BX_MODE_LONG_64;
BX_INFO(("Long Mode Activated"));
loadSRegLMNominal(BX_SEG_REG_CS, selector->value, 0, cpl);
}
}
else {
BX_CPU_THIS_PTR cpu_mode = BX_MODE_LONG_COMPAT;
}