-/* $OpenBSD: pmap.h,v 1.15 2022/09/10 20:35:29 miod Exp $ */
+/* $OpenBSD: pmap.h,v 1.16 2022/09/12 19:33:34 miod Exp $ */
/* $NetBSD: pmap.h,v 1.28 2006/04/10 23:12:11 uwe Exp $ */
/*-
#endif /* !_KERNEL */
-#define PVH_REFERENCED 1
-#define PVH_MODIFIED 2
+#define PG_PMAP_REF PG_PMAP0
+#define PG_PMAP_MOD PG_PMAP1
#ifndef _LOCORE
struct pv_entry;
struct vm_page_md {
SLIST_HEAD(, pv_entry) pvh_head;
- int pvh_flags;
};
#define VM_MDPAGE_INIT(pg) \
do { \
struct vm_page_md *pvh = &(pg)->mdpage; \
SLIST_INIT(&pvh->pvh_head); \
- pvh->pvh_flags = 0; \
} while (/*CONSTCOND*/0)
#endif /* _LOCORE */
-/* $OpenBSD: pmap.c,v 1.28 2016/10/19 08:28:20 guenther Exp $ */
+/* $OpenBSD: pmap.c,v 1.29 2022/09/12 19:33:34 miod Exp $ */
/* $NetBSD: pmap.c,v 1.55 2006/08/07 23:19:36 tsutsui Exp $ */
/*-
pmap_enter(pmap_t pmap, vaddr_t va, paddr_t pa, vm_prot_t prot, int flags)
{
struct vm_page *pg;
- struct vm_page_md *pvh;
pt_entry_t entry, *pte;
boolean_t kva = (pmap == pmap_kernel());
entry |= _PG_WIRED;
if (pg != NULL) { /* memory-space */
- pvh = &pg->mdpage;
entry |= PG_C; /* always cached */
/* Modified/reference tracking */
if (flags & PROT_WRITE) {
entry |= PG_V | PG_D;
- pvh->pvh_flags |= PVH_MODIFIED | PVH_REFERENCED;
+ atomic_setbits_int(&pg->pg_flags,
+ PG_PMAP_MOD | PG_PMAP_REF);
} else if (flags & PROT_MASK) {
entry |= PG_V;
- pvh->pvh_flags |= PVH_REFERENCED;
+ atomic_setbits_int(&pg->pg_flags, PG_PMAP_REF);
}
/* Protection */
- if ((prot & PROT_WRITE) && (pvh->pvh_flags & PVH_MODIFIED)) {
+ if ((prot & PROT_WRITE) && (pg->pg_flags & PG_PMAP_MOD)) {
if (kva)
entry |= PG_PR_KRW | PG_SH;
else
if (pv->pv_pmap == pmap && pv->pv_va == vaddr) {
if (SH_HAS_VIRTUAL_ALIAS ||
(SH_HAS_WRITEBACK_CACHE &&
- (pg->mdpage.pvh_flags & PVH_MODIFIED))) {
+ (pg->pg_flags & PG_PMAP_MOD))) {
/*
* Always use index ops. since I don't want to
* worry about address space.
boolean_t
pmap_is_referenced(struct vm_page *pg)
{
- return ((pg->mdpage.pvh_flags & PVH_REFERENCED) ? TRUE : FALSE);
+ return ((pg->pg_flags & PG_PMAP_REF) ? TRUE : FALSE);
}
boolean_t
vaddr_t va;
int s;
- if ((pg->mdpage.pvh_flags & PVH_REFERENCED) == 0)
+ if ((pg->pg_flags & PG_PMAP_REF) == 0)
return (FALSE);
- pg->mdpage.pvh_flags &= ~PVH_REFERENCED;
+ atomic_clearbits_int(&pg->pg_flags, PG_PMAP_REF);
s = splvm();
/* Restart reference bit emulation */
boolean_t
pmap_is_modified(struct vm_page *pg)
{
- return ((pg->mdpage.pvh_flags & PVH_MODIFIED) ? TRUE : FALSE);
+ return ((pg->pg_flags & PG_PMAP_MOD) ? TRUE : FALSE);
}
boolean_t
vaddr_t va;
int s;
- modified = pvh->pvh_flags & PVH_MODIFIED;
+ modified = pg->pg_flags & PG_PMAP_MOD;
if (!modified)
return (FALSE);
- pvh->pvh_flags &= ~PVH_MODIFIED;
+ atomic_clearbits_int(&pg->pg_flags, PG_PMAP_MOD);
s = splvm();
if (SLIST_EMPTY(&pvh->pvh_head)) {/* no map on this page */
/* Emulate reference/modified tracking for managed page. */
if (flags != 0 && (pg = PHYS_TO_VM_PAGE(entry & PG_PPN)) != NULL) {
- if (flags & PVH_REFERENCED) {
- pg->mdpage.pvh_flags |= PVH_REFERENCED;
+ if (flags & PG_PMAP_REF)
entry |= PG_V;
- }
- if (flags & PVH_MODIFIED) {
- pg->mdpage.pvh_flags |= PVH_MODIFIED;
+ if (flags & PG_PMAP_MOD)
entry |= PG_D;
- }
+ atomic_setbits_int(&pg->pg_flags, flags);
*pte = entry;
}
-/* $OpenBSD: trap.c,v 1.50 2021/12/23 18:50:32 guenther Exp $ */
+/* $OpenBSD: trap.c,v 1.51 2022/09/12 19:33:34 miod Exp $ */
/* $NetBSD: exception.c,v 1.32 2006/09/04 23:57:52 uwe Exp $ */
/* $NetBSD: syscall.c,v 1.6 2006/03/07 07:21:50 thorpej Exp $ */
switch (tf->tf_expevt) {
case EXPEVT_TLB_MISS_LD:
- track = PVH_REFERENCED;
+ track = PG_PMAP_REF;
access_type = PROT_READ;
break;
case EXPEVT_TLB_MISS_ST:
- track = PVH_REFERENCED;
+ track = PG_PMAP_REF;
access_type = PROT_WRITE;
break;
case EXPEVT_TLB_MOD:
- track = PVH_REFERENCED | PVH_MODIFIED;
+ track = PG_PMAP_REF | PG_PMAP_MOD;
access_type = PROT_WRITE;
break;
case EXPEVT_TLB_PROT_LD: