Skip to content

Commit afbadf5

Browse files
authored
[NTOS:MM][KMTESTS] MmMapViewOfSection: Handle PAGE_NOCACHE and PAGE_WRITECOMBINE flags (reactos#8502)
- Remove the hack for PAGE_NOCACHE flag that was introduced in commits aa52dc7 (r68611) and 33d53d4 (r68612) for CORE-9808. The test case for PAGE_NOCACHE, introduced in 7346aec (r68351), did not expose any additional problems without it anymore. - Allow a PAGE_WRITECOMBINE flag. Fixes a regression introduced in 59ae6b3 (CORE-20298) that caused the OpenGL ICD in Nvidia 78.05 driver to not use GPU hardware to accelerate OpenGL anymore (reported and tested by winterhell on Discord). - Add a test case for MmMapViewOfSection with PAGE_WRITECOMBINE. The test passes on Windows 2003 SP2 and Vista RTM. - Fix ASSERTs in MI_MAKE_HARDWARE_PTE functions.
1 parent c6c3855 commit afbadf5

4 files changed

Lines changed: 33 additions & 7 deletions

File tree

modules/rostests/kmtests/ntos_mm/MmSection.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,31 @@ TestPhysicalMemorySection(VOID)
646646
ok_eq_hex(Status, STATUS_SUCCESS);
647647
}
648648

649+
/* Map the zero page with write combining */
650+
Mapping = NULL;
651+
ViewSize = PAGE_SIZE;
652+
Status = ZwMapViewOfSection(SectionHandle,
653+
ZwCurrentProcess(),
654+
&Mapping,
655+
0,
656+
0,
657+
&ZeroPagePhysical,
658+
&ViewSize,
659+
ViewUnmap,
660+
0,
661+
PAGE_READWRITE | PAGE_WRITECOMBINE);
662+
ok_eq_hex(Status, STATUS_SUCCESS);
663+
if (!skip(NT_SUCCESS(Status), "No view\n"))
664+
{
665+
ok((LONG_PTR)Mapping > 0, "Mapping = %p\n", Mapping);
666+
EqualBytes = RtlCompareMemory(Mapping,
667+
ZeroPageContents,
668+
PAGE_SIZE);
669+
ok_eq_size(EqualBytes, PAGE_SIZE);
670+
Status = ZwUnmapViewOfSection(ZwCurrentProcess(), Mapping);
671+
ok_eq_hex(Status, STATUS_SUCCESS);
672+
}
673+
649674
/* Map our NP page, compare, and check that modifications are reflected */
650675
Mapping = NULL;
651676
ViewSize = PAGE_SIZE;

ntoskrnl/include/internal/mm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ typedef ULONG_PTR SWAPENTRY;
145145
PAGE_EXECUTE_READWRITE | \
146146
PAGE_EXECUTE_WRITECOPY | \
147147
PAGE_NOACCESS | \
148-
PAGE_NOCACHE)
148+
PAGE_NOCACHE | \
149+
PAGE_WRITECOMBINE)
149150

150151
#define PAGE_IS_READABLE \
151152
(PAGE_READONLY | \

ntoskrnl/mm/ARM3/miarm.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,8 @@ MI_MAKE_HARDWARE_PTE_KERNEL(IN PMMPTE NewPte,
786786

787787
/* Check that we are not setting valid a page that should not be */
788788
ASSERT(ProtectionMask & MM_PROTECT_ACCESS);
789-
ASSERT((ProtectionMask & MM_GUARDPAGE) == 0);
789+
ASSERT((ProtectionMask & MM_PROTECT_SPECIAL) != MM_GUARDPAGE);
790+
ASSERT(ProtectionMask != MM_OUTSWAPPED_KSTACK && ((ProtectionMask & ~MM_OUTSWAPPED_KSTACK) == 0));
790791

791792
/* Start fresh */
792793
NewPte->u.Long = 0;
@@ -815,7 +816,8 @@ MI_MAKE_HARDWARE_PTE(IN PMMPTE NewPte,
815816
{
816817
/* Check that we are not setting valid a page that should not be */
817818
ASSERT(ProtectionMask & MM_PROTECT_ACCESS);
818-
ASSERT((ProtectionMask & MM_GUARDPAGE) == 0);
819+
ASSERT((ProtectionMask & MM_PROTECT_SPECIAL) != MM_GUARDPAGE);
820+
ASSERT(ProtectionMask != MM_OUTSWAPPED_KSTACK && ((ProtectionMask & ~MM_OUTSWAPPED_KSTACK) == 0));
819821

820822
/* Set the protection and page */
821823
NewPte->u.Long = MiDetermineUserGlobalPteMask(MappingPte);
@@ -841,7 +843,8 @@ MI_MAKE_HARDWARE_PTE_USER(IN PMMPTE NewPte,
841843

842844
/* Check that we are not setting valid a page that should not be */
843845
ASSERT(ProtectionMask & MM_PROTECT_ACCESS);
844-
ASSERT((ProtectionMask & MM_GUARDPAGE) == 0);
846+
ASSERT((ProtectionMask & MM_PROTECT_SPECIAL) != MM_GUARDPAGE);
847+
ASSERT(ProtectionMask != MM_OUTSWAPPED_KSTACK && ((ProtectionMask & ~MM_OUTSWAPPED_KSTACK) == 0));
845848

846849
NewPte->u.Hard.Valid = TRUE;
847850
NewPte->u.Hard.Owner = TRUE;

ntoskrnl/mm/section.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4070,9 +4070,6 @@ MmMapViewOfSection(IN PVOID SectionObject,
40704070
IsAttached = TRUE;
40714071
}
40724072

4073-
/* FIXME: We should keep this, but it would break code checking equality */
4074-
Protect &= ~PAGE_NOCACHE;
4075-
40764073
Section = SectionObject;
40774074
AddressSpace = &Process->Vm;
40784075

0 commit comments

Comments
 (0)