[ros-diffs] [akorotaev] 31596: Some rework on merging, but it doesn't help bugcheck

akorotaev at svn.reactos.org akorotaev at svn.reactos.org
Fri Jan 4 22:23:17 CET 2008


Author: akorotaev
Date: Sat Jan  5 00:23:16 2008
New Revision: 31596

URL: http://svn.reactos.org/svn/reactos?rev=31596&view=rev
Log:
Some rework on merging, but it doesn't help bugcheck

Modified:
    branches/cache_manager_rewrite/mm/elf.inc.h
    branches/cache_manager_rewrite/mm/elf32.c
    branches/cache_manager_rewrite/mm/elf64.c
    branches/cache_manager_rewrite/mm/freelist.c
    branches/cache_manager_rewrite/mm/mminit.c
    branches/cache_manager_rewrite/mm/pageop.c
    branches/cache_manager_rewrite/mm/rmap.c
    branches/cache_manager_rewrite/mm/section.c
    branches/cache_manager_rewrite/mm/virtual.c

Modified: branches/cache_manager_rewrite/mm/elf.inc.h
URL: http://svn.reactos.org/svn/reactos/branches/cache_manager_rewrite/mm/elf.inc.h?rev=31596&r1=31595&r2=31596&view=diff
==============================================================================
--- branches/cache_manager_rewrite/mm/elf.inc.h (original)
+++ branches/cache_manager_rewrite/mm/elf.inc.h Sat Jan  5 00:23:16 2008
@@ -1,5 +1,6 @@
 /* $Id$
 */
+#include <ntoskrnl.h>
 
 #define NDEBUG
 #include <internal/debug.h>

Modified: branches/cache_manager_rewrite/mm/elf32.c
URL: http://svn.reactos.org/svn/reactos/branches/cache_manager_rewrite/mm/elf32.c?rev=31596&r1=31595&r2=31596&view=diff
==============================================================================
--- branches/cache_manager_rewrite/mm/elf32.c (original)
+++ branches/cache_manager_rewrite/mm/elf32.c Sat Jan  5 00:23:16 2008
@@ -7,7 +7,7 @@
  *
  * PROGRAMMERS:     No programmer listed.
  */
-#include <ntoskrnl.h>
+
 #define __ELF_WORD_SIZE 32
 #include "elf.inc.h"
 

Modified: branches/cache_manager_rewrite/mm/elf64.c
URL: http://svn.reactos.org/svn/reactos/branches/cache_manager_rewrite/mm/elf64.c?rev=31596&r1=31595&r2=31596&view=diff
==============================================================================
--- branches/cache_manager_rewrite/mm/elf64.c (original)
+++ branches/cache_manager_rewrite/mm/elf64.c Sat Jan  5 00:23:16 2008
@@ -7,6 +7,6 @@
  *
  * PROGRAMMERS:     No programmer listed.
  */
-#include <ntoskrnl.h>
+
 #define __ELF_WORD_SIZE 64
 #include "elf.inc.h"

Modified: branches/cache_manager_rewrite/mm/freelist.c
URL: http://svn.reactos.org/svn/reactos/branches/cache_manager_rewrite/mm/freelist.c?rev=31596&r1=31595&r2=31596&view=diff
==============================================================================
--- branches/cache_manager_rewrite/mm/freelist.c (original)
+++ branches/cache_manager_rewrite/mm/freelist.c Sat Jan  5 00:23:16 2008
@@ -183,8 +183,8 @@
 
    KeAcquireSpinLock(&PageListLock, &oldIrql);
 
