NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kern/53311: boot netbsd -d panics
The following reply was made to PR kern/53311; it has been noted by GNATS.
From: Edgar =?iso-8859-1?B?RnXf?= <ef%math.uni-bonn.de@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc:
Subject: Re: kern/53311: boot netbsd -d panics
Date: Tue, 17 Nov 2020 11:54:06 +0100
--6Nae48J/T25AfBN4
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
I've tried to back-port the three relevant commits to -8, which seems to be mostly string substitution on various PTE_ symbols. Note that ptp_masks has changed its meaning from -8 to -current (as far as I can tell).
I don't know what to do to the RCS/CVS/whatever IDs.
I'm running a modified kernel since yesterday. I could boot -d and it seems to behave. Nevertheless, someone In The Know should certainly review my patches.
The fix for -9 should be easier, I guess.
--6Nae48J/T25AfBN4
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="pmap.h.diff"
Index: sys/arch/x86/include/pmap.h
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/include/pmap.h,v
retrieving revision 1.64.6.2
diff -u -r1.64.6.2 pmap.h
--- sys/arch/x86/include/pmap.h 22 Mar 2018 16:59:04 -0000 1.64.6.2
+++ sys/arch/x86/include/pmap.h 13 Nov 2020 14:59:01 -0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.64.6.2 2018/03/22 16:59:04 martin Exp $ */
+/* $NetBSD: pmap.h,v 1.100 2019/03/10 16:30:01 maxv Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -291,7 +291,8 @@
pd_entry_t * const **);
void pmap_unmap_ptes(struct pmap *, struct pmap *);
-int pmap_pdes_invalid(vaddr_t, pd_entry_t * const *, pd_entry_t *);
+bool pmap_pdes_valid(vaddr_t, pd_entry_t * const *, pd_entry_t *,
+ int *lastlvl);
u_int x86_mmap_flags(paddr_t);
@@ -342,12 +343,6 @@
* inline functions
*/
-__inline static bool __unused
-pmap_pdes_valid(vaddr_t va, pd_entry_t * const *pdes, pd_entry_t *lastpde)
-{
- return pmap_pdes_invalid(va, pdes, lastpde) == 0;
-}
-
/*
* pmap_update_pg: flush one page from the TLB (or flush the whole thing
* if hardware doesn't support one-page flushing)
--6Nae48J/T25AfBN4
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="pmap.c.diff"
Index: sys/arch/x86/x86/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/pmap.c,v
retrieving revision 1.245.6.6
diff -u -r1.245.6.6 pmap.c
--- sys/arch/x86/x86/pmap.c 22 Mar 2018 16:59:04 -0000 1.245.6.6
+++ sys/arch/x86/x86/pmap.c 13 Nov 2020 15:37:49 -0000
@@ -28,6 +28,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
+/* $NetBSD: pmap.c,v 1.330 2019/03/10 16:30:01 maxv Exp $ */
/*
* Copyright (c) 2007 Manuel Bouyer.
@@ -171,7 +172,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.245.6.6 2018/03/22 16:59:04 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v XXX $");
#include "opt_user_ldt.h"
#include "opt_lockdebug.h"
@@ -3059,22 +3060,28 @@
* some misc. functions
*/
-int
-pmap_pdes_invalid(vaddr_t va, pd_entry_t * const *pdes, pd_entry_t *lastpde)
+bool
+pmap_pdes_valid(vaddr_t va, pd_entry_t * const *pdes, pd_entry_t *lastpde,
+ int *lastlvl)
{
- int i;
unsigned long index;
pd_entry_t pde;
+ int i;
for (i = PTP_LEVELS; i > 1; i--) {
index = pl_i(va, i);
pde = pdes[i - 2][index];
- if ((pde & PG_V) == 0)
- return i;
+ if ((pde & PG_V) == 0) {
+ *lastlvl = i;
+ return false;
+ }
+ if (pde & PG_PS)
+ break;
}
if (lastpde != NULL)
*lastpde = pde;
- return 0;
+ *lastlvl = i;
+ return true;
}
/*
@@ -3092,6 +3099,7 @@
paddr_t pa;
lwp_t *l;
bool hard, rv;
+ int lvl;
#ifdef __HAVE_DIRECT_MAP
if (va >= PMAP_DIRECT_BASE && va < PMAP_DIRECT_END) {
@@ -3108,8 +3116,8 @@
kpreempt_disable();
ci = l->l_cpu;
- if (__predict_true(!ci->ci_want_pmapload && ci->ci_pmap == pmap) ||
- pmap == pmap_kernel()) {
+ if (pmap == pmap_kernel() ||
+ __predict_true(!ci->ci_want_pmapload && ci->ci_pmap == pmap)) {
/*
* no need to lock, because it's pmap_kernel() or our
* own pmap and is active. if a user pmap, the caller
@@ -3126,14 +3134,17 @@
hard = true;
pmap_map_ptes(pmap, &pmap2, &ptes, &pdes);
}
- if (pmap_pdes_valid(va, pdes, &pde)) {
- pte = ptes[pl1_i(va)];
- if (pde & PG_PS) {
+ if (pmap_pdes_valid(va, pdes, &pde, &lvl)) {
+ if (lvl == 2) {
pa = (pde & PG_LGFRAME) | (va & (NBPD_L2 - 1));
rv = true;
- } else if (__predict_true((pte & PG_V) != 0)) {
- pa = pmap_pte2pa(pte) | (va & (NBPD_L1 - 1));
- rv = true;
+ } else {
+ KASSERT(lvl == 1);
+ pte = ptes[pl1_i(va)];
+ if (__predict_true((pte & PG_V) != 0)) {
+ pa = pmap_pte2pa(pte) | (va & (NBPD_L1 - 1));
+ rv = true;
+ }
}
}
if (__predict_false(hard)) {
@@ -3552,6 +3563,7 @@
vaddr_t blkendva, va = sva;
struct vm_page *ptp;
struct pmap *pmap2;
+ int lvl;
kpreempt_disable();
pmap_map_ptes(pmap, &pmap2, &ptes, &pdes); /* locks pmap */
@@ -3561,7 +3573,8 @@
*/
if (va + PAGE_SIZE == eva) {
- if (pmap_pdes_valid(va, pdes, &pde)) {
+ if (pmap_pdes_valid(va, pdes, &pde, &lvl)) {
+ KASSERT(lvl == 1);
/* PA of the PTP */
ptppa = pmap_pte2pa(pde);
@@ -3588,8 +3601,6 @@
pmap_free_ptp(pmap, ptp, va, ptes, pdes);
}
} else for (/* null */ ; va < eva ; va = blkendva) {
- int lvl;
-
/* determine range of block */
blkendva = x86_round_pdr(va+1);
if (blkendva > eva)
@@ -3609,14 +3620,14 @@
panic("PTE space accessed");
}
- lvl = pmap_pdes_invalid(va, pdes, &pde);
- if (lvl != 0) {
+ if (!pmap_pdes_valid(va, pdes, &pde, &lvl)) {
/*
* skip a range corresponding to an invalid pde.
*/
blkendva = (va & ptp_masks[lvl - 1]) + nbpd[lvl - 1];
continue;
}
+ KASSERT(lvl == 1);
/* PA of the PTP */
ptppa = pmap_pte2pa(pde);
@@ -4031,6 +4042,7 @@
pt_entry_t * const *pdes;
struct pmap *pmap2;
vaddr_t blockend, va;
+ int lvl;
KASSERT(curlwp->l_md.md_gc_pmap != pmap);
@@ -4072,10 +4084,11 @@
}
/* Is it a valid block? */
- if (!pmap_pdes_valid(va, pdes, NULL)) {
+ if (!pmap_pdes_valid(va, pdes, NULL, &lvl)) {
continue;
}
KASSERT(va < VM_MAXUSER_ADDRESS || va >= VM_MAX_ADDRESS);
+ KASSERT(lvl == 1);
spte = &ptes[pl1_i(va)];
epte = &ptes[pl1_i(blockend)];
@@ -4116,14 +4129,16 @@
pt_entry_t *ptes, *ptep, opte;
pd_entry_t * const *pdes;
struct pmap *pmap2;
+ int lvl;
/* Acquire pmap. */
kpreempt_disable();
pmap_map_ptes(pmap, &pmap2, &ptes, &pdes);
- if (!pmap_pdes_valid(va, pdes, NULL)) {
+ if (!pmap_pdes_valid(va, pdes, NULL, &lvl)) {
panic("pmap_unwire: invalid PDE");
}
+ KASSERT(lvl == 1);
ptep = &ptes[pl1_i(va)];
opte = *ptep;
@@ -4631,6 +4646,7 @@
pd_entry_t * const *pdes;
struct pmap *pmap2;
vaddr_t blkendva;
+ int lvl;
/*
* if end is out of range truncate.
@@ -4659,8 +4675,9 @@
blkendva = eva;
/* valid block? */
- if (!pmap_pdes_valid(sva, pdes, NULL))
+ if (!pmap_pdes_valid(sva, pdes, NULL, &lvl))
continue;
+ KASSERT(lvl == 1);
pte = &ptes[pl1_i(sva)];
for (/* null */; sva < blkendva ; sva += PAGE_SIZE, pte++) {
--6Nae48J/T25AfBN4
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="xen_pmap.c.diff"
Index: sys/arch/xen/x86/xen_pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/xen/x86/xen_pmap.c,v
retrieving revision 1.26
diff -u -r1.26 xen_pmap.c
--- sys/arch/xen/x86/xen_pmap.c 23 Mar 2017 18:08:06 -0000 1.26
+++ sys/arch/xen/x86/xen_pmap.c 13 Nov 2020 14:59:41 -0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xen_pmap.c,v 1.26 2017/03/23 18:08:06 maxv Exp $ */
+/* $NetBSD: xen_pmap.c,v 1.31 2019/03/10 16:30:01 maxv Exp $ */
/*
* Copyright (c) 2007 Manuel Bouyer.
@@ -101,7 +101,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xen_pmap.c,v 1.26 2017/03/23 18:08:06 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_pmap.c,v XXX $");
#include "opt_user_ldt.h"
#include "opt_lockdebug.h"
@@ -212,15 +212,17 @@
pd_entry_t pde;
pd_entry_t * const *pdes;
struct pmap *pmap2;
+ int lvl;
kpreempt_disable();
pmap_map_ptes(pmap, &pmap2, &ptes, &pdes);
- if (!pmap_pdes_valid(va, pdes, &pde)) {
+ if (!pmap_pdes_valid(va, pdes, &pde, &lvl)) {
pmap_unmap_ptes(pmap, pmap2);
kpreempt_enable();
return false;
}
+ KASSERT(lvl == 1);
pte = ptes[pl1_i(va)];
pmap_unmap_ptes(pmap, pmap2);
kpreempt_enable();
--6Nae48J/T25AfBN4--
Home |
Main Index |
Thread Index |
Old Index