- Add missing KERNEL_LARGE_STACK_COMMIT definition to DDK.

- Fix typo in MMWSL.
- Add RtlRandom to NDK.
- Add MEMORY_PRIORITY values to NDK.
- Add KeAcquireSpinLockRaiseToSynch to NDK.
- Make MmInitializeProcessAddressSpace take two more parameters: one to specify flags, such as large page support, and another one to define the process being cloned, when fork() support will be added.
- Add KeInvalidAccessAllowed to deal with page faults in the special S-List code. The assembly code currently handles simple faults, but our MmAccessFault handler needs to start verifying the fault too.
- Mark LoaderReserve pages as LoaderFree, it seems they end up this way in Windows.
- Use MmNumberOfPhysicalPages instead of MmStats.NrTotalPages.

All NDK changes are discussed with Alex.

svn path=/trunk/; revision=29254
This commit is contained in:
Aleksey Bragin 2007-09-27 18:07:44 +00:00
parent 2d7f6e6a42
commit 8f33e033e4
15 changed files with 97 additions and 24 deletions

View file

@ -231,7 +231,7 @@ typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT;
#define KERNEL_STACK_SIZE 12288 #define KERNEL_STACK_SIZE 12288
#define KERNEL_LARGE_STACK_SIZE 61440 #define KERNEL_LARGE_STACK_SIZE 61440
#define KERNEL_LARGE_STACK_COMMIT 12288
#define DPFLTR_ERROR_LEVEL 0 #define DPFLTR_ERROR_LEVEL 0
#define DPFLTR_WARNING_LEVEL 1 #define DPFLTR_WARNING_LEVEL 1

View file

@ -133,6 +133,11 @@ KeAcquireInStackQueuedSpinLockRaiseToSynch(
IN PKLOCK_QUEUE_HANDLE LockHandle IN PKLOCK_QUEUE_HANDLE LockHandle
); );
KIRQL
FASTCALL
KeAcquireSpinLockRaiseToSynch(
IN OUT PKSPIN_LOCK SpinLock
);
// //
// Interrupt Functions // Interrupt Functions

View file

@ -548,7 +548,7 @@ typedef struct _MMWSL
ULONG NextSlot; ULONG NextSlot;
PMMWSLE Wsle; PMMWSLE Wsle;
ULONG LastInitializedWsle; ULONG LastInitializedWsle;
ULONG NonDirectcout; ULONG NonDirectCount;
PMMWSLE_HASH HashTable; PMMWSLE_HASH HashTable;
ULONG HashTableSize; ULONG HashTableSize;
ULONG NumberOfCommittedPageTables; ULONG NumberOfCommittedPageTables;

View file

@ -98,6 +98,13 @@ Author:
#define PROCESS_PRIORITY_NORMAL 8 #define PROCESS_PRIORITY_NORMAL 8
#define PROCESS_PRIORITY_NORMAL_FOREGROUND 9 #define PROCESS_PRIORITY_NORMAL_FOREGROUND 9
//
// Process memory priorities
//
#define MEMORY_PRIORITY_BACKGROUND 0
#define MEMORY_PRIORITY_UNKNOWN 1
#define MEMORY_PRIORITY_FOREGROUND 2
// //
// Process Priority Separation Values (OR) // Process Priority Separation Values (OR)
// //

View file

@ -2920,6 +2920,13 @@ RtlUniform(
IN PULONG Seed IN PULONG Seed
); );
NTSYSAPI
ULONG
NTAPI
RtlRandom(
IN OUT PULONG Seed
);
NTSYSAPI NTSYSAPI
ULONG ULONG
NTAPI NTAPI

View file

@ -1483,7 +1483,7 @@ Phase1InitializationDiscard(IN PVOID Context)
&MsgEntry); &MsgEntry);
/* Get total RAM size */ /* Get total RAM size */
Size = MmStats.NrTotalPages * PAGE_SIZE / 1024 / 1024; Size = MmNumberOfPhysicalPages * PAGE_SIZE / 1024 / 1024;
/* Create the string */ /* Create the string */
StringBuffer = InitBuffer->VersionBuffer; StringBuffer = InitBuffer->VersionBuffer;