-   last = min(HighestAcceptableAddress.QuadPart / PAGE_SIZE, MmPageArraySize - 1);
-   boundary = BoundaryAddressMultiple.QuadPart / PAGE_SIZE;
+   last = min(HighestAcceptableAddress.LowPart / PAGE_SIZE, MmPageArraySize - 1);
+   boundary = BoundaryAddressMultiple.LowPart / PAGE_SIZE;
 
    for (j = 0; j < 2; j++)
    {
@@ -195,7 +195,7 @@
        * pages above the 16MB area because the caller has specify an upper limit.
        * The second try uses the specified lower limit.
        */
-      for (i = j == 0 ? 0x100000 / PAGE_SIZE : LowestAcceptableAddress.QuadPart / PAGE_SIZE; i <= last; )
+      for (i = j == 0 ? 0x100000 / PAGE_SIZE : LowestAcceptableAddress.LowPart / PAGE_SIZE; i <= last; )
       {
          if (MmPageArray[i].Flags.Type == MM_PHYSICAL_PAGE_FREE)
          {
@@ -1036,8 +1036,8 @@
    if (NumberOfPages == 0)
       return 0;
 
-   LowestPage = LowestAddress.QuadPart / PAGE_SIZE;
-   HighestPage = HighestAddress.QuadPart / PAGE_SIZE;
+   LowestPage = LowestAddress.LowPart / PAGE_SIZE;
+   HighestPage = HighestAddress.LowPart / PAGE_SIZE;
    if ((HighestAddress.u.LowPart % PAGE_SIZE) != 0)
       HighestPage++;
 
@@ -1172,7 +1172,7 @@
    ULONG Count;
 
    /* Free initial kernel memory */
-   MiFreeInitMemory();
+   //MiFreeInitMemory();
 
    /* Set our priority to 0 */
    KeGetCurrentThread()->BasePriority = 0;

Modified: branches/cache_manager_rewrite/mm/mminit.c
URL: http://svn.reactos.org/svn/reactos/branches/cache_manager_rewrite/mm/mminit.c?rev=31596&r1=31595&r2=31596&view=diff
==============================================================================
--- branches/cache_manager_rewrite/mm/mminit.c (original)
+++ branches/cache_manager_rewrite/mm/mminit.c Sat Jan  5 00:23:16 2008
@@ -493,10 +493,29 @@
     return TRUE;
 }
 
+#if 0
+
+VOID static
+MiFreeInitMemoryPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
+                     PFN_TYPE Page, SWAPENTRY SwapEntry,
+                     BOOLEAN Dirty)
+{
+   ASSERT(SwapEntry == 0);
+   if (Page != 0)
+   {
+      MmReleasePageMemoryConsumer(MC_NPPOOL, Page);
+   }
+}
+
 VOID
 NTAPI
 MiFreeInitMemory(VOID)
 {
    MmLockAddressSpace(MmGetKernelAddressSpace());
+   MmFreeMemoryAreaByPtr(MmGetKernelAddressSpace(),
+                         (PVOID)&_init_start__,
+                         MiFreeInitMemoryPage,
+                         NULL);
    MmUnlockAddressSpace(MmGetKernelAddressSpace());
 }
+#endif

Modified: branches/cache_manager_rewrite/mm/pageop.c
URL: http://svn.reactos.org/svn/reactos/branches/cache_manager_rewrite/mm/pageop.c?rev=31596&r1=31595&r2=31596&view=diff
==============================================================================
--- branches/cache_manager_rewrite/mm/pageop.c (original)
+++ branches/cache_manager_rewrite/mm/pageop.c Sat Jan  5 00:23:16 2008
@@ -46,10 +46,7 @@
       KeReleaseSpinLock(&MmPageOpHashTableLock, oldIrql);
       return;
    }
-   if (PageOp->MArea)
-   {
-      (void)InterlockedDecrementUL(&PageOp->MArea->PageOpCount);
-   }
+   (void)InterlockedDecrementUL(&PageOp->MArea->PageOpCount);
    PrevPageOp = MmPageOpHashTable[PageOp->Hash];
    if (PrevPageOp == PageOp)
    {
@@ -143,6 +140,8 @@
    KeReleaseSpinLock(&MmPageOpHashTableLock, oldIrql);
    return(NULL);
 }
+
+extern BOOLEAN RmapReady, PageOpReady, SectionsReady, PagingReady;
 
 PMM_PAGEOP
 NTAPI
@@ -157,6 +156,12 @@
    ULONG_PTR Hash = 0;
    KIRQL oldIrql;
    PMM_PAGEOP PageOp;
