Implement canonical address validation routine
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 31s
Builds / ExectOS (amd64, release) (push) Successful in 31s
Builds / ExectOS (i686, debug) (push) Successful in 41s
Builds / ExectOS (i686, release) (push) Successful in 39s

This commit is contained in:
2026-03-04 14:15:33 +01:00
parent 5368fe2e8d
commit 5a9b7c0258
7 changed files with 63 additions and 0 deletions

View File

@@ -31,6 +31,29 @@ MM::PageMap::AdvancePte(IN PMMPTE Pte,
return (PMMPTE)((ULONG_PTR)Pte + (Count * sizeof(MMPTE)));
}
/**
* Checks if the given address is canonical.
*
* @param VirtualAddress
* Specifies the virtual address to check.
*
* @return This routine returns TRUE if the address is canonical, FALSE otherwise.
*
* @since XT 1.0
*/
XTAPI
BOOLEAN
MM::PageMap::CanonicalAddress(IN PVOID VirtualAddress)
{
ULONG Shift;
/* Calculate the number of unused upper bits based on the paging mode */
Shift = 64 - PageMapInfo.VaBits;
/* Sign-extend via arithmetic shifts to verify the canonical form */
return ((((LONGLONG)VirtualAddress << Shift) >> Shift) == (LONGLONG)VirtualAddress);
}
/**
* Clears the contents of a page table entry (PTE).
*

View File

@@ -9,6 +9,24 @@
#include <xtos.hh>
/**
* Checks if the given address is canonical.
*
* @param VirtualAddress
* Specifies the virtual address to check.
*
* @return This routine returns TRUE, as all addresses in i686 are canonical.
*
* @since XT 1.0
*/
XTAPI
BOOLEAN
MM::PageMap::CanonicalAddress(IN PVOID VirtualAddress)
{
/* All addresses in i686 are canonical */
return TRUE;
}
/**
* Gets Page Map Level (PML) for current paging mode.
*

View File

@@ -31,6 +31,24 @@ MM::Paging::AdvancePte(IN PMMPTE Pte,
return PmlRoutines->AdvancePte(Pte, Count);
}
/**
* Checks if the given address is canonical.
*
* @param VirtualAddress
* Specifies the virtual address to check.
*
* @return This routine returns TRUE if the address is canonical, FALSE otherwise.
*
* @since XT 1.0
*/
XTAPI
BOOLEAN
MM::Paging::CanonicalAddress(IN PVOID VirtualAddress)
{
/* Return canonical address status */
return PmlRoutines->CanonicalAddress(VirtualAddress);
}
/**
* Clears the contents of a page table entry (PTE).
*