git: 0fd27bcab2f8 - main - arm64: Fix an assertion in pmap_enter_largepage()

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 26 Sep 2022 13:03:29 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=0fd27bcab2f83ffd28ff9443a343d610cbfba2d7

commit 0fd27bcab2f83ffd28ff9443a343d610cbfba2d7
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-09-26 12:56:11 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-09-26 12:56:11 +0000

    arm64: Fix an assertion in pmap_enter_largepage()
    
    The intent is to assert that either no mapping exists at the given VA,
    or that the existing L1 block mapping maps the same PA.
    
    Fixes:          36f1526a598c ("Add experimental 16k page support on arm64")
    Reviewed by:    alc
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D36698
---
 sys/arm64/arm64/pmap.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c
index 32cf3dd7636c..83eae8d5791f 100644
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -3893,6 +3893,8 @@ pmap_enter_largepage(pmap_t pmap, vm_offset_t va, pt_entry_t newpte, int flags,
 
 restart:
 	if (psind == 2) {
+		PMAP_ASSERT_L1_BLOCKS_SUPPORTED;
+
 		l0p = pmap_l0(pmap, va);
 		if ((pmap_load(l0p) & ATTR_DESCR_VALID) == 0) {
 			mp = _pmap_alloc_l3(pmap, pmap_l0_pindex(va), NULL);
@@ -3917,10 +3919,9 @@ restart:
 				mp->ref_count++;
 			}
 		}
-		KASSERT((origpte & ~ATTR_MASK) == (newpte & ~ATTR_MASK) ||
-		    (L1_BLOCKS_SUPPORTED &&
-		    (origpte & ATTR_DESCR_MASK) == L1_BLOCK &&
-		    (origpte & ATTR_DESCR_VALID) == 0),
+		KASSERT(((origpte & ~ATTR_MASK) == (newpte & ~ATTR_MASK) &&
+		    (origpte & ATTR_DESCR_MASK) == L1_BLOCK) ||
+		    (origpte & ATTR_DESCR_VALID) == 0,
 		    ("va %#lx changing 1G phys page l1 %#lx newpte %#lx",
 		    va, origpte, newpte));
 		pmap_store(l1p, newpte);