ReactOS  0.4.15-dev-316-g938df97
mmfault.c File Reference
#include <ntoskrnl.h>
#include <cache/section/newmm.h>
#include <debug.h>
#include "ARM3/miarm.h"
Include dependency graph for mmfault.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define MODULE_INVOLVED_IN_ARM3
 

Functions

NTSTATUS NTAPI MmpAccessFault (KPROCESSOR_MODE Mode, ULONG_PTR Address, BOOLEAN FromMdl)
 
NTSTATUS NTAPI MmNotPresentFault (KPROCESSOR_MODE Mode, ULONG_PTR Address, BOOLEAN FromMdl)
 
BOOLEAN Mmi386MakeKernelPageTableGlobal (PVOID Address)
 
NTSTATUS NTAPI MmAccessFault (IN ULONG FaultCode, IN PVOID Address, IN KPROCESSOR_MODE Mode, IN PVOID TrapInformation)
 

Macro Definition Documentation

◆ MODULE_INVOLVED_IN_ARM3

#define MODULE_INVOLVED_IN_ARM3

Definition at line 16 of file mmfault.c.

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file mmfault.c.

Function Documentation

◆ MmAccessFault()

NTSTATUS NTAPI MmAccessFault ( IN ULONG  FaultCode,
IN PVOID  Address,
IN KPROCESSOR_MODE  Mode,
IN PVOID  TrapInformation 
)

Definition at line 204 of file mmfault.c.

208 {
210 
211  /* Cute little hack for ROS */
213  {
214 #ifdef _M_IX86
215  /* Check for an invalid page directory in kernel mode */
217  {
218  /* All is well with the world */
219  return STATUS_SUCCESS;
220  }
221 #endif
222  }
223 
224  /* Handle shared user page, which doesn't have a VAD / MemoryArea */
226  {
227  /* This is an ARM3 fault */
228  DPRINT("ARM3 fault %p\n", MemoryArea);
229  return MmArmAccessFault(FaultCode, Address, Mode, TrapInformation);
230  }
231 
232  /* Is there a ReactOS address space yet? */
234  {
235  /* Check if this is an ARM3 memory area */
238  {
239  /* Could this be a VAD fault from user-mode? */
241  }
242  }
243 
244  /* Is this an ARM3 memory area, or is there no address space yet? */
248  {
249  /* This is an ARM3 fault */
250  DPRINT("ARM3 fault %p\n", MemoryArea);
251  return MmArmAccessFault(FaultCode, Address, Mode, TrapInformation);
252  }
253 
254  /* Keep same old ReactOS Behaviour */
255  if (!MI_IS_NOT_PRESENT_FAULT(FaultCode))
256  {
257  /* Call access fault */
258  return MmpAccessFault(Mode, (ULONG_PTR)Address, TrapInformation ? FALSE : TRUE);
259  }
260  else
261  {
262  /* Call not present */
263  return MmNotPresentFault(Mode, (ULONG_PTR)Address, TrapInformation ? FALSE : TRUE);
264  }
265 }
#define MM_HIGHEST_USER_ADDRESS
Definition: armddk.h:17
#define TRUE
Definition: types.h:120
#define MI_IS_NOT_PRESENT_FAULT(FaultCode)
Definition: mm.h:121
ULONG Type
Definition: mm.h:214
_In_ ULONG Mode
Definition: hubbusif.h:303
#define MM_SHARED_USER_DATA_VA
Definition: mmtypes.h:48
PMEMORY_AREA NTAPI MmLocateMemoryAreaByAddress(PMMSUPPORT AddressSpace, PVOID Address)
Definition: marea.c:60
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define MEMORY_AREA_OWNED_BY_ARM3
Definition: mm.h:73
NTSTATUS NTAPI MmpAccessFault(KPROCESSOR_MODE Mode, ULONG_PTR Address, BOOLEAN FromMdl)
Definition: mmfault.c:23
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
void DPRINT(...)
Definition: polytest.cpp:61
#define PAGE_ALIGN(Va)
BOOLEAN Mmi386MakeKernelPageTableGlobal(PVOID Address)
Definition: page.c:477
PVOID MmPagedPoolStart
Definition: miarm.h:581
FORCEINLINE PMMSUPPORT MmGetKernelAddressSpace(VOID)
Definition: mm.h:1453
NTSTATUS NTAPI MmNotPresentFault(KPROCESSOR_MODE Mode, ULONG_PTR Address, BOOLEAN FromMdl)
Definition: mmfault.c:110
NTSTATUS NTAPI MmArmAccessFault(IN ULONG FaultCode, IN PVOID Address, IN KPROCESSOR_MODE Mode, IN PVOID TrapInformation)
Definition: pagfault.c:1650
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define MmSystemRangeStart
Definition: mm.h:32
FORCEINLINE PMMSUPPORT MmGetCurrentAddressSpace(VOID)
Definition: mm.h:1446

