use PMAP_PAGE_INIT() to initialize mutex in pmap_page.

VM_MDPAGE_INIT() in pmap_free_pdp() had initialized pp_flags,
so it unintentionally cleared PMAP_PAGE_FLAGS_PV_TRACKED.
use PMAP_PAGE_INIT to avoid using PMAP_PAGE_FLAGS_PV_TRACKED.

pointed out by tnn@, thanks
This commit is contained in:
ryo 2020-04-08 00:13:40 +00:00
parent d93b379632
commit ebe3e284a8
2 changed files with 9 additions and 18 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap.c,v 1.68 2020/03/14 14:05:42 ad Exp $ */
/* $NetBSD: pmap.c,v 1.69 2020/04/08 00:13:40 ryo Exp $ */
/*
* Copyright (c) 2017 Ryo Shimizu <ryo@nerv.org>
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.68 2020/03/14 14:05:42 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.69 2020/04/08 00:13:40 ryo Exp $");
#include "opt_arm_debug.h"
#include "opt_ddb.h"
@ -249,12 +249,6 @@ pm_unlock(struct pmap *pm)
mutex_exit(&pm->pm_lock);
}
static inline void
_pmap_page_init(struct pmap_page *pp)
{
mutex_init(&pp->pp_pvlock, MUTEX_SPIN, IPL_VM);
}
static inline struct pmap_page *
phys_to_pp(paddr_t pa)
{
@ -265,13 +259,7 @@ phys_to_pp(paddr_t pa)
return VM_PAGE_TO_PP(pg);
#ifdef __HAVE_PMAP_PV_TRACK
struct pmap_page *pp = pmap_pv_tracked(pa);
if (pp != NULL && (pp->pp_flags & PMAP_PAGE_FLAGS_PV_TRACKED) == 0) {
/* XXX: initialize pv_tracked pmap_page. should not init here */
_pmap_page_init(pp);
pp->pp_flags |= PMAP_PAGE_FLAGS_PV_TRACKED;
}
return pp;
return pmap_pv_tracked(pa);
#else
return NULL;
#endif /* __HAVE_PMAP_PV_TRACK */
@ -537,7 +525,7 @@ pmap_init(void)
pfn++) {
pg = PHYS_TO_VM_PAGE(ptoa(pfn));
md = VM_PAGE_TO_MD(pg);
_pmap_page_init(&md->mdpg_pp);
PMAP_PAGE_INIT(&md->mdpg_pp);
}
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap.h,v 1.36 2020/02/29 21:32:22 ryo Exp $ */
/* $NetBSD: pmap.h,v 1.37 2020/04/08 00:13:40 ryo Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@ -92,7 +92,6 @@ struct pmap_page {
/* VM_PROT_READ means referenced, VM_PROT_WRITE means modified */
uint32_t pp_flags;
#define PMAP_PAGE_FLAGS_PV_TRACKED 0x80000000
};
struct vm_page_md {
@ -109,6 +108,10 @@ struct vm_page_md {
(pg)->mdpage.mdpg_pp.pp_flags = 0; \
} while (/*CONSTCOND*/ 0)
#define PMAP_PAGE_INIT(pp) \
do { \
mutex_init(&(pp)->pp_pvlock, MUTEX_SPIN, IPL_VM); \
} while (/*CONSTCOND*/ 0)
/* saved permission bit for referenced/modified emulation */
#define LX_BLKPAG_OS_READ LX_BLKPAG_OS_0