Skip to content

Commit eaaf713

Browse files
author
Sir Richard
committed
[NTOS]: Acquire PFN lock before setting up hyperspace PTE/page.
[NTOS]: Flush TLB after setting up hyperspace. [NTOS]: Use new MiRemoveAnyPage interface instead of MmAllocPage(MC_SYSTEM), as the first test of the new Page API/ABI. [NTOS]: Add support for creating software PTEs. svn path=/trunk/; revision=47150
1 parent af06182 commit eaaf713

File tree

2 files changed

+49
-7
lines changed

2 files changed

+49
-7
lines changed

reactos/ntoskrnl/mm/ARM3/i386/init.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
151151
MMPTE TempPde, TempPte;
152152
PVOID NonPagedPoolExpansionVa;
153153
ULONG OldCount;
154+
KIRQL OldIrql;
154155

155156
/* Check for kernel stack size that's too big */
156157
if (MmLargeStackSize > (KERNEL_LARGE_STACK_SIZE / _1KB))
@@ -541,21 +542,26 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
541542
//
542543
MiInitializeSystemPtes(PointerPte, MmNumberOfSystemPtes, SystemPteSpace);
543544

544-
//
545-
// Get the PDE For hyperspace
546-
//
545+
/* Get the PDE For hyperspace */
547546
StartPde = MiAddressToPde(HYPER_SPACE);
548547

549-
//
550-
// Allocate a page for it and create it
551-
//
552-
PageFrameIndex = MmAllocPage(MC_SYSTEM);
548+
/* Lock PFN database */
549+
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
550+
551+
/* Allocate a page for hyperspace and create it */
552+
PageFrameIndex = MiRemoveAnyPage(0);
553553
TempPde.u.Hard.PageFrameNumber = PageFrameIndex;
554554
TempPde.u.Hard.Global = FALSE; // Hyperspace is local!
555555
ASSERT(StartPde->u.Hard.Valid == 0);
556556
ASSERT(TempPde.u.Hard.Valid == 1);
557557
*StartPde = TempPde;
558558

559+
/* Flush the TLB */
560+
KeFlushCurrentTb();
561+
562+
/* Release the lock */
563+
KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
564+
559565
//
560566
// Zero out the page table now
561567
//

reactos/ntoskrnl/mm/ARM3/miarm.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,24 @@
8989
#define MM_DECOMMIT 0x10
9090
#define MM_NOACCESS (MM_DECOMMIT | MM_NOCACHE)
9191

92+
//
93+
// Corresponds to MMPTE_SOFTWARE.Protection
94+
//
95+
#ifdef _M_IX86
96+
#define MM_PTE_SOFTWARE_PROTECTION_BITS 5
97+
#elif _M_ARM
98+
#define MM_PTE_SOFTWARE_PROTECTION_BITS 5
99+
#elif _M_AMD64
100+
#define MM_PTE_SOFTWARE_PROTECTION_BITS 5
101+
#else
102+
#error Define these please!
103+
#endif
104+
105+
//
106+
// Creates a software PTE with the given protection
107+
//
108+
#define MI_MAKE_SOFTWARE_PTE(x) ((x) << MM_PTE_SOFTWARE_PROTECTION_BITS)
109+
92110
//
93111
// Special values for LoadedImports
94112
//
@@ -409,6 +427,12 @@ MmArmAccessFault(
409427
IN PVOID TrapInformation
410428
);
411429

430+
NTSTATUS
431+
FASTCALL
432+
MiCheckPdeForPagedPool(
433+
IN PVOID Address
434+
);
435+
412436
VOID
413437
NTAPI
414438
MiInitializeNonPagedPool(
@@ -532,6 +556,18 @@ MiRemoveHeadList(
532556
IN PMMPFNLIST ListHead
533557
);
534558

559+
PFN_NUMBER
560+
NTAPI
561+
MiAllocatePfn(
562+
IN PMMPTE PointerPte,
563+
IN ULONG Protection
564+
);
565+
566+
PFN_NUMBER
567+
NTAPI
568+
MiRemoveAnyPage(
569+
IN ULONG Color
570+
);
535571

536572
VOID
537573
NTAPI

0 commit comments

Comments
 (0)