@@ -377,7 +377,10 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
377
377
KIRQL OldIrql ;
378
378
PLIST_ENTRY NextEntry , NextHead , LastHead ;
379
379
PMMPTE PointerPte , StartPte ;
380
+ PMMPDE PointerPde ;
381
+ ULONG EndAllocation ;
380
382
MMPTE TempPte ;
383
+ MMPDE TempPde ;
381
384
PMMPFN Pfn1 ;
382
385
PVOID BaseVa , BaseVaStart ;
383
386
PMMFREE_POOL_ENTRY FreeEntry ;
@@ -409,7 +412,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
409
412
//
410
413
// Get the page bit count
411
414
//
412
- i = ((SizeInPages - 1 ) / 1024 ) + 1 ;
415
+ i = ((SizeInPages - 1 ) / PTE_COUNT ) + 1 ;
413
416
DPRINT1 ("Paged pool expansion: %d %x\n" , i , SizeInPages );
414
417
415
418
//
@@ -450,15 +453,15 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
450
453
}
451
454
452
455
//
453
- // Get the template PTE we'll use to expand
456
+ // Get the template PDE we'll use to expand
454
457
//
455
- TempPte = ValidKernelPte ;
458
+ TempPde = ValidKernelPde ;
456
459
457
460
//
458
461
// Get the first PTE in expansion space
459
462
//
460
- PointerPte = MmPagedPoolInfo .NextPdeForPagedPoolExpansion ;
461
- BaseVa = MiPteToAddress (PointerPte );
463
+ PointerPde = MmPagedPoolInfo .NextPdeForPagedPoolExpansion ;
464
+ BaseVa = MiPteToAddress (PointerPde );
462
465
BaseVaStart = BaseVa ;
463
466
464
467
//
@@ -470,11 +473,13 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
470
473
//
471
474
// It should not already be valid
472
475
//
473
- ASSERT (PointerPte -> u .Hard .Valid == 0 );
476
+ ASSERT (PointerPde -> u .Hard .Valid == 0 );
474
477
475
478
/* Request a page */
479
+ DPRINT1 ("Requesting %d PDEs\n" , i );
476
480
PageFrameNumber = MiRemoveAnyPage (MI_GET_NEXT_COLOR ());
477
- TempPte .u .Hard .PageFrameNumber = PageFrameNumber ;
481
+ TempPde .u .Hard .PageFrameNumber = PageFrameNumber ;
482
+ DPRINT1 ("We have a PDE: %lx\n" , PageFrameNumber );
478
483
479
484
#if (_MI_PAGING_LEVELS >= 3 )
480
485
/* On PAE/x64 systems, there's no double-buffering */
@@ -483,38 +488,38 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
483
488
//
484
489
// Save it into our double-buffered system page directory
485
490
//
486
- /* This seems to be making the assumption that one PDE is one page long */
487
- C_ASSERT (PAGE_SIZE == (PD_COUNT * (sizeof (MMPTE ) * PDE_COUNT )));
488
- MmSystemPagePtes [(ULONG_PTR )PointerPte & (PAGE_SIZE - 1 ) /
489
- sizeof (MMPTE )] = TempPte ;
490
-
491
+ MmSystemPagePtes [(ULONG_PTR )PointerPde & (SYSTEM_PD_SIZE - 1 )] = TempPde ;
492
+
491
493
/* Initialize the PFN */
492
494
MiInitializePfnForOtherProcess (PageFrameNumber ,
493
- PointerPte ,
494
- MmSystemPageDirectory [(PointerPte - ( PMMPTE ) PDE_BASE ) / PDE_COUNT ]);
495
+ PointerPde ,
496
+ MmSystemPageDirectory [(PointerPde - MiAddressToPde ( NULL ) ) / PDE_COUNT ]);
495
497
496
- /* Write the actual PTE now */
497
- MI_WRITE_VALID_PTE (PointerPte ++ , TempPte );
498
+ /* Write the actual PDE now */
499
+ MI_WRITE_VALID_PTE (PointerPde , TempPde );
498
500
#endif
499
501
//
500
502
// Move on to the next expansion address
501
503
//
504
+ PointerPde ++ ;
502
505
BaseVa = (PVOID )((ULONG_PTR )BaseVa + PAGE_SIZE );
503
- } while (-- i > 0 );
506
+ i -- ;
507
+ } while (i > 0 );
504
508
505
509
//
506
510
// Release the PFN database lock
507
511
//
508
512
KeReleaseQueuedSpinLock (LockQueuePfnLock , OldIrql );
509
-
513
+
510
514
//
511
515
// These pages are now available, clear their availablity bits
512
516
//
517
+ EndAllocation = (MmPagedPoolInfo .NextPdeForPagedPoolExpansion -
518
+ MiAddressToPte (MmPagedPoolInfo .FirstPteForPagedPool )) *
519
+ PTE_COUNT ;
513
520
RtlClearBits (MmPagedPoolInfo .PagedPoolAllocationMap ,
514
- (MmPagedPoolInfo .NextPdeForPagedPoolExpansion -
515
- MiAddressToPte (MmPagedPoolInfo .FirstPteForPagedPool )) *
516
- 1024 ,
517
- SizeInPages * 1024 );
521
+ EndAllocation ,
522
+ SizeInPages * PTE_COUNT );
518
523
519
524
//
520
525
// Update the next expansion location
@@ -553,7 +558,8 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
553
558
// Update the end bitmap so we know the bounds of this allocation when
554
559
// the time comes to free it
555
560
//
556
- RtlSetBit (MmPagedPoolInfo .EndOfPagedPoolBitmap , i + SizeInPages - 1 );
561
+ EndAllocation = i + SizeInPages - 1 ;
562
+ RtlSetBit (MmPagedPoolInfo .EndOfPagedPoolBitmap , EndAllocation );
557
563
558
564
//
559
565
// Now we can release the lock (it mainly protects the bitmap)
@@ -583,9 +589,8 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
583
589
//
584
590
// Write the demand zero PTE and keep going
585
591
//
586
- ASSERT (PointerPte -> u .Hard .Valid == 0 );
587
- * PointerPte ++ = TempPte ;
588
- } while (PointerPte < StartPte );
592
+ MI_WRITE_INVALID_PTE (PointerPte , TempPte );
593
+ } while (++ PointerPte < StartPte );
589
594
590
595
//
591
596
// Return the allocation address to the caller
0 commit comments