git: 99fe523778af - main - riscv: add an assert to pmap_remove_pages()

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Thu, 06 Oct 2022 22:05:40 UTC
The branch main has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=99fe523778af8cd0db3a17b253adb77a980176be

commit 99fe523778af8cd0db3a17b253adb77a980176be
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2022-08-25 20:08:20 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2022-10-06 22:04:41 +0000

    riscv: add an assert to pmap_remove_pages()
    
    Similar checks exist for both arm64 and amd64, but note that for amd64
    it is a bare panic().
    
    Reviewed by:    markj
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D36564
---
 sys/riscv/riscv/pmap.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c
index 9f73a020d0f4..de7f548b6519 100644
--- a/sys/riscv/riscv/pmap.c
+++ b/sys/riscv/riscv/pmap.c
@@ -3908,6 +3908,10 @@ pmap_remove_pages(pmap_t pmap)
 				ptepde = pmap_load(pte);
 				pte = pmap_l1_to_l2(pte, pv->pv_va);
 				tpte = pmap_load(pte);
+
+				KASSERT((tpte & PTE_V) != 0,
+				    ("L2 PTE is invalid... bogus PV entry? "
+				    "va=%#lx, pte=%#lx", pv->pv_va, tpte));
 				if ((tpte & PTE_RWX) != 0) {
 					superpage = true;
 				} else {