diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2021-10-12 18:06:16 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2021-10-12 18:06:16 +0000 |
commit | de50b3320839fde09f3b1445c58ea84ddf50b650 (patch) | |
tree | 06e5a3e4667165f7fd14f9926f18b4431df85b9a /sys/arch/powerpc64 | |
parent | c5b81f0c1acee501cd3aa265432cf0314d0edf62 (diff) |
Add (minimal) accounting for wired pages in userland pmaps.
This enables enforcing of RLIMIT_MEMLOCK on powerpc64.
ok mpi@
Diffstat (limited to 'sys/arch/powerpc64')
-rw-r--r-- | sys/arch/powerpc64/include/pmap.h | 3 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/pmap.c | 26 |
2 files changed, 27 insertions, 2 deletions
diff --git a/sys/arch/powerpc64/include/pmap.h b/sys/arch/powerpc64/include/pmap.h index bb6c29dd926..c7f4c9e257b 100644 --- a/sys/arch/powerpc64/include/pmap.h +++ b/sys/arch/powerpc64/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.17 2021/05/30 15:08:08 visa Exp $ */ +/* $OpenBSD: pmap.h,v 1.18 2021/10/12 18:06:15 kettenis Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> @@ -62,6 +62,7 @@ extern struct pmap kernel_pmap_store; #define pmap_kernel() (&kernel_pmap_store) #define pmap_resident_count(pm) ((pm)->pm_stats.resident_count) +#define pmap_wired_count(pm) ((pm)->pm_stats.wired_count) #define pmap_unuse_final(p) #define pmap_remove_holes(vm) diff --git a/sys/arch/powerpc64/powerpc64/pmap.c b/sys/arch/powerpc64/powerpc64/pmap.c index f18c919049e..9d19c54295a 100644 --- a/sys/arch/powerpc64/powerpc64/pmap.c +++ b/sys/arch/powerpc64/powerpc64/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.56 2021/05/11 18:21:12 kettenis Exp $ */ +/* $OpenBSD: pmap.c,v 1.57 2021/10/12 18:06:15 kettenis Exp $ */ /* * Copyright (c) 2015 Martin Pieuchot @@ -218,6 +218,12 @@ PTED_MANAGED(struct pte_desc *pted) } static inline int +PTED_WIRED(struct pte_desc *pted) +{ + return !!(pted->pted_va & PTED_VA_WIRED_M); +} + +static inline int PTED_VALID(struct pte_desc *pted) { return !!(pted->pted_pte.pte_hi & PTE_VALID); @@ -858,6 +864,11 @@ pmap_remove_pted(pmap_t pm, struct pte_desc *pted) pm->pm_stats.resident_count--; + if (PTED_WIRED(pted)) { + pm->pm_stats.wired_count--; + pted->pted_va &= ~PTED_VA_WIRED_M; + } + PMAP_HASH_LOCK(s); if ((pte = pmap_ptedinhash(pted)) != NULL) pte_zap(pte, pted); @@ -1085,6 +1096,10 @@ pmap_enter(pmap_t pm, vaddr_t va, paddr_t pa, vm_prot_t prot, int flags) prot &= ~PROT_WRITE; pmap_fill_pte(pm, va, pa, pted, prot, cache); + if (flags & PMAP_WIRED) { + pted->pted_va |= PTED_VA_WIRED_M; + pm->pm_stats.wired_count++; + } if (pg != NULL) { pmap_enter_pv(pted, pg); /* only managed mem */ @@ -1438,6 +1453,15 @@ pmap_deactivate(struct proc *p) void pmap_unwire(pmap_t pm, vaddr_t va) { + struct pte_desc *pted; + + PMAP_VP_LOCK(pm); + pted = pmap_vp_lookup(pm, va); + if (pted && PTED_WIRED(pted)) { + pm->pm_stats.wired_count--; + pted->pted_va &= ~PTED_VA_WIRED_M; + } + PMAP_VP_UNLOCK(pm); } void |