From 0721214a60cbfe95fef3fabe256de8f8e62b3427 Mon Sep 17 00:00:00 2001 From: Jessica Clarke Date: Wed, 13 May 2020 17:20:51 +0000 Subject: [PATCH] riscv: Fix pmap_protect for superpages When protecting a superpage, we would previously fall through to the non-superpage case and read the contents of the superpage as PTEs, potentially modifying them and trying to look up underlying VM pages that don't exist if they happen to look like PTEs we would care about. This led to nginx causing an unexpected page fault in pmap_protect that panic'ed the kernel. Instead, if we see a superpage, we are done for this range and should continue to the next. Reviewed by: markj, jhb (mentor) Approved by: markj, jhb (mentor) Differential Revision: https://reviews.freebsd.org/D24827 --- sys/riscv/riscv/pmap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c index ff2451d55f7..9947a296290 100644 --- a/sys/riscv/riscv/pmap.c +++ b/sys/riscv/riscv/pmap.c @@ -2329,6 +2329,7 @@ retryl2: if (!atomic_fcmpset_long(l2, &l2e, l2e & ~mask)) goto retryl2; anychanged = true; + continue; } else { if (!pv_lists_locked) { pv_lists_locked = true;