mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[NTOS:MM:X64] Fix session space initialization on x64
This commit is contained in:
parent
9095dbf5a5
commit
d55811f160
3 changed files with 51 additions and 27 deletions
|
@ -21,8 +21,8 @@
|
||||||
#define MI_PAGED_POOL_START (PVOID)0xFFFFF8A000000000ULL // 128 GB paged pool [MiVaPagedPool]
|
#define MI_PAGED_POOL_START (PVOID)0xFFFFF8A000000000ULL // 128 GB paged pool [MiVaPagedPool]
|
||||||
//#define MI_PAGED_POOL_END 0xFFFFF8BFFFFFFFFFULL
|
//#define MI_PAGED_POOL_END 0xFFFFF8BFFFFFFFFFULL
|
||||||
//#define MI_SESSION_SPACE_START 0xFFFFF90000000000ULL // 512 GB session space [MiVaSessionSpace]
|
//#define MI_SESSION_SPACE_START 0xFFFFF90000000000ULL // 512 GB session space [MiVaSessionSpace]
|
||||||
#define MI_SESSION_VIEW_END 0xFFFFF97FFF000000ULL
|
//#define MI_SESSION_VIEW_END 0xFFFFF97FFF000000ULL
|
||||||
#define MI_SESSION_SPACE_END 0xFFFFF97FFFFFFFFFULL
|
#define MI_SESSION_SPACE_END 0xFFFFF98000000000ULL
|
||||||
#define MI_SYSTEM_CACHE_START 0xFFFFF98000000000ULL // 1 TB system cache (on Vista+ this is dynamic VA space) [MiVaSystemCache,MiVaSpecialPoolPaged,MiVaSpecialPoolNonPaged]
|
#define MI_SYSTEM_CACHE_START 0xFFFFF98000000000ULL // 1 TB system cache (on Vista+ this is dynamic VA space) [MiVaSystemCache,MiVaSpecialPoolPaged,MiVaSpecialPoolNonPaged]
|
||||||
#define MI_SYSTEM_CACHE_END 0xFFFFFA7FFFFFFFFFULL
|
#define MI_SYSTEM_CACHE_END 0xFFFFFA7FFFFFFFFFULL
|
||||||
#define MI_PFN_DATABASE 0xFFFFFA8000000000ULL // up to 5.5 TB PFN database followed by non paged pool [MiVaPfnDatabase/MiVaNonPagedPool]
|
#define MI_PFN_DATABASE 0xFFFFFA8000000000ULL // up to 5.5 TB PFN database followed by non paged pool [MiVaPfnDatabase/MiVaNonPagedPool]
|
||||||
|
@ -58,11 +58,11 @@
|
||||||
#define MI_MIN_INIT_PAGED_POOLSIZE (32 * _1MB)
|
#define MI_MIN_INIT_PAGED_POOLSIZE (32 * _1MB)
|
||||||
#define MI_MAX_INIT_NONPAGED_POOL_SIZE (128ULL * 1024 * 1024 * 1024)
|
#define MI_MAX_INIT_NONPAGED_POOL_SIZE (128ULL * 1024 * 1024 * 1024)
|
||||||
#define MI_MAX_NONPAGED_POOL_SIZE (128ULL * 1024 * 1024 * 1024)
|
#define MI_MAX_NONPAGED_POOL_SIZE (128ULL * 1024 * 1024 * 1024)
|
||||||
#define MI_SYSTEM_VIEW_SIZE (16 * _1MB)
|
#define MI_SYSTEM_VIEW_SIZE (104 * _1MB)
|
||||||
#define MI_SESSION_VIEW_SIZE (20 * _1MB)
|
#define MI_SESSION_VIEW_SIZE (104 * _1MB)
|
||||||
#define MI_SESSION_POOL_SIZE (16 * _1MB)
|
#define MI_SESSION_POOL_SIZE (64 * _1MB)
|
||||||
#define MI_SESSION_IMAGE_SIZE (8 * _1MB)
|
#define MI_SESSION_IMAGE_SIZE (16 * _1MB)
|
||||||
#define MI_SESSION_WORKING_SET_SIZE (4 * _1MB)
|
#define MI_SESSION_WORKING_SET_SIZE (16 * _1MB)
|
||||||
#define MI_SESSION_SIZE (MI_SESSION_VIEW_SIZE + \
|
#define MI_SESSION_SIZE (MI_SESSION_VIEW_SIZE + \
|
||||||
MI_SESSION_POOL_SIZE + \
|
MI_SESSION_POOL_SIZE + \
|
||||||
MI_SESSION_IMAGE_SIZE + \
|
MI_SESSION_IMAGE_SIZE + \
|
||||||
|
@ -289,9 +289,10 @@ FORCEINLINE
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
MI_IS_MAPPED_PTE(PMMPTE PointerPte)
|
MI_IS_MAPPED_PTE(PMMPTE PointerPte)
|
||||||
{
|
{
|
||||||
/// FIXME
|
return ((PointerPte->u.Hard.Valid != 0) ||
|
||||||
__debugbreak();
|
(PointerPte->u.Proto.Prototype != 0) ||
|
||||||
return ((PointerPte->u.Long & 0xFFFFFC01) != 0);
|
(PointerPte->u.Trans.Transition != 0) ||
|
||||||
|
(PointerPte->u.Hard.PageFrameNumber != 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
INIT_FUNCTION
|
INIT_FUNCTION
|
||||||
|
|
|
@ -603,10 +603,14 @@ NTAPI
|
||||||
MiSessionCreateInternal(OUT PULONG SessionId)
|
MiSessionCreateInternal(OUT PULONG SessionId)
|
||||||
{
|
{
|
||||||
PEPROCESS Process = PsGetCurrentProcess();
|
PEPROCESS Process = PsGetCurrentProcess();
|
||||||
ULONG NewFlags, Flags, Size, i, Color;
|
ULONG NewFlags, Flags, i, Color;
|
||||||
|
#if (_MI_PAGING_LEVELS < 3)
|
||||||
|
ULONG Size;
|
||||||
|
#endif // (_MI_PAGING_LEVELS < 3)
|
||||||
|
PMMPDE PageTables = NULL;
|
||||||
KIRQL OldIrql;
|
KIRQL OldIrql;
|
||||||
PMMPTE PointerPte, SessionPte;
|
PMMPTE PointerPte, SessionPte;
|
||||||
PMMPDE PointerPde, PageTables;
|
PMMPDE PointerPde;
|
||||||
PMM_SESSION_SPACE SessionGlobal;
|
PMM_SESSION_SPACE SessionGlobal;
|
||||||
MMPTE TempPte;
|
MMPTE TempPte;
|
||||||
MMPDE TempPde;
|
MMPDE TempPde;
|
||||||
|
@ -644,6 +648,7 @@ MiSessionCreateInternal(OUT PULONG SessionId)
|
||||||
/* Now we should own the flag */
|
/* Now we should own the flag */
|
||||||
ASSERT(Process->Flags & PSF_SESSION_CREATION_UNDERWAY_BIT);
|
ASSERT(Process->Flags & PSF_SESSION_CREATION_UNDERWAY_BIT);
|
||||||
|
|
||||||
|
#if (_MI_PAGING_LEVELS < 3)
|
||||||
/*
|
/*
|
||||||
* Session space covers everything from 0xA0000000 to 0xC0000000.
|
* Session space covers everything from 0xA0000000 to 0xC0000000.
|
||||||
* Allocate enough page tables to describe the entire region
|
* Allocate enough page tables to describe the entire region
|
||||||
|
@ -652,6 +657,7 @@ MiSessionCreateInternal(OUT PULONG SessionId)
|
||||||
PageTables = ExAllocatePoolWithTag(NonPagedPool, Size, 'tHmM');
|
PageTables = ExAllocatePoolWithTag(NonPagedPool, Size, 'tHmM');
|
||||||
ASSERT(PageTables != NULL);
|
ASSERT(PageTables != NULL);
|
||||||
RtlZeroMemory(PageTables, Size);
|
RtlZeroMemory(PageTables, Size);
|
||||||
|
#endif // (_MI_PAGING_LEVELS < 3)
|
||||||
|
|
||||||
/* Lock the session ID creation mutex */
|
/* Lock the session ID creation mutex */
|
||||||
KeAcquireGuardedMutex(&MiSessionIdMutex);
|
KeAcquireGuardedMutex(&MiSessionIdMutex);
|
||||||
|
@ -662,7 +668,9 @@ MiSessionCreateInternal(OUT PULONG SessionId)
|
||||||
{
|
{
|
||||||
/* We ran out of session IDs, we should expand */
|
/* We ran out of session IDs, we should expand */
|
||||||
DPRINT1("Too many sessions created. Expansion not yet supported\n");
|
DPRINT1("Too many sessions created. Expansion not yet supported\n");
|
||||||
|
#if (_MI_PAGING_LEVELS < 3)
|
||||||
ExFreePoolWithTag(PageTables, 'tHmM');
|
ExFreePoolWithTag(PageTables, 'tHmM');
|
||||||
|
#endif // (_MI_PAGING_LEVELS < 3)
|
||||||
return STATUS_NO_MEMORY;
|
return STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -786,6 +794,7 @@ MiSessionCreateInternal(OUT PULONG SessionId)
|
||||||
MmSessionSpace->PageTables[PointerPde - MiAddressToPde(MmSessionBase)] = *PointerPde;
|
MmSessionSpace->PageTables[PointerPde - MiAddressToPde(MmSessionBase)] = *PointerPde;
|
||||||
#endif
|
#endif
|
||||||
InitializeListHead(&MmSessionSpace->ImageList);
|
InitializeListHead(&MmSessionSpace->ImageList);
|
||||||
|
|
||||||
DPRINT1("Session %lu is ready to go: 0x%p 0x%p, %lx 0x%p\n",
|
DPRINT1("Session %lu is ready to go: 0x%p 0x%p, %lx 0x%p\n",
|
||||||
*SessionId, MmSessionSpace, SessionGlobal, SessionPageDirIndex, PageTables);
|
*SessionId, MmSessionSpace, SessionGlobal, SessionPageDirIndex, PageTables);
|
||||||
|
|
||||||
|
|
|
@ -15,11 +15,11 @@
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <mm/ARM3/miarm.h>
|
#include <mm/ARM3/miarm.h>
|
||||||
|
#include <fltkernel.h>
|
||||||
|
|
||||||
extern PMMPTE MmDebugPte;
|
extern PMMPTE MmDebugPte;
|
||||||
|
|
||||||
/* Helper macros */
|
/* Helper macros */
|
||||||
#define IS_ALIGNED(addr, align) (((ULONG64)(addr) & (align - 1)) == 0)
|
|
||||||
#define IS_PAGE_ALIGNED(addr) IS_ALIGNED(addr, PAGE_SIZE)
|
#define IS_PAGE_ALIGNED(addr) IS_ALIGNED(addr, PAGE_SIZE)
|
||||||
|
|
||||||
/* GLOBALS *****************************************************************/
|
/* GLOBALS *****************************************************************/
|
||||||
|
@ -62,28 +62,31 @@ VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
MiInitializeSessionSpaceLayout(VOID)
|
MiInitializeSessionSpaceLayout(VOID)
|
||||||
{
|
{
|
||||||
|
/* This is the entire size */
|
||||||
MmSessionSize = MI_SESSION_SIZE;
|
MmSessionSize = MI_SESSION_SIZE;
|
||||||
MmSessionViewSize = MI_SESSION_VIEW_SIZE;
|
|
||||||
MmSessionPoolSize = MI_SESSION_POOL_SIZE;
|
|
||||||
MmSessionImageSize = MI_SESSION_IMAGE_SIZE;
|
|
||||||
MmSystemViewSize = MI_SYSTEM_VIEW_SIZE;
|
|
||||||
|
|
||||||
/* Set up session space */
|
/* Start with session space end */
|
||||||
MiSessionSpaceEnd = (PVOID)MI_SESSION_SPACE_END;
|
MiSessionSpaceEnd = (PVOID)MI_SESSION_SPACE_END;
|
||||||
|
|
||||||
/* This is where we will load Win32k.sys and the video driver */
|
/* The highest range is the session image range */
|
||||||
|
MmSessionImageSize = MI_SESSION_IMAGE_SIZE;
|
||||||
MiSessionImageEnd = MiSessionSpaceEnd;
|
MiSessionImageEnd = MiSessionSpaceEnd;
|
||||||
MiSessionImageStart = (PCHAR)MiSessionImageEnd - MmSessionImageSize;
|
MiSessionImageStart = (PUCHAR)MiSessionImageEnd - MmSessionImageSize;
|
||||||
|
ASSERT(IS_PAGE_ALIGNED(MiSessionImageStart));
|
||||||
|
|
||||||
/* The view starts right below the session working set (itself below
|
/* Session working set is below the session image range */
|
||||||
* the image area) */
|
MiSessionSpaceWs = (PUCHAR)MiSessionImageStart - MI_SESSION_WORKING_SET_SIZE;
|
||||||
MiSessionViewEnd = (PVOID)MI_SESSION_VIEW_END;
|
|
||||||
MiSessionViewStart = (PCHAR)MiSessionViewEnd - MmSessionViewSize;
|
/* Session view is below the session working set */
|
||||||
|
MmSessionViewSize = MI_SESSION_VIEW_SIZE;
|
||||||
|
MiSessionViewEnd = MiSessionSpaceWs;
|
||||||
|
MiSessionViewStart = (PUCHAR)MiSessionViewEnd - MmSessionViewSize;
|
||||||
ASSERT(IS_PAGE_ALIGNED(MiSessionViewStart));
|
ASSERT(IS_PAGE_ALIGNED(MiSessionViewStart));
|
||||||
|
|
||||||
/* Session pool follows */
|
/* Session pool is below session view */
|
||||||
|
MmSessionPoolSize = MI_SESSION_POOL_SIZE;
|
||||||
MiSessionPoolEnd = MiSessionViewStart;
|
MiSessionPoolEnd = MiSessionViewStart;
|
||||||
MiSessionPoolStart = (PCHAR)MiSessionPoolEnd - MmSessionPoolSize;
|
MiSessionPoolStart = (PUCHAR)MiSessionPoolEnd - MmSessionPoolSize;
|
||||||
ASSERT(IS_PAGE_ALIGNED(MiSessionPoolStart));
|
ASSERT(IS_PAGE_ALIGNED(MiSessionPoolStart));
|
||||||
|
|
||||||
/* And it all begins here */
|
/* And it all begins here */
|
||||||
|
@ -91,12 +94,23 @@ MiInitializeSessionSpaceLayout(VOID)
|
||||||
|
|
||||||
/* System view space ends at session space, so now that we know where
|
/* System view space ends at session space, so now that we know where
|
||||||
* this is, we can compute the base address of system view space itself. */
|
* this is, we can compute the base address of system view space itself. */
|
||||||
MiSystemViewStart = (PCHAR)MmSessionBase - MmSystemViewSize;
|
MmSystemViewSize = MI_SYSTEM_VIEW_SIZE;
|
||||||
|
MiSystemViewStart = (PUCHAR)MmSessionBase - MmSystemViewSize;
|
||||||
ASSERT(IS_PAGE_ALIGNED(MiSystemViewStart));
|
ASSERT(IS_PAGE_ALIGNED(MiSystemViewStart));
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
ASSERT(Add2Ptr(MmSessionBase, MmSessionSize) == MiSessionSpaceEnd);
|
||||||
ASSERT(MiSessionViewEnd <= MiSessionImageStart);
|
ASSERT(MiSessionViewEnd <= MiSessionImageStart);
|
||||||
ASSERT(MmSessionBase <= MiSessionPoolStart);
|
ASSERT(MmSessionBase <= MiSessionPoolStart);
|
||||||
|
|
||||||
|
/* Compute the PTE addresses for all the addresses we carved out */
|
||||||
|
MiSessionImagePteStart = MiAddressToPte(MiSessionImageStart);
|
||||||
|
MiSessionImagePteEnd = MiAddressToPte(MiSessionImageEnd);
|
||||||
|
MiSessionBasePte = MiAddressToPte(MmSessionBase);
|
||||||
|
MiSessionLastPte = MiAddressToPte(MiSessionSpaceEnd);
|
||||||
|
|
||||||
|
/* Initialize the pointer to the session space structure */
|
||||||
|
MmSessionSpace = (PMM_SESSION_SPACE)Add2Ptr(MiSessionImageStart, 0x10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
|
Loading…
Reference in a new issue