This commit is contained in:
Stanislav Shwartsman 2010-04-02 21:22:17 +00:00
parent 9d3eee21fc
commit 93220f6b6e
3 changed files with 37 additions and 42 deletions

View File

@ -1,5 +1,5 @@
////////////////////////////////////////////////////////////////////////
// $Id: ctrl_xfer_pro.cc,v 1.84 2010-03-14 15:51:26 sshwarts Exp $
// $Id: ctrl_xfer_pro.cc,v 1.85 2010-04-02 21:22:17 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2009 The Bochs Project
@ -42,12 +42,9 @@ void BX_CPU_C::check_cs(bx_descriptor_t *descriptor, Bit16u cs_raw, Bit8u check_
}
#if BX_SUPPORT_X86_64
if (descriptor->u.segment.l) {
if (! BX_CPU_THIS_PTR efer.get_LMA()) {
BX_ERROR(("check_cs(0x%04x): attempt to jump to long mode without enabling EFER.LMA !", cs_raw));
}
else if (descriptor->u.segment.d_b) {
BX_ERROR(("check_cs(0x%04x): Both L and D bits enabled for segment descriptor !", cs_raw));
if (long_mode()) {
if (descriptor->u.segment.l && descriptor->u.segment.d_b) {
BX_ERROR(("check_cs(0x%04x): Both CS.L and CS.D_B bits enabled !", cs_raw));
exception(BX_GP_EXCEPTION, cs_raw & 0xfffc);
}
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: proc_ctrl.cc,v 1.327 2010-03-27 16:30:01 sshwarts Exp $
// $Id: proc_ctrl.cc,v 1.328 2010-04-02 21:22:17 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2010 The Bochs Project
@ -920,23 +920,19 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::SYSEXIT(bxInstruction_c *i)
exception(BX_GP_EXCEPTION, 0);
}
#if BX_SUPPORT_X86_64
if (i->os64L()) {
if (!IsCanonical(RDX)) {
BX_ERROR(("SYSEXIT with non-canonical RDX (RIP) pointer !"));
exception(BX_GP_EXCEPTION, 0);
}
if (!IsCanonical(RCX)) {
BX_ERROR(("SYSEXIT with non-canonical RCX (RSP) pointer !"));
exception(BX_GP_EXCEPTION, 0);
}
}
#endif
invalidate_prefetch_q();
#if BX_SUPPORT_X86_64
if (i->os64L()) {
if (!IsCanonical(RDX)) {
BX_ERROR(("SYSEXIT with non-canonical RDX (RIP) pointer !"));
exception(BX_GP_EXCEPTION, 0);
}
if (!IsCanonical(RCX)) {
BX_ERROR(("SYSEXIT with non-canonical RCX (RSP) pointer !"));
exception(BX_GP_EXCEPTION, 0);
}
parse_selector(((BX_CPU_THIS_PTR msr.sysenter_cs_msr + 32) & BX_SELECTOR_RPL_MASK) | 3,
&BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector);
@ -1147,18 +1143,16 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::SYSRET(bxInstruction_c *i)
exception(BX_GP_EXCEPTION, 0);
}
#if BX_SUPPORT_X86_64
if (!IsCanonical(RCX)) {
BX_ERROR(("SYSRET: canonical failure for RCX (RIP)"));
exception(BX_GP_EXCEPTION, 0);
}
#endif
invalidate_prefetch_q();
if (BX_CPU_THIS_PTR cpu_mode == BX_MODE_LONG_64)
{
if (i->os64L()) {
if (!IsCanonical(RCX)) {
BX_ERROR(("SYSRET: canonical failure for RCX (RIP)"));
exception(BX_GP_EXCEPTION, 0);
}
// Return to 64-bit mode, set up CS segment, flat, 64-bit DPL=3
parse_selector((((MSR_STAR >> 48) + 16) & BX_SELECTOR_RPL_MASK) | 3,
&BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: protect_ctrl.cc,v 1.100 2010-04-02 19:53:29 sshwarts Exp $
// $Id: protect_ctrl.cc,v 1.101 2010-04-02 21:22:17 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2009 The Bochs Project
@ -227,7 +227,7 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::LSL_GvEw(bxInstruction_c *i)
case BX_SYS_SEGMENT_AVAIL_386_TSS:
case BX_SYS_SEGMENT_BUSY_386_TSS:
#if BX_SUPPORT_X86_64
if (BX_CPU_THIS_PTR cpu_mode == BX_MODE_LONG_64) {
if (long64_mode()) {
if (!fetch_raw_descriptor2_64(&selector, &dword1, &dword2, &dword3)) {
BX_ERROR(("LSL: failed to fetch 64-bit descriptor"));
clear_ZF();
@ -393,12 +393,14 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::LLDT_Ew(bxInstruction_c *i)
}
#if BX_SUPPORT_X86_64
descriptor.u.segment.base |= ((Bit64u)(dword3) << 32);
BX_DEBUG(("64 bit LDT base = 0x%08x%08x",
GET32H(descriptor.u.segment.base), GET32L(descriptor.u.segment.base)));
if (!IsCanonical(descriptor.u.segment.base)) {
BX_ERROR(("LLDT: non-canonical LDT descriptor base!"));
exception(BX_GP_EXCEPTION, raw_selector & 0xfffc);
if (BX_CPU_THIS_PTR cpu_mode == BX_MODE_LONG_64) {
descriptor.u.segment.base |= ((Bit64u)(dword3) << 32);
BX_DEBUG(("64 bit LDT base = 0x%08x%08x",
GET32H(descriptor.u.segment.base), GET32L(descriptor.u.segment.base)));
if (!IsCanonical(descriptor.u.segment.base)) {
BX_ERROR(("LLDT: non-canonical LDT descriptor base!"));
exception(BX_GP_EXCEPTION, raw_selector & 0xfffc);
}
}
#endif
@ -486,12 +488,14 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::LTR_Ew(bxInstruction_c *i)
}
#if BX_SUPPORT_X86_64
descriptor.u.segment.base |= ((Bit64u)(dword3) << 32);
BX_DEBUG(("64 bit TSS base = 0x%08x%08x",
GET32H(descriptor.u.segment.base), GET32L(descriptor.u.segment.base)));
if (!IsCanonical(descriptor.u.segment.base)) {
BX_ERROR(("LTR: non-canonical TSS descriptor base!"));
exception(BX_GP_EXCEPTION, raw_selector & 0xfffc);
if (BX_CPU_THIS_PTR cpu_mode == BX_MODE_LONG_64) {
descriptor.u.segment.base |= ((Bit64u)(dword3) << 32);
BX_DEBUG(("64 bit TSS base = 0x%08x%08x",
GET32H(descriptor.u.segment.base), GET32L(descriptor.u.segment.base)));
if (!IsCanonical(descriptor.u.segment.base)) {
BX_ERROR(("LTR: non-canonical TSS descriptor base!"));
exception(BX_GP_EXCEPTION, raw_selector & 0xfffc);
}
}
#endif