Referenced by KiDataAbortHandler(), KiPageFaultHandler(), KiTrap0EHandler(), MiLockVirtualMemory(), MiMakeSystemAddressValid(), MiMakeSystemAddressValidPfn(), and MmProbeAndLockPages().

◆ Mmi386MakeKernelPageTableGlobal()

BOOLEAN Mmi386MakeKernelPageTableGlobal ( PVOID  Address)

Definition at line 477 of file page.c.

478 {
479  PMMPDE PointerPde = MiAddressToPde(Address);
480  PMMPTE PointerPte = MiAddressToPte(Address);
481 
482  if (PointerPde->u.Hard.Valid == 0)
483  {
484  if(!MiSynchronizeSystemPde(PointerPde))
485  return FALSE;
486  return PointerPte->u.Hard.Valid != 0;
487  }
488  return FALSE;
489 }
#define MiAddressToPde(x)
Definition: mmx86.c:20
#define MiAddressToPte(x)
Definition: mmx86.c:19
static WCHAR Address[46]
Definition: ping.c:68
ULONG64 Valid
Definition: mmtypes.h:150
union _MMPTE::@2280 u
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217

Referenced by MmAccessFault().

◆ MmNotPresentFault()

NTSTATUS NTAPI MmNotPresentFault ( KPROCESSOR_MODE  Mode,
ULONG_PTR  Address,
BOOLEAN  FromMdl 
)

Definition at line 110 of file mmfault.c.

113 {
117 
118  DPRINT("MmNotPresentFault(Mode %d, Address %x)\n", Mode, Address);
119 
121  {
122  DPRINT1("Page fault at high IRQL was %u, address %x\n", KeGetCurrentIrql(), Address);
123  return(STATUS_UNSUCCESSFUL);
124  }
125 
126  /*
127  * Find the memory area for the faulting address
128  */
130  {
131  /*
132  * Check permissions
133  */
134  if (Mode != KernelMode)
135  {
136  DPRINT1("Address: %x\n", Address);
137  return(STATUS_ACCESS_VIOLATION);
138  }
140  }
141  else
142  {
144  }
145 
146  if (!FromMdl)
147  {
149  }
150 
151  /*
152  * Call the memory area specific fault handler
153  */
154  do
155  {
158  {
159  if (!FromMdl)
160  {
162  }
163  return (STATUS_ACCESS_VIOLATION);
164  }
165 
166  switch (MemoryArea->Type)
167  {
170  MemoryArea,
171  (PVOID)Address,
172  FromMdl);
173  break;
174 
175  case MEMORY_AREA_CACHE:
176  // This code locks for itself to keep from having to break a lock
177  // passed in.
178  if (!FromMdl)
181  if (!FromMdl)
183  break;
184 
185  default:
187  break;
188  }
189  }
191 
192  DPRINT("Completed page fault handling\n");
193  if (!FromMdl)
194  {
196  }
197  return(Status);
198 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
ULONG Type
Definition: mm.h:214
_In_ ULONG Mode
Definition: hubbusif.h:303
#define STATUS_MM_RESTART_OPERATION
Definition: mm.h:80
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2268
FORCEINLINE VOID MmUnlockAddressSpace(PMMSUPPORT AddressSpace)
Definition: mm.h:1431
LONG NTSTATUS
Definition: precomp.h:26
PMEMORY_AREA NTAPI MmLocateMemoryAreaByAddress(PMMSUPPORT AddressSpace, PVOID Address)
Definition: marea.c:60
#define MEMORY_AREA_CACHE
Definition: mm.h:72
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define PsGetCurrentProcess
Definition: psfuncs.h:17
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
void DPRINT(...)
Definition: polytest.cpp:61
#define MEMORY_AREA_SECTION_VIEW
Definition: mm.h:71
BOOLEAN DeleteInProgress
Definition: mm.h:217
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
NTSTATUS NTAPI MmNotPresentFaultCacheSection(KPROCESSOR_MODE Mode, ULONG_PTR Address, BOOLEAN FromMdl)
Definition: fault.c:907
Status
Definition: gdiplustypes.h:24
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
FORCEINLINE PMMSUPPORT MmGetKernelAddressSpace(VOID)
Definition: mm.h:1453
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:228
#define DPRINT1
Definition: precomp.h:8
NTSTATUS NTAPI MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace, MEMORY_AREA *MemoryArea, PVOID Address, BOOLEAN Locked)
Definition: section.c:1364
struct _MEMORY_AREA * MemoryArea
Definition: newmm.h:65
FORCEINLINE VOID MmLockAddressSpace(PMMSUPPORT AddressSpace)
Definition: mm.h:1424
#define MmSystemRangeStart
Definition: mm.h:32

