/* Get the table entry */
TableEntry.Value = Fast486GetPageTableEntry(State, Page, FALSE);
+ /* Check if this is the first page */
+ if (Page == PAGE_ALIGN(LinearAddress))
+ {
+ /* Start reading from the offset from the beginning of the page */
+ PageOffset = PAGE_OFFSET(LinearAddress);
+ PageLength -= PageOffset;
+ }
+
if (!TableEntry.Present || (!TableEntry.Usermode && (Cpl > 0)))
{
+ State->ControlRegisters[FAST486_REG_CR2] = Page + PageOffset;
+
/* Exception */
Fast486ExceptionWithErrorCode(State,
FAST486_EXCEPTION_PF,
return FALSE;
}
- /* Check if this is the first page */
- if (Page == PAGE_ALIGN(LinearAddress))
- {
- /* Start reading from the offset from the beginning of the page */
- PageOffset = PAGE_OFFSET(LinearAddress);
- PageLength -= PageOffset;
- }
-
/* Check if this is the last page */
if (Page == PAGE_ALIGN(LinearAddress + Size - 1))
{
/* Get the table entry */
TableEntry.Value = Fast486GetPageTableEntry(State, Page, TRUE);
+ /* Check if this is the first page */
+ if (Page == PAGE_ALIGN(LinearAddress))
+ {
+ /* Start writing from the offset from the beginning of the page */
+ PageOffset = PAGE_OFFSET(LinearAddress);
+ PageLength -= PageOffset;
+ }
+
if ((!TableEntry.Present || (!TableEntry.Usermode && (Cpl > 0)))
|| ((State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_WP)
&& !TableEntry.Writeable))
{
+ State->ControlRegisters[FAST486_REG_CR2] = Page + PageOffset;
+
/* Exception */
Fast486ExceptionWithErrorCode(State,
FAST486_EXCEPTION_PF,
return FALSE;
}
- /* Check if this is the first page */
- if (Page == PAGE_ALIGN(LinearAddress))
- {
- /* Start writing from the offset from the beginning of the page */
- PageOffset = PAGE_OFFSET(LinearAddress);
- PageLength -= PageOffset;
- }
-
/* Check if this is the last page */
if (Page == PAGE_ALIGN(LinearAddress + Size - 1))
{