ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
February 2021
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
30 participants
434 discussions
Start a n
N
ew thread
[reactos] 57/100: Fix physical memory section creation
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=543112008aafc40b34fd6…
commit 543112008aafc40b34fd68b43baa04645aeaaaf1 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Dec 18 16:53:39 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:22 2021 +0100 Fix physical memory section creation --- ntoskrnl/mm/section.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index b709a50cd8d..b9242c6eade 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -2068,7 +2068,7 @@ MmCreatePhysicalMemorySection(VOID) /* * Create the section mapping physical memory */ - SectionSize.QuadPart = MmNumberOfPhysicalPages * PAGE_SIZE; + SectionSize.QuadPart = MmHighestPhysicalPage * PAGE_SIZE; InitializeObjectAttributes(&Obj, &Name, OBJ_PERMANENT | OBJ_KERNEL_EXCLUSIVE, @@ -2136,6 +2136,7 @@ MmCreatePhysicalMemorySection(VOID) if (!NT_SUCCESS(Status)) { ObDereferenceObject(PhysSection); + return Status; } ObCloseHandle(Handle, KernelMode); @@ -3654,16 +3655,17 @@ NtQuerySection( Sbi.BaseAddress = (PVOID)Section->Address.StartingVpn; Sbi.Attributes = 0; - if (Section->u.Flags.Commit) - Sbi.Attributes |= SEC_COMMIT; - if (Section->u.Flags.Reserve) - Sbi.Attributes |= SEC_RESERVE; if (Section->u.Flags.File) Sbi.Attributes |= SEC_FILE; if (Section->u.Flags.Image) Sbi.Attributes |= SEC_IMAGE; - /* FIXME : Complete/test the list of flags passed back from NtCreateSection */ + /* Those are not set ************* + if (Section->u.Flags.Commit) + Sbi.Attributes |= SEC_COMMIT; + if (Section->u.Flags.Reserve) + Sbi.Attributes |= SEC_RESERVE; + **********************************/ if (Section->u.Flags.Image) { @@ -4005,8 +4007,9 @@ MmMapViewOfSection(IN PVOID SectionObject, { (*ViewSize) = Section->SizeOfSection.QuadPart - ViewOffset; } - else if (((*ViewSize)+ViewOffset) > Section->SizeOfSection.QuadPart) + else if ((ExGetPreviousMode() == UserMode) && (((*ViewSize)+ViewOffset) > Section->SizeOfSection.QuadPart)) { + /* Dubious */ (*ViewSize) = MIN(Section->SizeOfSection.QuadPart - ViewOffset, SIZE_T_MAX - PAGE_SIZE); } @@ -4329,8 +4332,16 @@ MmCreateSection (OUT PVOID * Section, return STATUS_INVALID_PARAMETER_6; } - /* Did the caller pass a handle? */ - if (FileHandle) + /* Did the caller pass a file object ? */ + if (FileObject) + { + /* Reference the object directly */ + ObReferenceObject(FileObject); + + /* We don't create image mappings with file objects */ + AllocationAttributes &= ~SEC_IMAGE; + } + else { /* Reference the file handle to get the object */ Status = ObReferenceObjectByHandle(FileHandle, @@ -4368,11 +4379,6 @@ MmCreateSection (OUT PVOID * Section, DPRINT1("Creating image map with writers open on the file!\n"); #endif } - else - { - /* Reference the object directly */ - ObReferenceObject(FileObject); - } } else {
3 years, 10 months
1
0
0
0
[reactos] 56/100: Disable CcScheduleReadAhead call
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=91f6fa0259cc2a98371b8…
commit 91f6fa0259cc2a98371b8644310d47d7fdf79e12 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Dec 18 16:19:45 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:22 2021 +0100 Disable CcScheduleReadAhead call --- ntoskrnl/cc/copy.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ntoskrnl/cc/copy.c b/ntoskrnl/cc/copy.c index 3dd172fa9db..502dfb03ee8 100644 --- a/ntoskrnl/cc/copy.c +++ b/ntoskrnl/cc/copy.c @@ -556,6 +556,7 @@ CcCopyRead ( IoStatus->Status = STATUS_SUCCESS; IoStatus->Information = ReadLength; +#if 0 /* If that was a successful sync read operation, let's handle read ahead */ if (Length == 0 && Wait) { @@ -576,6 +577,7 @@ CcCopyRead ( PrivateCacheMap->FileOffset2.QuadPart = FileOffset->QuadPart; PrivateCacheMap->BeyondLastByte2.QuadPart = FileOffset->QuadPart + ReadLength; } +#endif return TRUE; }
3 years, 10 months
1
0
0
0
[reactos] 55/100: [NTOS:CC] Fix some tests, complain where the current implementation won't let us do the right thing
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6d97d8d2e15d9db634a21…
commit 6d97d8d2e15d9db634a2188d0f17983d74ea156c Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Dec 18 15:24:09 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS:CC] Fix some tests, complain where the current implementation won't let us do the right thing --- ntoskrnl/cc/pin.c | 9 ++++++++- ntoskrnl/cc/view.c | 6 ------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ntoskrnl/cc/pin.c b/ntoskrnl/cc/pin.c index 0d5642b9932..597468f6fd7 100644 --- a/ntoskrnl/cc/pin.c +++ b/ntoskrnl/cc/pin.c @@ -225,9 +225,13 @@ CcpPinData( BOOLEAN Result; VacbOffset = (ULONG)(FileOffset->QuadPart % VACB_MAPPING_GRANULARITY); - /* This seems to be valid, according to KMTests */ + if ((VacbOffset + Length) > VACB_MAPPING_GRANULARITY) + { + /* Complain loudly, we shoud pin the whole range */ + DPRINT1("TRUNCATING DATA PIN FROM %lu to %lu!\n", Length, VACB_MAPPING_GRANULARITY - VacbOffset); Length = VACB_MAPPING_GRANULARITY - VacbOffset; + } KeAcquireSpinLock(&SharedCacheMap->BcbSpinLock, &OldIrql); NewBcb = CcpFindBcb(SharedCacheMap, FileOffset, Length, TRUE); @@ -353,7 +357,10 @@ CcMapData ( VacbOffset = (ULONG)(FileOffset->QuadPart % VACB_MAPPING_GRANULARITY); /* KMTests seem to show that it is allowed to call accross mapping granularity */ if ((VacbOffset + Length) > VACB_MAPPING_GRANULARITY) + { + DPRINT1("TRUNCATING DATA MAP FROM %lu to %lu!\n", Length, VACB_MAPPING_GRANULARITY - VacbOffset); Length = VACB_MAPPING_GRANULARITY - VacbOffset; + } KeAcquireSpinLock(&SharedCacheMap->BcbSpinLock, &OldIrql); iBcb = CcpFindBcb(SharedCacheMap, FileOffset, Length, FALSE); diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c index ae6464f2b58..3952986dc44 100644 --- a/ntoskrnl/cc/view.c +++ b/ntoskrnl/cc/view.c @@ -572,12 +572,6 @@ CcRosCreateVacb ( DPRINT("CcRosCreateVacb()\n"); - if (FileOffset >= SharedCacheMap->SectionSize.QuadPart) - { - *Vacb = NULL; - return STATUS_INVALID_PARAMETER; - } - current = ExAllocateFromNPagedLookasideList(&VacbLookasideList); current->BaseAddress = NULL; current->Valid = FALSE;
3 years, 10 months
1
0
0
0
[reactos] 54/100: [NTOS:MM] Remove a check for now
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=674ab3dce3da08ca41b96…
commit 674ab3dce3da08ca41b9685cbec5bb3d48fdcece Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Thu Dec 17 18:09:56 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS:MM] Remove a check for now --- ntoskrnl/mm/section.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index c20c506c2b8..b709a50cd8d 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -4356,12 +4356,17 @@ MmCreateSection (OUT PVOID * Section, FileLock = TRUE; /* Deny access if there are writes on the file */ +#if 0 if ((AllocationAttributes & SEC_IMAGE) && (Status == STATUS_FILE_LOCKED_WITH_WRITERS)) { DPRINT1("Cannot create image maps with writers open on the file!\n"); Status = STATUS_ACCESS_DENIED; goto Quit; } +#else + if ((AllocationAttributes & SEC_IMAGE) && (Status == STATUS_FILE_LOCKED_WITH_WRITERS)) + DPRINT1("Creating image map with writers open on the file!\n"); +#endif } else { @@ -4415,7 +4420,6 @@ MmCreateSection (OUT PVOID * Section, Status = STATUS_INVALID_PARAMETER; } -Quit: if (FileLock) FsRtlReleaseFile(FileObject); if (FileObject)
3 years, 10 months
1
0
0
0
[reactos] 53/100: [NTOS:MM] Do not reference the section when mapping it.
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1f796267bc885ad0b8154…
commit 1f796267bc885ad0b8154352bf714477ea2a0b58 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Mon Dec 14 15:55:08 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS:MM] Do not reference the section when mapping it. Referencing the segment is enough. --- ntoskrnl/include/internal/mm.h | 2 +- ntoskrnl/mm/section.c | 51 ++++++++++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index 55e9fcfc29c..05f89c50cb9 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -202,6 +202,7 @@ typedef struct _MM_IMAGE_SECTION_OBJECT PMM_SECTION_SEGMENT Segments; } MM_IMAGE_SECTION_OBJECT, *PMM_IMAGE_SECTION_OBJECT; +#define MM_PHYSICALMEMORY_SEGMENT (0x1) #define MM_DATAFILE_SEGMENT (0x2) #define MM_SEGMENT_INDELETE (0x4) #define MM_SEGMENT_INCREATE (0x8) @@ -222,7 +223,6 @@ typedef struct _MEMORY_AREA struct { - PSECTION Section; LARGE_INTEGER ViewOffset; PMM_SECTION_SEGMENT Segment; LIST_ENTRY RegionListHead; diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index a3efe4f0b6b..c20c506c2b8 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -83,6 +83,14 @@ _MmUnlockSectionSegment(PMM_SECTION_SEGMENT Segment, const char *file, int line) } #endif +/* Somewhat grotesque, but eh... */ +PMM_IMAGE_SECTION_OBJECT ImageSectionObjectFromSegment(PMM_SECTION_SEGMENT Segment) +{ + ASSERT((Segment->SegFlags & MM_DATAFILE_SEGMENT) == 0); + + return CONTAINING_RECORD(Segment->ReferenceCount, MM_IMAGE_SECTION_OBJECT, RefCount); +} + NTSTATUS NTAPI MiMapViewInSystemSpace(IN PVOID Section, @@ -1209,15 +1217,18 @@ MiReadPage(PMEMORY_AREA MemoryArea, if (Status == STATUS_END_OF_FILE) { + DPRINT1("Got STATUS_END_OF_FILE at offset %I64d for file %wZ.\n", SegOffset, &FileObject->FileName); Status = STATUS_SUCCESS; } - if (!MemoryArea->SectionData.Section->u.Flags.Reserve + if ((MemoryArea->VadNode.u.VadFlags.VadType == VadImageMap) && ((SegOffset + PAGE_SIZE) > MemoryArea->SectionData.Segment->RawLength.QuadPart)) { KIRQL OldIrql; PUCHAR PageMap; + DPRINT("Zeroing at offset %I64d for file %wZ.\n", SegOffset, &FileObject->FileName); + /* Zero out the end of it */ PageMap = MiMapPageInHyperSpace(PsGetCurrentProcess(), *Page, &OldIrql); RtlZeroMemory(PageMap + MemoryArea->SectionData.Segment->RawLength.QuadPart - SegOffset, @@ -1352,7 +1363,6 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace, LARGE_INTEGER Offset; PFN_NUMBER Page; NTSTATUS Status; - PSECTION Section; PMM_SECTION_SEGMENT Segment; ULONG_PTR Entry; ULONG_PTR Entry1; @@ -1391,7 +1401,6 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace, + MemoryArea->SectionData.ViewOffset.QuadPart; Segment = MemoryArea->SectionData.Segment; - Section = MemoryArea->SectionData.Section; Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea), &MemoryArea->SectionData.RegionListHead, Address, NULL); @@ -1537,7 +1546,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace, /* * Satisfying a page fault on a map of /Device/PhysicalMemory is easy */ - if (Section->u.Flags.PhysicalMemory) + if ((*Segment->Flags) & MM_PHYSICALMEMORY_SEGMENT) { MmUnlockSectionSegment(Segment); /* @@ -1600,6 +1609,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace, } else { + DPRINT("Getting fresh page for file %wZ at offset %I64d.\n", &Segment->FileObject->FileName, Offset.QuadPart); Status = MiReadPage(MemoryArea, Offset.QuadPart, &Page); if (!NT_SUCCESS(Status)) { @@ -2111,7 +2121,7 @@ MmCreatePhysicalMemorySection(VOID) Segment->Protection = PAGE_EXECUTE_READWRITE; Segment->RawLength = SectionSize; Segment->Length = SectionSize; - Segment->SegFlags = 0; + Segment->SegFlags = MM_PHYSICALMEMORY_SEGMENT; Segment->WriteCopy = FALSE; Segment->Image.VirtualAddress = 0; Segment->Image.Characteristics = 0; @@ -2230,7 +2240,6 @@ MmCreateDataFileSection(PSECTION *SectionObject, if (!NT_SUCCESS(Status)) { ObDereferenceObject(Section); - ObDereferenceObject(FileObject); return Status; } @@ -3283,10 +3292,9 @@ MmMapViewOfSegment(PMMSUPPORT AddressSpace, return(Status); } - ObReferenceObject((PVOID)Section); + InterlockedIncrementUL(Segment->ReferenceCount); MArea->SectionData.Segment = Segment; - MArea->SectionData.Section = Section; MArea->SectionData.ViewOffset.QuadPart = ViewOffset; if (Section->u.Flags.Image) { @@ -3390,7 +3398,6 @@ MmUnmapViewOfSegment(PMMSUPPORT AddressSpace, { NTSTATUS Status; PMEMORY_AREA MemoryArea; - PSECTION Section; PMM_SECTION_SEGMENT Segment; PLIST_ENTRY CurrentEntry; PMM_REGION CurrentRegion; @@ -3403,7 +3410,6 @@ MmUnmapViewOfSegment(PMMSUPPORT AddressSpace, return(STATUS_UNSUCCESSFUL); } - Section = MemoryArea->SectionData.Section; Segment = MemoryArea->SectionData.Segment; #ifdef NEWCC @@ -3429,7 +3435,7 @@ MmUnmapViewOfSegment(PMMSUPPORT AddressSpace, ExFreePoolWithTag(CurrentRegion, TAG_MM_REGION); } - if (Section->u.Flags.PhysicalMemory) + if ((*Segment->Flags) & MM_PHYSICALMEMORY_SEGMENT) { Status = MmFreeMemoryArea(AddressSpace, MemoryArea, @@ -3444,7 +3450,7 @@ MmUnmapViewOfSegment(PMMSUPPORT AddressSpace, AddressSpace); } MmUnlockSectionSegment(Segment); - ObDereferenceObject(Section); + MmDereferenceSegment(Segment); return(Status); } @@ -3457,7 +3463,6 @@ MiRosUnmapViewOfSection(IN PEPROCESS Process, NTSTATUS Status; PMEMORY_AREA MemoryArea; PMMSUPPORT AddressSpace; - PSECTION Section; PVOID ImageBaseAddress = 0; DPRINT("Opening memory area Process %p BaseAddress %p\n", @@ -3484,9 +3489,7 @@ MiRosUnmapViewOfSection(IN PEPROCESS Process, return STATUS_NOT_MAPPED_VIEW; } - Section = MemoryArea->SectionData.Section; - - if ((Section != NULL) && Section->u.Flags.Image) + if (MemoryArea->VadNode.u.VadFlags.VadType == VadImageMap) { ULONG i; ULONG NrSegments; @@ -3495,7 +3498,7 @@ MiRosUnmapViewOfSection(IN PEPROCESS Process, PMM_SECTION_SEGMENT Segment; Segment = MemoryArea->SectionData.Segment; - ImageSectionObject = ((PMM_IMAGE_SECTION_OBJECT)Section->Segment); + ImageSectionObject = ImageSectionObjectFromSegment(Segment); SectionSegments = ImageSectionObject->Segments; NrSegments = ImageSectionObject->NrSegments; @@ -3937,6 +3940,15 @@ MmMapViewOfSection(IN PVOID SectionObject, MmUnlockSectionSegment(&SectionSegments[i]); if (!NT_SUCCESS(Status)) { + /* roll-back */ + while (i--) + { + SBaseAddress = ((char*)ImageBase + (ULONG_PTR)SectionSegments[i].Image.VirtualAddress); + MmLockSectionSegment(&SectionSegments[i]); + MmUnmapViewOfSegment(AddressSpace, SBaseAddress); + MmUnlockSectionSegment(&SectionSegments[i]); + } + MmUnlockAddressSpace(AddressSpace); return(Status); } @@ -4018,7 +4030,6 @@ MmMapViewOfSection(IN PVOID SectionObject, } MmUnlockAddressSpace(AddressSpace); - ASSERT(*BaseAddress == ALIGN_DOWN_POINTER_BY(*BaseAddress, MM_VIRTMEM_GRANULARITY)); if (NotAtBase) Status = STATUS_IMAGE_NOT_AT_BASE; @@ -4074,7 +4085,7 @@ CheckSectionPointer: else { /* We can't shrink, but we can extend */ - Ret = NewFileSize->QuadPart > Segment->RawLength.QuadPart; + Ret = NewFileSize->QuadPart >= Segment->RawLength.QuadPart; } } else @@ -4679,6 +4690,8 @@ MmCheckDirtySegment( IoSetTopLevelIrp((PIRP)FSRTL_MOD_WRITE_TOP_LEVEL_IRP); /* Go ahead and write the page */ + DPRINT("Writing page at offset %I64d for file %wZ, Pageout: %s\n", + Offset->QuadPart, &Segment->FileObject->FileName, PageOut ? "TRUE" : "FALSE"); Status = MiWritePage(Segment, Offset->QuadPart, Page); if (PageOut)
3 years, 10 months
1
0
0
0
[reactos] 52/100: [NTOS:MM] Save the dirty bit when sharing a segment page
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3c2b1bf59b0771a92f7d2…
commit 3c2b1bf59b0771a92f7d2aa8c96cad1dd58dc31d Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Mon Dec 14 15:48:27 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS:MM] Save the dirty bit when sharing a segment page --- ntoskrnl/mm/section.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 8acc368a884..a3efe4f0b6b 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -1020,6 +1020,7 @@ MmSharePageEntrySectionSegment(PMM_SECTION_SEGMENT Segment, PLARGE_INTEGER Offset) { ULONG_PTR Entry; + BOOLEAN Dirty; Entry = MmGetPageEntrySectionSegment(Segment, Offset); if (Entry == 0) @@ -1036,7 +1037,10 @@ MmSharePageEntrySectionSegment(PMM_SECTION_SEGMENT Segment, { KeBugCheck(MEMORY_MANAGEMENT); } + Dirty = IS_DIRTY_SSE(Entry); Entry = MAKE_SSE(PAGE_FROM_SSE(Entry), SHARE_COUNT_FROM_SSE(Entry) + 1); + if (Dirty) + Entry = DIRTY_SSE(Entry); MmSetPageEntrySectionSegment(Segment, Offset, Entry); }
3 years, 10 months
1
0
0
0
[reactos] 51/100: [NTOS:MM] Various fixes.
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3141668724e37d0dac6ce…
commit 3141668724e37d0dac6cee831db1fe4eda6bf84f Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Dec 11 18:53:32 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS:MM] Various fixes. Fix MmFlushImageSection behaviour Remove an invalid ASSERT --- ntoskrnl/mm/section.c | 48 ++++++++++++++---------------------------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 8e9669d9ab9..8acc368a884 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -4093,46 +4093,26 @@ CheckSectionPointer: */ BOOLEAN NTAPI MmFlushImageSection (IN PSECTION_OBJECT_POINTERS SectionObjectPointer, - IN MMFLUSH_TYPE FlushType) + IN MMFLUSH_TYPE FlushType) { - BOOLEAN Result = TRUE; -#ifdef NEWCC - PMM_SECTION_SEGMENT Segment; -#endif - switch(FlushType) { - case MmFlushForDelete: - if (SectionObjectPointer->ImageSectionObject || - SectionObjectPointer->DataSectionObject) + case MmFlushForDelete: + case MmFlushForWrite: { - return FALSE; - } -#ifndef NEWCC - CcRosRemoveIfClosed(SectionObjectPointer); -#endif - return TRUE; - case MmFlushForWrite: - { - DPRINT("MmFlushImageSection(%d)\n", FlushType); -#ifdef NEWCC - Segment = (PMM_SECTION_SEGMENT)SectionObjectPointer->DataSectionObject; -#endif + BOOLEAN Ret = TRUE; + KIRQL OldIrql = MiAcquirePfnLock(); - if (SectionObjectPointer->ImageSectionObject) - { - DPRINT1("SectionObject has ImageSection\n"); - return FALSE; - } + if (SectionObjectPointer->ImageSectionObject) + { + PMM_IMAGE_SECTION_OBJECT ImageSectionObject = SectionObjectPointer->ImageSectionObject; + if (!(ImageSectionObject->SegFlags & MM_SEGMENT_INDELETE)) + Ret = FALSE; + } -#ifdef NEWCC - CcpLock(); - Result = !SectionObjectPointer->SharedCacheMap || (Segment->ReferenceCount == CcpCountCacheSections((PNOCC_CACHE_MAP)SectionObjectPointer->SharedCacheMap)); - CcpUnlock(); - DPRINT("Result %d\n", Result); -#endif - return Result; - } + MiReleasePfnLock(OldIrql); + return Ret; + } } return FALSE; }
3 years, 10 months
1
0
0
0
[reactos] 50/100: [NTOS] Zero data unconditionally after segment end, unless section is created with SEC_RESERVE
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=30f71c7fc0f6404cb2988…
commit 30f71c7fc0f6404cb298841a9d2123eaca1877be Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Dec 11 15:29:35 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS] Zero data unconditionally after segment end, unless section is created with SEC_RESERVE Use a SEC_RESERVE section in Cc --- ntoskrnl/cc/view.c | 2 +- ntoskrnl/mm/section.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c index ee0ec497d40..ae6464f2b58 100644 --- a/ntoskrnl/cc/view.c +++ b/ntoskrnl/cc/view.c @@ -1286,7 +1286,7 @@ CcRosInitializeFileCache ( NULL, &SharedCacheMap->SectionSize, PAGE_READWRITE, - 0, + SEC_RESERVE, NULL, FileObject); diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index d71bc490934..8e9669d9ab9 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -1208,7 +1208,8 @@ MiReadPage(PMEMORY_AREA MemoryArea, Status = STATUS_SUCCESS; } - if ((MemoryArea->VadNode.u.VadFlags.VadType == VadImageMap) && ((SegOffset + PAGE_SIZE) > MemoryArea->SectionData.Segment->RawLength.QuadPart)) + if (!MemoryArea->SectionData.Section->u.Flags.Reserve + && ((SegOffset + PAGE_SIZE) > MemoryArea->SectionData.Segment->RawLength.QuadPart)) { KIRQL OldIrql; PUCHAR PageMap; @@ -2209,6 +2210,8 @@ MmCreateDataFileSection(PSECTION *SectionObject, if (AllocationAttributes & SEC_NO_CHANGE) Section->u.Flags.NoChange = 1; + if (AllocationAttributes & SEC_RESERVE) + Section->u.Flags.Reserve = 1; if (!GotFileHandle) { @@ -4832,13 +4835,16 @@ MmExtendSection( PMM_SECTION_SEGMENT Segment = (PMM_SECTION_SEGMENT)Section->Segment; Section->SizeOfSection = *NewSize; - MmLockSectionSegment(Segment); - if (Segment->RawLength.QuadPart < NewSize->QuadPart) + if (!Section->u.Flags.Reserve) { - Segment->RawLength = *NewSize; - Segment->Length.QuadPart = (NewSize->QuadPart + PAGE_SIZE - 1) & ~((LONGLONG)PAGE_SIZE); + MmLockSectionSegment(Segment); + if (Segment->RawLength.QuadPart < NewSize->QuadPart) + { + Segment->RawLength = *NewSize; + Segment->Length.QuadPart = (NewSize->QuadPart + PAGE_SIZE - 1) & ~((LONGLONG)PAGE_SIZE); + } + MmUnlockSectionSegment(Segment); } - MmUnlockSectionSegment(Segment); } return STATUS_SUCCESS;
3 years, 10 months
1
0
0
0
[reactos] 49/100: [NTOS:CC] Restore read-ahead behaviour in CcCopyRead
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a52bc6d1799385726097e…
commit a52bc6d1799385726097ecf701f833b7a327a08e Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Dec 11 14:31:08 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS:CC] Restore read-ahead behaviour in CcCopyRead --- ntoskrnl/cc/copy.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ntoskrnl/cc/copy.c b/ntoskrnl/cc/copy.c index 315e9f1f1b0..3dd172fa9db 100644 --- a/ntoskrnl/cc/copy.c +++ b/ntoskrnl/cc/copy.c @@ -556,6 +556,27 @@ CcCopyRead ( IoStatus->Status = STATUS_SUCCESS; IoStatus->Information = ReadLength; + /* If that was a successful sync read operation, let's handle read ahead */ + if (Length == 0 && Wait) + { + PPRIVATE_CACHE_MAP PrivateCacheMap = FileObject->PrivateCacheMap; + + /* If file isn't random access and next read may get us cross VACB boundary, + * schedule next read + */ + if (!BooleanFlagOn(FileObject->Flags, FO_RANDOM_ACCESS) && + (CurrentOffset - 1) / VACB_MAPPING_GRANULARITY != (CurrentOffset + ReadLength - 1) / VACB_MAPPING_GRANULARITY) + { + CcScheduleReadAhead(FileObject, FileOffset, ReadLength); + } + + /* And update read history in private cache map */ + PrivateCacheMap->FileOffset1.QuadPart = PrivateCacheMap->FileOffset2.QuadPart; + PrivateCacheMap->BeyondLastByte1.QuadPart = PrivateCacheMap->BeyondLastByte2.QuadPart; + PrivateCacheMap->FileOffset2.QuadPart = FileOffset->QuadPart; + PrivateCacheMap->BeyondLastByte2.QuadPart = FileOffset->QuadPart + ReadLength; + } + return TRUE; }
3 years, 10 months
1
0
0
0
[reactos] 48/100: [NTOS:CC] Fix some tests for CcCopyRead and CcCopyWrite
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4441b1cd44bbf0f16b493…
commit 4441b1cd44bbf0f16b49383759bf50a35828da6a Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Tue Dec 8 10:28:52 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS:CC] Fix some tests for CcCopyRead and CcCopyWrite Most importantly: raise the right status when provided an invalid buffer. --- ntoskrnl/cc/copy.c | 51 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/ntoskrnl/cc/copy.c b/ntoskrnl/cc/copy.c index 357e98162e6..315e9f1f1b0 100644 --- a/ntoskrnl/cc/copy.c +++ b/ntoskrnl/cc/copy.c @@ -447,6 +447,26 @@ CcCanIWrite ( return TRUE; } +static +int +CcpCheckInvalidUserBuffer(PEXCEPTION_POINTERS Except, PVOID Buffer, ULONG Length) +{ + ULONG_PTR ExceptionAddress; + ULONG_PTR BeginAddress = (ULONG_PTR)Buffer; + ULONG_PTR EndAddress = (ULONG_PTR)Buffer + Length; + + if (Except->ExceptionRecord->ExceptionCode != STATUS_ACCESS_VIOLATION) + return EXCEPTION_CONTINUE_SEARCH; + if (Except->ExceptionRecord->NumberParameters < 2) + return EXCEPTION_CONTINUE_SEARCH; + + ExceptionAddress = Except->ExceptionRecord->ExceptionInformation[1]; + if ((ExceptionAddress >= BeginAddress) && (ExceptionAddress < EndAddress)) + return EXCEPTION_EXECUTE_HANDLER; + + return EXCEPTION_CONTINUE_SEARCH; +} + /* * @implemented */ @@ -465,6 +485,7 @@ CcCopyRead ( NTSTATUS Status; LONGLONG CurrentOffset; LONGLONG ReadEnd = FileOffset->QuadPart + Length; + ULONG ReadLength = 0; CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%I64d Length=%lu Wait=%d\n", FileObject, FileOffset->QuadPart, Length, Wait); @@ -480,9 +501,6 @@ CcCopyRead ( /* Documented to ASSERT, but KMTests test this case... */ // ASSERT((FileOffset->QuadPart + Length) <= SharedCacheMap->FileSize.QuadPart); - IoStatus->Status = STATUS_SUCCESS; - IoStatus->Information = 0; - CurrentOffset = FileOffset->QuadPart; while(CurrentOffset < ReadEnd) { @@ -506,13 +524,23 @@ CcCopyRead ( if (CurrentOffset + VacbLength > SharedCacheMap->SectionSize.QuadPart) CopyLength = SharedCacheMap->SectionSize.QuadPart - CurrentOffset; if (CopyLength != 0) - RtlCopyMemory(Buffer, (PUCHAR)Vacb->BaseAddress + VacbOffset, CopyLength); + { + _SEH2_TRY + { + RtlCopyMemory(Buffer, (PUCHAR)Vacb->BaseAddress + VacbOffset, CopyLength); + } + _SEH2_EXCEPT(CcpCheckInvalidUserBuffer(_SEH2_GetExceptionInformation(), Buffer, VacbLength)) + { + ExRaiseStatus(STATUS_INVALID_USER_BUFFER); + } + _SEH2_END; + } /* Zero-out the buffer tail if needed */ if (CopyLength < VacbLength) RtlZeroMemory((PUCHAR)Buffer + CopyLength, VacbLength - CopyLength); - IoStatus->Information += VacbLength; + ReadLength += VacbLength; Buffer = (PVOID)((ULONG_PTR)Buffer + VacbLength); CurrentOffset += VacbLength; @@ -525,6 +553,9 @@ CcCopyRead ( _SEH2_END; } + IoStatus->Status = STATUS_SUCCESS; + IoStatus->Information = ReadLength; + return TRUE; } @@ -578,7 +609,15 @@ CcCopyWrite ( return FALSE; } - RtlCopyMemory((PVOID)((ULONG_PTR)Vacb->BaseAddress + VacbOffset), Buffer, VacbLength); + _SEH2_TRY + { + RtlCopyMemory((PVOID)((ULONG_PTR)Vacb->BaseAddress + VacbOffset), Buffer, VacbLength); + } + _SEH2_EXCEPT(CcpCheckInvalidUserBuffer(_SEH2_GetExceptionInformation(), Buffer, VacbLength)) + { + ExRaiseStatus(STATUS_INVALID_USER_BUFFER); + } + _SEH2_END; Buffer = (PVOID)((ULONG_PTR)Buffer + VacbLength); CurrentOffset += VacbLength;
3 years, 10 months
1
0
0
0
← Newer
1
...
33
34
35
36
37
38
39
...
44
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Results per page:
10
25
50
100
200