mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 07:56:59 +00:00
[NTOS:MM] Make use of FaultCode and MI_IS_NOT_PRESENT_FAULT and MI_IS_WRITE_ACCESS macros in MmArmAccessFault.
This commit is contained in:
parent
d5c71429d7
commit
4d043aa05e
4 changed files with 18 additions and 16 deletions
|
@ -108,6 +108,7 @@
|
||||||
|
|
||||||
/* Macros to identify the page fault reason from the error code */
|
/* Macros to identify the page fault reason from the error code */
|
||||||
#define MI_IS_NOT_PRESENT_FAULT(FaultCode) !BooleanFlagOn(FaultCode, 0x1)
|
#define MI_IS_NOT_PRESENT_FAULT(FaultCode) !BooleanFlagOn(FaultCode, 0x1)
|
||||||
|
#define MI_IS_WRITE_ACCESS(FaultCode) BooleanFlagOn(FaultCode, 0x2)
|
||||||
|
|
||||||
/* On x64, these are the same */
|
/* On x64, these are the same */
|
||||||
#define MI_WRITE_VALID_PPE MI_WRITE_VALID_PTE
|
#define MI_WRITE_VALID_PPE MI_WRITE_VALID_PTE
|
||||||
|
|
|
@ -90,6 +90,7 @@
|
||||||
|
|
||||||
/* Macros to identify the page fault reason from the error code */
|
/* Macros to identify the page fault reason from the error code */
|
||||||
#define MI_IS_NOT_PRESENT_FAULT(FaultCode) TRUE
|
#define MI_IS_NOT_PRESENT_FAULT(FaultCode) TRUE
|
||||||
|
#define MI_IS_WRITE_ACCESS(FaultCode) TRUE
|
||||||
|
|
||||||
/* Convert an address to a corresponding PTE */
|
/* Convert an address to a corresponding PTE */
|
||||||
#define MiAddressToPte(x) \
|
#define MiAddressToPte(x) \
|
||||||
|
|
|
@ -114,6 +114,7 @@
|
||||||
|
|
||||||
/* Macros to identify the page fault reason from the error code */
|
/* Macros to identify the page fault reason from the error code */
|
||||||
#define MI_IS_NOT_PRESENT_FAULT(FaultCode) !BooleanFlagOn(FaultCode, 0x1)
|
#define MI_IS_NOT_PRESENT_FAULT(FaultCode) !BooleanFlagOn(FaultCode, 0x1)
|
||||||
|
#define MI_IS_WRITE_ACCESS(FaultCode) BooleanFlagOn(FaultCode, 0x2)
|
||||||
|
|
||||||
/* On x86, these two are the same */
|
/* On x86, these two are the same */
|
||||||
#define MI_WRITE_VALID_PPE MI_WRITE_VALID_PTE
|
#define MI_WRITE_VALID_PPE MI_WRITE_VALID_PTE
|
||||||
|
|
|
@ -1644,7 +1644,6 @@ MmArmAccessFault(IN ULONG FaultCode,
|
||||||
ULONG Color;
|
ULONG Color;
|
||||||
BOOLEAN IsSessionAddress;
|
BOOLEAN IsSessionAddress;
|
||||||
PMMPFN Pfn1;
|
PMMPFN Pfn1;
|
||||||
BOOLEAN StoreInstruction = !MI_IS_NOT_PRESENT_FAULT(FaultCode);
|
|
||||||
DPRINT("ARM3 FAULT AT: %p\n", Address);
|
DPRINT("ARM3 FAULT AT: %p\n", Address);
|
||||||
|
|
||||||
/* Check for page fault on high IRQL */
|
/* Check for page fault on high IRQL */
|
||||||
|
@ -1694,10 +1693,10 @@ MmArmAccessFault(IN ULONG FaultCode,
|
||||||
|
|
||||||
/* Not yet implemented in ReactOS */
|
/* Not yet implemented in ReactOS */
|
||||||
ASSERT(MI_IS_PAGE_LARGE(PointerPde) == FALSE);
|
ASSERT(MI_IS_PAGE_LARGE(PointerPde) == FALSE);
|
||||||
ASSERT(((StoreInstruction) && MI_IS_PAGE_COPY_ON_WRITE(PointerPte)) == FALSE);
|
ASSERT((!MI_IS_NOT_PRESENT_FAULT(FaultCode) && MI_IS_PAGE_COPY_ON_WRITE(PointerPte)) == FALSE);
|
||||||
|
|
||||||
/* Check if this was a write */
|
/* Check if this was a write */
|
||||||
if (StoreInstruction)
|
if (MI_IS_WRITE_ACCESS(FaultCode))
|
||||||
{
|
{
|
||||||
/* Was it to a read-only page? */
|
/* Was it to a read-only page? */
|
||||||
Pfn1 = MI_PFN_ELEMENT(PointerPte->u.Hard.PageFrameNumber);
|
Pfn1 = MI_PFN_ELEMENT(PointerPte->u.Hard.PageFrameNumber);
|
||||||
|
@ -1745,7 +1744,7 @@ MmArmAccessFault(IN ULONG FaultCode,
|
||||||
/* PXE/PPE/PDE (still) not valid, kill the system */
|
/* PXE/PPE/PDE (still) not valid, kill the system */
|
||||||
KeBugCheckEx(PAGE_FAULT_IN_NONPAGED_AREA,
|
KeBugCheckEx(PAGE_FAULT_IN_NONPAGED_AREA,
|
||||||
(ULONG_PTR)Address,
|
(ULONG_PTR)Address,
|
||||||
StoreInstruction,
|
FaultCode,
|
||||||
(ULONG_PTR)TrapInformation,
|
(ULONG_PTR)TrapInformation,
|
||||||
2);
|
2);
|
||||||
}
|
}
|
||||||
|
@ -1766,7 +1765,7 @@ MmArmAccessFault(IN ULONG FaultCode,
|
||||||
if (TempPte.u.Hard.Valid)
|
if (TempPte.u.Hard.Valid)
|
||||||
{
|
{
|
||||||
/* Check if this was a write */
|
/* Check if this was a write */
|
||||||
if (StoreInstruction)
|
if (MI_IS_WRITE_ACCESS(FaultCode))
|
||||||
{
|
{
|
||||||
/* Was it to a read-only page? */
|
/* Was it to a read-only page? */
|
||||||
Pfn1 = MI_PFN_ELEMENT(PointerPte->u.Hard.PageFrameNumber);
|
Pfn1 = MI_PFN_ELEMENT(PointerPte->u.Hard.PageFrameNumber);
|
||||||
|
@ -1799,7 +1798,7 @@ MmArmAccessFault(IN ULONG FaultCode,
|
||||||
/* It failed, this address is invalid */
|
/* It failed, this address is invalid */
|
||||||
KeBugCheckEx(PAGE_FAULT_IN_NONPAGED_AREA,
|
KeBugCheckEx(PAGE_FAULT_IN_NONPAGED_AREA,
|
||||||
(ULONG_PTR)Address,
|
(ULONG_PTR)Address,
|
||||||
StoreInstruction,
|
FaultCode,
|
||||||
(ULONG_PTR)TrapInformation,
|
(ULONG_PTR)TrapInformation,
|
||||||
6);
|
6);
|
||||||
}
|
}
|
||||||
|
@ -1867,7 +1866,7 @@ _WARN("Session space stuff is not implemented yet!")
|
||||||
if (TempPte.u.Hard.Valid == 1)
|
if (TempPte.u.Hard.Valid == 1)
|
||||||
{
|
{
|
||||||
/* Check if this was a write */
|
/* Check if this was a write */
|
||||||
if (StoreInstruction)
|
if (MI_IS_WRITE_ACCESS(FaultCode))
|
||||||
{
|
{
|
||||||
/* Was it to a read-only page that is not copy on write? */
|
/* Was it to a read-only page that is not copy on write? */
|
||||||
Pfn1 = MI_PFN_ELEMENT(PointerPte->u.Hard.PageFrameNumber);
|
Pfn1 = MI_PFN_ELEMENT(PointerPte->u.Hard.PageFrameNumber);
|
||||||
|
@ -1889,7 +1888,7 @@ _WARN("Session space stuff is not implemented yet!")
|
||||||
|
|
||||||
/* Check for read-only write in session space */
|
/* Check for read-only write in session space */
|
||||||
if ((IsSessionAddress) &&
|
if ((IsSessionAddress) &&
|
||||||
(StoreInstruction) &&
|
MI_IS_WRITE_ACCESS(FaultCode) &&
|
||||||
!MI_IS_PAGE_WRITEABLE(&TempPte))
|
!MI_IS_PAGE_WRITEABLE(&TempPte))
|
||||||
{
|
{
|
||||||
/* Sanity check */
|
/* Sanity check */
|
||||||
|
@ -1932,7 +1931,7 @@ _WARN("Session space stuff is not implemented yet!")
|
||||||
/* Bad boy, bad boy, whatcha gonna do, whatcha gonna do when ARM3 comes for you! */
|
/* Bad boy, bad boy, whatcha gonna do, whatcha gonna do when ARM3 comes for you! */
|
||||||
KeBugCheckEx(DRIVER_CAUGHT_MODIFYING_FREED_POOL,
|
KeBugCheckEx(DRIVER_CAUGHT_MODIFYING_FREED_POOL,
|
||||||
(ULONG_PTR)Address,
|
(ULONG_PTR)Address,
|
||||||
StoreInstruction,
|
FaultCode,
|
||||||
Mode,
|
Mode,
|
||||||
4);
|
4);
|
||||||
}
|
}
|
||||||
|
@ -1962,7 +1961,7 @@ _WARN("Session space stuff is not implemented yet!")
|
||||||
/* Bugcheck the system! */
|
/* Bugcheck the system! */
|
||||||
KeBugCheckEx(PAGE_FAULT_IN_NONPAGED_AREA,
|
KeBugCheckEx(PAGE_FAULT_IN_NONPAGED_AREA,
|
||||||
(ULONG_PTR)Address,
|
(ULONG_PTR)Address,
|
||||||
StoreInstruction,
|
FaultCode,
|
||||||
(ULONG_PTR)TrapInformation,
|
(ULONG_PTR)TrapInformation,
|
||||||
1);
|
1);
|
||||||
}
|
}
|
||||||
|
@ -1973,14 +1972,14 @@ _WARN("Session space stuff is not implemented yet!")
|
||||||
/* Bugcheck the system! */
|
/* Bugcheck the system! */
|
||||||
KeBugCheckEx(PAGE_FAULT_IN_NONPAGED_AREA,
|
KeBugCheckEx(PAGE_FAULT_IN_NONPAGED_AREA,
|
||||||
(ULONG_PTR)Address,
|
(ULONG_PTR)Address,
|
||||||
StoreInstruction,
|
FaultCode,
|
||||||
(ULONG_PTR)TrapInformation,
|
(ULONG_PTR)TrapInformation,
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for demand page */
|
/* Check for demand page */
|
||||||
if ((StoreInstruction) &&
|
if (MI_IS_WRITE_ACCESS(FaultCode) &&
|
||||||
!(ProtoPte) &&
|
!(ProtoPte) &&
|
||||||
!(IsSessionAddress) &&
|
!(IsSessionAddress) &&
|
||||||
!(TempPte.u.Hard.Valid))
|
!(TempPte.u.Hard.Valid))
|
||||||
|
@ -1999,7 +1998,7 @@ _WARN("Session space stuff is not implemented yet!")
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now do the real fault handling */
|
/* Now do the real fault handling */
|
||||||
Status = MiDispatchFault(StoreInstruction,
|
Status = MiDispatchFault(!MI_IS_NOT_PRESENT_FAULT(FaultCode),
|
||||||
Address,
|
Address,
|
||||||
PointerPte,
|
PointerPte,
|
||||||
ProtoPte,
|
ProtoPte,
|
||||||
|
@ -2148,7 +2147,7 @@ UserFault:
|
||||||
if (TempPte.u.Hard.Valid)
|
if (TempPte.u.Hard.Valid)
|
||||||
{
|
{
|
||||||
/* Check if this is a write on a readonly PTE */
|
/* Check if this is a write on a readonly PTE */
|
||||||
if (StoreInstruction)
|
if (MI_IS_WRITE_ACCESS(FaultCode))
|
||||||
{
|
{
|
||||||
/* Is this a copy on write PTE? */
|
/* Is this a copy on write PTE? */
|
||||||
if (MI_IS_PAGE_COPY_ON_WRITE(&TempPte))
|
if (MI_IS_PAGE_COPY_ON_WRITE(&TempPte))
|
||||||
|
@ -2417,7 +2416,7 @@ UserFault:
|
||||||
{
|
{
|
||||||
/* Run a software access check first, including to detect guard pages */
|
/* Run a software access check first, including to detect guard pages */
|
||||||
Status = MiAccessCheck(PointerPte,
|
Status = MiAccessCheck(PointerPte,
|
||||||
StoreInstruction,
|
!MI_IS_NOT_PRESENT_FAULT(FaultCode),
|
||||||
Mode,
|
Mode,
|
||||||
ProtectionCode,
|
ProtectionCode,
|
||||||
TrapInformation,
|
TrapInformation,
|
||||||
|
@ -2444,7 +2443,7 @@ UserFault:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dispatch the fault */
|
/* Dispatch the fault */
|
||||||
Status = MiDispatchFault(StoreInstruction,
|
Status = MiDispatchFault(!MI_IS_NOT_PRESENT_FAULT(FaultCode),
|
||||||
Address,
|
Address,
|
||||||
PointerPte,
|
PointerPte,
|
||||||
ProtoPte,
|
ProtoPte,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue