Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Jan 2021 15:15:16 GMT
From:      Mitchell Horne <mhorne@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 0628f6835702 - main - riscv pmap: add some pv list assertions
Message-ID:  <202101121515.10CFFG1H070095@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=0628f6835702943bd6da52fba30ee53971f9029c

commit 0628f6835702943bd6da52fba30ee53971f9029c
Author:     mhorne <mhorne@FreeBSD.org>
AuthorDate: 2020-11-04 17:51:10 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2021-01-12 15:12:02 +0000

    riscv pmap: add some pv list assertions
    
    Ensure that we don't end up with a superpage in the vm_page_t's pv list.
    
    This may help with debugging the panic reported in PR 250866, in which
    l3 in pmap_remove_write() was found to be NULL. Adding a KASSERT to this
    function will help narrow down the cause of this panic the next time it
    occurs.
    
    Reviewed by:    markj
    Differential Revision:  https://reviews.freebsd.org/D28109
---
 sys/riscv/riscv/pmap.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c
index 4ad46731f158..f30dda17afae 100644
--- a/sys/riscv/riscv/pmap.c
+++ b/sys/riscv/riscv/pmap.c
@@ -3498,7 +3498,10 @@ restart:
 				goto restart;
 			}
 		}
-		l3 = pmap_l3(pmap, pv->pv_va);
+		l2 = pmap_l2(pmap, pv->pv_va);
+		KASSERT((pmap_load(l2) & PTE_RWX) == 0,
+		    ("%s: found a 2mpage in page %p's pv list", __func__, m));
+		l3 = pmap_l2_to_l3(l2, pv->pv_va);
 		if ((pmap_load(l3) & PTE_SW_WIRED) != 0)
 			count++;
 		PMAP_UNLOCK(pmap);
@@ -3745,7 +3748,10 @@ restart:
 				goto restart;
 			}
 		}
-		l3 = pmap_l3(pmap, pv->pv_va);
+		l2 = pmap_l2(pmap, pv->pv_va);
+		KASSERT((pmap_load(l2) & PTE_RWX) == 0,
+		    ("%s: found a 2mpage in page %p's pv list", __func__, m));
+		l3 = pmap_l2_to_l3(l2, pv->pv_va);
 		rv = (pmap_load(l3) & mask) == mask;
 		PMAP_UNLOCK(pmap);
 		if (rv)
@@ -3901,7 +3907,10 @@ retry_pv_loop:
 				goto retry_pv_loop;
 			}
 		}
-		l3 = pmap_l3(pmap, pv->pv_va);
+		l2 = pmap_l2(pmap, pv->pv_va);
+		KASSERT((pmap_load(l2) & PTE_RWX) == 0,
+		    ("%s: found a 2mpage in page %p's pv list", __func__, m));
+		l3 = pmap_l2_to_l3(l2, pv->pv_va);
 		oldl3 = pmap_load(l3);
 retry:
 		if ((oldl3 & PTE_W) != 0) {
@@ -4172,8 +4181,7 @@ restart:
 		}
 		l2 = pmap_l2(pmap, pv->pv_va);
 		KASSERT((pmap_load(l2) & PTE_RWX) == 0,
-		    ("pmap_clear_modify: found a 2mpage in page %p's pv list",
-		    m));
+		    ("%s: found a 2mpage in page %p's pv list", __func__, m));
 		l3 = pmap_l2_to_l3(l2, pv->pv_va);
 		if ((pmap_load(l3) & (PTE_D | PTE_W)) == (PTE_D | PTE_W)) {
 			pmap_clear_bits(l3, PTE_D | PTE_W);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101121515.10CFFG1H070095>