git: 3c2ee7b28cfd - main - arm64: Enhance pmap_pte_exists()'s error reporting

From: Alan Cox <alc_at_FreeBSD.org>
Date: Tue, 28 Dec 2021 23:46:40 UTC
The branch main has been updated by alc:

URL: https://cgit.FreeBSD.org/src/commit/?id=3c2ee7b28cfd715e28e72d76efd89ba3c38aa970

commit 3c2ee7b28cfd715e28e72d76efd89ba3c38aa970
Author:     Alan Cox <alc@FreeBSD.org>
AuthorDate: 2021-12-28 23:17:42 +0000
Commit:     Alan Cox <alc@FreeBSD.org>
CommitDate: 2021-12-28 23:46:21 +0000

    arm64: Enhance pmap_pte_exists()'s error reporting
    
    Report the descriptor type and level at which the page table does not
    match the caller's expectations.
    
    MFC after:      1 week
---
 sys/arm64/arm64/pmap.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c
index 4bd3eef7a18f..15bb813f591d 100644
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -607,6 +607,7 @@ pmap_pte_exists(pmap_t pmap, vm_offset_t va, int level, const char *diag)
 {
 	pd_entry_t *l0p, *l1p, *l2p;
 	pt_entry_t desc, *l3p;
+	int walk_level __diagused;
 
 	KASSERT(level >= 0 && level < 4,
 	    ("%s: %s passed an out-of-range level (%d)", __func__, diag,
@@ -628,11 +629,17 @@ pmap_pte_exists(pmap_t pmap, vm_offset_t va, int level, const char *diag)
 				desc = pmap_load(l3p) & ATTR_DESCR_MASK;
 				if (desc == L3_PAGE && level == 3)
 					return (l3p);
-			}
-		}
-	}
+				else
+					walk_level = 3;
+			} else
+				walk_level = 2;
+		} else
+			walk_level = 1;
+	} else
+		walk_level = 0;
 	KASSERT(diag == NULL,
-	    ("%s: va %#lx is not mapped at level %d", diag, va, level));
+	    ("%s: va %#lx not mapped at level %d, desc %ld at level %d",
+	    diag, va, level, desc, walk_level));
 	return (NULL);
 }