Generate #GP exception instead of #TS when TSS selector points to bad TSS
This commit is contained in:
parent
1f2cde53f0
commit
f863d1e902
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: apic.h,v 1.22 2005-12-11 21:58:53 sshwarts Exp $
|
||||
// $Id: apic.h,v 1.23 2005-12-12 19:44:06 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -30,7 +30,6 @@
|
||||
# define BX_CPU_APIC_H 1
|
||||
|
||||
typedef enum {
|
||||
APIC_TYPE_NONE,
|
||||
APIC_TYPE_IOAPIC,
|
||||
APIC_TYPE_LOCAL_APIC
|
||||
} bx_apic_type_t;
|
||||
|
@ -1,5 +1,5 @@
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// $Id: call_far.cc,v 1.6 2005-08-04 19:38:49 sshwarts Exp $
|
||||
// $Id: call_far.cc,v 1.7 2005-12-12 19:44:06 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -157,25 +157,26 @@ BX_CPU_C::call_protected(bxInstruction_c *i, Bit16u cs_raw, bx_address disp)
|
||||
// must specify global in the local/global bit else #TS(TSS selector)
|
||||
raw_tss_selector = gate_descriptor.u.taskgate.tss_selector;
|
||||
parse_selector(raw_tss_selector, &tss_selector);
|
||||
|
||||
if (tss_selector.ti) {
|
||||
BX_ERROR(("call_protected: tss_selector.ti=1"));
|
||||
exception(BX_TS_EXCEPTION, raw_tss_selector & 0xfffc, 0);
|
||||
exception(BX_GP_EXCEPTION, raw_tss_selector & 0xfffc, 0);
|
||||
}
|
||||
|
||||
// index must be within GDT limits else #TS(TSS selector)
|
||||
fetch_raw_descriptor(&tss_selector, &dword1, &dword2, BX_TS_EXCEPTION);
|
||||
fetch_raw_descriptor(&tss_selector, &dword1, &dword2, BX_GP_EXCEPTION);
|
||||
|
||||
// descriptor AR byte must specify available TSS
|
||||
// else #TS(TSS selector)
|
||||
parse_descriptor(dword1, dword2, &tss_descriptor);
|
||||
|
||||
// descriptor AR byte must specify available TSS
|
||||
// else #GP(TSS selector)
|
||||
if (tss_descriptor.valid==0 || tss_descriptor.segment) {
|
||||
BX_ERROR(("call_protected: TSS selector points to bad TSS"));
|
||||
exception(BX_TS_EXCEPTION, raw_tss_selector & 0xfffc, 0);
|
||||
exception(BX_GP_EXCEPTION, raw_tss_selector & 0xfffc, 0);
|
||||
}
|
||||
if (tss_descriptor.type!=9 && tss_descriptor.type!=1) {
|
||||
BX_ERROR(("call_protected: TSS selector points to bad TSS"));
|
||||
exception(BX_TS_EXCEPTION, raw_tss_selector & 0xfffc, 0);
|
||||
exception(BX_GP_EXCEPTION, raw_tss_selector & 0xfffc, 0);
|
||||
}
|
||||
|
||||
// task state segment must be present, else #NP(tss selector)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: cpu.cc,v 1.116 2005-12-09 21:21:29 sshwarts Exp $
|
||||
// $Id: cpu.cc,v 1.117 2005-12-12 19:44:06 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -302,12 +302,13 @@ void BX_CPU_C::cpu_loop(Bit32s max_instr_count)
|
||||
// or the boundary fetch (across pages), by this point.
|
||||
BX_INSTR_FETCH_DECODE_COMPLETED(BX_CPU_ID, i);
|
||||
|
||||
#if BX_DEBUGGER
|
||||
//#if BX_DEBUGGER
|
||||
if (BX_CPU_THIS_PTR trace) {
|
||||
// print the instruction that is about to be executed.
|
||||
bx_dbg_disassemble_current (BX_CPU_ID, 1); // only one cpu, print time stamp
|
||||
debug(BX_CPU_THIS_PTR prev_eip);
|
||||
// bx_dbg_disassemble_current (BX_CPU_ID, 1); // only one cpu, print time stamp
|
||||
}
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
// decoding instruction compeleted -> continue with execution
|
||||
BX_INSTR_BEFORE_EXECUTION(BX_CPU_ID, i);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: cpu.h,v 1.247 2005-11-26 21:36:51 sshwarts Exp $
|
||||
// $Id: cpu.h,v 1.248 2005-12-12 19:44:06 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -1179,7 +1179,6 @@ public: // for now...
|
||||
Bit8u magic_break;
|
||||
#endif
|
||||
Bit8u stop_reason;
|
||||
Bit8u trace;
|
||||
Bit8u trace_reg;
|
||||
Bit8u mode_break; /* BW */
|
||||
bx_bool debug_vm; /* BW contains current mode*/
|
||||
@ -1187,6 +1186,7 @@ public: // for now...
|
||||
Bit8u show_flag; /* BW shows instr class executed */
|
||||
bx_guard_found_t guard_found;
|
||||
#endif
|
||||
Bit8u trace;
|
||||
|
||||
#if BX_GDBSTUB
|
||||
Bit8u ispanic;
|
||||
@ -2795,13 +2795,13 @@ public: // for now...
|
||||
BX_SMF void load_cs(bx_selector_t *selector, bx_descriptor_t *descriptor, Bit8u cpl) BX_CPP_AttrRegparmN(3);
|
||||
BX_SMF void load_ss(bx_selector_t *selector, bx_descriptor_t *descriptor, Bit8u cpl) BX_CPP_AttrRegparmN(3);
|
||||
BX_SMF void fetch_raw_descriptor(bx_selector_t *selector,
|
||||
Bit32u *dword1, Bit32u *dword2, Bit8u exception) BX_CPP_AttrRegparmN(3);
|
||||
Bit32u *dword1, Bit32u *dword2, unsigned exception) BX_CPP_AttrRegparmN(3);
|
||||
BX_SMF bx_bool fetch_raw_descriptor2(bx_selector_t *selector,
|
||||
Bit32u *dword1, Bit32u *dword2) BX_CPP_AttrRegparmN(3);
|
||||
BX_SMF void load_seg_reg(bx_segment_reg_t *seg, Bit16u new_value) BX_CPP_AttrRegparmN(2);
|
||||
#if BX_SUPPORT_X86_64
|
||||
BX_SMF void fetch_raw_descriptor64(bx_selector_t *selector,
|
||||
Bit32u *dword1, Bit32u *dword2, Bit32u *dword3, Bit8u exception_no);
|
||||
Bit32u *dword1, Bit32u *dword2, Bit32u *dword3, unsigned exception_no);
|
||||
BX_SMF void loadSRegLMNominal(unsigned seg, unsigned selector,
|
||||
bx_address base, unsigned dpl);
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: exception.cc,v 1.65 2005-10-17 13:06:09 sshwarts Exp $
|
||||
// $Id: exception.cc,v 1.66 2005-12-12 19:44:06 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -343,29 +343,26 @@ void BX_CPU_C::protected_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error
|
||||
parse_selector(raw_tss_selector, &tss_selector);
|
||||
|
||||
// must specify global in the local/global bit,
|
||||
// else #TS(TSS selector)
|
||||
// +++
|
||||
// 486/Pent books say #TSS(selector)
|
||||
// PPro+ says #GP(selector)
|
||||
// else #GP(TSS selector)
|
||||
if (tss_selector.ti) {
|
||||
BX_PANIC(("interrupt: tss_selector.ti=1"));
|
||||
exception(BX_TS_EXCEPTION, raw_tss_selector & 0xfffc, 0);
|
||||
exception(BX_GP_EXCEPTION, raw_tss_selector & 0xfffc, 0);
|
||||
}
|
||||
|
||||
// index must be within GDT limits, else #TS(TSS selector)
|
||||
fetch_raw_descriptor(&tss_selector, &dword1, &dword2, BX_TS_EXCEPTION);
|
||||
|
||||
// AR byte must specify available TSS,
|
||||
// else #TS(TSS selector)
|
||||
parse_descriptor(dword1, dword2, &tss_descriptor);
|
||||
|
||||
// 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"));
|
||||
exception(BX_TS_EXCEPTION, raw_tss_selector & 0xfffc, 0);
|
||||
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"));
|
||||
exception(BX_TS_EXCEPTION, raw_tss_selector & 0xfffc, 0);
|
||||
exception(BX_GP_EXCEPTION, raw_tss_selector & 0xfffc, 0);
|
||||
}
|
||||
|
||||
// TSS must be present, else #NP(TSS selector)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: fetchdecode.h,v 1.18 2005-09-23 16:45:41 sshwarts Exp $
|
||||
// $Id: fetchdecode.h,v 1.19 2005-12-12 19:44:06 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2003 Stanislav Shwartsman
|
||||
@ -159,7 +159,7 @@ static BxOpcodeInfo_t BxOpcodeInfo_FPGroupDB[8] = {
|
||||
/* 0 */ { 0, &BX_CPU_C::FILD_DWORD_INTEGER },
|
||||
/* 1 */ { 0, &BX_CPU_C::FISTTP32 },
|
||||
/* 2 */ { 0, &BX_CPU_C::FIST_DWORD_INTEGER },
|
||||
/* 3 */ { 0, &BX_CPU_C::FIST_DWORD_INTEGER }, // FISTP
|
||||
/* 3 */ { 0, &BX_CPU_C::FIST_DWORD_INTEGER }, // FISTP_DWORD_INTEGER
|
||||
/* 4 */ { 0, &BX_CPU_C::BxError },
|
||||
/* 5 */ { 0, &BX_CPU_C::FLD_EXTENDED_REAL },
|
||||
/* 6 */ { 0, &BX_CPU_C::BxError },
|
||||
@ -195,7 +195,7 @@ static BxOpcodeInfo_t BxOpcodeInfo_FPGroupDE[8] = {
|
||||
/* 0 */ { 0, &BX_CPU_C::FIADD_WORD_INTEGER },
|
||||
/* 1 */ { 0, &BX_CPU_C::FIMUL_WORD_INTEGER },
|
||||
/* 2 */ { 0, &BX_CPU_C::FICOM_WORD_INTEGER },
|
||||
/* 3 */ { 0, &BX_CPU_C::FICOM_WORD_INTEGER }, // FISTP_WORD_INTEGER
|
||||
/* 3 */ { 0, &BX_CPU_C::FICOM_WORD_INTEGER }, // FICOMP_WORD_INTEGER
|
||||
/* 4 */ { 0, &BX_CPU_C::FISUB_WORD_INTEGER },
|
||||
/* 5 */ { 0, &BX_CPU_C::FISUBR_WORD_INTEGER },
|
||||
/* 6 */ { 0, &BX_CPU_C::FIDIV_WORD_INTEGER },
|
||||
@ -207,7 +207,7 @@ static BxOpcodeInfo_t BxOpcodeInfo_FPGroupDF[8] = {
|
||||
/* 0 */ { 0, &BX_CPU_C::FILD_WORD_INTEGER },
|
||||
/* 1 */ { 0, &BX_CPU_C::FISTTP16 },
|
||||
/* 2 */ { 0, &BX_CPU_C::FIST_WORD_INTEGER },
|
||||
/* 3 */ { 0, &BX_CPU_C::FIST_WORD_INTEGER }, // FISTP
|
||||
/* 3 */ { 0, &BX_CPU_C::FIST_WORD_INTEGER }, // FISTP_WORD_INTEGER
|
||||
/* 4 */ { 0, &BX_CPU_C::FBLD_PACKED_BCD },
|
||||
/* 5 */ { 0, &BX_CPU_C::FILD_QWORD_INTEGER },
|
||||
/* 6 */ { 0, &BX_CPU_C::FBSTP_PACKED_BCD },
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: proc_ctrl.cc,v 1.125 2005-11-27 18:36:19 sshwarts Exp $
|
||||
// $Id: proc_ctrl.cc,v 1.126 2005-12-12 19:44:06 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -47,6 +47,12 @@ void BX_CPU_C::UndefinedOpcode(bxInstruction_c *i)
|
||||
void BX_CPU_C::NOP(bxInstruction_c *i)
|
||||
{
|
||||
// No operation.
|
||||
/*
|
||||
if (i->repUsedL()) {
|
||||
// BX_CPU_THIS_PTR trace = 1;
|
||||
BX_TICKN(128);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void BX_CPU_C::PREFETCH(bxInstruction_c *i)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: segment_ctrl_pro.cc,v 1.49 2005-11-07 22:45:25 sshwarts Exp $
|
||||
// $Id: segment_ctrl_pro.cc,v 1.50 2005-12-12 19:44:06 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -476,7 +476,7 @@ BX_CPU_C::load_ss(bx_selector_t *selector, bx_descriptor_t *descriptor, Bit8u cp
|
||||
#if BX_CPU_LEVEL >= 2
|
||||
void BX_CPP_AttrRegparmN(3)
|
||||
BX_CPU_C::fetch_raw_descriptor(bx_selector_t *selector,
|
||||
Bit32u *dword1, Bit32u *dword2, Bit8u exception_no)
|
||||
Bit32u *dword1, Bit32u *dword2, unsigned exception_no)
|
||||
{
|
||||
if (selector->ti == 0) { /* GDT */
|
||||
if ((selector->index*8 + 7) > BX_CPU_THIS_PTR gdtr.limit) {
|
||||
@ -509,8 +509,7 @@ BX_CPU_C::fetch_raw_descriptor(bx_selector_t *selector,
|
||||
}
|
||||
|
||||
bx_bool BX_CPP_AttrRegparmN(3)
|
||||
BX_CPU_C::fetch_raw_descriptor2(bx_selector_t *selector,
|
||||
Bit32u *dword1, Bit32u *dword2)
|
||||
BX_CPU_C::fetch_raw_descriptor2(bx_selector_t *selector, Bit32u *dword1, Bit32u *dword2)
|
||||
{
|
||||
if (selector->ti == 0) { /* GDT */
|
||||
if ((selector->index*8 + 7) > BX_CPU_THIS_PTR gdtr.limit)
|
||||
@ -538,7 +537,7 @@ BX_CPU_C::fetch_raw_descriptor2(bx_selector_t *selector,
|
||||
|
||||
#if BX_SUPPORT_X86_64
|
||||
void BX_CPU_C::fetch_raw_descriptor64(bx_selector_t *selector,
|
||||
Bit32u *dword1, Bit32u *dword2, Bit32u *dword3, Bit8u exception_no)
|
||||
Bit32u *dword1, Bit32u *dword2, Bit32u *dword3, unsigned exception_no)
|
||||
{
|
||||
if (selector->ti == 0) { /* GDT */
|
||||
if ((selector->index*8 + 15) > BX_CPU_THIS_PTR gdtr.limit) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user