ReactOS  0.4.15-dev-2350-g7194f2f
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 205 of file mmfault.c.

209 {
211 
212  /* Cute little hack for ROS */
214  {
215 #ifdef _M_IX86
216  /* Check for an invalid page directory in kernel mode */
218  {
219  /* All is well with the world */
220  return STATUS_SUCCESS;
221  }
222 #endif
223  }
224 
225  /* Handle shared user page, which doesn't have a VAD / MemoryArea */
227  {
228  /* This is an ARM3 fault */
229  DPRINT("ARM3 fault %p\n", MemoryArea);
230  return MmArmAccessFault(FaultCode, Address, Mode, TrapInformation);
231  }
232 
233  /* Is there a ReactOS address space yet? */
235  {
236  /* Check if this is an ARM3 memory area */
239  {
240  /* Could this be a VAD fault from user-mode? */
242  }
243  }
244 
245  /* Is this an ARM3 memory area, or is there no address space yet? */
249  {
250  /* This is an ARM3 fault */
251  DPRINT("ARM3 fault %p\n", MemoryArea);
252  return MmArmAccessFault(FaultCode, Address, Mode, TrapInformation);
253  }
254 
255  /* Keep same old ReactOS Behaviour */
256  if (!MI_IS_NOT_PRESENT_FAULT(FaultCode))
257  {
258  /* Call access fault */
259  return MmpAccessFault(Mode, (ULONG_PTR)Address, TrapInformation ? FALSE : TRUE);
260  }
261  else
262  {
263  /* Call not present */
264  return MmNotPresentFault(Mode, (ULONG_PTR)Address, TrapInformation ? FALSE : TRUE);
265  }
266 }
#define MM_HIGHEST_USER_ADDRESS
Definition: armddk.h:17
#define MI_IS_NOT_PRESENT_FAULT(FaultCode)
Definition: mm.h:121
ULONG Type
Definition: mm.h:219
_In_ ULONG Mode
Definition: hubbusif.h:303
#define TRUE
Definition: types.h:120
#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:65
#define MEMORY_AREA_OWNED_BY_ARM3
Definition: mm.h:75
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI MmpAccessFault(KPROCESSOR_MODE Mode, ULONG_PTR Address, BOOLEAN FromMdl)
Definition: mmfault.c:23
static WCHAR Address[46]
Definition: ping.c:68
#define PAGE_ALIGN(Va)
BOOLEAN Mmi386MakeKernelPageTableGlobal(PVOID Address)
Definition: pagepae.c:844
PVOID MmPagedPoolStart
Definition: miarm.h:581
FORCEINLINE PMMSUPPORT MmGetKernelAddressSpace(VOID)
Definition: mm.h:1563
NTSTATUS NTAPI MmNotPresentFault(KPROCESSOR_MODE Mode, ULONG_PTR Address, BOOLEAN FromMdl)
Definition: mmfault.c:111
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65
NTSTATUS NTAPI MmArmAccessFault(IN ULONG FaultCode, IN PVOID Address, IN KPROCESSOR_MODE Mode, IN PVOID TrapInformation)
Definition: pagfault.c:1656
#define DPRINT
Definition: sndvol32.h:71
#define MmSystemRangeStart
Definition: mm.h:32
FORCEINLINE PMMSUPPORT MmGetCurrentAddressSpace(VOID)
Definition: mm.h:1556

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

◆ Mmi386MakeKernelPageTableGlobal()

BOOLEAN Mmi386MakeKernelPageTableGlobal ( PVOID  Address)

Definition at line 844 of file pagepae.c.

845 {
846  if (Ke386Pae)
847  {
848  PULONGLONG Pt;
849  PULONGLONG Pde;
850  Pde = PAE_ADDR_TO_PDE(PAddress);
851  if (*Pde == 0LL)
852  {
853  Pt = MmGetPageTableForProcessForPAE(NULL, PAddress, FALSE);
854 #if 0
855  /* Non existing mappings are not cached within the tlb. We must not invalidate this entry */
856  FLASH_TLB_ONE(PAddress);
857 #endif
858  if (Pt != NULL)
859  {
860  return TRUE;
861  }
862  }
863  }
864  else
865  {
866  PULONG Pt, Pde;
867  Pde = ADDR_TO_PDE(PAddress);
868  if (*Pde == 0)
869  {
870  Pt = MmGetPageTableForProcess(NULL, PAddress, FALSE);
871 #if 0
872  /* Non existing mappings are not cached within the tlb. We must not invalidate this entry */
873  FLASH_TLB_ONE(PAddress);
874 #endif
875  if (Pt != NULL)
876  {
877  return TRUE;
878  }
879  }
880  }
881  return(FALSE);
882 }
#define LL
Definition: tui.h:84
#define TRUE
Definition: types.h:120
#define ADDR_TO_PDE(v)
Definition: pagepae.c:152
#define FALSE
Definition: types.h:117
static PULONGLONG MmGetPageTableForProcessForPAE(PEPROCESS Process, PVOID Address, BOOLEAN Create)
Definition: pagepae.c:321
static PULONG MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create)
Definition: pagepae.c:435
unsigned int * PULONG
Definition: retypes.h:1
#define NULL
Definition: types.h:112
BOOLEAN Ke386Pae
Definition: cpu.c:33
#define PAE_ADDR_TO_PDE(v)
Definition: pagepae.c:163
__GNU_EXTENSION typedef unsigned __int64 * PULONGLONG
Definition: ntbasedef.h:383

Referenced by MmAccessFault().

◆ MmNotPresentFault()

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

Definition at line 111 of file mmfault.c.

114 {
118 
119  DPRINT("MmNotPresentFault(Mode %d, Address %x)\n", Mode, Address);
120 
122  {
123  DPRINT1("Page fault at high IRQL was %u, address %x\n", KeGetCurrentIrql(), Address);
124  return(STATUS_UNSUCCESSFUL);
125  }
126 
127  /*
128  * Find the memory area for the faulting address
129  */
131  {
132  /*
133  * Check permissions
134  */
135  if (Mode != KernelMode)
136  {
137  DPRINT1("Address: %x\n", Address);
138  return(STATUS_ACCESS_VIOLATION);
139  }
141  }
142  else
143  {
145  }
146 
147  if (!FromMdl)
148  {
150  }
151 
152  /*
153  * Call the memory area specific fault handler
154  */
155  do
156  {
159  {
160  if (!FromMdl)
161  {
163  }
164  return (STATUS_ACCESS_VIOLATION);
165  }
166 
167  switch (MemoryArea->Type)
168  {
171  MemoryArea,
172  (PVOID)Address,
173  !FromMdl);
174  break;
175 #ifdef NEWCC
176  case MEMORY_AREA_CACHE:
177  // This code locks for itself to keep from having to break a lock
178  // passed in.
179  if (!FromMdl)
182  if (!FromMdl)
184  break;
185 #endif
186  default:
188  break;
189  }
190  }
192 
193  DPRINT("Completed page fault handling\n");
194  if (!FromMdl)
195  {
197  }
198  return(Status);
199 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
ULONG Type
Definition: mm.h:219
_In_ ULONG Mode
Definition: hubbusif.h:303
#define STATUS_MM_RESTART_OPERATION
Definition: mm.h:82
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2268
FORCEINLINE VOID MmUnlockAddressSpace(PMMSUPPORT AddressSpace)
Definition: mm.h:1541
LONG NTSTATUS
Definition: precomp.h:26
PMEMORY_AREA NTAPI MmLocateMemoryAreaByAddress(PMMSUPPORT AddressSpace, PVOID Address)
Definition: marea.c:60
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define PsGetCurrentProcess
Definition: psfuncs.h:17
static WCHAR Address[46]
Definition: ping.c:68
#define MEMORY_AREA_SECTION_VIEW
Definition: mm.h:71
Status
Definition: gdiplustypes.h:24
BOOLEAN DeleteInProgress
Definition: mm.h:221
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
FORCEINLINE PMMSUPPORT MmGetKernelAddressSpace(VOID)
Definition: mm.h:1563
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
NTSTATUS NTAPI MmNotPresentFaultCacheSection(KPROCESSOR_MODE Mode, ULONG_PTR Address, BOOLEAN FromMdl)
#define DPRINT
Definition: sndvol32.h:71
NTSTATUS NTAPI MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace, MEMORY_AREA *MemoryArea, PVOID Address, BOOLEAN Locked)
Definition: section.c:1511
struct _MEMORY_AREA * MemoryArea
Definition: newmm.h:37
FORCEINLINE VOID MmLockAddressSpace(PMMSUPPORT AddressSpace)
Definition: mm.h:1534
#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  !FromMdl);
82  break;
83 #ifdef NEWCC
84  case MEMORY_AREA_CACHE:
85  // This code locks for itself to keep from having to break a lock
86  // passed in.
87  if (!FromMdl)
90  if (!FromMdl)
92  break;
93 #endif
94  default:
96  break;
97  }
98  }
100 
101  DPRINT("Completed page fault handling\n");
102  if (!FromMdl)
103  {
105  }
106  return(Status);
107 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
NTSTATUS NTAPI MmAccessFaultCacheSection(KPROCESSOR_MODE Mode, ULONG_PTR Address, BOOLEAN FromMdl)
ULONG Type
Definition: mm.h:219
_In_ ULONG Mode
Definition: hubbusif.h:303
#define STATUS_MM_RESTART_OPERATION
Definition: mm.h:82
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2268
FORCEINLINE VOID MmUnlockAddressSpace(PMMSUPPORT AddressSpace)
Definition: mm.h:1541
LONG NTSTATUS
Definition: precomp.h:26
PMEMORY_AREA NTAPI MmLocateMemoryAreaByAddress(PMMSUPPORT AddressSpace, PVOID Address)
Definition: marea.c:60
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define PsGetCurrentProcess
Definition: psfuncs.h:17
NTSTATUS NTAPI MmAccessFaultSectionView(PMMSUPPORT AddressSpace, MEMORY_AREA *MemoryArea, PVOID Address, BOOLEAN Locked)
Definition: section.c:1877
static WCHAR Address[46]
Definition: ping.c:68
#define MEMORY_AREA_SECTION_VIEW
Definition: mm.h:71
Status
Definition: gdiplustypes.h:24
BOOLEAN DeleteInProgress
Definition: mm.h:221
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
FORCEINLINE PMMSUPPORT MmGetKernelAddressSpace(VOID)
Definition: mm.h:1563
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#define DPRINT
Definition: sndvol32.h:71
struct _MEMORY_AREA * MemoryArea
Definition: newmm.h:37
FORCEINLINE VOID MmLockAddressSpace(PMMSUPPORT AddressSpace)
Definition: mm.h:1534
#define MmSystemRangeStart
Definition: mm.h:32

Referenced by MmAccessFault().