+
+   if (!PageOpReady)
+   {
+       DPRINT1("PAGEOPS USED TOO SOON!!!\n");
+       while (TRUE);
+   }
 
    /*
     * Calcuate the hash value for pageop structure
@@ -256,10 +261,7 @@
    PageOp->MArea = MArea;
    KeInitializeEvent(&PageOp->CompletionEvent, NotificationEvent, FALSE);
    MmPageOpHashTable[Hash] = PageOp;
-   if (MArea)
-   {
-      (void)InterlockedIncrementUL(&MArea->PageOpCount);
-   }
+   (void)InterlockedIncrementUL(&MArea->PageOpCount);
 
    KeReleaseSpinLock(&MmPageOpHashTableLock, oldIrql);
    return(PageOp);
@@ -281,10 +283,3 @@
                                     TAG_MM_PAGEOP,
                                     50);
 }
-
-
-
-
-
-
-

Modified: branches/cache_manager_rewrite/mm/rmap.c
URL: http://svn.reactos.org/svn/reactos/branches/cache_manager_rewrite/mm/rmap.c?rev=31596&r1=31595&r2=31596&view=diff
==============================================================================
--- branches/cache_manager_rewrite/mm/rmap.c (original)
+++ branches/cache_manager_rewrite/mm/rmap.c Sat Jan  5 00:23:16 2008
@@ -390,6 +390,8 @@
    return(FALSE);
 }
 
+extern BOOLEAN RmapReady, PageOpReady, SectionsReady, PagingReady;
+
 VOID
 NTAPI
 MmInsertRmap(PFN_TYPE Page, PEPROCESS Process,
@@ -399,6 +401,12 @@
    PMM_RMAP_ENTRY new_entry;
    ULONG PrevSize;
 
+   if (!RmapReady)
+   {
+       DPRINT1("RMAPS USED TOO SOON!!!\n");
+       while (TRUE);
+   }
+
    Address = (PVOID)PAGE_ROUND_DOWN(Address);
 
    new_entry = ExAllocateFromNPagedLookasideList(&RmapLookasideList);
@@ -409,7 +417,11 @@
    new_entry->Address = Address;
    new_entry->Process = (PEPROCESS)Process;
 #ifdef DBG
+#ifdef __GNUC__
    new_entry->Caller = __builtin_return_address(0);
+#else
+   new_entry->Caller = _ReturnAddress();
+#endif
 #endif
 
    if (MmGetPfnForProcess(Process, Address) != Page)
@@ -431,9 +443,9 @@
       {
           DbgPrint("MmInsertRmap tries to add a second rmap entry for address %p\n    current caller ",
                    current_entry->Address);
-          KeRosPrintAddress(new_entry->Caller);
+          DbgPrint("%p", new_entry->Caller);
           DbgPrint("\n    previous caller ");
-          KeRosPrintAddress(current_entry->Caller);
+          DbgPrint("%p", current_entry->Caller);
           DbgPrint("\n");
           KeBugCheck(0);
       }
@@ -466,6 +478,12 @@
    PMM_RMAP_ENTRY previous_entry;
    PEPROCESS Process;
 
+   if (!RmapReady)
+   {
+       DPRINT1("RMAPS USED TOO SOON!!!\n");
+       while (TRUE);
+   }
+
    ExAcquireFastMutex(&RmapListLock);
    current_entry = MmGetRmapListHeadPage(Page);
    if (current_entry == NULL)
@@ -503,6 +521,12 @@
              PVOID Address)
 {
    PMM_RMAP_ENTRY current_entry, previous_entry;
+
+   if (!RmapReady)
+   {
+       DPRINT1("RMAPS USED TOO SOON!!!\n");
+       while (TRUE);
+   }
 
    ExAcquireFastMutex(&RmapListLock);
    previous_entry = NULL;
@@ -535,6 +559,5 @@
       previous_entry = current_entry;
       current_entry = current_entry->Next;
    }
-   DPRINT1("%x %x %x\n", Page, Process, Address);
    KEBUGCHECK(0);
 }

Modified: branches/cache_manager_rewrite/mm/section.c
URL: http://svn.reactos.org/svn/reactos/branches/cache_manager_rewrite/mm/section.c?rev=31596&r1=31595&r2=31596&view=diff
==============================================================================
--- branches/cache_manager_rewrite/mm/section.c (original)
+++ branches/cache_manager_rewrite/mm/section.c Sat Jan  5 00:23:16 2008
@@ -32,7 +32,7 @@
  *                  Ge van Geldorp
  *                  Royce Mitchell III
  *                  Filip Navara
- *                  Aleksey Bragin
+ *                  Aleksey Bragin 
  *                  Jason Filby
  *                  Thomas Weidenmueller
  *                  Gunnar Andre' Dalsnes
@@ -182,7 +182,7 @@
     /*
      * FIXME: TODO.
      * Filip says to get the MADDRESS_SPACE from EPROCESS,
-     * then use the MmMarea routines to locate the Marea that
+     * then use the MmMarea routines to locate the Marea that 
      * corresponds to the address. Then make sure it's a section
      * view type (MEMORY_AREA_SECTION_VIEW) and use the marea's
      * per-type union to get the .u.SectionView.Section pointer to
@@ -1049,8 +1049,8 @@
            AddressSpace, MemoryArea, Address, Locked);
 
    PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
-   SegmentOffset = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress
-                 + MemoryArea->Data.SectionData.ViewOffset;
+   SegmentOffset = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress 
+            + MemoryArea->Data.SectionData.ViewOffset;
 
    Segment = MemoryArea->Data.SectionData.Segment;
    Section = MemoryArea->Data.SectionData.Section;
@@ -2281,7 +2281,7 @@
     * Find the offset of the page
     */
    PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
-   Offset = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress
+   Offset = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress 
             + MemoryArea->Data.SectionData.ViewOffset;
 
    Segment = MemoryArea->Data.SectionData.Segment;
@@ -2459,7 +2459,7 @@
    {
       MmUnlockAddressSpace((PMADDRESS_SPACE)&Process->VadRoot);
    }
