Author: tkreuzer
Date: Sat Feb 4 23:08:20 2012
New Revision: 55423
URL:
http://svn.reactos.org/svn/reactos?rev=55423&view=rev
Log:
[NTOSKRNL]
- Fix a bug in CmpSetSystemValues, where an uninitialized handle would be closed in the
failure path.
- Add a hack on top of the MI_GET_ROS_DATA(x) hack so that we can squeeze a pointer into a
32 bit field.
Make MmInitializeProcessAddressSpace amd64 ready and use a portable way to determine the
page table base pfn in MiInitializeWorkingSetList
- Make MmProbeAndLockPages ready for 3 and 4 level page tables
add MiIsPteOnP*eBoundary macros - use these in MmProbeAndLockPages
- Raise IRQL to SYNCH_LEVEL not DISPATCH_LEVEL in KiAcquireDispatcherLock
- Add MiNonPagedSystemSize for all architectures
- Fix amd64 definition of KERNEL_HANDLE_FLAG
- Fix definition of PrototypePte
- Fix KiGetLinkedTrapFrame()
- Make MmProtectTpPteMask 64 bit wide
- Fix definition of MI_PTE_LOOKUP_NEEDED for amd64
- Impllement KiSendEOI() to be able to send an EOI from C code.
- Fix some MSVC/amd64 warnings
Modified:
trunk/reactos/ntoskrnl/config/cmsysini.c
trunk/reactos/ntoskrnl/ex/zw.S
trunk/reactos/ntoskrnl/include/internal/amd64/ke.h
trunk/reactos/ntoskrnl/include/internal/ke_x.h
trunk/reactos/ntoskrnl/include/internal/ob.h
trunk/reactos/ntoskrnl/io/iomgr/irp.c
trunk/reactos/ntoskrnl/mm/ARM3/i386/init.c
trunk/reactos/ntoskrnl/mm/ARM3/mdlsup.c
trunk/reactos/ntoskrnl/mm/ARM3/miarm.h
trunk/reactos/ntoskrnl/mm/ARM3/mminit.c
trunk/reactos/ntoskrnl/mm/ARM3/procsup.c
trunk/reactos/ntoskrnl/mm/ARM3/special.c
trunk/reactos/ntoskrnl/ps/job.c
trunk/reactos/ntoskrnl/ps/process.c
trunk/reactos/ntoskrnl/ps/query.c
Modified: trunk/reactos/ntoskrnl/config/cmsysini.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmsysini.c…
==============================================================================
--- trunk/reactos/ntoskrnl/config/cmsysini.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/config/cmsysini.c [iso-8859-1] Sat Feb 4 23:08:20 2012
@@ -333,7 +333,7 @@
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName, ValueName = { 0, 0, NULL };
- HANDLE KeyHandle;
+ HANDLE KeyHandle = NULL;
NTSTATUS Status;
ASSERT(LoaderBlock != NULL);
@@ -374,7 +374,7 @@
RtlFreeUnicodeString(&ValueName);
/* Close the key and return */
- NtClose(KeyHandle);
+ if (KeyHandle) NtClose(KeyHandle);
/* Return the status */
return (ExpInTextModeSetup ? STATUS_SUCCESS : Status);
@@ -1098,7 +1098,8 @@
{
WCHAR FileBuffer[MAX_PATH], RegBuffer[MAX_PATH], ConfigPath[MAX_PATH];
UNICODE_STRING TempName, FileName, RegName;
- ULONG FileStart, i, ErrorResponse, WorkerCount, Length;
+ ULONG i, ErrorResponse, WorkerCount, Length;
+ USHORT FileStart;
//ULONG RegStart;
ULONG PrimaryDisposition, SecondaryDisposition, ClusterSize;
PCMHIVE CmHive;
@@ -1259,7 +1260,8 @@
UNICODE_STRING TempName, FileName, RegName;
HANDLE Thread;
NTSTATUS Status;
- ULONG RegStart, i;
+ ULONG i;
+ USHORT RegStart;
PSECURITY_DESCRIPTOR SecurityDescriptor;
PAGED_CODE();
@@ -1611,25 +1613,25 @@
PLIST_ENTRY NextEntry, OldEntry;
PBOOT_DRIVER_NODE DriverNode;
PAGED_CODE();
-
+
/* Parse the current list */
NextEntry = DriverList->Flink;
while (NextEntry != DriverList)
{
/* Get the driver node */
DriverNode = CONTAINING_RECORD(NextEntry, BOOT_DRIVER_NODE, ListEntry.Link);
-
+
/* Get the next entry now, since we're going to free it later */
OldEntry = NextEntry;
NextEntry = NextEntry->Flink;
-
+
/* Was there a name? */
if (DriverNode->Name.Buffer)
{
/* Free it */
CmpFree(DriverNode->Name.Buffer, DriverNode->Name.Length);
}
-
+
/* Was there a registry path? */
if (DriverNode->ListEntry.RegistryPath.Buffer)
{
@@ -1637,7 +1639,7 @@
CmpFree(DriverNode->ListEntry.RegistryPath.Buffer,
DriverNode->ListEntry.RegistryPath.MaximumLength);
}
-
+
/* Was there a file path? */
if (DriverNode->ListEntry.FilePath.Buffer)
{
@@ -1645,7 +1647,7 @@
CmpFree(DriverNode->ListEntry.FilePath.Buffer,
DriverNode->ListEntry.FilePath.MaximumLength);
}
-
+
/* Now free the node, and move on */
CmpFree(OldEntry, sizeof(BOOT_DRIVER_NODE));
}
@@ -1673,7 +1675,7 @@
/* Initialize the driver list */
InitializeListHead(&DriverList);
-
+
/* Open the system hive key */
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\System");
InitializeObjectAttributes(&ObjectAttributes,
@@ -1683,7 +1685,7 @@
NULL);
Status = NtOpenKey(&KeyHandle, KEY_READ, &ObjectAttributes);
if (!NT_SUCCESS(Status)) return NULL;
-
+
/* Reference the key object to get the root hive/cell to access directly */
Status = ObReferenceObjectByHandle(KeyHandle,
KEY_QUERY_VALUE,
@@ -1697,38 +1699,38 @@
NtClose(KeyHandle);
return NULL;
}
-
+
/* Do all this under the registry lock */
CmpLockRegistryExclusive();
-
+
/* Get the hive and key cell */
Hive = KeyBody->KeyControlBlock->KeyHive;
RootCell = KeyBody->KeyControlBlock->KeyCell;
-
+
/* Open the current control set key */
RtlInitUnicodeString(&KeyName, L"Current");
ControlCell = CmpFindControlSet(Hive, RootCell, &KeyName, &AutoSelect);
if (ControlCell == HCELL_NIL) goto EndPath;
-
+
/* Find all system drivers */
Success = CmpFindDrivers(Hive, ControlCell, SystemLoad, NULL, &DriverList);
if (!Success) goto EndPath;
-
+
/* Sort by group/tag */
if (!CmpSortDriverList(Hive, ControlCell, &DriverList)) goto EndPath;
-
+
/* Remove circular dependencies (cycles) and sort */
if (!CmpResolveDriverDependencies(&DriverList)) goto EndPath;
-
+
/* Loop the list to count drivers */
for (i = 0, NextEntry = DriverList.Flink;
NextEntry != &DriverList;
i++, NextEntry = NextEntry->Flink);
-
+
/* Allocate the array */
ServicePath = ExAllocatePool(NonPagedPool, (i + 1) * sizeof(PUNICODE_STRING));
if (!ServicePath) KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 2, 1, 0, 0);
-
+
/* Loop the driver list */
for (i = 0, NextEntry = DriverList.Flink;
NextEntry != &DriverList;
@@ -1743,17 +1745,17 @@
&DriverEntry->RegistryPath,
ServicePath[i]);
}
-
+
/* Terminate the list */
ServicePath[i] = NULL;
-
+
EndPath:
/* Free the driver list if we had one */
if (!IsListEmpty(&DriverList)) CmpFreeDriverList(Hive, &DriverList);
-
+
/* Unlock the registry */
CmpUnlockRegistry();
-
+
/* Close the key handle and dereference the object, then return the path */
ObDereferenceObject(KeyBody);
NtClose(KeyHandle);
Modified: trunk/reactos/ntoskrnl/ex/zw.S
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/zw.S?rev=55423…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/zw.S [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ex/zw.S [iso-8859-1] Sat Feb 4 23:08:20 2012
@@ -5,7 +5,9 @@
#ifdef _M_IX86
EXTERN _KiSystemService:PROC
#elif defined(_M_AMD64)
+#include <ksamd64.inc>
EXTERN KiSystemService:PROC
+EXTERN KiZwSystemService:PROC
#endif
.code
Modified: trunk/reactos/ntoskrnl/include/internal/amd64/ke.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/amd64/ke.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/amd64/ke.h [iso-8859-1] Sat Feb 4 23:08:20
2012
@@ -56,6 +56,8 @@
#define AMD64_TSS 9
+#define APIC_EOI_REGISTER 0xFFFFFFFFFFFE00B0ULL
+
#ifndef __ASM__
#include "intrin_i.h"
@@ -67,6 +69,17 @@
UCHAR IstIndex;
PVOID ServiceRoutine;
} KIDT_INIT, *PKIDT_INIT;
+
+#include <pshpack1.h>
+typedef struct _KI_INTERRUPT_DISPATCH_ENTRY
+{
+ UCHAR _Op_nop;
+ UCHAR _Op_push;
+ UCHAR _Vector;
+ UCHAR _Op_jmp;
+ ULONG RelativeAddress;
+} KI_INTERRUPT_DISPATCH_ENTRY, *PKI_INTERRUPT_DISPATCH_ENTRY;
+#include <poppack.h>
extern ULONG Ke386CacheAlignment;
extern ULONG KeI386NpxPresent;
@@ -95,7 +108,7 @@
((TrapFrame)->Rip)
#define KiGetLinkedTrapFrame(x) \
- (PKTRAP_FRAME)((x)->Rdx)
+ (PKTRAP_FRAME)((x)->TrapFrame)
#define KeGetContextReturnRegister(Context) \
((Context)->Rax)
@@ -235,11 +248,20 @@
VOID
FORCEINLINE
+KiSendEOI()
+{
+ /* Write 0 to the apic EOI register */
+ *((volatile ULONG*)APIC_EOI_REGISTER) = 0;
+}
+
+VOID
+FORCEINLINE
KiEndInterrupt(IN KIRQL Irql,
IN PKTRAP_FRAME TrapFrame)
{
/* Make sure this is from the clock handler */
ASSERT(TrapFrame->ErrorCode == 0xc10c4);
+ //KeLowerIrql(Irql);
}
BOOLEAN
Modified: trunk/reactos/ntoskrnl/include/internal/ke_x.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ke_x.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/ke_x.h [iso-8859-1] Sat Feb 4 23:08:20 2012
@@ -127,8 +127,8 @@
KIRQL
KiAcquireDispatcherLock(VOID)
{
- /* Raise to DPC level */
- return KeRaiseIrqlToDpcLevel();
+ /* Raise to synch level */
+ return KfRaiseIrql(SYNCH_LEVEL);
}
FORCEINLINE
@@ -303,7 +303,7 @@
/* Let the CPU know that this is a loop */
YieldProcessor();
- }
+ }
/* Try acquiring the lock now */
} while (InterlockedCompareExchange(&Object->Lock,
@@ -902,7 +902,7 @@
{
ULONG Hand;
PKTIMER_TABLE_ENTRY TableEntry;
-
+
/* Remove the timer from the timer list and check if it's empty */
Hand = Timer->Header.Hand;
if (RemoveEntryList(&Timer->TimerListEntry))
@@ -962,17 +962,17 @@
OUT PULONG Hand)
{
LARGE_INTEGER InterruptTime, SystemTime, DifferenceTime;
-
+
/* Convert to relative time if needed */
Timer->Header.Absolute = FALSE;
if (DueTime.HighPart >= 0)
{
/* Get System Time */
KeQuerySystemTime(&SystemTime);
-
+
/* Do the conversion */
DifferenceTime.QuadPart = SystemTime.QuadPart - DueTime.QuadPart;
-
+
/* Make sure it hasn't already expired */
Timer->Header.Absolute = TRUE;
if (DifferenceTime.HighPart >= 0)
@@ -984,17 +984,17 @@
*Hand = 0;
return FALSE;
}
-
+
/* Set the time as Absolute */
DueTime = DifferenceTime;
}
-
+
/* Get the Interrupt Time */
InterruptTime.QuadPart = KeQueryInterruptTime();
-
+
/* Recalculate due time */
Timer->DueTime.QuadPart = InterruptTime.QuadPart - DueTime.QuadPart;
-
+
/* Get the handle */
*Hand = KiComputeTimerTableIndex(Timer->DueTime.QuadPart);
Timer->Header.Hand = (UCHAR)*Hand;
@@ -1515,7 +1515,7 @@
GuardedMutex->Count = GM_LOCK_BIT;
GuardedMutex->Owner = NULL;
GuardedMutex->Contention = 0;
-
+
/* Initialize the Wait Gate */
KeInitializeGate(&GuardedMutex->Gate);
}
@@ -1525,21 +1525,21 @@
_KeAcquireGuardedMutexUnsafe(IN OUT PKGUARDED_MUTEX GuardedMutex)
{
PKTHREAD Thread = KeGetCurrentThread();
-
+
/* Sanity checks */
ASSERT((KeGetCurrentIrql() == APC_LEVEL) ||
(Thread->SpecialApcDisable < 0) ||
(Thread->Teb == NULL) ||
(Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
ASSERT(GuardedMutex->Owner != Thread);
-
+
/* Remove the lock */
if (!InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V))
{
/* The Guarded Mutex was already locked, enter contented case */
KiAcquireGuardedMutex(GuardedMutex);
}
-
+
/* Set the Owner */
GuardedMutex->Owner = Thread;
}
@@ -1549,21 +1549,21 @@
_KeReleaseGuardedMutexUnsafe(IN OUT PKGUARDED_MUTEX GuardedMutex)
{
LONG OldValue, NewValue;
-
+
/* Sanity checks */
ASSERT((KeGetCurrentIrql() == APC_LEVEL) ||
(KeGetCurrentThread()->SpecialApcDisable < 0) ||
(KeGetCurrentThread()->Teb == NULL) ||
(KeGetCurrentThread()->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
ASSERT(GuardedMutex->Owner == KeGetCurrentThread());
-
+
/* Destroy the Owner */
GuardedMutex->Owner = NULL;
-
+
/* Add the Lock Bit */
OldValue = InterlockedExchangeAdd(&GuardedMutex->Count, GM_LOCK_BIT);
ASSERT((OldValue & GM_LOCK_BIT) == 0);
-
+
/* Check if it was already locked, but not woken */
if ((OldValue) && !(OldValue & GM_LOCK_WAITER_WOKEN))
{
@@ -1573,7 +1573,7 @@
/* The mutex will be woken, minus one waiter */
NewValue = OldValue + GM_LOCK_WAITER_WOKEN -
GM_LOCK_WAITER_INC;
-
+
/* Remove the Woken bit */
if (InterlockedCompareExchange(&GuardedMutex->Count,
NewValue,
@@ -1590,21 +1590,21 @@
_KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
{
PKTHREAD Thread = KeGetCurrentThread();
-
+
/* Sanity checks */
ASSERT(KeGetCurrentIrql() <= APC_LEVEL);
ASSERT(GuardedMutex->Owner != Thread);
-
+
/* Disable Special APCs */
KeEnterGuardedRegion();
-
+
/* Remove the lock */
if (!InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V))
{
/* The Guarded Mutex was already locked, enter contented case */
KiAcquireGuardedMutex(GuardedMutex);
}
-
+
/* Set the Owner and Special APC Disable state */
GuardedMutex->Owner = Thread;
GuardedMutex->SpecialApcDisable = Thread->SpecialApcDisable;
@@ -1615,20 +1615,20 @@
_KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
{
LONG OldValue, NewValue;
-
+
/* Sanity checks */
ASSERT(KeGetCurrentIrql() <= APC_LEVEL);
ASSERT(GuardedMutex->Owner == KeGetCurrentThread());
ASSERT(KeGetCurrentThread()->SpecialApcDisable ==
GuardedMutex->SpecialApcDisable);
-
+
/* Destroy the Owner */
GuardedMutex->Owner = NULL;
-
+
/* Add the Lock Bit */
OldValue = InterlockedExchangeAdd(&GuardedMutex->Count, GM_LOCK_BIT);
ASSERT((OldValue & GM_LOCK_BIT) == 0);
-
+
/* Check if it was already locked, but not woken */
if ((OldValue) && !(OldValue & GM_LOCK_WAITER_WOKEN))
{
@@ -1638,7 +1638,7 @@
/* The mutex will be woken, minus one waiter */
NewValue = OldValue + GM_LOCK_WAITER_WOKEN -
GM_LOCK_WAITER_INC;
-
+
/* Remove the Woken bit */
if (InterlockedCompareExchange(&GuardedMutex->Count,
NewValue,
@@ -1648,7 +1648,7 @@
KeSignalGateBoostPriority(&GuardedMutex->Gate);
}
}
-
+
/* Re-enable APCs */
KeLeaveGuardedRegion();
}
@@ -1658,21 +1658,21 @@
_KeTryToAcquireGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
{
PKTHREAD Thread = KeGetCurrentThread();
-
+
/* Block APCs */
KeEnterGuardedRegion();
-
+
/* Remove the lock */
if (!InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V))
{
/* Re-enable APCs */
KeLeaveGuardedRegion();
YieldProcessor();
-
+
/* Return failure */
return FALSE;
}
-
+
/* Set the Owner and APC State */
GuardedMutex->Owner = Thread;
GuardedMutex->SpecialApcDisable = Thread->SpecialApcDisable;
Modified: trunk/reactos/ntoskrnl/include/internal/ob.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ob.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/ob.h [iso-8859-1] Sat Feb 4 23:08:20 2012
@@ -56,8 +56,11 @@
//
// Identifies a Kernel Handle
//
-#define KERNEL_HANDLE_FLAG \
- ((ULONG_PTR)1 << ((sizeof(HANDLE) * 8) - 1))
+#ifdef _WIN64
+#define KERNEL_HANDLE_FLAG 0xFFFFFFFF80000000ULL
+#else
+#define KERNEL_HANDLE_FLAG 0x80000000
+#endif
#define ObIsKernelHandle(Handle, ProcessorMode) \
(((ULONG_PTR)(Handle) & KERNEL_HANDLE_FLAG) && \
((ProcessorMode) == KernelMode))
Modified: trunk/reactos/ntoskrnl/io/iomgr/irp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/irp.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/irp.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/irp.c [iso-8859-1] Sat Feb 4 23:08:20 2012
@@ -1650,7 +1650,8 @@
/* Return the session */
if ((Process = IoGetRequestorProcess(Irp)))
{
- *pSessionId = Process->Session;
+ // FIXME: broken
+ *pSessionId = PtrToUlong(Process->Session);
return STATUS_SUCCESS;
}
Modified: trunk/reactos/ntoskrnl/mm/ARM3/i386/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/i386/init…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/i386/init.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/i386/init.c [iso-8859-1] Sat Feb 4 23:08:20 2012
@@ -281,8 +281,9 @@
// nonpaged pool expansion (above) and the system PTEs. Note that it is
// then aligned to a PDE boundary (4MB).
//
+ MiNonPagedSystemSize = (MmNumberOfSystemPtes + 1) * PAGE_SIZE;
MmNonPagedSystemStart = (PVOID)((ULONG_PTR)MmNonPagedPoolStart -
- (MmNumberOfSystemPtes + 1) * PAGE_SIZE);
+ MiNonPagedSystemSize);
MmNonPagedSystemStart = (PVOID)((ULONG_PTR)MmNonPagedSystemStart &
~(PDE_MAPPED_VA - 1));
Modified: trunk/reactos/ntoskrnl/mm/ARM3/mdlsup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/mdlsup.c?…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/mdlsup.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/mdlsup.c [iso-8859-1] Sat Feb 4 23:08:20 2012
@@ -593,6 +593,12 @@
NTSTATUS ProbeStatus;
PMMPTE PointerPte, LastPte;
PMMPDE PointerPde;
+#if (_MI_PAGING_LEVELS >= 3)
+ PMMPDE PointerPpe;
+#endif
+#if (_MI_PAGING_LEVELS == 4)
+ PMMPDE PointerPxe;
+#endif
PFN_NUMBER PageFrameIndex;
BOOLEAN UsePfnLock;
KIRQL OldIrql;
@@ -741,9 +747,11 @@
PointerPte = MiAddressToPte(StartAddress);
PointerPde = MiAddressToPde(StartAddress);
#if (_MI_PAGING_LEVELS >= 3)
- DPRINT1("PAE/x64 Not Implemented\n");
- ASSERT(FALSE);
+ PointerPpe = MiAddressToPpe(StartAddress);
#endif
+#if (_MI_PAGING_LEVELS == 4)
+ PointerPxe = MiAddressToPxe(StartAddress);
+#endif
//
// Sanity check
@@ -776,7 +784,7 @@
//
// Check if this came from kernel mode
//
- if (Base >= MM_HIGHEST_USER_ADDRESS)
+ if (Base > MM_HIGHEST_USER_ADDRESS)
{
//
// We should not have a process
@@ -834,11 +842,14 @@
// Assume failure and check for non-mapped pages
//
*MdlPages = LIST_HEAD;
+ while (
+#if (_MI_PAGING_LEVELS == 4)
+ (PointerPxe->u.Hard.Valid == 0) ||
+#endif
#if (_MI_PAGING_LEVELS >= 3)
- /* Should be checking the PPE and PXE */
- ASSERT(FALSE);
+ (PointerPpe->u.Hard.Valid == 0) ||
#endif
- while ((PointerPde->u.Hard.Valid == 0) ||
+ (PointerPde->u.Hard.Valid == 0) ||
(PointerPte->u.Hard.Valid == 0))
{
//
@@ -1042,7 +1053,14 @@
PointerPte++;
/* Check if we're on a PDE boundary */
- if (!((ULONG_PTR)PointerPte & (PD_SIZE - 1))) PointerPde++;
+ if (MiIsPteOnPdeBoundary(PointerPte)) PointerPde++;
+#if (_MI_PAGING_LEVELS >= 3)
+ if (MiIsPteOnPpeBoundary(PointerPte)) PointerPpe++;
+#endif
+#if (_MI_PAGING_LEVELS == 4)
+ if (MiIsPteOnPxeBoundary(PointerPte)) PointerPxe++;
+#endif
+
} while (PointerPte <= LastPte);
//
Modified: trunk/reactos/ntoskrnl/mm/ARM3/miarm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/miarm.h?r…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] Sat Feb 4 23:08:20 2012
@@ -78,6 +78,8 @@
#define PDE_COUNT 1024
#define PTE_COUNT 1024
C_ASSERT(SYSTEM_PD_SIZE == PAGE_SIZE);
+#define MiIsPteOnPdeBoundary(PointerPte) \
+ ((((ULONG_PTR)PointerPte) & (PAGE_SIZE - 1)) == 0)
#elif _M_ARM
#define PD_COUNT 1
#define PDE_COUNT 4096
@@ -164,7 +166,7 @@
#error Define these please!
#endif
-extern const ULONG MmProtectToPteMask[32];
+extern const ULONG_PTR MmProtectToPteMask[32];
extern const ULONG MmProtectToValue[32];
//
@@ -262,7 +264,11 @@
//
// Prototype PTEs that don't yet have a pagefile association
//
+#ifdef _M_AMD64
+#define MI_PTE_LOOKUP_NEEDED 0xffffffffULL
+#else
#define MI_PTE_LOOKUP_NEEDED 0xFFFFF
+#endif
//
// System views are binned into 64K chunks
@@ -444,6 +450,7 @@
extern PFN_NUMBER MmMaximumNonPagedPoolInPages;
extern PFN_NUMBER MmSizeOfPagedPoolInPages;
extern PVOID MmNonPagedSystemStart;
+extern SIZE_T MiNonPagedSystemSize;
extern PVOID MmNonPagedPoolStart;
extern PVOID MmNonPagedPoolExpansionStart;
extern PVOID MmNonPagedPoolEnd;
@@ -1379,7 +1386,14 @@
//
// New ARM3<->RosMM PAGE Architecture
//
+#ifdef _WIN64
+// HACK ON TOP OF HACK ALERT!!!
+#define MI_GET_ROS_DATA(x) \
+ (((x)->RosMmData == 0) ? NULL : ((PMMROSPFN)((ULONG64)(ULONG)((x)->RosMmData) |
\
+ ((ULONG64)MmNonPagedPoolStart &
0xffffffff00000000ULL))))
+#else
#define MI_GET_ROS_DATA(x) ((PMMROSPFN)(x->RosMmData))
+#endif
#define MI_IS_ROS_PFN(x) (((x)->u4.AweAllocation == TRUE) &&
(MI_GET_ROS_DATA(x) != NULL))
#define ASSERT_IS_ROS_PFN(x) ASSERT(MI_IS_ROS_PFN(x) == TRUE);
typedef struct _MMROSPFN
Modified: trunk/reactos/ntoskrnl/mm/ARM3/mminit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/mminit.c?…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/mminit.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/mminit.c [iso-8859-1] Sat Feb 4 23:08:20 2012
@@ -93,6 +93,7 @@
//
http://www.ditii.com/2007/09/28/windows-memory-management-x86-virtual-addre…
//
PVOID MmNonPagedSystemStart;
+SIZE_T MiNonPagedSystemSize;
PVOID MmNonPagedPoolStart;
PVOID MmNonPagedPoolExpansionStart;
PVOID MmNonPagedPoolEnd = MI_NONPAGED_POOL_END;
Modified: trunk/reactos/ntoskrnl/mm/ARM3/procsup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/procsup.c…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/procsup.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/procsup.c [iso-8859-1] Sat Feb 4 23:08:20 2012
@@ -913,7 +913,7 @@
MmWorkingSetList->LastInitializedWsle = 4;
/* The rule is that the owner process is always in the FLINK of the PDE's PFN
entry */
- Pfn1 = MiGetPfnEntry(MiAddressToPte(PDE_BASE)->u.Hard.PageFrameNumber);
+ Pfn1 = MiGetPfnEntry(CurrentProcess->Pcb.DirectoryTableBase[0] >>
PAGE_SHIFT);
ASSERT(Pfn1->u4.PteFrame == MiGetPfnEntryIndex(Pfn1));
Pfn1->u1.Event = (PKEVENT)CurrentProcess;
}
@@ -963,13 +963,23 @@
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
/* Setup the PFN for the PDE base of this process */
+#ifdef _M_AMD64
+ PointerPte = MiAddressToPte(PXE_BASE);
+#else
PointerPte = MiAddressToPte(PDE_BASE);
+#endif
PageFrameNumber = PFN_FROM_PTE(PointerPte);
+ ASSERT(Process->Pcb.DirectoryTableBase[0] == PageFrameNumber * PAGE_SIZE);
MiInitializePfn(PageFrameNumber, PointerPte, TRUE);
/* Do the same for hyperspace */
+#ifdef _M_AMD64
+ PointerPde = MiAddressToPxe((PVOID)HYPER_SPACE);
+#else
PointerPde = MiAddressToPde(HYPER_SPACE);
+#endif
PageFrameNumber = PFN_FROM_PTE(PointerPde);
+ //ASSERT(Process->Pcb.DirectoryTableBase[0] == PageFrameNumber * PAGE_SIZE); //
we're not lucky
MiInitializePfn(PageFrameNumber, (PMMPTE)PointerPde, TRUE);
/* Setup the PFN for the PTE for the working set */
Modified: trunk/reactos/ntoskrnl/mm/ARM3/special.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/special.c…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/special.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/special.c [iso-8859-1] Sat Feb 4 23:08:20 2012
@@ -261,7 +261,7 @@
RtlZeroMemory(Header, sizeof(POOL_HEADER));
/* Save allocation size there */
- Header->Ulong1 = NumberOfBytes;
+ Header->Ulong1 = (ULONG)NumberOfBytes;
/* Make sure it's all good */
ASSERT((NumberOfBytes <= PAGE_SIZE - sizeof(POOL_HEADER)) &&
@@ -286,7 +286,7 @@
That time will be used to check memory consistency within the allocated
page. */
Header->PoolTag = Tag;
- Header->BlockSize = TickCount.LowPart;
+ Header->BlockSize = (USHORT)TickCount.LowPart;
DPRINT1("%p\n", Entry);
return Entry;
}
@@ -305,7 +305,7 @@
Ptr = P + BytesRequested;
/* Calculate how many bytes to check */
- BytesToCheck = (PUCHAR)PAGE_ALIGN(P) + PAGE_SIZE - Ptr;
+ BytesToCheck = (ULONG)((PUCHAR)PAGE_ALIGN(P) + PAGE_SIZE - Ptr);
/* Remove pool header size if we're catching underruns */
if (((ULONG_PTR)P & (PAGE_SIZE - 1)) == 0)
@@ -335,7 +335,7 @@
KIRQL Irql = KeGetCurrentIrql();
POOL_TYPE PoolType;
ULONG BytesRequested, BytesReal = 0;
- ULONG_PTR PtrOffset;
+ ULONG PtrOffset;
PUCHAR b;
PMI_FREED_SPECIAL_POOL FreedHeader;
LARGE_INTEGER TickCount;
@@ -358,7 +358,7 @@
}
/* Determine if it's a underruns or overruns pool pointer */
- PtrOffset = (ULONG_PTR)P & (PAGE_SIZE - 1);
+ PtrOffset = (ULONG)((ULONG_PTR)P & (PAGE_SIZE - 1));
if (PtrOffset)
{
/* Pool catches overruns */
Modified: trunk/reactos/ntoskrnl/ps/job.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/job.c?rev=5542…
==============================================================================
--- trunk/reactos/ntoskrnl/ps/job.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ps/job.c [iso-8859-1] Sat Feb 4 23:08:20 2012
@@ -165,7 +165,8 @@
ExAcquireRundownProtection(&Process->RundownProtect);
if(NT_SUCCESS(Status))
{
- if(Process->Job == NULL && Process->Session ==
Job->SessionId)
+ // FIXME: This is broken
+ if(Process->Job == NULL && PtrToUlong(Process->Session)
== Job->SessionId)
{
/* Just store the pointer to the job object in the process,
we'll
assign it later. The reason we can't do this here is that
locking
@@ -269,7 +270,7 @@
/* setup the job object */
InitializeListHead(&Job->ProcessListHead);
- Job->SessionId = CurrentProcess->Session; /* inherit the session id from
the caller */
+ Job->SessionId = PtrToUlong(CurrentProcess->Session); /* inherit the
session id from the caller, FIXME: broken */
Status = ExInitializeResource(&Job->JobLock);
if(!NT_SUCCESS(Status))
Modified: trunk/reactos/ntoskrnl/ps/process.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/process.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ps/process.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ps/process.c [iso-8859-1] Sat Feb 4 23:08:20 2012
@@ -1113,7 +1113,8 @@
NTAPI
PsGetCurrentProcessSessionId(VOID)
{
- return PsGetCurrentProcess()->Session;
+ // FIXME: this is broken!
+ return PtrToUlong(PsGetCurrentProcess()->Session);
}
/*
Modified: trunk/reactos/ntoskrnl/ps/query.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/query.c?rev=55…
==============================================================================
--- trunk/reactos/ntoskrnl/ps/query.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ps/query.c [iso-8859-1] Sat Feb 4 23:08:20 2012
@@ -419,7 +419,7 @@
_SEH2_TRY
{
/* Write back the Session ID */
- SessionInfo->SessionId = Process->Session;
//MmGetSessionId(Process);
+ SessionInfo->SessionId = PtrToUlong(PsGetProcessSessionId(Process));
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
@@ -818,32 +818,32 @@
}
_SEH2_END;
break;
-
+
case ProcessImageInformation:
DPRINT1("Image Information Query Not implemented: %lx\n",
ProcessInformationClass);
Status = STATUS_NOT_IMPLEMENTED;
break;
-
+
case ProcessDebugObjectHandle:
DPRINT1("Debug Object Query Not implemented: %lx\n",
ProcessInformationClass);
Status = STATUS_NOT_IMPLEMENTED;
break;
-
+
case ProcessHandleTracing:
DPRINT1("Handle tracing Not implemented: %lx\n",
ProcessInformationClass);
Status = STATUS_NOT_IMPLEMENTED;
break;
-
+
case ProcessLUIDDeviceMapsEnabled:
DPRINT1("LUID Device Maps Not implemented: %lx\n",
ProcessInformationClass);
Status = STATUS_NOT_IMPLEMENTED;
break;
-
+
case ProcessExecuteFlags:
DPRINT1("No execute Not implemented: %lx\n",
ProcessInformationClass);
Status = STATUS_NOT_IMPLEMENTED;
break;
-
+
case ProcessWow64Information:
case ProcessLdtInformation:
case ProcessWx86Information:
@@ -855,12 +855,12 @@
DPRINT1("WS Watch Not implemented: %lx\n",
ProcessInformationClass);
Status = STATUS_NOT_IMPLEMENTED;
break;
-
+
case ProcessPooledUsageAndLimits:
DPRINT1("Pool limits Not implemented: %lx\n",
ProcessInformationClass);
Status = STATUS_NOT_IMPLEMENTED;
break;
-
+
/* Not supported by Server 2003 */
default:
DPRINT1("Unsupported info class: %lx\n", ProcessInformationClass);
@@ -978,7 +978,7 @@
Status = STATUS_PRIVILEGE_NOT_HELD;
break;
}
-
+
/* Get the LPC Port */
Status = ObReferenceObjectByHandle(PortHandle,
0,
@@ -1050,10 +1050,10 @@
_SEH2_YIELD(break);
}
_SEH2_END;
-
+
/* Set the mode */
Process->DefaultHardErrorProcessing = DefaultHardErrorMode;
-
+
/* Call Ke for the update */
if (DefaultHardErrorMode & SEM_NOALIGNMENTFAULTEXCEPT)
{
@@ -1219,7 +1219,7 @@
PsProcessPriorityBackground);
Status = STATUS_SUCCESS;
break;
-
+
case ProcessBasePriority:
/* Validate input length */
@@ -1242,7 +1242,7 @@
_SEH2_YIELD(break);
}
_SEH2_END;
-
+
/* Extract the memory priority out of there */
if (BasePriority & 0x80000000)
{
@@ -1253,22 +1253,22 @@
{
MemoryPriority = MEMORY_PRIORITY_BACKGROUND;
}
-
+
/* Validate the number */
if ((BasePriority > HIGH_PRIORITY) || (BasePriority <= LOW_PRIORITY))
{
return STATUS_INVALID_PARAMETER;
}
-
+
/* Check if the new base is higher */
if (BasePriority > Process->Pcb.BasePriority)
{
DPRINT1("Should check privilege\n");
}
-
+
/* Call Ke */
KeSetPriorityAndQuantumProcess(&Process->Pcb, BasePriority, 0);
-
+
/* Now set the memory priority */
MmSetMemoryPriorityProcess(Process, MemoryPriority);
Status = STATUS_SUCCESS;
@@ -1351,14 +1351,14 @@
_SEH2_YIELD(break);
}
_SEH2_END;
-
+
/* Setting 'break on termination' requires the SeDebugPrivilege */
if (!SeSinglePrivilegeCheck(SeDebugPrivilege, PreviousMode))
{
Status = STATUS_PRIVILEGE_NOT_HELD;
break;
}
-
+
/* Set or clear the flag */
if (Break)
{
@@ -1370,9 +1370,9 @@
}
break;
-
+
case ProcessAffinityMask:
-
+
/* Check buffer length */
if (ProcessInformationLength != sizeof(KAFFINITY))
{
@@ -1393,7 +1393,7 @@
_SEH2_YIELD(break);
}
_SEH2_END;
-
+
/* Make sure it's valid for the CPUs present */
ValidAffinity = Affinity & KeActiveProcessors;
if (!Affinity || (ValidAffinity != Affinity))
@@ -1435,7 +1435,7 @@
Status = STATUS_PROCESS_IS_TERMINATING;
}
break;
-
+
/* Priority Boosting status */
case ProcessPriorityBoost:
@@ -1469,7 +1469,7 @@
/* Call Ke to do the work */
KeSetDisableBoostProcess(&Process->Pcb, DisableBoost);
-
+
/* Loop the threads too */
for (Next = Process->ThreadListHead.Flink;
Next != &Process->ThreadListHead;
@@ -1494,7 +1494,7 @@
Status = STATUS_PROCESS_IS_TERMINATING;
}
break;
-
+
case ProcessDebugFlags:
/* Check buffer length */
@@ -1516,7 +1516,7 @@
_SEH2_YIELD(break);
}
_SEH2_END;
-
+
/* Set the mode */
if (DebugFlags & ~1)
{
@@ -1537,7 +1537,7 @@
/* Done */
Status = STATUS_SUCCESS;
break;
-
+
case ProcessEnableAlignmentFaultFixup:
/* Check buffer length */
@@ -1559,7 +1559,7 @@
_SEH2_YIELD(break);
}
_SEH2_END;
-
+
/* Set the mode */
if (EnableFixup)
{
@@ -1569,12 +1569,12 @@
{
Process->DefaultHardErrorProcessing &=
~SEM_NOALIGNMENTFAULTEXCEPT;
}
-
+
/* Call Ke for the update */
KeSetAutoAlignmentProcess(&Process->Pcb, FALSE);
Status = STATUS_SUCCESS;
break;
-
+
/* We currently don't implement any of these */
case ProcessLdtInformation:
case ProcessLdtSize:
@@ -1584,32 +1584,32 @@
DPRINT1("VDM/16-bit Request not implemented: %lx\n",
ProcessInformationClass);
Status = STATUS_NOT_IMPLEMENTED;
break;
-
+
case ProcessQuotaLimits:
DPRINT1("Quota Limits not implemented\n");
Status = STATUS_NOT_IMPLEMENTED;
break;
-
+
case ProcessWorkingSetWatch:
DPRINT1("WS watch not implemented\n");
Status = STATUS_NOT_IMPLEMENTED;
break;
-
+
case ProcessDeviceMap:
DPRINT1("Device map not implemented\n");
Status = STATUS_NOT_IMPLEMENTED;
break;
-
+
case ProcessHandleTracing:
DPRINT1("Handle tracing not implemented\n");
Status = STATUS_NOT_IMPLEMENTED;
break;
-
+
case ProcessExecuteFlags:
DPRINT1("No execute support not implemented\n");
Status = STATUS_NOT_IMPLEMENTED;
break;
-
+
/* Anything else is invalid */
default:
DPRINT1("Invalid Server 2003 Info Class: %lx\n",
ProcessInformationClass);