Fixed bug with jumping from long mode when executing interrupt

This commit is contained in:
Stanislav Shwartsman 2005-03-30 22:31:03 +00:00
parent 1bd414c4df
commit 6d491de4d3
4 changed files with 13 additions and 20 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: cpu.h,v 1.212 2005-03-30 20:52:42 sshwarts Exp $
// $Id: cpu.h,v 1.213 2005-03-30 22:30:37 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -451,10 +451,12 @@ typedef struct {
} \
} \
BX_CPP_INLINE void BX_CPU_C::clear_VM() { \
BX_CPU_THIS_PTR eflags.val32 &= ~(1<<bitnum); \
BX_CPU_THIS_PTR eflags.VM_cached = 0; \
if (BX_CPU_THIS_PTR cr0.pe) { \
BX_CPU_THIS_PTR cpu_mode = BX_MODE_IA32_PROTECTED; \
if (BX_CPU_THIS_PTR eflags.VM_cached) { \
BX_CPU_THIS_PTR eflags.val32 &= ~(1<<bitnum); \
BX_CPU_THIS_PTR eflags.VM_cached = 0; \
if (BX_CPU_THIS_PTR cr0.pe) { \
BX_CPU_THIS_PTR cpu_mode = BX_MODE_IA32_PROTECTED; \
} \
} \
} \
BX_CPP_INLINE Bit32u BX_CPU_C::get_VM() { \

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: debugstuff.cc,v 1.37 2005-03-30 19:56:02 sshwarts Exp $
// $Id: debugstuff.cc,v 1.38 2005-03-30 22:31:02 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -215,7 +215,7 @@ void BX_CPU_C::debug(bx_address offset)
Base,
EIP, instr_buf, char_buf);
#if BX_SUPPORT_X86_64
isize = 16;
if (BX_CPU_THIS_PTR cpu_mode == BX_MODE_LONG_64) isize = 16;
#endif
for (unsigned j=0; j<isize; j++)
BX_INFO((">> %02x", (unsigned) instr_buf[j]));

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: exception.cc,v 1.52 2005-03-30 21:43:08 sshwarts Exp $
// $Id: exception.cc,v 1.53 2005-03-30 22:31:03 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -232,9 +232,6 @@ void BX_CPU_C::interrupt(Bit8u vector, bx_bool is_INT, bx_bool is_error_code, Bi
// load new RSP values from TSS
int savemode = BX_CPU_THIS_PTR cpu_mode;
BX_CPU_THIS_PTR cpu_mode = BX_MODE_LONG_64;
// need to switch to 64 bit mode temporarily here.
// this means that any exception after here might be delivered
// a little insanely. Like faults are page faults..
@ -266,7 +263,6 @@ void BX_CPU_C::interrupt(Bit8u vector, bx_bool is_INT, bx_bool is_error_code, Bi
if ( is_error_code )
push_64(error_code);
BX_CPU_THIS_PTR cpu_mode = savemode;
load_cs(&cs_selector, &cs_descriptor, cs_descriptor.dpl);
RIP = gate_dest_offset;
@ -298,9 +294,6 @@ void BX_CPU_C::interrupt(Bit8u vector, bx_bool is_INT, bx_bool is_error_code, Bi
// align stack
RSP = RSP & BX_CONST64(0xfffffffffffffff0);
int savemode = BX_CPU_THIS_PTR cpu_mode;
BX_CPU_THIS_PTR cpu_mode = BX_MODE_LONG_64;
// push flags onto stack
// push current CS selector onto stack
// push return offset onto stack
@ -312,8 +305,6 @@ void BX_CPU_C::interrupt(Bit8u vector, bx_bool is_INT, bx_bool is_error_code, Bi
if ( is_error_code )
push_64(error_code);
BX_CPU_THIS_PTR cpu_mode = savemode;
// load CS:IP from gate
// load CS descriptor
// set the RPL field of CS to CPL

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: segment_ctrl_pro.cc,v 1.34 2005-03-30 20:53:04 sshwarts Exp $
// $Id: segment_ctrl_pro.cc,v 1.35 2005-03-30 22:31:03 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -560,11 +560,11 @@ 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"));
BX_DEBUG(("Long Mode Activated"));
loadSRegLMNominal(BX_SEG_REG_CS, selector->value, 0, cpl);
}
else {
BX_INFO(("Compatibility Mode Activated"));
BX_DEBUG(("Compatibility Mode Activated"));
BX_CPU_THIS_PTR cpu_mode = BX_MODE_LONG_COMPAT;
}
}