Fix paging abstraction for PDE/PTE virtual address calculation
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 29s
Builds / ExectOS (amd64, release) (push) Successful in 27s
Builds / ExectOS (i686, release) (push) Successful in 26s
Builds / ExectOS (i686, debug) (push) Successful in 28s

This commit is contained in:
2025-12-18 22:26:31 +01:00
parent 687c58d923
commit b183d52806
2 changed files with 83 additions and 41 deletions

View File

@@ -81,23 +81,6 @@ MM::PageMap::GetPdeIndex(IN PVOID Address)
return ((((ULONG_PTR)(Address)) >> PageMapInfo.PdiShift) & (PageMapInfo.Xpa ? 0x1FF : 0x3FF));
}
/**
* Gets the virtual address that is mapped by a given Page Directory Entry.
*
* @param PdePointer
* Specifies the address of the PDE.
*
* @return This routine returns the virtual address mapped by the PDE.
*
* @since XT 1.0
*/
XTAPI
PVOID
MM::PageMap::GetPdeVirtualAddress(IN PMMPDE PdePointer)
{
/* Return PDE virtual address */
return ((PVOID)((ULONG)(PdePointer) << 20));
}
/**
* Gets the address of the PPE (Page Directory Pointer Table Entry), that maps given address.
@@ -123,7 +106,7 @@ MM::PageMap::GetPpeAddress(IN PVOID Address)
* @param Address
* Specifies the virtual address for which to retrieve the corresponding PPE.
*
* @return This routine returns the index of the PPE.
* @return This routine returns the offset of the PPE.
*
* @since XT 1.0
*/
@@ -131,8 +114,8 @@ XTAPI
ULONG
MM::PageMap::GetPpeIndex(IN PVOID Address)
{
/* Return PPE index */
return ((((ULONG_PTR)(Address)) >> MM_PPI_SHIFT) & 0x3) * PageMapInfo.Xpa;
/* Return zero */
return 0;
}
/**
@@ -149,8 +132,8 @@ XTAPI
PVOID
MM::PageMap::GetPpeVirtualAddress(IN PMMPPE PpePointer)
{
/* Return PPE virtual address */
return (PVOID)((ULONG)(PpePointer) << 30);
/* Return zero */
return (PVOID)0;
}
/**
@@ -192,23 +175,6 @@ MM::PageMap::GetPteIndex(IN PVOID Address)
return ((((ULONG_PTR)(Address)) >> MM_PTI_SHIFT) & (PageMapInfo.Xpa ? 0x1FF : 0x3FF));
}
/**
* Gets the virtual address that is mapped by a given Page Table Entry.
*
* @param PtePointer
* Specifies the virtual address of the PTE.
*
* @return This routine returns the virtual address mapped by the PTE.
*
* @since XT 1.0
*/
XTAPI
PVOID
MM::PageMap::GetPteVirtualAddress(IN PMMPTE PtePointer)
{
/* Return PTE virtual address */
return ((PVOID)((ULONG)(PtePointer) << 10));
}
/**
* Gets the status of Extended Paging Address (XPA) mode.
@@ -317,6 +283,24 @@ MM::PageMapBasic::GetPageFrameNumber(IN PMMPTE Pte)
return Pte->Pml2.Hardware.PageFrameNumber;
}
/**
* Gets the virtual address that is mapped by a given Page Directory Entry.
*
* @param PdePointer
* Specifies the address of the PDE.
*
* @return This routine returns the virtual address mapped by the PDE.
*
* @since XT 1.0
*/
XTAPI
PVOID
MM::PageMapBasic::GetPdeVirtualAddress(IN PMMPDE PdePointer)
{
/* Return PDE virtual address */
return ((PVOID)((ULONG)(PdePointer) << 20));
}
/**
* Calculates the distance between two PTE pointers.
*
@@ -354,6 +338,24 @@ MM::PageMapBasic::GetPteSize(VOID)
return sizeof(MMPML2_PTE);
}
/**
* Gets the virtual address that is mapped by a given Page Table Entry.
*
* @param PtePointer
* Specifies the virtual address of the PTE.
*
* @return This routine returns the virtual address mapped by the PTE.
*
* @since XT 1.0
*/
XTAPI
PVOID
MM::PageMapBasic::GetPteVirtualAddress(IN PMMPTE PtePointer)
{
/* Return PTE virtual address */
return ((PVOID)((ULONG)(PtePointer) << 10));
}
/**
* Initializes page map information for basic paging (PML2).
*
@@ -590,6 +592,24 @@ MM::PageMapXpa::GetPageFrameNumber(IN PMMPTE Pte)
return Pte->Pml3.Hardware.PageFrameNumber;
}
/**
* Gets the virtual address that is mapped by a given Page Directory Entry.
*
* @param PdePointer
* Specifies the address of the PDE.
*
* @return This routine returns the virtual address mapped by the PDE.
*
* @since XT 1.0
*/
XTAPI
PVOID
MM::PageMapXpa::GetPdeVirtualAddress(IN PMMPDE PdePointer)
{
/* Return PDE virtual address */
return ((PVOID)((ULONG)(PdePointer) << 18));
}
/**
* Calculates the distance between two PTE pointers.
*
@@ -627,6 +647,24 @@ MM::PageMapXpa::GetPteSize(VOID)
return sizeof(MMPML3_PTE);
}
/**
* Gets the virtual address that is mapped by a given Page Table Entry.
*
* @param PtePointer
* Specifies the virtual address of the PTE.
*
* @return This routine returns the virtual address mapped by the PTE.
*
* @since XT 1.0
*/
XTAPI
PVOID
MM::PageMapXpa::GetPteVirtualAddress(IN PMMPTE PtePointer)
{
/* Return PTE virtual address */
return ((PVOID)((ULONG)(PtePointer) << 9));
}
/**
* Initializes page map information for basic paging (PML3).
*