Got rid of Ctrl-M's in exception.cc, introduced with the
implementation of SYSCALL.
This commit is contained in:
parent
6dff398915
commit
2baf4372d1
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: exception.cc,v 1.25 2002-10-03 04:52:39 bdenney Exp $
|
||||
// $Id: exception.cc,v 1.26 2002-10-06 18:05:21 kevinlawton Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -1070,63 +1070,63 @@ BX_CPU_C::SYSCALL(bxInstruction_c *i)
|
||||
SYSCALL_START:
|
||||
|
||||
IF (MSR_EFER.SCE = 0) // Check if syscall/sysret are enabled.
|
||||
EXCEPTION [#UD]
|
||||
|
||||
IF (LONG_MODE)
|
||||
SYSCALL_LONG_MODE
|
||||
ELSE // (LEGACY_MODE)
|
||||
SYSCALL_LEGACY_MODE
|
||||
|
||||
|
||||
SYSCALL_LONG_MODE:
|
||||
|
||||
RCX.q = next_RIP
|
||||
R11.q = RFLAGS // with rf cleared
|
||||
|
||||
IF (64BIT_MODE)
|
||||
temp_RIP.q = MSR_LSTAR
|
||||
ELSE // (COMPATIBILITY_MODE)
|
||||
temp_RIP.q = MSR_CSTAR
|
||||
|
||||
CS.sel = MSR_STAR.SYSCALL_CS AND 0xFFFC
|
||||
CS.attr = 64-bit code,dpl0 // Always switch to 64-bit mode in long mode.
|
||||
CS.base = 0x00000000
|
||||
CS.limit = 0xFFFFFFFF
|
||||
|
||||
SS.sel = MSR_STAR.SYSCALL_CS + 8
|
||||
SS.attr = 64-bit stack,dpl0
|
||||
SS.base = 0x00000000
|
||||
SS.limit = 0xFFFFFFFF
|
||||
|
||||
RFLAGS = RFLAGS AND ~MSR_SFMASK
|
||||
RFLAGS.RF = 0
|
||||
|
||||
CPL = 0
|
||||
|
||||
RIP = temp_RIP
|
||||
EXIT
|
||||
|
||||
SYSCALL_LEGACY_MODE:
|
||||
|
||||
RCX.d = next_RIP
|
||||
|
||||
temp_RIP.d = MSR_STAR.EIP
|
||||
|
||||
CS.sel = MSR_STAR.SYSCALL_CS AND 0xFFFC
|
||||
CS.attr = 32-bit code,dpl0 // Always switch to 32-bit mode in legacy mode.
|
||||
CS.base = 0x00000000
|
||||
CS.limit = 0xFFFFFFFF
|
||||
|
||||
SS.sel = MSR_STAR.SYSCALL_CS + 8
|
||||
SS.attr = 32-bit stack,dpl0
|
||||
SS.base = 0x00000000
|
||||
SS.limit = 0xFFFFFFFF
|
||||
|
||||
RFLAGS.VM,IF,RF=0
|
||||
|
||||
CPL = 0
|
||||
|
||||
RIP = temp_RIP
|
||||
EXCEPTION [#UD]
|
||||
|
||||
IF (LONG_MODE)
|
||||
SYSCALL_LONG_MODE
|
||||
ELSE // (LEGACY_MODE)
|
||||
SYSCALL_LEGACY_MODE
|
||||
|
||||
|
||||
SYSCALL_LONG_MODE:
|
||||
|
||||
RCX.q = next_RIP
|
||||
R11.q = RFLAGS // with rf cleared
|
||||
|
||||
IF (64BIT_MODE)
|
||||
temp_RIP.q = MSR_LSTAR
|
||||
ELSE // (COMPATIBILITY_MODE)
|
||||
temp_RIP.q = MSR_CSTAR
|
||||
|
||||
CS.sel = MSR_STAR.SYSCALL_CS AND 0xFFFC
|
||||
CS.attr = 64-bit code,dpl0 // Always switch to 64-bit mode in long mode.
|
||||
CS.base = 0x00000000
|
||||
CS.limit = 0xFFFFFFFF
|
||||
|
||||
SS.sel = MSR_STAR.SYSCALL_CS + 8
|
||||
SS.attr = 64-bit stack,dpl0
|
||||
SS.base = 0x00000000
|
||||
SS.limit = 0xFFFFFFFF
|
||||
|
||||
RFLAGS = RFLAGS AND ~MSR_SFMASK
|
||||
RFLAGS.RF = 0
|
||||
|
||||
CPL = 0
|
||||
|
||||
RIP = temp_RIP
|
||||
EXIT
|
||||
|
||||
SYSCALL_LEGACY_MODE:
|
||||
|
||||
RCX.d = next_RIP
|
||||
|
||||
temp_RIP.d = MSR_STAR.EIP
|
||||
|
||||
CS.sel = MSR_STAR.SYSCALL_CS AND 0xFFFC
|
||||
CS.attr = 32-bit code,dpl0 // Always switch to 32-bit mode in legacy mode.
|
||||
CS.base = 0x00000000
|
||||
CS.limit = 0xFFFFFFFF
|
||||
|
||||
SS.sel = MSR_STAR.SYSCALL_CS + 8
|
||||
SS.attr = 32-bit stack,dpl0
|
||||
SS.base = 0x00000000
|
||||
SS.limit = 0xFFFFFFFF
|
||||
|
||||
RFLAGS.VM,IF,RF=0
|
||||
|
||||
CPL = 0
|
||||
|
||||
RIP = temp_RIP
|
||||
EXIT
|
||||
|
||||
*/
|
||||
@ -1200,53 +1200,53 @@ BX_CPU_C::SYSRET(bxInstruction_c *i)
|
||||
/* from AMD manual
|
||||
|
||||
SYSRET_START:
|
||||
|
||||
IF (MSR_EFER.SCE = 0) // Check if syscall/sysret are enabled.
|
||||
EXCEPTION [#UD]
|
||||
|
||||
IF ((!PROTECTED_MODE) || (CPL != 0))
|
||||
EXCEPTION [#GP(0)] // SYSRET requires protected mode, cpl0
|
||||
|
||||
IF (64BIT_MODE)
|
||||
SYSRET_64BIT_MODE
|
||||
ELSE // (!64BIT_MODE)
|
||||
SYSRET_NON_64BIT_MODE
|
||||
|
||||
SYSRET_64BIT_MODE:
|
||||
IF (OPERAND_SIZE = 64) // Return to 64-bit mode.
|
||||
{
|
||||
CS.sel = (MSR_STAR.SYSRET_CS + 16) OR 3
|
||||
CS.base = 0x00000000
|
||||
CS.limit = 0xFFFFFFFF
|
||||
CS.attr = 64-bit code,dpl3
|
||||
temp_RIP.q = RCX
|
||||
}
|
||||
ELSE // Return to 32-bit compatibility mode.
|
||||
{
|
||||
CS.sel = MSR_STAR.SYSRET_CS OR 3
|
||||
CS.base = 0x00000000
|
||||
CS.limit = 0xFFFFFFFF
|
||||
CS.attr = 32-bit code,dpl3
|
||||
temp_RIP.d = RCX
|
||||
}
|
||||
SS.sel = MSR_STAR.SYSRET_CS + 8 // SS selector is changed,
|
||||
// SS base, limit, attributes unchanged.
|
||||
RFLAGS.q = R11 // RF=0,VM=0
|
||||
CPL = 3
|
||||
RIP = temp_RIP
|
||||
EXIT
|
||||
|
||||
SYSRET_NON_64BIT_MODE:
|
||||
CS.sel = MSR_STAR.SYSRET_CS OR 3 // Return to 32-bit legacy protected mode.
|
||||
CS.base = 0x00000000
|
||||
CS.limit = 0xFFFFFFFF
|
||||
CS.attr = 32-bit code,dpl3
|
||||
temp_RIP.d = RCX
|
||||
SS.sel = MSR_STAR.SYSRET_CS + 8 // SS selector is changed.
|
||||
// SS base, limit, attributes unchanged.
|
||||
RFLAGS.IF = 1
|
||||
CPL = 3
|
||||
RIP = temp_RIP
|
||||
|
||||
IF (MSR_EFER.SCE = 0) // Check if syscall/sysret are enabled.
|
||||
EXCEPTION [#UD]
|
||||
|
||||
IF ((!PROTECTED_MODE) || (CPL != 0))
|
||||
EXCEPTION [#GP(0)] // SYSRET requires protected mode, cpl0
|
||||
|
||||
IF (64BIT_MODE)
|
||||
SYSRET_64BIT_MODE
|
||||
ELSE // (!64BIT_MODE)
|
||||
SYSRET_NON_64BIT_MODE
|
||||
|
||||
SYSRET_64BIT_MODE:
|
||||
IF (OPERAND_SIZE = 64) // Return to 64-bit mode.
|
||||
{
|
||||
CS.sel = (MSR_STAR.SYSRET_CS + 16) OR 3
|
||||
CS.base = 0x00000000
|
||||
CS.limit = 0xFFFFFFFF
|
||||
CS.attr = 64-bit code,dpl3
|
||||
temp_RIP.q = RCX
|
||||
}
|
||||
ELSE // Return to 32-bit compatibility mode.
|
||||
{
|
||||
CS.sel = MSR_STAR.SYSRET_CS OR 3
|
||||
CS.base = 0x00000000
|
||||
CS.limit = 0xFFFFFFFF
|
||||
CS.attr = 32-bit code,dpl3
|
||||
temp_RIP.d = RCX
|
||||
}
|
||||
SS.sel = MSR_STAR.SYSRET_CS + 8 // SS selector is changed,
|
||||
// SS base, limit, attributes unchanged.
|
||||
RFLAGS.q = R11 // RF=0,VM=0
|
||||
CPL = 3
|
||||
RIP = temp_RIP
|
||||
EXIT
|
||||
|
||||
SYSRET_NON_64BIT_MODE:
|
||||
CS.sel = MSR_STAR.SYSRET_CS OR 3 // Return to 32-bit legacy protected mode.
|
||||
CS.base = 0x00000000
|
||||
CS.limit = 0xFFFFFFFF
|
||||
CS.attr = 32-bit code,dpl3
|
||||
temp_RIP.d = RCX
|
||||
SS.sel = MSR_STAR.SYSRET_CS + 8 // SS selector is changed.
|
||||
// SS base, limit, attributes unchanged.
|
||||
RFLAGS.IF = 1
|
||||
CPL = 3
|
||||
RIP = temp_RIP
|
||||
EXIT
|
||||
|
||||
*/
|
||||
@ -1276,47 +1276,47 @@ SYSRET_NON_64BIT_MODE:
|
||||
|
||||
temp_RIP = RCX;
|
||||
|
||||
}
|
||||
else { // Return to 32-bit compatibility mode.
|
||||
|
||||
parse_selector((MSR_STAR >> 48) | 3, &cs_selector);
|
||||
fetch_raw_descriptor(&cs_selector, &dword1, &dword2, BX_GP_EXCEPTION);
|
||||
}
|
||||
else { // Return to 32-bit compatibility mode.
|
||||
|
||||
parse_selector((MSR_STAR >> 48) | 3, &cs_selector);
|
||||
fetch_raw_descriptor(&cs_selector, &dword1, &dword2, BX_GP_EXCEPTION);
|
||||
parse_descriptor(dword1, dword2, &cs_descriptor);
|
||||
load_cs(&cs_selector, &cs_descriptor, 3);
|
||||
|
||||
temp_RIP = ECX;
|
||||
|
||||
}
|
||||
|
||||
parse_selector((MSR_STAR >> 48) + 8, &ss_selector);
|
||||
fetch_raw_descriptor(&ss_selector, &dword1, &dword2, BX_GP_EXCEPTION);
|
||||
temp_RIP = ECX;
|
||||
|
||||
}
|
||||
|
||||
parse_selector((MSR_STAR >> 48) + 8, &ss_selector);
|
||||
fetch_raw_descriptor(&ss_selector, &dword1, &dword2, BX_GP_EXCEPTION);
|
||||
parse_descriptor(dword1, dword2, &ss_descriptor);
|
||||
load_ss(&ss_selector, &ss_descriptor, 0);
|
||||
|
||||
// SS base, limit, attributes unchanged.
|
||||
write_eflags(R11,1,1,1,1);
|
||||
|
||||
RIP = temp_RIP;
|
||||
|
||||
}
|
||||
else { // (!64BIT_MODE)
|
||||
|
||||
parse_selector((MSR_STAR >> 48) + 16, &cs_selector);
|
||||
fetch_raw_descriptor(&cs_selector, &dword1, &dword2, BX_GP_EXCEPTION);
|
||||
// SS base, limit, attributes unchanged.
|
||||
write_eflags(R11,1,1,1,1);
|
||||
|
||||
RIP = temp_RIP;
|
||||
|
||||
}
|
||||
else { // (!64BIT_MODE)
|
||||
|
||||
parse_selector((MSR_STAR >> 48) + 16, &cs_selector);
|
||||
fetch_raw_descriptor(&cs_selector, &dword1, &dword2, BX_GP_EXCEPTION);
|
||||
parse_descriptor(dword1, dword2, &cs_descriptor);
|
||||
load_cs(&cs_selector, &cs_descriptor, 3);
|
||||
|
||||
temp_RIP = ECX;
|
||||
|
||||
parse_selector((MSR_STAR >> 48) + 8, &ss_selector);
|
||||
fetch_raw_descriptor(&ss_selector, &dword1, &dword2, BX_GP_EXCEPTION);
|
||||
temp_RIP = ECX;
|
||||
|
||||
parse_selector((MSR_STAR >> 48) + 8, &ss_selector);
|
||||
fetch_raw_descriptor(&ss_selector, &dword1, &dword2, BX_GP_EXCEPTION);
|
||||
parse_descriptor(dword1, dword2, &ss_descriptor);
|
||||
load_ss(&ss_selector, &ss_descriptor, 0);
|
||||
|
||||
BX_CPU_THIS_PTR assert_IF ();
|
||||
|
||||
RIP = temp_RIP;
|
||||
BX_CPU_THIS_PTR assert_IF ();
|
||||
|
||||
RIP = temp_RIP;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endif // BX_SUPPORT_X86_64
|
||||
|
Loading…
Reference in New Issue
Block a user