mirror of
https://github.com/reactos/reactos.git
synced 2024-08-01 09:01:13 +00:00
[NTOS/MM]
- Fix ZeroBits check in NtMapViewOfSection - Implement handling MEM_DOS_LIM AllocationType This fixes all but a few NtMapViewOfSection (due to some temp file not being removed) wine tests + tests from 72468 svn path=/trunk/; revision=72469
This commit is contained in:
parent
9726a48493
commit
2215ccef67
|
@ -1269,20 +1269,25 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea,
|
||||||
ULONG QuotaCharge = 0, QuotaExcess = 0;
|
ULONG QuotaCharge = 0, QuotaExcess = 0;
|
||||||
PMMPTE PointerPte, LastPte;
|
PMMPTE PointerPte, LastPte;
|
||||||
MMPTE TempPte;
|
MMPTE TempPte;
|
||||||
|
ULONG Granularity = MM_VIRTMEM_GRANULARITY;
|
||||||
|
|
||||||
DPRINT("Mapping ARM3 data section\n");
|
DPRINT("Mapping ARM3 data section\n");
|
||||||
|
|
||||||
/* Get the segment for this section */
|
/* Get the segment for this section */
|
||||||
Segment = ControlArea->Segment;
|
Segment = ControlArea->Segment;
|
||||||
|
|
||||||
|
#ifdef _M_IX86
|
||||||
|
/* ALlow being less restrictive on x86. */
|
||||||
|
if (AllocationType & MEM_DOS_LIM)
|
||||||
|
Granularity = PAGE_SIZE;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* One can only reserve a file-based mapping, not shared memory! */
|
/* One can only reserve a file-based mapping, not shared memory! */
|
||||||
if ((AllocationType & MEM_RESERVE) && !(ControlArea->FilePointer))
|
if ((AllocationType & MEM_RESERVE) && !(ControlArea->FilePointer))
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_PARAMETER_9;
|
return STATUS_INVALID_PARAMETER_9;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This flag determines alignment, but ARM3 does not yet support it */
|
|
||||||
ASSERT((AllocationType & MEM_DOS_LIM) == 0);
|
|
||||||
|
|
||||||
/* First, increase the map count. No purging is supported yet */
|
/* First, increase the map count. No purging is supported yet */
|
||||||
Status = MiCheckPurgeAndUpMapCount(ControlArea, FALSE);
|
Status = MiCheckPurgeAndUpMapCount(ControlArea, FALSE);
|
||||||
if (!NT_SUCCESS(Status)) return Status;
|
if (!NT_SUCCESS(Status)) return Status;
|
||||||
|
@ -1432,7 +1437,7 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea,
|
||||||
if (*BaseAddress != NULL)
|
if (*BaseAddress != NULL)
|
||||||
{
|
{
|
||||||
/* Just align what the caller gave us */
|
/* Just align what the caller gave us */
|
||||||
StartAddress = ROUND_UP((ULONG_PTR)*BaseAddress, _64K);
|
StartAddress = ALIGN_DOWN_BY((ULONG_PTR)*BaseAddress, Granularity);
|
||||||
}
|
}
|
||||||
else if (Section->Address.StartingVpn != 0)
|
else if (Section->Address.StartingVpn != 0)
|
||||||
{
|
{
|
||||||
|
@ -1449,7 +1454,7 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea,
|
||||||
&StartAddress,
|
&StartAddress,
|
||||||
ViewSizeInPages * PAGE_SIZE,
|
ViewSizeInPages * PAGE_SIZE,
|
||||||
MAXULONG_PTR >> ZeroBits,
|
MAXULONG_PTR >> ZeroBits,
|
||||||
MM_VIRTMEM_GRANULARITY,
|
Granularity,
|
||||||
AllocationType);
|
AllocationType);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
@ -3447,13 +3452,13 @@ NtMapViewOfSection(IN HANDLE SectionHandle,
|
||||||
ACCESS_MASK DesiredAccess;
|
ACCESS_MASK DesiredAccess;
|
||||||
ULONG ProtectionMask;
|
ULONG ProtectionMask;
|
||||||
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
|
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
|
||||||
|
#ifdef _M_IX86
|
||||||
/* Check for invalid zero bits */
|
static const ULONG ValidAllocationType = (MEM_TOP_DOWN | MEM_LARGE_PAGES |
|
||||||
if (ZeroBits > 21) // per-arch?
|
MEM_DOS_LIM | SEC_NO_CHANGE | MEM_RESERVE);
|
||||||
{
|
#else
|
||||||
DPRINT1("Invalid zero bits\n");
|
static const ULONG ValidAllocationType = (MEM_TOP_DOWN | MEM_LARGE_PAGES |
|
||||||
return STATUS_INVALID_PARAMETER_4;
|
SEC_NO_CHANGE | MEM_RESERVE);
|
||||||
}
|
#endif
|
||||||
|
|
||||||
/* Check for invalid inherit disposition */
|
/* Check for invalid inherit disposition */
|
||||||
if ((InheritDisposition > ViewUnmap) || (InheritDisposition < ViewShare))
|
if ((InheritDisposition > ViewUnmap) || (InheritDisposition < ViewShare))
|
||||||
|
@ -3463,8 +3468,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allow only valid allocation types */
|
/* Allow only valid allocation types */
|
||||||
if ((AllocationType & ~(MEM_TOP_DOWN | MEM_LARGE_PAGES | MEM_DOS_LIM |
|
if (AllocationType & ~ValidAllocationType)
|
||||||
SEC_NO_CHANGE | MEM_RESERVE)))
|
|
||||||
{
|
{
|
||||||
DPRINT1("Invalid allocation type\n");
|
DPRINT1("Invalid allocation type\n");
|
||||||
return STATUS_INVALID_PARAMETER_9;
|
return STATUS_INVALID_PARAMETER_9;
|
||||||
|
@ -3478,13 +3482,6 @@ NtMapViewOfSection(IN HANDLE SectionHandle,
|
||||||
return STATUS_INVALID_PAGE_PROTECTION;
|
return STATUS_INVALID_PAGE_PROTECTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for non-allocation-granularity-aligned BaseAddress */
|
|
||||||
if (BaseAddress && (*BaseAddress != ALIGN_DOWN_POINTER_BY(*BaseAddress, MM_VIRTMEM_GRANULARITY)))
|
|
||||||
{
|
|
||||||
DPRINT("BaseAddress is not at 64-kilobyte address boundary.");
|
|
||||||
return STATUS_MAPPED_ALIGNMENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now convert the protection mask into desired section access mask */
|
/* Now convert the protection mask into desired section access mask */
|
||||||
DesiredAccess = MmMakeSectionAccess[ProtectionMask & 0x7];
|
DesiredAccess = MmMakeSectionAccess[ProtectionMask & 0x7];
|
||||||
|
|
||||||
|
@ -3521,6 +3518,33 @@ NtMapViewOfSection(IN HANDLE SectionHandle,
|
||||||
}
|
}
|
||||||
_SEH2_END;
|
_SEH2_END;
|
||||||
|
|
||||||
|
/* Check for invalid zero bits */
|
||||||
|
if (ZeroBits && SafeBaseAddress)
|
||||||
|
{
|
||||||
|
if ((((ULONG_PTR)SafeBaseAddress << ZeroBits) >> ZeroBits) != (ULONG_PTR)SafeBaseAddress)
|
||||||
|
{
|
||||||
|
DPRINT1("Invalid zero bits\n");
|
||||||
|
return STATUS_INVALID_PARAMETER_4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(AllocationType & MEM_DOS_LIM))
|
||||||
|
{
|
||||||
|
/* Check for non-allocation-granularity-aligned BaseAddress */
|
||||||
|
if (SafeBaseAddress != ALIGN_DOWN_POINTER_BY(SafeBaseAddress, MM_VIRTMEM_GRANULARITY))
|
||||||
|
{
|
||||||
|
DPRINT("BaseAddress is not at 64-kilobyte address boundary.");
|
||||||
|
return STATUS_MAPPED_ALIGNMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Do the same for the section offset */
|
||||||
|
if (SafeSectionOffset.LowPart != ALIGN_DOWN_BY(SafeSectionOffset.LowPart, MM_VIRTMEM_GRANULARITY))
|
||||||
|
{
|
||||||
|
DPRINT("SectionOffset is not at 64-kilobyte address boundary.");
|
||||||
|
return STATUS_MAPPED_ALIGNMENT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Check for kernel-mode address */
|
/* Check for kernel-mode address */
|
||||||
if (SafeBaseAddress > MM_HIGHEST_VAD_ADDRESS)
|
if (SafeBaseAddress > MM_HIGHEST_VAD_ADDRESS)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue