mirror of
https://github.com/reactos/reactos.git
synced 2025-05-01 03:29:37 +00:00
[FAST486]
Don't perform privilege checks while reading the IDT, GDT or TSS. svn path=/trunk/; revision=67648
This commit is contained in:
parent
ee08940855
commit
f1bf14da62
3 changed files with 39 additions and 22 deletions
|
@ -123,7 +123,7 @@ Fast486ReadMemory(PFAST486_STATE State,
|
||||||
{
|
{
|
||||||
/* We can't prefetch without possibly violating page permissions */
|
/* We can't prefetch without possibly violating page permissions */
|
||||||
State->PrefetchValid = FALSE;
|
State->PrefetchValid = FALSE;
|
||||||
return Fast486ReadLinearMemory(State, LinearAddress, Buffer, Size);
|
return Fast486ReadLinearMemory(State, LinearAddress, Buffer, Size, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,8 @@ Fast486ReadMemory(PFAST486_STATE State,
|
||||||
if (Fast486ReadLinearMemory(State,
|
if (Fast486ReadLinearMemory(State,
|
||||||
State->PrefetchAddress,
|
State->PrefetchAddress,
|
||||||
State->PrefetchCache,
|
State->PrefetchCache,
|
||||||
FAST486_CACHE_SIZE))
|
FAST486_CACHE_SIZE,
|
||||||
|
TRUE))
|
||||||
{
|
{
|
||||||
State->PrefetchValid = TRUE;
|
State->PrefetchValid = TRUE;
|
||||||
|
|
||||||
|
@ -150,7 +151,7 @@ Fast486ReadMemory(PFAST486_STATE State,
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* Read from the linear address */
|
/* Read from the linear address */
|
||||||
return Fast486ReadLinearMemory(State, LinearAddress, Buffer, Size);
|
return Fast486ReadLinearMemory(State, LinearAddress, Buffer, Size, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,7 +237,7 @@ Fast486WriteMemory(PFAST486_STATE State,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Write to the linear address */
|
/* Write to the linear address */
|
||||||
return Fast486WriteLinearMemory(State, LinearAddress, Buffer, Size);
|
return Fast486WriteLinearMemory(State, LinearAddress, Buffer, Size, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOLEAN
|
static inline BOOLEAN
|
||||||
|
@ -253,7 +254,8 @@ Fast486GetIntVector(PFAST486_STATE State,
|
||||||
State->Idtr.Address
|
State->Idtr.Address
|
||||||
+ Number * sizeof(*IdtEntry),
|
+ Number * sizeof(*IdtEntry),
|
||||||
IdtEntry,
|
IdtEntry,
|
||||||
sizeof(*IdtEntry)))
|
sizeof(*IdtEntry),
|
||||||
|
FALSE))
|
||||||
{
|
{
|
||||||
/* Exception occurred */
|
/* Exception occurred */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -325,7 +327,8 @@ Fast486InterruptInternal(PFAST486_STATE State,
|
||||||
State->TaskReg.Base,
|
State->TaskReg.Base,
|
||||||
&Tss,
|
&Tss,
|
||||||
State->TaskReg.Limit >= sizeof(FAST486_TSS)
|
State->TaskReg.Limit >= sizeof(FAST486_TSS)
|
||||||
? sizeof(FAST486_TSS) : sizeof(FAST486_LEGACY_TSS)))
|
? sizeof(FAST486_TSS) : sizeof(FAST486_LEGACY_TSS),
|
||||||
|
FALSE))
|
||||||
{
|
{
|
||||||
/* Exception occurred */
|
/* Exception occurred */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -622,7 +625,8 @@ Fast486TaskSwitch(PFAST486_STATE State, FAST486_TASK_SWITCH_TYPE Type, USHORT Se
|
||||||
State->TaskReg.Base,
|
State->TaskReg.Base,
|
||||||
&OldTss,
|
&OldTss,
|
||||||
State->TaskReg.Limit >= sizeof(FAST486_TSS)
|
State->TaskReg.Limit >= sizeof(FAST486_TSS)
|
||||||
? sizeof(FAST486_TSS) : sizeof(FAST486_LEGACY_TSS)))
|
? sizeof(FAST486_TSS) : sizeof(FAST486_LEGACY_TSS),
|
||||||
|
FALSE))
|
||||||
{
|
{
|
||||||
/* Exception occurred */
|
/* Exception occurred */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -649,7 +653,8 @@ Fast486TaskSwitch(PFAST486_STATE State, FAST486_TASK_SWITCH_TYPE Type, USHORT Se
|
||||||
if (!Fast486ReadLinearMemory(State,
|
if (!Fast486ReadLinearMemory(State,
|
||||||
State->Gdtr.Address + GET_SEGMENT_INDEX(Selector),
|
State->Gdtr.Address + GET_SEGMENT_INDEX(Selector),
|
||||||
&NewTssDescriptor,
|
&NewTssDescriptor,
|
||||||
sizeof(NewTssDescriptor)))
|
sizeof(NewTssDescriptor),
|
||||||
|
FALSE))
|
||||||
{
|
{
|
||||||
/* Exception occurred */
|
/* Exception occurred */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -703,7 +708,8 @@ Fast486TaskSwitch(PFAST486_STATE State, FAST486_TASK_SWITCH_TYPE Type, USHORT Se
|
||||||
NewTssAddress,
|
NewTssAddress,
|
||||||
&NewTss,
|
&NewTss,
|
||||||
NewTssLimit >= sizeof(FAST486_TSS)
|
NewTssLimit >= sizeof(FAST486_TSS)
|
||||||
? sizeof(FAST486_TSS) : sizeof(FAST486_LEGACY_TSS)))
|
? sizeof(FAST486_TSS) : sizeof(FAST486_LEGACY_TSS),
|
||||||
|
FALSE))
|
||||||
{
|
{
|
||||||
/* Exception occurred */
|
/* Exception occurred */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -718,7 +724,8 @@ Fast486TaskSwitch(PFAST486_STATE State, FAST486_TASK_SWITCH_TYPE Type, USHORT Se
|
||||||
State->Gdtr.Address
|
State->Gdtr.Address
|
||||||
+ GET_SEGMENT_INDEX(State->TaskReg.Selector),
|
+ GET_SEGMENT_INDEX(State->TaskReg.Selector),
|
||||||
&OldTssDescriptor,
|
&OldTssDescriptor,
|
||||||
sizeof(OldTssDescriptor)))
|
sizeof(OldTssDescriptor),
|
||||||
|
FALSE))
|
||||||
{
|
{
|
||||||
/* Exception occurred */
|
/* Exception occurred */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -730,7 +737,8 @@ Fast486TaskSwitch(PFAST486_STATE State, FAST486_TASK_SWITCH_TYPE Type, USHORT Se
|
||||||
State->Gdtr.Address
|
State->Gdtr.Address
|
||||||
+ GET_SEGMENT_INDEX(State->TaskReg.Selector),
|
+ GET_SEGMENT_INDEX(State->TaskReg.Selector),
|
||||||
&OldTssDescriptor,
|
&OldTssDescriptor,
|
||||||
sizeof(OldTssDescriptor)))
|
sizeof(OldTssDescriptor),
|
||||||
|
FALSE))
|
||||||
{
|
{
|
||||||
/* Exception occurred */
|
/* Exception occurred */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -789,7 +797,8 @@ Fast486TaskSwitch(PFAST486_STATE State, FAST486_TASK_SWITCH_TYPE Type, USHORT Se
|
||||||
State->TaskReg.Base,
|
State->TaskReg.Base,
|
||||||
&OldTss,
|
&OldTss,
|
||||||
State->TaskReg.Limit >= sizeof(FAST486_TSS)
|
State->TaskReg.Limit >= sizeof(FAST486_TSS)
|
||||||
? sizeof(FAST486_TSS) : sizeof(FAST486_LEGACY_TSS)))
|
? sizeof(FAST486_TSS) : sizeof(FAST486_LEGACY_TSS),
|
||||||
|
FALSE))
|
||||||
{
|
{
|
||||||
/* Exception occurred */
|
/* Exception occurred */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -802,7 +811,8 @@ Fast486TaskSwitch(PFAST486_STATE State, FAST486_TASK_SWITCH_TYPE Type, USHORT Se
|
||||||
if (!Fast486WriteLinearMemory(State,
|
if (!Fast486WriteLinearMemory(State,
|
||||||
State->Gdtr.Address + GET_SEGMENT_INDEX(Selector),
|
State->Gdtr.Address + GET_SEGMENT_INDEX(Selector),
|
||||||
&NewTssDescriptor,
|
&NewTssDescriptor,
|
||||||
sizeof(NewTssDescriptor)))
|
sizeof(NewTssDescriptor),
|
||||||
|
FALSE))
|
||||||
{
|
{
|
||||||
/* Exception occurred */
|
/* Exception occurred */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1041,7 +1051,8 @@ Fast486CallGate(PFAST486_STATE State,
|
||||||
State->TaskReg.Base,
|
State->TaskReg.Base,
|
||||||
&Tss,
|
&Tss,
|
||||||
State->TaskReg.Limit >= sizeof(FAST486_TSS)
|
State->TaskReg.Limit >= sizeof(FAST486_TSS)
|
||||||
? sizeof(FAST486_TSS) : sizeof(FAST486_LEGACY_TSS)))
|
? sizeof(FAST486_TSS) : sizeof(FAST486_LEGACY_TSS),
|
||||||
|
FALSE))
|
||||||
{
|
{
|
||||||
/* Exception occurred */
|
/* Exception occurred */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -150,7 +150,8 @@ FASTCALL
|
||||||
Fast486ReadLinearMemory(PFAST486_STATE State,
|
Fast486ReadLinearMemory(PFAST486_STATE State,
|
||||||
ULONG LinearAddress,
|
ULONG LinearAddress,
|
||||||
PVOID Buffer,
|
PVOID Buffer,
|
||||||
ULONG Size)
|
ULONG Size,
|
||||||
|
BOOLEAN CheckPrivilege)
|
||||||
{
|
{
|
||||||
/* Check if paging is enabled */
|
/* Check if paging is enabled */
|
||||||
if (State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_PG)
|
if (State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_PG)
|
||||||
|
@ -177,7 +178,7 @@ Fast486ReadLinearMemory(PFAST486_STATE State,
|
||||||
PageLength -= PageOffset;
|
PageLength -= PageOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TableEntry.Present || (!TableEntry.Usermode && (Cpl > 0)))
|
if (CheckPrivilege && (!TableEntry.Present || (!TableEntry.Usermode && (Cpl > 0))))
|
||||||
{
|
{
|
||||||
State->ControlRegisters[FAST486_REG_CR2] = Page + PageOffset;
|
State->ControlRegisters[FAST486_REG_CR2] = Page + PageOffset;
|
||||||
|
|
||||||
|
@ -219,7 +220,8 @@ FASTCALL
|
||||||
Fast486WriteLinearMemory(PFAST486_STATE State,
|
Fast486WriteLinearMemory(PFAST486_STATE State,
|
||||||
ULONG LinearAddress,
|
ULONG LinearAddress,
|
||||||
PVOID Buffer,
|
PVOID Buffer,
|
||||||
ULONG Size)
|
ULONG Size,
|
||||||
|
BOOLEAN CheckPrivilege)
|
||||||
{
|
{
|
||||||
/* Check if paging is enabled */
|
/* Check if paging is enabled */
|
||||||
if (State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_PG)
|
if (State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_PG)
|
||||||
|
@ -246,9 +248,10 @@ Fast486WriteLinearMemory(PFAST486_STATE State,
|
||||||
PageLength -= PageOffset;
|
PageLength -= PageOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!TableEntry.Present || (!TableEntry.Usermode && (Cpl > 0)))
|
if (CheckPrivilege
|
||||||
|
&& ((!TableEntry.Present || (!TableEntry.Usermode && (Cpl > 0)))
|
||||||
|| ((State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_WP)
|
|| ((State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_WP)
|
||||||
&& !TableEntry.Writeable))
|
&& !TableEntry.Writeable)))
|
||||||
{
|
{
|
||||||
State->ControlRegisters[FAST486_REG_CR2] = Page + PageOffset;
|
State->ControlRegisters[FAST486_REG_CR2] = Page + PageOffset;
|
||||||
|
|
||||||
|
@ -503,7 +506,8 @@ Fast486ReadDescriptorEntry(PFAST486_STATE State,
|
||||||
State->Gdtr.Address
|
State->Gdtr.Address
|
||||||
+ GET_SEGMENT_INDEX(Selector),
|
+ GET_SEGMENT_INDEX(Selector),
|
||||||
Entry,
|
Entry,
|
||||||
sizeof(*Entry)))
|
sizeof(*Entry),
|
||||||
|
FALSE))
|
||||||
{
|
{
|
||||||
/* Exception occurred */
|
/* Exception occurred */
|
||||||
*EntryValid = FALSE;
|
*EntryValid = FALSE;
|
||||||
|
@ -524,7 +528,8 @@ Fast486ReadDescriptorEntry(PFAST486_STATE State,
|
||||||
State->Ldtr.Base
|
State->Ldtr.Base
|
||||||
+ GET_SEGMENT_INDEX(Selector),
|
+ GET_SEGMENT_INDEX(Selector),
|
||||||
Entry,
|
Entry,
|
||||||
sizeof(*Entry)))
|
sizeof(*Entry),
|
||||||
|
FALSE))
|
||||||
{
|
{
|
||||||
/* Exception occurred */
|
/* Exception occurred */
|
||||||
*EntryValid = FALSE;
|
*EntryValid = FALSE;
|
||||||
|
|
|
@ -1979,7 +1979,8 @@ FAST486_OPCODE_HANDLER(Fast486ExtOpcodeGroup0F00)
|
||||||
Fast486WriteLinearMemory(State,
|
Fast486WriteLinearMemory(State,
|
||||||
State->Gdtr.Address + GET_SEGMENT_INDEX(Selector),
|
State->Gdtr.Address + GET_SEGMENT_INDEX(Selector),
|
||||||
&GdtEntry,
|
&GdtEntry,
|
||||||
sizeof(GdtEntry));
|
sizeof(GdtEntry),
|
||||||
|
FALSE /* We already made sure CPL is 0 */);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue