Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

checkpte.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1989 Microsoft Corporation 00004 00005 Module Name: 00006 00007 checkpte.c 00008 00009 Abstract: 00010 00011 This module contains routines for sanity checking the page directory. 00012 00013 Author: 00014 00015 Lou Perazzoli (loup) 25-Apr-1989 00016 00017 Revision History: 00018 00019 --*/ 00020 00021 #include "mi.h" 00022 00023 #if DBG 00024 #if 0 // LWFIX: fix this up for Sundown before re-enabling 00025 00026 VOID 00027 CheckValidPte ( 00028 IN PMMPTE PointerPte 00029 ); 00030 00031 VOID 00032 CheckInvalidPte ( 00033 IN PMMPTE PointerPte 00034 ); 00035 00036 00037 VOID 00038 MiCheckPte ( 00039 VOID 00040 ) 00041 00042 /*++ 00043 00044 Routine Description: 00045 00046 This routine checks each page table page in an address space to 00047 ensure it is in the proper state. 00048 00049 Arguments: 00050 00051 None. 00052 00053 Return Value: 00054 00055 None. 00056 00057 Environment: 00058 00059 Kernel mode, APC's disabled. 00060 00061 --*/ 00062 00063 { 00064 ULONG i,j; 00065 PMMPTE PointerPte; 00066 PMMPTE PointerPde; 00067 PMMPFN Pfn1; 00068 ULONG ValidCount; 00069 ULONG TransitionCount; 00070 KIRQL PreviousIrql; 00071 KIRQL OldIrql; 00072 PEPROCESS TargetProcess; 00073 USHORT UsedPages; 00074 ULONG PdeValidCount; 00075 00076 TargetProcess = PsGetCurrentProcess (); 00077 00078 KeRaiseIrql (APC_LEVEL, &PreviousIrql); 00079 00080 LOCK_WS (TargetProcess); 00081 LOCK_PFN (OldIrql); 00082 00083 PointerPde = MiGetPdeAddress(0); 00084 00085 UsedPages = 0; 00086 PdeValidCount = 1; 00087 00088 for (i = 0; i < PDE_PER_PAGE; i++) { 00089 if (PointerPde->u.Hard.Valid) { 00090 00091 if ((i < 512) || (i == 769) || (i== 896) ) { 00092 PdeValidCount += 1; 00093 } 00094 00095 ValidCount = 0; 00096 TransitionCount = 0; 00097 CheckValidPte (PointerPde); 00098 00099 PointerPte = MiGetPteAddress (i<<22); 00100 00101 for (j=0; j < PTE_PER_PAGE; j++) { 00102 00103 if ((PointerPte >= MiGetPteAddress(HYPER_SPACE)) && 00104 (PointerPte < MiGetPteAddress(WORKING_SET_LIST))) { 00105 goto endloop; 00106 } 00107 00108 if (PointerPte->u.Hard.Valid) { 00109 ValidCount += 1; 00110 CheckValidPte (PointerPte); 00111 00112 } else { 00113 CheckInvalidPte (PointerPte); 00114 00115 if ((PointerPte->u.Soft.Transition == 1) && 00116 (PointerPte->u.Soft.Prototype == 0)) { 00117 00118 // 00119 // Transition PTE, up the transition count. 00120 // 00121 00122 TransitionCount += 1; 00123 00124 } 00125 } 00126 00127 if (PointerPte->u.Long != 0) { 00128 UsedPages += 1; 00129 } 00130 endloop: 00131 PointerPte++; 00132 00133 } 00134 if ((i < 512) || (i == 896)) { 00135 if (MmWorkingSetList->UsedPageTableEntries[i] != UsedPages) { 00136 DbgPrint("used pages and page table used not equal %lx %lx %lx\n", 00137 i,MmWorkingSetList->UsedPageTableEntries[i], UsedPages); 00138 } 00139 } 00140 00141 // 00142 // Check the share count for the page table page. 00143 // 00144 if ((i < 511) || (i == 896)) { 00145 Pfn1 = MI_PFN_ELEMENT (PointerPde->u.Hard.PageFrameNumber); 00146 if (Pfn1->u2.ShareCount != ((ULONG)1+ValidCount+TransitionCount)) { 00147 DbgPrint("share count for page table page bad - %lx %lx %lx\n", 00148 i,ValidCount, TransitionCount); 00149 MiFormatPfn(Pfn1); 00150 } 00151 } 00152 } 00153 PointerPde++; 00154 UsedPages = 0; 00155 } 00156 00157 PointerPde = (PMMPTE)(ULONG_PTR)0xc0300c00; 00158 Pfn1 = MI_PFN_ELEMENT(PointerPde->u.Hard.PageFrameNumber); 00159 UNLOCK_PFN (OldIrql); 00160 UNLOCK_WS (TargetProcess); 00161 KeLowerIrql (PreviousIrql); 00162 return; 00163 00164 } 00165 00166 VOID 00167 CheckValidPte ( 00168 IN PMMPTE PointerPte 00169 ) 00170 00171 { 00172 PMMPFN Pfn1; 00173 PMMPTE PointerPde; 00174 00175 if (MI_GET_PAGE_FRAME_FROM_PTE (PointerPte) > MmNumberOfPhysicalPages) { 00176 return; 00177 } 00178 00179 00180 Pfn1 = MI_PFN_ELEMENT(PointerPte->u.Hard.PageFrameNumber); 00181 00182 if (PointerPte->u.Hard.PageFrameNumber == 0) { 00183 DbgPrint("physical page zero mapped\n"); 00184 MiFormatPte(PointerPte); 00185 MiFormatPfn(Pfn1); 00186 } 00187 00188 if (Pfn1->u3.e1.PageLocation != ActiveAndValid) { 00189 DbgPrint("valid PTE with page frame not active and valid\n"); 00190 MiFormatPfn(Pfn1); 00191 MiFormatPte(PointerPte); 00192 } 00193 00194 if (Pfn1->u3.e1.PrototypePte == 0) { 00195 // 00196 // This is not a prototype PTE. 00197 // 00198 if (Pfn1->PteAddress != PointerPte) { 00199 DbgPrint("checkpte - pfn pte address and pte address not equal\n"); 00200 MiFormatPte(PointerPte); 00201 MiFormatPfn(Pfn1); 00202 return; 00203 } 00204 00205 } 00206 00207 if (!MmIsAddressValid(Pfn1->PteAddress)) { 00208 return; 00209 } 00210 00211 PointerPde = MiGetPteAddress (Pfn1->PteAddress); 00212 if (PointerPde->u.Hard.Valid == 1) { 00213 00214 if (MI_GET_PAGE_FRAME_FROM_PTE (PointerPde) != Pfn1->PteFrame) { 00215 DbgPrint("checkpte - pteframe not right\n"); 00216 MiFormatPfn(Pfn1); 00217 MiFormatPte(PointerPte); 00218 MiFormatPte(PointerPde); 00219 } 00220 } 00221 return; 00222 00223 } 00224 00225 VOID 00226 CheckInvalidPte ( 00227 IN PMMPTE PointerPte 00228 ) 00229 00230 00231 { 00232 PointerPte; 00233 return; 00234 00235 } 00236 #endif // 0 00237 #endif //DBG

Generated on Sat May 15 19:39:23 2004 for test by doxygen 1.3.7