Skip to content

Commit aee730d

Browse files
authored
Fix aarch64 page table parsing for 5 level paging (#158)
With 2511, the arm mmu library added support for an additional paging level. When this occurs the current debugger logic will underflow and start parsing the page tables with garbage levels and entry counts. This change updates the level calculation to reflect the arm mmu library changes.
1 parent 2c18756 commit aee730d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

DebuggerFeaturePkg/Library/DebugAgent/AARCH64/DebugAarch64.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ DebugArchInit (
332332
BOOLEAN
333333
ParsePageTableLevel (
334334
IN UINT64 *TranslationTable,
335-
IN UINTN TableLevel,
335+
IN INTN TableLevel,
336336
IN UINT64 *LastBlockEntry,
337337
IN UINTN Address,
338338
OUT UINTN *Attributes
@@ -388,7 +388,7 @@ CheckPageAccess (
388388
)
389389
{
390390
UINT64 *TranslationTable;
391-
UINTN TableLevel;
391+
INTN TableLevel;
392392
UINTN EntryCount;
393393
UINTN T0SZ;
394394
BOOLEAN Result;
@@ -405,8 +405,8 @@ CheckPageAccess (
405405
Attributes = 0;
406406
TranslationTable = (UINT64 *)DebugGetTTBR0BaseAddress ();
407407
T0SZ = DebugGetTCR () & TCR_T0SZ_MASK;
408-
TableLevel = (T0SZ - MIN_T0SZ) / BITS_PER_LEVEL;
409-
EntryCount = TT_ENTRY_COUNT >> (T0SZ - MIN_T0SZ) % BITS_PER_LEVEL;
408+
TableLevel = (T0SZ < MIN_T0SZ) ? -1 : (INTN)(T0SZ - MIN_T0SZ) / BITS_PER_LEVEL;
409+
EntryCount = TT_ENTRY_COUNT >> (INTN)(T0SZ - MIN_T0SZ) % BITS_PER_LEVEL;
410410

411411
Result = ParsePageTableLevel (
412412
TranslationTable,

0 commit comments

Comments
 (0)