[FAST486]

- Always use the descriptor type, and never the limit, to identify
legacy vs. modern TSSes.
- Don't forget to write back the modified TSS link.


svn path=/trunk/; revision=69407
This commit is contained in:
Aleksandar Andrejevic 2015-09-28 18:51:48 +00:00
parent 304222462c
commit 646f9543f1

View file

@ -716,7 +716,8 @@ Fast486TaskSwitch(PFAST486_STATE State, FAST486_TASK_SWITCH_TYPE Type, USHORT Se
if (!Fast486ReadLinearMemory(State, if (!Fast486ReadLinearMemory(State,
NewTssAddress, NewTssAddress,
&NewTss, &NewTss,
NewTssLimit >= (sizeof(FAST486_TSS) - 1) (NewTssDescriptor.Signature == FAST486_TSS_SIGNATURE)
|| (NewTssDescriptor.Signature == FAST486_BUSY_TSS_SIGNATURE)
? sizeof(FAST486_TSS) : sizeof(FAST486_LEGACY_TSS), ? sizeof(FAST486_TSS) : sizeof(FAST486_LEGACY_TSS),
FALSE)) FALSE))
{ {
@ -756,8 +757,37 @@ Fast486TaskSwitch(PFAST486_STATE State, FAST486_TASK_SWITCH_TYPE Type, USHORT Se
else else
{ {
/* Store the link */ /* Store the link */
if (NewTssLimit >= (sizeof(FAST486_TSS) - 1)) NewTss.Link = State->TaskReg.Selector; if ((NewTssDescriptor.Signature == FAST486_TSS_SIGNATURE)
else NewLegacyTss->Link = State->TaskReg.Selector; || (NewTssDescriptor.Signature == FAST486_BUSY_TSS_SIGNATURE))
{
NewTss.Link = State->TaskReg.Selector;
/* Write back the new TSS link */
if (!Fast486WriteLinearMemory(State,
NewTssAddress,
&NewTss.Link,
sizeof(NewTss.Link),
FALSE))
{
/* Exception occurred */
return FALSE;
}
}
else
{
NewLegacyTss->Link = State->TaskReg.Selector;
/* Write back the new legacy TSS link */
if (!Fast486WriteLinearMemory(State,
NewTssAddress,
&NewLegacyTss->Link,
sizeof(NewLegacyTss->Link),
FALSE))
{
/* Exception occurred */
return FALSE;
}
}
} }
/* Save the current task into the TSS */ /* Save the current task into the TSS */
@ -814,7 +844,17 @@ Fast486TaskSwitch(PFAST486_STATE State, FAST486_TASK_SWITCH_TYPE Type, USHORT Se
} }
/* Mark the new task as busy */ /* Mark the new task as busy */
if (NewTssDescriptor.Signature == FAST486_TSS_SIGNATURE
|| NewTssDescriptor.Signature == FAST486_BUSY_TSS_SIGNATURE)
{
/* 32-bit TSS */
NewTssDescriptor.Signature = FAST486_BUSY_TSS_SIGNATURE; NewTssDescriptor.Signature = FAST486_BUSY_TSS_SIGNATURE;
}
else
{
/* 16-bit TSS */
NewTssDescriptor.Signature = FAST486_BUSY_TSS_16_SIGNATURE;
}
/* Write back the new TSS descriptor */ /* Write back the new TSS descriptor */
if (!Fast486WriteLinearMemory(State, if (!Fast486WriteLinearMemory(State,
@ -835,7 +875,7 @@ Fast486TaskSwitch(PFAST486_STATE State, FAST486_TASK_SWITCH_TYPE Type, USHORT Se
State->TaskReg.Base = NewTssAddress; State->TaskReg.Base = NewTssAddress;
State->TaskReg.Limit = NewTssLimit; State->TaskReg.Limit = NewTssLimit;
if (NewTssLimit >= (sizeof(FAST486_TSS) - 1)) if (NewTssDescriptor.Signature == FAST486_BUSY_TSS_SIGNATURE)
{ {
/* Change the page directory */ /* Change the page directory */
State->ControlRegisters[FAST486_REG_CR3] = NewTss.Cr3; State->ControlRegisters[FAST486_REG_CR3] = NewTss.Cr3;
@ -845,8 +885,14 @@ Fast486TaskSwitch(PFAST486_STATE State, FAST486_TASK_SWITCH_TYPE Type, USHORT Se
Fast486FlushTlb(State); Fast486FlushTlb(State);
/* Update the CPL */ /* Update the CPL */
if (NewTssLimit >= (sizeof(FAST486_TSS) - 1)) State->Cpl = GET_SEGMENT_RPL(NewTss.Cs); if (NewTssDescriptor.Signature == FAST486_BUSY_TSS_SIGNATURE)
else State->Cpl = GET_SEGMENT_RPL(NewLegacyTss->Cs); {
State->Cpl = GET_SEGMENT_RPL(NewTss.Cs);
}
else
{
State->Cpl = GET_SEGMENT_RPL(NewLegacyTss->Cs);
}
#ifndef FAST486_NO_PREFETCH #ifndef FAST486_NO_PREFETCH
/* Context switching invalidates the prefetch */ /* Context switching invalidates the prefetch */
@ -854,7 +900,7 @@ Fast486TaskSwitch(PFAST486_STATE State, FAST486_TASK_SWITCH_TYPE Type, USHORT Se
#endif #endif
/* Load the registers */ /* Load the registers */
if (NewTssLimit >= (sizeof(FAST486_TSS) - 1)) if (NewTssDescriptor.Signature == FAST486_BUSY_TSS_SIGNATURE)
{ {
State->InstPtr.Long = State->SavedInstPtr.Long = NewTss.Eip; State->InstPtr.Long = State->SavedInstPtr.Long = NewTss.Eip;
State->Flags.Long = NewTss.Eflags; State->Flags.Long = NewTss.Eflags;
@ -970,7 +1016,7 @@ Fast486TaskSwitch(PFAST486_STATE State, FAST486_TASK_SWITCH_TYPE Type, USHORT Se
return FALSE; return FALSE;
} }
if (NewTssLimit >= (sizeof(FAST486_TSS) - 1)) if (NewTssDescriptor.Signature == FAST486_BUSY_TSS_SIGNATURE)
{ {
if (!Fast486LoadSegmentInternal(State, if (!Fast486LoadSegmentInternal(State,
FAST486_REG_FS, FAST486_REG_FS,