View file

@ -760,6 +760,10 @@ FASTCALL
KeZeroPages(IN PVOID Address, KeZeroPages(IN PVOID Address,
IN ULONG Size); IN ULONG Size);
BOOLEAN
FASTCALL
KeInvalidAccessAllowed(IN PVOID TrapInformation OPTIONAL);
VOID VOID
NTAPI NTAPI
KeRosDumpStackFrames( KeRosDumpStackFrames(

View file

@ -13,6 +13,7 @@ extern ULONG MmPagedPoolSize;
extern ULONG MmTotalPagedPoolQuota; extern ULONG MmTotalPagedPoolQuota;
extern ULONG MmTotalNonPagedPoolQuota; extern ULONG MmTotalNonPagedPoolQuota;
extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress; extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress;
extern ULONG MmNumberOfPhysicalPages;
extern PVOID MmPagedPoolBase; extern PVOID MmPagedPoolBase;
extern ULONG MmPagedPoolSize; extern ULONG MmPagedPoolSize;
@ -614,7 +615,9 @@ NTSTATUS
NTAPI NTAPI
MmInitializeProcessAddressSpace( MmInitializeProcessAddressSpace(
IN PEPROCESS Process, IN PEPROCESS Process,
IN PEPROCESS Clone OPTIONAL,
IN PVOID Section OPTIONAL, IN PVOID Section OPTIONAL,
IN OUT PULONG Flags,
IN POBJECT_NAME_INFORMATION *AuditName OPTIONAL IN POBJECT_NAME_INFORMATION *AuditName OPTIONAL
); );

View file

@ -249,7 +249,7 @@ KeRosDumpTriageForBugZillaReport(VOID)
&KeRosBiosVersion, &KeRosBiosVersion,
&KeRosVideoBiosDate, &KeRosVideoBiosDate,
&KeRosVideoBiosVersion, &KeRosVideoBiosVersion,
MmStats.NrTotalPages * PAGE_SIZE); MmNumberOfPhysicalPages * PAGE_SIZE);
#endif #endif
} }
@ -971,12 +971,6 @@ KeBugCheckWithTf(IN ULONG BugCheckCode,
} }
} }
/* ROS HACK: Unlock the Kernel Address Space if we own it */
if (KernelAddressSpaceLock.Owner == KeGetCurrentThread())
{
MmUnlockAddressSpace(MmGetKernelAddressSpace());
}
/* Raise IRQL to HIGH_LEVEL */ /* Raise IRQL to HIGH_LEVEL */
_disable(); _disable();
KfRaiseIrql(HIGH_LEVEL); KfRaiseIrql(HIGH_LEVEL);

View file

@ -427,8 +427,8 @@ KiRosBuildOsMemoryMap(VOID)
{ {
/* It's over 16MB, so that memory gets marked as reserve */ /* It's over 16MB, so that memory gets marked as reserve */
Status = KiRosConfigureArcDescriptor(PageStart, Status = KiRosConfigureArcDescriptor(PageStart,
PageEnd, PageEnd,
LoaderReserve); LoaderFree);
} }
else else
{ {
@ -448,7 +448,7 @@ KiRosBuildOsMemoryMap(VOID)
/* Any code in the memory hole region ends up as reserve */ /* Any code in the memory hole region ends up as reserve */
Status = KiRosConfigureArcDescriptor(PageStart, Status = KiRosConfigureArcDescriptor(PageStart,
PageEnd, PageEnd,
LoaderReserve); LoaderFree);
} }
/* If we failed, break out, otherwise, go to the next BIOS block */ /* If we failed, break out, otherwise, go to the next BIOS block */

View file

