split rd/wr CR opcodes for simplicity

This commit is contained in:
Stanislav Shwartsman 2010-12-19 22:36:19 +00:00
parent c7017b1c05
commit 29a674e520
6 changed files with 363 additions and 235 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: cpu.h,v 1.692 2010-12-19 21:41:15 sshwarts Exp $
// $Id: cpu.h,v 1.693 2010-12-19 22:36:19 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2010 The Bochs Project
@ -1373,9 +1373,15 @@ public: // for now...
BX_SMF void WBINVD(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void CLFLUSH(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_CdRd(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_CR0Rd(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_CR2Rd(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_CR3Rd(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_CR4Rd(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_RdCR0(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_RdCR2(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_RdCR3(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_RdCR4(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_DdRd(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_RdCd(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_RdDd(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_TdRd(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_RdTd(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
@ -2594,9 +2600,15 @@ public: // for now...
BX_SMF void LEAVE64(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void IRET64(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_CqRq(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_CR0Rq(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_CR2Rq(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_CR3Rq(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_CR4Rq(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_RqCR0(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_RqCR2(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_RqCR3(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_RqCR4(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_DqRq(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_RqCq(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void MOV_RqDq(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
BX_SMF void SHLD_EqGqM(bxInstruction_c *) BX_CPP_AttrRegparmN(1);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: crregs.cc,v 1.23 2010-12-19 07:06:40 sshwarts Exp $
// $Id: crregs.cc,v 1.24 2010-12-19 22:36:19 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2010 Stanislav Shwartsman
@ -387,267 +387,277 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_RqDq(bxInstruction_c *i)
}
#endif // #if BX_SUPPORT_X86_64
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_CdRd(bxInstruction_c *i)
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_CR0Rd(bxInstruction_c *i)
{
unsigned cr_ok = 0x0d;
#if BX_CPU_LEVEL >= 4
cr_ok |= 0x10;
#endif
if (! (cr_ok & (1 << i->nnn()))) {
BX_ERROR(("MOV_CdRd: #UD - register index out of range"));
exception(BX_UD_EXCEPTION, 0);
}
if (!real_mode() && CPL!=0) {
BX_ERROR(("MOV_CdRd: CPL!=0 not in real mode"));
BX_ERROR(("MOV_CR0Rd: CPL!=0 not in real mode"));
exception(BX_GP_EXCEPTION, 0);
}
invalidate_prefetch_q();
/* This instruction is always treated as a register-to-register,
* regardless of the encoding of the MOD field in the MODRM byte.
*/
if (!i->modC0())
BX_PANIC(("MOV_CdRd(): rm field not a register!"));
Bit32u val_32 = BX_READ_32BIT_REG(i->rm());
#if BX_SUPPORT_VMX
val_32 = VMexit_CR0_Write(i, val_32);
#endif
if (! SetCR0(val_32))
exception(BX_GP_EXCEPTION, 0);
}
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_CR2Rd(bxInstruction_c *i)
{
if (!real_mode() && CPL!=0) {
BX_ERROR(("MOV_CR2Rd: CPL!=0 not in real mode"));
exception(BX_GP_EXCEPTION, 0);
}
BX_CPU_THIS_PTR cr2 = BX_READ_32BIT_REG(i->rm());
}
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_CR3Rd(bxInstruction_c *i)
{
if (!real_mode() && CPL!=0) {
BX_ERROR(("MOV_CR3Rd: CPL!=0 not in real mode"));
exception(BX_GP_EXCEPTION, 0);
}
invalidate_prefetch_q();
Bit32u val_32 = BX_READ_32BIT_REG(i->rm());
switch (i->nnn()) {
case 0: // CR0 (MSW)
#if BX_SUPPORT_VMX
val_32 = VMexit_CR0_Write(i, val_32);
VMexit_CR3_Write(i, val_32);
#endif
if (! SetCR0(val_32))
exception(BX_GP_EXCEPTION, 0);
break;
case 2: /* CR2 */
BX_CPU_THIS_PTR cr2 = val_32;
break;
case 3: // CR3
#if BX_SUPPORT_VMX
VMexit_CR3_Write(i, val_32);
#endif
#if BX_CPU_LEVEL >= 6
if (BX_CPU_THIS_PTR cr0.get_PG() && BX_CPU_THIS_PTR cr4.get_PAE() && !long_mode()) {
if (! CheckPDPTR(val_32)) {
BX_ERROR(("SetCR3(): PDPTR check failed !"));
exception(BX_GP_EXCEPTION, 0);
}
}
#endif
if (! SetCR3(val_32))
exception(BX_GP_EXCEPTION, 0);
BX_INSTR_TLB_CNTRL(BX_CPU_ID, BX_INSTR_MOV_CR3, val_32);
break;
#if BX_CPU_LEVEL > 3
case 4: // CR4
#if BX_SUPPORT_VMX
val_32 = VMexit_CR4_Write(i, val_32);
#endif
if (! SetCR4(val_32))
exception(BX_GP_EXCEPTION, 0);
break;
#endif
default:
BX_ERROR(("MOV_CdRd: #UD - control register %d index out of range", i->nnn()));
exception(BX_UD_EXCEPTION, 0);
if (BX_CPU_THIS_PTR cr0.get_PG() && BX_CPU_THIS_PTR cr4.get_PAE() && !long_mode()) {
if (! CheckPDPTR(val_32)) {
BX_ERROR(("SetCR3(): PDPTR check failed !"));
exception(BX_GP_EXCEPTION, 0);
}
}
#endif
if (! SetCR3(val_32))
exception(BX_GP_EXCEPTION, 0);
BX_INSTR_TLB_CNTRL(BX_CPU_ID, BX_INSTR_MOV_CR3, val_32);
}
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_RdCd(bxInstruction_c *i)
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_CR4Rd(bxInstruction_c *i)
{
// mov control register data to register
Bit32u val_32 = 0;
unsigned cr_ok = 0x0d;
#if BX_CPU_LEVEL >= 4
cr_ok |= 0x10;
#endif
if (! (cr_ok & (1 << i->nnn()))) {
BX_ERROR(("MOV_RdCd: #UD - register index out of range"));
exception(BX_UD_EXCEPTION, 0);
if (!real_mode() && CPL!=0) {
BX_ERROR(("MOV_CR4Rd: CPL!=0 not in real mode"));
exception(BX_GP_EXCEPTION, 0);
}
invalidate_prefetch_q();
Bit32u val_32 = BX_READ_32BIT_REG(i->rm());
#if BX_SUPPORT_VMX
val_32 = VMexit_CR4_Write(i, val_32);
#endif
if (! SetCR4(val_32))
exception(BX_GP_EXCEPTION, 0);
#endif
}
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_RdCR0(bxInstruction_c *i)
{
if (!real_mode() && CPL!=0) {
BX_ERROR(("MOV_RdCR0: CPL!=0 not in real mode"));
exception(BX_GP_EXCEPTION, 0);
}
Bit32u val_32 = (Bit32u) read_CR0(); /* correctly handle VMX */
BX_WRITE_32BIT_REGZ(i->rm(), val_32);
}
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_RdCR2(bxInstruction_c *i)
{
if (!real_mode() && CPL!=0) {
BX_ERROR(("MOV_RdCd: CPL!=0 not in real mode"));
exception(BX_GP_EXCEPTION, 0);
}
/* This instruction is always treated as a register-to-register,
* regardless of the encoding of the MOD field in the MODRM byte.
*/
if (!i->modC0())
BX_PANIC(("MOV_RdCd(): rm field not a register!"));
BX_WRITE_32BIT_REGZ(i->rm(), (Bit32u) BX_CPU_THIS_PTR cr2);
}
switch (i->nnn()) {
case 0: // CR0 (MSW)
val_32 = (Bit32u) read_CR0(); /* correctly handle VMX */
break;
case 2: /* CR2 */
val_32 = (Bit32u) BX_CPU_THIS_PTR cr2;
break;
case 3: // CR3
#if BX_SUPPORT_VMX
VMexit_CR3_Read(i);
#endif
val_32 = (Bit32u) BX_CPU_THIS_PTR cr3;
break;
#if BX_CPU_LEVEL > 3
case 4: // CR4
val_32 = (Bit32u) read_CR4(); /* correctly handle VMX */
break;
#endif
default:
BX_ERROR(("MOV_RdCd: #UD - control register %d index out of range", i->nnn()));
exception(BX_UD_EXCEPTION, 0);
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_RdCR3(bxInstruction_c *i)
{
if (!real_mode() && CPL!=0) {
BX_ERROR(("MOV_RdCd: CPL!=0 not in real mode"));
exception(BX_GP_EXCEPTION, 0);
}
#if BX_SUPPORT_VMX
VMexit_CR3_Read(i);
#endif
Bit32u val_32 = (Bit32u) BX_CPU_THIS_PTR cr3;
BX_WRITE_32BIT_REGZ(i->rm(), val_32);
}
#if BX_SUPPORT_X86_64
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_CqRq(bxInstruction_c *i)
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_RdCR4(bxInstruction_c *i)
{
unsigned cr_ok = 0x011d;
if (! (cr_ok & (1 << i->nnn()))) {
BX_ERROR(("MOV_CqRq: #UD - register index out of range"));
exception(BX_UD_EXCEPTION, 0);
#if BX_CPU_LEVEL >= 4
if (!real_mode() && CPL!=0) {
BX_ERROR(("MOV_RdCd: CPL!=0 not in real mode"));
exception(BX_GP_EXCEPTION, 0);
}
/* #GP(0) if CPL is not 0 */
Bit32u val_32 = (Bit32u) read_CR4(); /* correctly handle VMX */
BX_WRITE_32BIT_REGZ(i->rm(), val_32);
#endif
}
#if BX_SUPPORT_X86_64
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_CR0Rq(bxInstruction_c *i)
{
if (CPL!=0) {
BX_ERROR(("MOV_CqRq: #GP(0) if CPL is not 0"));
BX_ERROR(("MOV_CR0Rq: #GP(0) if CPL is not 0"));
exception(BX_GP_EXCEPTION, 0);
}
invalidate_prefetch_q();
/* This instruction is always treated as a register-to-register,
* regardless of the encoding of the MOD field in the MODRM byte.
*/
if (!i->modC0())
BX_PANIC(("MOV_CqRq(): rm field not a register!"));
Bit64u val_64 = BX_READ_64BIT_REG(i->rm());
switch (i->nnn()) {
case 0: // CR0
if (i->nnn() == 0) {
// CR0
#if BX_SUPPORT_VMX
val_64 = VMexit_CR0_Write(i, val_64);
val_64 = VMexit_CR0_Write(i, val_64);
#endif
if (! SetCR0(val_64))
exception(BX_GP_EXCEPTION, 0);
break;
case 2: /* CR2 */
BX_CPU_THIS_PTR cr2 = val_64;
break;
case 3: // CR3
if (! SetCR0(val_64))
exception(BX_GP_EXCEPTION, 0);
}
else {
// CR8
#if BX_SUPPORT_VMX
VMexit_CR3_Write(i, val_64);
VMexit_CR8_Write(i);
#endif
// no PDPTR checks in long mode
if (! SetCR3(val_64))
exception(BX_GP_EXCEPTION, 0);
BX_INSTR_TLB_CNTRL(BX_CPU_ID, BX_INSTR_MOV_CR3, val_64);
break;
case 4: // CR4
#if BX_SUPPORT_VMX
val_64 = VMexit_CR4_Write(i, val_64);
#endif
BX_DEBUG(("MOV_CqRq: write to CR4 of %08x:%08x", GET32H(val_64), GET32L(val_64)));
if (! SetCR4(val_64))
exception(BX_GP_EXCEPTION, 0);
break;
case 8: // CR8
#if BX_SUPPORT_VMX
VMexit_CR8_Write(i);
#endif
// CR8 is aliased to APIC->TASK PRIORITY register
// APIC.TPR[7:4] = CR8[3:0]
// APIC.TPR[3:0] = 0
// Reads of CR8 return zero extended APIC.TPR[7:4]
// Write to CR8 update APIC.TPR[7:4]
// CR8 is aliased to APIC->TASK PRIORITY register
// APIC.TPR[7:4] = CR8[3:0]
// APIC.TPR[3:0] = 0
// Reads of CR8 return zero extended APIC.TPR[7:4]
// Write to CR8 update APIC.TPR[7:4]
#if BX_SUPPORT_APIC
if (val_64 & BX_CONST64(0xfffffffffffffff0)) {
BX_ERROR(("MOV_CqRq: Attempt to set reserved bits of CR8"));
exception(BX_GP_EXCEPTION, 0);
}
#if BX_SUPPORT_VMX
if (BX_CPU_THIS_PTR in_vmx_guest && VMEXIT(VMX_VM_EXEC_CTRL2_TPR_SHADOW)) {
VMX_Write_VTPR((val_64 & 0xF) << 4);
break;
}
#endif
BX_CPU_THIS_PTR lapic.set_tpr((val_64 & 0xF) << 4);
break;
#endif
if (val_64 & BX_CONST64(0xfffffffffffffff0)) {
BX_ERROR(("MOV_CqRq: Attempt to set reserved bits of CR8"));
exception(BX_GP_EXCEPTION, 0);
}
default:
BX_ERROR(("MOV_CqRq: #UD - control register %d index out of range", i->nnn()));
exception(BX_UD_EXCEPTION, 0);
#if BX_SUPPORT_VMX
if (BX_CPU_THIS_PTR in_vmx_guest && VMEXIT(VMX_VM_EXEC_CTRL2_TPR_SHADOW)) {
VMX_Write_VTPR((val_64 & 0xF) << 4);
}
#endif
else
{
BX_CPU_THIS_PTR lapic.set_tpr((val_64 & 0xF) << 4);
}
#endif
}
}
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_RqCq(bxInstruction_c *i)
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_CR2Rq(bxInstruction_c *i)
{
unsigned cr_ok = 0x011d;
if (! (cr_ok & (1 << i->nnn()))) {
BX_ERROR(("MOV_RqCq: #UD - register index out of range"));
if (i->nnn() != 2) {
BX_ERROR(("MOV_CR2Rq: #UD - register index out of range"));
exception(BX_UD_EXCEPTION, 0);
}
if (CPL!=0) {
BX_ERROR(("MOV_CR2Rq: #GP(0) if CPL is not 0"));
exception(BX_GP_EXCEPTION, 0);
}
BX_CPU_THIS_PTR cr2 = BX_READ_64BIT_REG(i->rm());
}
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_CR3Rq(bxInstruction_c *i)
{
if (i->nnn() != 3) {
BX_ERROR(("MOV_CR3Rq: #UD - register index out of range"));
exception(BX_UD_EXCEPTION, 0);
}
if (CPL!=0) {
BX_ERROR(("MOV_CR3Rq: #GP(0) if CPL is not 0"));
exception(BX_GP_EXCEPTION, 0);
}
invalidate_prefetch_q();
Bit64u val_64 = BX_READ_64BIT_REG(i->rm());
#if BX_SUPPORT_VMX
VMexit_CR3_Write(i, val_64);
#endif
// no PDPTR checks in long mode
if (! SetCR3(val_64))
exception(BX_GP_EXCEPTION, 0);
BX_INSTR_TLB_CNTRL(BX_CPU_ID, BX_INSTR_MOV_CR3, val_64);
}
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_CR4Rq(bxInstruction_c *i)
{
if (i->nnn() != 4) {
BX_ERROR(("MOV_CR4Rq: #UD - register index out of range"));
exception(BX_UD_EXCEPTION, 0);
}
if (CPL!=0) {
BX_ERROR(("MOV_CR4Rq: #GP(0) if CPL is not 0"));
exception(BX_GP_EXCEPTION, 0);
}
invalidate_prefetch_q();
Bit64u val_64 = BX_READ_64BIT_REG(i->rm());
#if BX_SUPPORT_VMX
val_64 = VMexit_CR4_Write(i, val_64);
#endif
BX_DEBUG(("MOV_CqRq: write to CR4 of %08x:%08x", GET32H(val_64), GET32L(val_64)));
if (! SetCR4(val_64))
exception(BX_GP_EXCEPTION, 0);
}
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_RqCR0(bxInstruction_c *i)
{
// mov control register data to register
Bit64u val_64 = 0;
/* #GP(0) if CPL is not 0 */
if (CPL!=0) {
BX_ERROR(("MOV_RqCq: #GP(0) if CPL is not 0"));
exception(BX_GP_EXCEPTION, 0);
}
/* This instruction is always treated as a register-to-register,
* regardless of the encoding of the MOD field in the MODRM byte.
*/
if (!i->modC0())
BX_PANIC(("MOV_RqCq(): rm field not a register!"));
if (i->nnn() == 0) {
// CR0
val_64 = read_CR0(); /* correctly handle VMX */
}
else {
// CR8
switch (i->nnn()) {
case 0: // CR0 (MSW)
val_64 = read_CR0(); /* correctly handle VMX */
break;
case 2: /* CR2 */
val_64 = BX_CPU_THIS_PTR cr2;
break;
case 3: // CR3
#if BX_SUPPORT_VMX
VMexit_CR3_Read(i);
#endif
val_64 = BX_CPU_THIS_PTR cr3;
break;
case 4: // CR4
val_64 = read_CR4(); /* correctly handle VMX */
break;
case 8: // CR8
#if BX_SUPPORT_VMX
VMexit_CR8_Read(i);
if (BX_CPU_THIS_PTR in_vmx_guest && VMEXIT(VMX_VM_EXEC_CTRL2_TPR_SHADOW)) {
val_64 = (VMX_Read_VTPR() >> 4) & 0xf;
break;
}
VMexit_CR8_Read(i);
if (BX_CPU_THIS_PTR in_vmx_guest && VMEXIT(VMX_VM_EXEC_CTRL2_TPR_SHADOW)) {
val_64 = (VMX_Read_VTPR() >> 4) & 0xf;
}
else
#endif
{
// CR8 is aliased to APIC->TASK PRIORITY register
// APIC.TPR[7:4] = CR8[3:0]
// APIC.TPR[3:0] = 0
@ -655,15 +665,63 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_RqCq(bxInstruction_c *i)
// Write to CR8 update APIC.TPR[7:4]
#if BX_SUPPORT_APIC
val_64 = (BX_CPU_THIS_PTR lapic.get_tpr() >> 4) & 0xF;
break;
#endif
default:
BX_ERROR(("MOV_RqCq: #UD - control register %d index out of range", i->nnn()));
exception(BX_UD_EXCEPTION, 0);
}
}
BX_WRITE_64BIT_REG(i->rm(), val_64);
}
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_RqCR2(bxInstruction_c *i)
{
if (i->nnn() != 2) {
BX_ERROR(("MOV_RqCR2: #UD - register index out of range"));
exception(BX_UD_EXCEPTION, 0);
}
if (CPL!=0) {
BX_ERROR(("MOV_RqCR2: #GP(0) if CPL is not 0"));
exception(BX_GP_EXCEPTION, 0);
}
BX_WRITE_64BIT_REG(i->rm(), BX_CPU_THIS_PTR cr2);
}
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_RqCR3(bxInstruction_c *i)
{
if (i->nnn() != 3) {
BX_ERROR(("MOV_RqCR3: #UD - register index out of range"));
exception(BX_UD_EXCEPTION, 0);
}
if (CPL!=0) {
BX_ERROR(("MOV_RqCR3: #GP(0) if CPL is not 0"));
exception(BX_GP_EXCEPTION, 0);
}
#if BX_SUPPORT_VMX
VMexit_CR3_Read(i);
#endif
BX_WRITE_64BIT_REG(i->rm(), BX_CPU_THIS_PTR cr3);
}
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOV_RqCR4(bxInstruction_c *i)
{
if (i->nnn() != 4) {
BX_ERROR(("MOV_RqCR4: #UD - register index out of range"));
exception(BX_UD_EXCEPTION, 0);
}
if (CPL!=0) {
BX_ERROR(("MOV_RqCR4: #GP(0) if CPL is not 0"));
exception(BX_GP_EXCEPTION, 0);
}
Bit64u val_64 = read_CR4(); /* correctly handle VMX */
BX_WRITE_64BIT_REG(i->rm(), val_64);
}
#endif // #if BX_SUPPORT_X86_64
void BX_CPP_AttrRegparmN(1) BX_CPU_C::LMSW_Ew(bxInstruction_c *i)

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: fetchdecode.cc,v 1.282 2010-12-06 21:45:56 sshwarts Exp $
// $Id: fetchdecode.cc,v 1.283 2010-12-19 22:36:19 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2010 The Bochs Project
@ -808,12 +808,12 @@ static const BxOpcodeInfo_t BxOpcodeInfo32[512*2*2] = {
/* 0F 1F /wr */ { 0, BX_IA_ERROR },
/* 0F 1F /wm */ { 0, BX_IA_ERROR },
#endif
/* 0F 20 /wr */ { 0, BX_IA_MOV_RdCd },
/* 0F 20 /wm */ { 0, BX_IA_MOV_RdCd },
/* 0F 20 /wr */ { BxGroupN, BX_IA_ERROR, BxOpcodeInfoMOV_RdCd },
/* 0F 20 /wm */ { BxGroupN, BX_IA_ERROR, BxOpcodeInfoMOV_RdCd },
/* 0F 21 /wr */ { 0, BX_IA_MOV_RdDd },
/* 0F 21 /wm */ { 0, BX_IA_MOV_RdDd },
/* 0F 22 /wr */ { BxTraceEnd, BX_IA_MOV_CdRd },
/* 0F 22 /wm */ { BxTraceEnd, BX_IA_MOV_CdRd },
/* 0F 22 /wr */ { BxGroupN, BX_IA_ERROR, BxOpcodeInfoMOV_CdRd },
/* 0F 22 /wm */ { BxGroupN, BX_IA_ERROR, BxOpcodeInfoMOV_CdRd },
/* 0F 23 /wr */ { BxTraceEnd, BX_IA_MOV_DdRd },
/* 0F 23 /wm */ { BxTraceEnd, BX_IA_MOV_DdRd },
/* 0F 24 /wr */ { BxTraceEnd, BX_IA_MOV_RdTd }, // not implemented
@ -1886,12 +1886,12 @@ static const BxOpcodeInfo_t BxOpcodeInfo32[512*2*2] = {
/* 0F 1F /dr */ { 0, BX_IA_ERROR },
/* 0F 1F /dm */ { 0, BX_IA_ERROR },
#endif
/* 0F 20 /dr */ { 0, BX_IA_MOV_RdCd },
/* 0F 20 /dm */ { 0, BX_IA_MOV_RdCd },
/* 0F 20 /dr */ { BxGroupN, BX_IA_ERROR, BxOpcodeInfoMOV_RdCd },
/* 0F 20 /dm */ { BxGroupN, BX_IA_ERROR, BxOpcodeInfoMOV_RdCd },
/* 0F 21 /dr */ { 0, BX_IA_MOV_RdDd },
/* 0F 21 /dm */ { 0, BX_IA_MOV_RdDd },
/* 0F 22 /dr */ { BxTraceEnd, BX_IA_MOV_CdRd },
/* 0F 22 /dm */ { BxTraceEnd, BX_IA_MOV_CdRd },
/* 0F 22 /dr */ { BxGroupN, BX_IA_ERROR, BxOpcodeInfoMOV_CdRd },
/* 0F 22 /dm */ { BxGroupN, BX_IA_ERROR, BxOpcodeInfoMOV_CdRd },
/* 0F 23 /dr */ { BxTraceEnd, BX_IA_MOV_DdRd },
/* 0F 23 /dm */ { BxTraceEnd, BX_IA_MOV_DdRd },
/* 0F 24 /dr */ { BxTraceEnd, BX_IA_MOV_RdTd }, // not implemented

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: fetchdecode.h,v 1.104 2010-07-22 16:41:59 sshwarts Exp $
// $Id: fetchdecode.h,v 1.105 2010-12-19 22:36:19 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2005-2010 Stanislav Shwartsman
@ -984,4 +984,50 @@ static const BxOpcodeInfo_t BxOpcodeInfoG15R64[8] = {
};
#endif
static const BxOpcodeInfo_t BxOpcodeInfoMOV_RdCd[8] = {
/* 0 */ { 0, BX_IA_MOV_RdCR0 },
/* 1 */ { 0, BX_IA_ERROR },
/* 2 */ { 0, BX_IA_MOV_RdCR2 },
/* 3 */ { 0, BX_IA_MOV_RdCR3 },
/* 4 */ { 0, BX_IA_MOV_RdCR4 },
/* 5 */ { 0, BX_IA_ERROR },
/* 6 */ { 0, BX_IA_ERROR },
/* 7 */ { 0, BX_IA_ERROR }
};
static const BxOpcodeInfo_t BxOpcodeInfoMOV_CdRd[8] = {
/* 0 */ { BxTraceEnd, BX_IA_MOV_CR0Rd },
/* 1 */ { 0, BX_IA_ERROR },
/* 2 */ { 0, BX_IA_MOV_CR2Rd },
/* 3 */ { BxTraceEnd, BX_IA_MOV_CR3Rd },
/* 4 */ { BxTraceEnd, BX_IA_MOV_CR4Rd },
/* 5 */ { 0, BX_IA_ERROR },
/* 6 */ { 0, BX_IA_ERROR },
/* 7 */ { 0, BX_IA_ERROR }
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeInfoMOV_RqCq[8] = {
/* 0 */ { 0, BX_IA_MOV_RqCR0 },
/* 1 */ { 0, BX_IA_ERROR },
/* 2 */ { 0, BX_IA_MOV_RqCR2 },
/* 3 */ { 0, BX_IA_MOV_RqCR3 },
/* 4 */ { 0, BX_IA_MOV_RqCR4 },
/* 5 */ { 0, BX_IA_ERROR },
/* 6 */ { 0, BX_IA_ERROR },
/* 7 */ { 0, BX_IA_ERROR }
};
static const BxOpcodeInfo_t BxOpcodeInfoMOV_CqRq[8] = {
/* 0 */ { BxTraceEnd, BX_IA_MOV_CR0Rq },
/* 1 */ { 0, BX_IA_ERROR },
/* 2 */ { 0, BX_IA_MOV_CR2Rq },
/* 3 */ { BxTraceEnd, BX_IA_MOV_CR3Rq },
/* 4 */ { BxTraceEnd, BX_IA_MOV_CR4Rq },
/* 5 */ { 0, BX_IA_ERROR },
/* 6 */ { 0, BX_IA_ERROR },
/* 7 */ { 0, BX_IA_ERROR }
};
#endif
#endif // BX_COMMON_FETCHDECODE_TABLES_H

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: fetchdecode64.cc,v 1.278 2010-12-06 21:45:56 sshwarts Exp $
// $Id: fetchdecode64.cc,v 1.279 2010-12-19 22:36:19 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2010 The Bochs Project
@ -733,12 +733,12 @@ static const BxOpcodeInfo_t BxOpcodeInfo64[512*3*2] = {
/* 0F 1E /wm */ { 0, BX_IA_NOP }, // multi-byte NOP
/* 0F 1F /wr */ { 0, BX_IA_NOP }, // multi-byte NOP
/* 0F 1F /wm */ { 0, BX_IA_NOP }, // multi-byte NOP
/* 0F 20 /wr */ { 0, BX_IA_MOV_RqCq },
/* 0F 20 /wm */ { 0, BX_IA_MOV_RqCq },
/* 0F 20 /wr */ { BxGroupN, BX_IA_ERROR, BxOpcodeInfoMOV_RqCq },
/* 0F 20 /wm */ { BxGroupN, BX_IA_ERROR, BxOpcodeInfoMOV_RqCq },
/* 0F 21 /wr */ { 0, BX_IA_MOV_RqDq },
/* 0F 21 /wm */ { 0, BX_IA_MOV_RqDq },
/* 0F 22 /wr */ { BxTraceEnd, BX_IA_MOV_CqRq },
/* 0F 22 /wm */ { BxTraceEnd, BX_IA_MOV_CqRq },
/* 0F 22 /wr */ { BxGroupN, BX_IA_ERROR, BxOpcodeInfoMOV_CqRq },
/* 0F 22 /wm */ { BxGroupN, BX_IA_ERROR, BxOpcodeInfoMOV_CqRq },
/* 0F 23 /wr */ { BxTraceEnd, BX_IA_MOV_DqRq },
/* 0F 23 /wm */ { BxTraceEnd, BX_IA_MOV_DqRq },
/* 0F 24 /wr */ { 0, BX_IA_ERROR },
@ -1760,12 +1760,12 @@ static const BxOpcodeInfo_t BxOpcodeInfo64[512*3*2] = {
/* 0F 1E /dm */ { 0, BX_IA_NOP }, // multi-byte NOP
/* 0F 1F /dr */ { 0, BX_IA_NOP }, // multi-byte NOP
/* 0F 1F /dm */ { 0, BX_IA_NOP }, // multi-byte NOP
/* 0F 20 /dr */ { 0, BX_IA_MOV_RqCq },
/* 0F 20 /dm */ { 0, BX_IA_MOV_RqCq },
/* 0F 20 /dr */ { BxGroupN, BX_IA_ERROR, BxOpcodeInfoMOV_RqCq },
/* 0F 20 /dm */ { BxGroupN, BX_IA_ERROR, BxOpcodeInfoMOV_RqCq },
/* 0F 21 /dr */ { 0, BX_IA_MOV_RqDq },
/* 0F 21 /dm */ { 0, BX_IA_MOV_RqDq },
/* 0F 22 /dr */ { BxTraceEnd, BX_IA_MOV_CqRq },
/* 0F 22 /dm */ { BxTraceEnd, BX_IA_MOV_CqRq },
/* 0F 22 /dr */ { BxGroupN, BX_IA_ERROR, BxOpcodeInfoMOV_CqRq },
/* 0F 22 /dm */ { BxGroupN, BX_IA_ERROR, BxOpcodeInfoMOV_CqRq },
/* 0F 23 /dr */ { BxTraceEnd, BX_IA_MOV_DqRq },
/* 0F 23 /dm */ { BxTraceEnd, BX_IA_MOV_DqRq },
/* 0F 24 /dr */ { 0, BX_IA_ERROR },
@ -2787,12 +2787,12 @@ static const BxOpcodeInfo_t BxOpcodeInfo64[512*3*2] = {
/* 0F 1E /qm */ { 0, BX_IA_NOP }, // multi-byte NOP
/* 0F 1F /qr */ { 0, BX_IA_NOP }, // multi-byte NOP
/* 0F 1F /qm */ { 0, BX_IA_NOP }, // multi-byte NOP
/* 0F 20 /qr */ { 0, BX_IA_MOV_RqCq },
/* 0F 20 /qm */ { 0, BX_IA_MOV_RqCq },
/* 0F 20 /qr */ { BxGroupN, BX_IA_ERROR, BxOpcodeInfoMOV_RqCq },
/* 0F 20 /qm */ { BxGroupN, BX_IA_ERROR, BxOpcodeInfoMOV_RqCq },
/* 0F 21 /qr */ { 0, BX_IA_MOV_RqDq },
/* 0F 21 /qm */ { 0, BX_IA_MOV_RqDq },
/* 0F 22 /qr */ { BxTraceEnd, BX_IA_MOV_CqRq },
/* 0F 22 /qm */ { BxTraceEnd, BX_IA_MOV_CqRq },
/* 0F 22 /qr */ { BxGroupN, BX_IA_ERROR, BxOpcodeInfoMOV_CqRq },
/* 0F 22 /qm */ { BxGroupN, BX_IA_ERROR, BxOpcodeInfoMOV_CqRq },
/* 0F 23 /qr */ { BxTraceEnd, BX_IA_MOV_DqRq },
/* 0F 23 /qm */ { BxTraceEnd, BX_IA_MOV_DqRq },
/* 0F 24 /qr */ { 0, BX_IA_ERROR },

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: ia_opcodes.h,v 1.51 2010-12-18 11:58:16 sshwarts Exp $
// $Id: ia_opcodes.h,v 1.52 2010-12-19 22:36:19 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2008-2010 Stanislav Shwartsman
@ -296,7 +296,15 @@ bx_define_opcode(BX_IA_LSS_GwMp, &BX_CPU_C::LSS_GwMp, NULL, 0)
bx_define_opcode(BX_IA_LTR_Ew, &BX_CPU_C::LTR_Ew, NULL, 0)
bx_define_opcode(BX_IA_MOV_ALOd, &BX_CPU_C::MOV_ALOd, NULL, 0)
bx_define_opcode(BX_IA_MOV_AXOd, &BX_CPU_C::MOV_AXOd, NULL, 0)
bx_define_opcode(BX_IA_MOV_CdRd, &BX_CPU_C::MOV_CdRd, NULL, 0)
bx_define_opcode(BX_IA_MOV_CR0Rd, &BX_CPU_C::MOV_CR0Rd, NULL, 0)
bx_define_opcode(BX_IA_MOV_CR2Rd, &BX_CPU_C::MOV_CR2Rd, NULL, 0)
bx_define_opcode(BX_IA_MOV_CR3Rd, &BX_CPU_C::MOV_CR3Rd, NULL, 0)
bx_define_opcode(BX_IA_MOV_CR4Rd, &BX_CPU_C::MOV_CR4Rd, NULL, BX_CPU_486)
bx_define_opcode(BX_IA_MOV_RdCR0, &BX_CPU_C::MOV_RdCR0, NULL, 0)
bx_define_opcode(BX_IA_MOV_RdCR2, &BX_CPU_C::MOV_RdCR2, NULL, 0)
bx_define_opcode(BX_IA_MOV_RdCR3, &BX_CPU_C::MOV_RdCR3, NULL, 0)
bx_define_opcode(BX_IA_MOV_RdCR4, &BX_CPU_C::MOV_RdCR4, NULL, BX_CPU_486)
bx_define_opcode(BX_IA_MOV_RdDd, &BX_CPU_C::MOV_RdDd, NULL, 0)
bx_define_opcode(BX_IA_MOV_DdRd, &BX_CPU_C::MOV_DdRd, NULL, 0)
bx_define_opcode(BX_IA_MOV_EAXOd, &BX_CPU_C::MOV_EAXOd, NULL, 0)
bx_define_opcode(BX_IA_MOV_EbGbM, &BX_CPU_C::MOV_EbGbM, NULL, 0)
@ -320,13 +328,11 @@ bx_define_opcode(BX_IA_MOV_GwEwR, &BX_CPU_C::MOV_GwEwR, NULL, 0)
bx_define_opcode(BX_IA_MOV_OdAL, &BX_CPU_C::MOV_OdAL, NULL, 0)
bx_define_opcode(BX_IA_MOV_OdAX, &BX_CPU_C::MOV_OdAX, NULL, 0)
bx_define_opcode(BX_IA_MOV_OdEAX, &BX_CPU_C::MOV_OdEAX, NULL, 0)
bx_define_opcode(BX_IA_MOV_RdCd, &BX_CPU_C::MOV_RdCd, NULL, 0)
bx_define_opcode(BX_IA_MOV_RdDd, &BX_CPU_C::MOV_RdDd, NULL, 0)
bx_define_opcode(BX_IA_MOV_RdTd, &BX_CPU_C::MOV_RdTd, NULL, 0)
bx_define_opcode(BX_IA_MOV_RHIb, &BX_CPU_C::MOV_RHIb, NULL, 0)
bx_define_opcode(BX_IA_MOV_RLIb, &BX_CPU_C::MOV_RLIb, NULL, 0)
bx_define_opcode(BX_IA_MOV_RXIw, &BX_CPU_C::MOV_RXIw, NULL, 0)
bx_define_opcode(BX_IA_MOV_SwEw, &BX_CPU_C::MOV_SwEw, NULL, 0)
bx_define_opcode(BX_IA_MOV_RdTd, &BX_CPU_C::MOV_RdTd, NULL, 0)
bx_define_opcode(BX_IA_MOV_TdRd, &BX_CPU_C::MOV_TdRd, NULL, 0)
bx_define_opcode(BX_IA_MOVSX_GdEbM, &BX_CPU_C::MOVSX_GdEbM, NULL, 0)
bx_define_opcode(BX_IA_MOVSX_GdEbR, &BX_CPU_C::MOVSX_GdEbR, NULL, 0)
@ -1475,10 +1481,6 @@ bx_define_opcode(BX_IA_JNLE_Jq, &BX_CPU_C::JNLE_Jq, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_ENTER64_IwIb, &BX_CPU_C::ENTER64_IwIb, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_LEAVE64, &BX_CPU_C::LEAVE64, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_IRET64, &BX_CPU_C::IRET64, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_MOV_CqRq, &BX_CPU_C::MOV_CqRq, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_MOV_DqRq, &BX_CPU_C::MOV_DqRq, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_MOV_RqCq, &BX_CPU_C::MOV_RqCq, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_MOV_RqDq, &BX_CPU_C::MOV_RqDq, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_SHLD_EqGqR, &BX_CPU_C::SHLD_EqGqR, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_SHLD_EqGqM, &BX_CPU_C::SHLD_EqGqM, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_SHRD_EqGqR, &BX_CPU_C::SHRD_EqGqR, NULL, BX_CPU_X86_64)
@ -1635,6 +1637,16 @@ bx_define_opcode(BX_IA_MOVQ_VdqEqM, &BX_CPU_C::MOVQ_VqWqM, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_MOVNTI_MqGq, &BX_CPU_C::MOVNTI_MqGq, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_SYSCALL, &BX_CPU_C::SYSCALL, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_SYSRET, &BX_CPU_C::SYSRET, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_MOV_CR0Rq, &BX_CPU_C::MOV_CR0Rq, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_MOV_CR2Rq, &BX_CPU_C::MOV_CR2Rq, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_MOV_CR3Rq, &BX_CPU_C::MOV_CR3Rq, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_MOV_CR4Rq, &BX_CPU_C::MOV_CR4Rq, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_MOV_RqCR0, &BX_CPU_C::MOV_RqCR0, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_MOV_RqCR2, &BX_CPU_C::MOV_RqCR2, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_MOV_RqCR3, &BX_CPU_C::MOV_RqCR3, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_MOV_RqCR4, &BX_CPU_C::MOV_RqCR4, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_MOV_DqRq, &BX_CPU_C::MOV_DqRq, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_MOV_RqDq, &BX_CPU_C::MOV_RqDq, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_SWAPGS, &BX_CPU_C::SWAPGS, NULL, BX_CPU_X86_64)
bx_define_opcode(BX_IA_RDFSBASE, &BX_CPU_C::RDFSBASE, NULL, BX_CPU_X86_64 | BX_CPU_FSGSBASE)
bx_define_opcode(BX_IA_RDGSBASE, &BX_CPU_C::RDGSBASE, NULL, BX_CPU_X86_64 | BX_CPU_FSGSBASE)