Referenced by KiPageFaultHandler(), and MmAccessFault().

◆ MmpAccessFault()

NTSTATUS NTAPI MmpAccessFault ( KPROCESSOR_MODE  Mode,
ULONG_PTR  Address,
BOOLEAN  FromMdl 
)

Definition at line 23 of file mmfault.c.

26 {
30 
31  DPRINT("MmAccessFault(Mode %d, Address %x)\n", Mode, Address);
32 
34  {
35  DPRINT1("Page fault at high IRQL was %u\n", KeGetCurrentIrql());
36  return(STATUS_UNSUCCESSFUL);
37  }
38 
39  /*
40  * Find the memory area for the faulting address
41  */
43  {
44  /*
45  * Check permissions
46  */
47  if (Mode != KernelMode)
48  {
49  DPRINT1("MmAccessFault(Mode %d, Address %x)\n", Mode, Address);
51  }
53  }
54  else
55  {
57  }
58 
59  if (!FromMdl)
60  {
62  }
63  do
64  {
67  {
68  if (!FromMdl)
69  {
71  }
72  return (STATUS_ACCESS_VIOLATION);
73  }
74 
75  switch (MemoryArea->Type)
76  {
79  MemoryArea,
80  (PVOID)Address);
81  break;
82 
83  case MEMORY_AREA_CACHE:
84  // This code locks for itself to keep from having to break a lock
85  // passed in.
86  if (!FromMdl)
89  if (!FromMdl)
91  break;
92 
93  default:
95  break;
96  }
97  }
99 
100  DPRINT("Completed page fault handling\n");
101  if (!FromMdl)
102  {
104  }
105  return(Status);
106 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
NTSTATUS NTAPI MmAccessFaultSectionView(PMMSUPPORT AddressSpace, MEMORY_AREA *MemoryArea, PVOID Address)
Definition: section.c:1797
ULONG Type
Definition: mm.h:214
_In_ ULONG Mode
Definition: hubbusif.h:303
#define STATUS_MM_RESTART_OPERATION
Definition: mm.h:80
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2268
FORCEINLINE VOID MmUnlockAddressSpace(PMMSUPPORT AddressSpace)
Definition: mm.h:1431
LONG NTSTATUS
Definition: precomp.h:26
PMEMORY_AREA NTAPI MmLocateMemoryAreaByAddress(PMMSUPPORT AddressSpace, PVOID Address)
Definition: marea.c:60
#define MEMORY_AREA_CACHE
Definition: mm.h:72
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define PsGetCurrentProcess
Definition: psfuncs.h:17
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
void DPRINT(...)
Definition: polytest.cpp:61
#define MEMORY_AREA_SECTION_VIEW
Definition: mm.h:71
BOOLEAN DeleteInProgress
Definition: mm.h:217
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
FORCEINLINE PMMSUPPORT MmGetKernelAddressSpace(VOID)
Definition: mm.h:1453
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:228
#define DPRINT1
Definition: precomp.h:8
NTSTATUS NTAPI MmAccessFaultCacheSection(KPROCESSOR_MODE Mode, ULONG_PTR Address, BOOLEAN FromMdl)
Definition: fault.c:688
struct _MEMORY_AREA * MemoryArea
Definition: newmm.h:65
FORCEINLINE VOID MmLockAddressSpace(PMMSUPPORT AddressSpace)
Definition: mm.h:1424
#define MmSystemRangeStart
Definition: mm.h:32

Referenced by MmAccessFault().