-/* $OpenBSD: pmap.c,v 1.87 2021/03/11 11:16:54 jsg Exp $ */
+/* $OpenBSD: pmap.c,v 1.88 2022/09/12 19:35:20 miod Exp $ */
/* $NetBSD: pmap.c,v 1.154 2000/12/07 22:18:55 thorpej Exp $ */
/*-
int pmap_physpage_addref(void *);
int pmap_physpage_delref(void *);
+/* pmap_physpage_alloc() page usage */
+#define PGU_NORMAL 0 /* free or normal use */
+#define PGU_PVENT 1 /* PV entries */
+#define PGU_L1PT 2 /* level 1 page table */
+#define PGU_L2PT 3 /* level 2 page table */
+#define PGU_L3PT 4 /* level 3 page table */
+
/*
* PMAP_ISACTIVE{,_TEST}:
*
panic("pmap_enter: access type exceeds prot");
#endif
if (flags & PROT_WRITE)
- pg->mdpage.pvh_attrs |= (PGA_REFERENCED|PGA_MODIFIED);
+ atomic_setbits_int(&pg->pg_flags,
+ PG_PMAP_REF | PG_PMAP_MOD);
else if (flags & PROT_MASK)
- pg->mdpage.pvh_attrs |= PGA_REFERENCED;
- attrs = pg->mdpage.pvh_attrs;
+ atomic_setbits_int(&pg->pg_flags, PG_PMAP_REF);
/*
* Set up referenced/modified emulation for new mapping.
*/
- if ((attrs & PGA_REFERENCED) == 0)
+ attrs = pg->pg_flags;
+ if ((attrs & PG_PMAP_REF) == 0)
npte |= PG_FOR | PG_FOW | PG_FOE;
- else if ((attrs & PGA_MODIFIED) == 0)
+ else if ((attrs & PG_PMAP_MOD) == 0)
npte |= PG_FOW;
/*
#endif
mtx_enter(&pg->mdpage.pvh_mtx);
- if (pg->mdpage.pvh_attrs & PGA_MODIFIED) {
+ if (pg->pg_flags & PG_PMAP_MOD) {
rv = TRUE;
pmap_changebit(pg, PG_FOW, ~0, cpu_id);
- pg->mdpage.pvh_attrs &= ~PGA_MODIFIED;
+ atomic_clearbits_int(&pg->pg_flags, PG_PMAP_MOD);
}
mtx_leave(&pg->mdpage.pvh_mtx);
#endif
mtx_enter(&pg->mdpage.pvh_mtx);
- if (pg->mdpage.pvh_attrs & PGA_REFERENCED) {
+ if (pg->pg_flags & PG_PMAP_REF) {
rv = TRUE;
pmap_changebit(pg, PG_FOR | PG_FOW | PG_FOE, ~0, cpu_id);
- pg->mdpage.pvh_attrs &= ~PGA_REFERENCED;
+ atomic_clearbits_int(&pg->pg_flags, PG_PMAP_REF);
}
mtx_leave(&pg->mdpage.pvh_mtx);
{
boolean_t rv;
- rv = ((pg->mdpage.pvh_attrs & PGA_REFERENCED) != 0);
+ rv = ((pg->pg_flags & PG_PMAP_REF) != 0);
#ifdef DEBUG
if (pmapdebug & PDB_FOLLOW) {
printf("pmap_is_referenced(%p) -> %c\n", pg, "FT"[rv]);
{
boolean_t rv;
- rv = ((pg->mdpage.pvh_attrs & PGA_MODIFIED) != 0);
+ rv = ((pg->pg_flags & PG_PMAP_MOD) != 0);
#ifdef DEBUG
if (pmapdebug & PDB_FOLLOW) {
printf("pmap_is_modified(%p) -> %c\n", pg, "FT"[rv]);
mtx_enter(&pg->mdpage.pvh_mtx);
if (type == ALPHA_MMCSR_FOW) {
- pg->mdpage.pvh_attrs |= (PGA_REFERENCED|PGA_MODIFIED);
+ atomic_setbits_int(&pg->pg_flags, PG_PMAP_REF | PG_PMAP_MOD);
faultoff = PG_FOR | PG_FOW;
} else {
- pg->mdpage.pvh_attrs |= PGA_REFERENCED;
+ atomic_setbits_int(&pg->pg_flags, PG_PMAP_REF);
faultoff = PG_FOR;
if (exec) {
faultoff |= PG_FOE;
pg = PHYS_TO_VM_PAGE(pa);
- printf("pa 0x%lx (attrs = 0x%x):\n", pa, pg->mdpage.pvh_attrs);
+ printf("pa 0x%lx (attrs = 0x%x):\n",
+ pa, pg->pg_flags & (PG_PMAP_REF | PG_PMAP_MOD));
mtx_enter(&pg->mdpage.pvh_mtx);
for (pv = pg->mdpage.pvh_list; pv != NULL; pv = pv->pv_next)
printf(" pmap %p, va 0x%lx\n",
-/* $OpenBSD: pmap.h,v 1.41 2022/09/10 20:35:28 miod Exp $ */
+/* $OpenBSD: pmap.h,v 1.42 2022/09/12 19:35:20 miod Exp $ */
/* $NetBSD: pmap.h,v 1.37 2000/11/19 03:16:35 thorpej Exp $ */
/*-
pt_entry_t *pv_pte; /* PTE that maps the VA */
} *pv_entry_t;
-/* pvh_attrs */
-#define PGA_MODIFIED 0x01 /* modified */
-#define PGA_REFERENCED 0x02 /* referenced */
-
-/* pvh_usage */
-#define PGU_NORMAL 0 /* free or normal use */
-#define PGU_PVENT 1 /* PV entries */
-#define PGU_L1PT 2 /* level 1 page table */
-#define PGU_L2PT 3 /* level 2 page table */
-#define PGU_L3PT 4 /* level 3 page table */
-
-#define PGU_ISPTPAGE(pgu) ((pgu) >= PGU_L1PT)
+/* pg_flags extra flags */
+#define PG_PMAP_MOD PG_PMAP0 /* modified */
+#define PG_PMAP_REF PG_PMAP1 /* referenced */
#if defined(NEW_SCC_DRIVER)
#if defined(DEC_KN8AE)
struct vm_page_md {
struct mutex pvh_mtx;
struct pv_entry *pvh_list; /* pv entry list */
- int pvh_attrs; /* page attributes */
};
#define VM_MDPAGE_INIT(pg) \
do { \
mtx_init(&(pg)->mdpage.pvh_mtx, IPL_VM); \
(pg)->mdpage.pvh_list = NULL; \
- (pg)->mdpage.pvh_attrs = 0; \
} while (0)
#endif /* _PMAP_MACHINE_ */