-
+   
    if (PageOutContext->Private)
    {
       MmReleasePageMemoryConsumer(PageOutContext->Consumer, Page);
@@ -2494,7 +2494,7 @@
 
    Context.Consumer = MemoryArea->Type == MEMORY_AREA_CACHE_SEGMENT ? MC_CACHE : MC_USER;
 
-   Context.Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress
+   Context.Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress 
                     + MemoryArea->Data.SectionData.ViewOffset;
    FileOffset = Context.Offset + Context.Segment->FileOffset;
 
@@ -2796,7 +2796,7 @@
 
    Address = (PVOID)PAGE_ROUND_DOWN(Address);
 
-   Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress
+   Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress 
             + MemoryArea->Data.SectionData.ViewOffset;
 
    /*
@@ -2965,7 +2965,7 @@
             ULONG Entry;
             PFN_TYPE Page;
 
-            Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress
+            Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress 
                      + MemoryArea->Data.SectionData.ViewOffset;
             Entry = MmGetPageEntrySectionSegment(Segment, Offset);
             Page = MmGetPfnForProcess(AddressSpace->Process, Address);
@@ -3272,7 +3272,7 @@
    UNICODE_STRING Name;
 
    DPRINT("Creating Section Object Type\n");
-
+  
    /* Initialize the Section object type  */
    RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
    RtlInitUnicodeString(&Name, L"Section");
@@ -3434,13 +3434,10 @@
    /*
     * Reference the file object
     */
-   Status = ObReferenceObjectByHandle(FileObject,
-                                      FileAccess,
-                                      IoFileObjectType,
-                                      ExGetPreviousMode(),
-                                      (PVOID*)(PVOID)&FileObject,
-                                      NULL);
-
+   Status = ObReferenceObjectByPointer(FileObject,
+                                       FileAccess,
+                                       IoFileObjectType,
+                                       UserMode);
    if (!NT_SUCCESS(Status))
    {
       ObDereferenceObject(Section);
@@ -4375,7 +4372,7 @@
          ObDereferenceObject(Section);
          return(STATUS_NO_MEMORY);
       }
-
+      
       RtlZeroMemory(ImageSectionObject, sizeof(MM_IMAGE_SECTION_OBJECT));
 
       StatusExeFmt = ExeFmtpCreateImageSection(FileObject, ImageSectionObject);
@@ -4760,6 +4757,8 @@
      SafeViewSize = (ViewSize != NULL ? *ViewSize : 0);
    }
 
+   SafeSectionOffset.LowPart = PAGE_ROUND_DOWN(SafeSectionOffset.LowPart);
+
    Status = ObReferenceObjectByHandle(ProcessHandle,
                                       PROCESS_VM_OPERATION,
                                       PsProcessType,
@@ -4796,6 +4795,18 @@
                                InheritDisposition,
                                AllocationType,
                                Protect);
+
+   /* Check if this is an image for the current process */
+   if ((Section->AllocationAttributes & SEC_IMAGE) &&
+       (Process == PsGetCurrentProcess()) &&
+       (Status != STATUS_IMAGE_NOT_AT_BASE))
+   {
+        /* Notify the debugger */
+       DbgkMapViewOfSection(Section,
+                            SafeBaseAddress,
+                            SafeSectionOffset.LowPart,
+                            SafeViewSize);
+   }
 
    ObDereferenceObject(Section);
    ObDereferenceObject(Process);
@@ -4990,7 +5001,7 @@
    ASSERT(Process);
 
    AddressSpace = (PMADDRESS_SPACE)&(Process)->VadRoot;
-
+   
    MmLockAddressSpace(AddressSpace);
    MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace,
                                             BaseAddress);
@@ -5626,6 +5637,8 @@
             ImageSize = max(ImageSize, MaxExtent);
          }
       }
+
+      ImageSectionObject->ImageSize = ImageSize;
 
       /* Check there is enough space to map the section at that point. */
       if (MmLocateMemoryAreaByRegion(AddressSpace, (PVOID)ImageBase,

Modified: branches/cache_manager_rewrite/mm/virtual.c
URL: http://svn.reactos.org/svn/reactos/branches/cache_manager_rewrite/mm/virtual.c?rev=31596&r1=31595&r2=31596&view=diff
==============================================================================
--- branches/cache_manager_rewrite/mm/virtual.c (original)
+++ branches/cache_manager_rewrite/mm/virtual.c Sat Jan  5 00:23:16 2008
@@ -397,7 +397,7 @@
     NTSTATUS Status;
 
     *NumberOfBytesToProtect =
-        PAGE_ROUND_UP((ULONG_PTR)(*BaseAddress) + (*NumberOfBytesToProtect)) -
+        PAGE_ROUND_UP((ULONG_PTR)(*BaseAddress) + (ULONG_PTR)(*NumberOfBytesToProtect)) -
         PAGE_ROUND_DOWN(*BaseAddress);
     *BaseAddress = (PVOID)PAGE_ROUND_DOWN(*BaseAddress);
 




More information about the Ros-diffs mailing list