@ -799,6 +799,45 @@ KeTrapFrameToContext(IN PKTRAP_FRAME TrapFrame,
if (OldIrql < APC_LEVEL) KeLowerIrql(OldIrql); if (OldIrql < APC_LEVEL) KeLowerIrql(OldIrql);
} }
BOOLEAN
FASTCALL
KeInvalidAccessAllowed(IN PVOID TrapInformation OPTIONAL)
{
ULONG Eip;
PKTRAP_FRAME TrapFrame = TrapInformation;
VOID NTAPI ExpInterlockedPopEntrySListFault(VOID);
/* Don't do anything if we didn't get a trap frame */
if (!TrapInformation) return FALSE;
/* Check where we came from */
switch (TrapFrame->SegCs)
{
/* Kernel mode */
case KGDT_R0_CODE:
/* Allow S-LIST Routine to fail */
Eip = (ULONG)&ExpInterlockedPopEntrySListFault;
break;
/* User code */
case KGDT_R3_CODE | RPL_MASK:
/* Allow S-LIST Routine to fail */
//Eip = (ULONG)KeUserPopEntrySListFault;
Eip = 0;
break;
default:
/* Anything else gets a bugcheck */
Eip = 0;
}
/* Return TRUE if we want to keep the system up */
return (TrapFrame->Eip == Eip) ? TRUE : FALSE;
}
VOID VOID
NTAPI NTAPI
KiDispatchException(IN PEXCEPTION_RECORD ExceptionRecord, KiDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,

View file

@ -1,5 +1,4 @@
/* $Id$ /*
*
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/i386/ldt.c * FILE: ntoskrnl/ke/i386/ldt.c
@ -221,3 +220,4 @@ NtSetLdtEntries (ULONG Selector1,
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }

View file

@ -38,6 +38,8 @@ PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress;
PVOID MiNonPagedPoolStart; PVOID MiNonPagedPoolStart;
ULONG MiNonPagedPoolLength; ULONG MiNonPagedPoolLength;
ULONG MmNumberOfPhysicalPages;
VOID INIT_FUNCTION NTAPI MmInitVirtualMemory(ULONG_PTR LastKernelAddress, ULONG KernelLength); VOID INIT_FUNCTION NTAPI MmInitVirtualMemory(ULONG_PTR LastKernelAddress, ULONG KernelLength);
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
@ -347,6 +349,7 @@ MmInit1(ULONG_PTR FirstKrnlPhysAddr,
* Free physical memory not used by the kernel * Free physical memory not used by the kernel
*/ */
MmStats.NrTotalPages = MmFreeLdrMemHigher/4; MmStats.NrTotalPages = MmFreeLdrMemHigher/4;
MmNumberOfPhysicalPages = MmStats.NrTotalPages;
if (!MmStats.NrTotalPages) if (!MmStats.NrTotalPages)
{ {
DbgPrint("Memory not detected, default to 8 MB\n"); DbgPrint("Memory not detected, default to 8 MB\n");
@ -427,13 +430,18 @@ NTAPI
MmInitSystem(IN ULONG Phase, MmInitSystem(IN ULONG Phase,
IN PLOADER_PARAMETER_BLOCK LoaderBlock) IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{ {
ULONG Flags = 0;
if (Phase == 0) if (Phase == 0)
{ {
/* Initialize the Loader Lock */ /* Initialize the Loader Lock */
KeInitializeMutant(&MmSystemLoadLock, FALSE); KeInitializeMutant(&MmSystemLoadLock, FALSE);
/* Initialize the address space for the system process */ /* Initialize the address space for the system process */
MmInitializeProcessAddressSpace(PsGetCurrentProcess(), NULL, NULL); MmInitializeProcessAddressSpace(PsGetCurrentProcess(),
NULL,
NULL,
&Flags,
NULL);
/* Reload boot drivers */ /* Reload boot drivers */
MiReloadBootLoadedDrivers(LoaderBlock); MiReloadBootLoadedDrivers(LoaderBlock);

View file

@ -498,7 +498,9 @@ MmInitializeHandBuiltProcess2(IN PEPROCESS Process)
NTSTATUS NTSTATUS
NTAPI NTAPI
MmInitializeProcessAddressSpace(IN PEPROCESS Process, MmInitializeProcessAddressSpace(IN PEPROCESS Process,
IN PEPROCESS ProcessClone OPTIONAL,
IN PVOID Section OPTIONAL, IN PVOID Section OPTIONAL,
IN OUT PULONG Flags,
IN POBJECT_NAME_INFORMATION *AuditName OPTIONAL) IN POBJECT_NAME_INFORMATION *AuditName OPTIONAL)
{ {
NTSTATUS Status; NTSTATUS Status;

View file

@ -555,7 +555,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle,
/* Set default exit code */ /* Set default exit code */
Process->ExitStatus = STATUS_TIMEOUT; Process->ExitStatus = STATUS_TIMEOUT;
/* Check if this is the initial process being built */ /* Check if this is the initial process being built */
if (Parent) if (Parent)
{ {
@ -576,7 +576,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle,
Status = MmInitializeHandBuiltProcess(Process, &DirectoryTableBase); Status = MmInitializeHandBuiltProcess(Process, &DirectoryTableBase);
if (!NT_SUCCESS(Status)) goto CleanupWithRef; if (!NT_SUCCESS(Status)) goto CleanupWithRef;
} }
/* We now have an address space */ /* We now have an address space */
InterlockedOr((PLONG)&Process->Flags, PSF_HAS_ADDRESS_SPACE_BIT); InterlockedOr((PLONG)&Process->Flags, PSF_HAS_ADDRESS_SPACE_BIT);
@ -596,7 +596,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle,
/* Set default priority class */ /* Set default priority class */
Process->PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL; Process->PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL;
/* Check if we have a parent */ /* Check if we have a parent */
if (Parent) if (Parent)
{ {
@ -628,7 +628,9 @@ PspCreateProcess(OUT PHANDLE ProcessHandle,
{ {
/* Initialize the address space */ /* Initialize the address space */
Status = MmInitializeProcessAddressSpace(Process, Status = MmInitializeProcessAddressSpace(Process,
NULL,
SectionObject, SectionObject,
&Flags,
&Process-> &Process->
SeAuditProcessCreationInfo. SeAuditProcessCreationInfo.
ImageFileName); ImageFileName);
@ -644,13 +646,13 @@ PspCreateProcess(OUT PHANDLE ProcessHandle,
} }
else else
{ {
/* This is a system process other than the boot one (MmInit1) */ /* This is the initial system process */
Flags &= ~PS_LARGE_PAGES; Flags &= ~PS_LARGE_PAGES;
Status = MmInitializeProcessAddressSpace(Process, Status = MmInitializeProcessAddressSpace(Process,
NULL, NULL,
&Process-> NULL,
SeAuditProcessCreationInfo. &Flags,
ImageFileName); NULL);
if (!NT_SUCCESS(Status)) goto CleanupWithRef; if (!NT_SUCCESS(Status)) goto CleanupWithRef;
/* Create a dummy image file name */ /* Create a dummy image file name */
@ -670,7 +672,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle,
sizeof(OBJECT_NAME_INFORMATION)); sizeof(OBJECT_NAME_INFORMATION));
} }
} }
/* Check if we have a section object and map the system DLL */ /* Check if we have a section object and map the system DLL */
if (SectionObject) PspMapSystemDll(Process, NULL, FALSE); if (SectionObject) PspMapSystemDll(Process, NULL, FALSE);
@ -680,6 +682,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle,
Process->UniqueProcessId = ExCreateHandle(PspCidTable, &CidEntry); Process->UniqueProcessId = ExCreateHandle(PspCidTable, &CidEntry);
if (!Process->UniqueProcessId) if (!Process->UniqueProcessId)
{ {
/* Fail */
Status = STATUS_INSUFFICIENT_RESOURCES; Status = STATUS_INSUFFICIENT_RESOURCES;
goto CleanupWithRef; goto CleanupWithRef;
} }
@ -701,6 +704,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle,
/* Create PEB only for User-Mode Processes */ /* Create PEB only for User-Mode Processes */
if (Parent) if (Parent)
{ {
/* Create it */
Status = MmCreatePeb(Process); Status = MmCreatePeb(Process);
if (!NT_SUCCESS(Status)) goto CleanupWithRef; if (!NT_SUCCESS(Status)) goto CleanupWithRef;
} }