Skip to content

Commit 8ecc0aa

Browse files
committed
mincore: expose capability presence information
Now that we're tracking capdirty, it might be informative to show userland. Once upon a time, we thought this might be part of the revoker implementation, but now we think it's just diagnostics.
1 parent 772196a commit 8ecc0aa

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

sys/mips/mips/pmap.c

+2
Original file line numberDiff line numberDiff line change
@@ -3365,6 +3365,8 @@ pmap_mincore(pmap_t pmap, vm_offset_t addr, vm_paddr_t *pap)
33653365
val = MINCORE_INCORE;
33663366
if (pte_test(&pte, PTE_D))
33673367
val |= MINCORE_MODIFIED | MINCORE_MODIFIED_OTHER;
3368+
if (!pte_test(&pte, PTE_SC))
3369+
val |= MINCORE_CAPDIRTY;
33683370
pa = TLBLO_PTE_TO_PA(pte);
33693371
if (pte_test(&pte, PTE_MANAGED)) {
33703372
/*

sys/sys/mman.h

+1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
#define MINCORE_REFERENCED_OTHER 0x8 /* Page has been referenced */
198198
#define MINCORE_MODIFIED_OTHER 0x10 /* Page has been modified */
199199
#define MINCORE_SUPER 0x20 /* Page is a "super" page */
200+
#define MINCORE_CAPDIRTY 0x40 /* Page may contain capabilities */
200201

201202
/*
202203
* Anonymous object constant for shm_open().

sys/vm/vm_mmap.c

+14
Original file line numberDiff line numberDiff line change
@@ -1459,6 +1459,20 @@ kern_mincore(struct thread *td, uintptr_t addr0, size_t len,
14591459
pmap_is_referenced(m) ||
14601460
(m->a.flags & PGA_REFERENCED) != 0)
14611461
mincoreinfo |= MINCORE_REFERENCED_OTHER;
1462+
1463+
/*
1464+
* The pmap may have told us that this
1465+
* particular mapping is already capdirty,
1466+
* and if so don't bother with the more
1467+
* elaborate probes and especially not with
1468+
* the expensive pmap_is_capdirty.
1469+
*/
1470+
if ((mincoreinfo & MINCORE_CAPDIRTY) == 0 &&
1471+
((m->a.flags & PGA_CAPDIRTY) != 0 ||
1472+
(m->flags & VPO_FASTCAPDIRTY) != 0 ||
1473+
pmap_is_capdirty(m) ||
1474+
(m->a.flags & PGA_CAPDIRTY) != 0))
1475+
mincoreinfo |= MINCORE_CAPDIRTY;
14621476
}
14631477
if (object != NULL)
14641478
VM_OBJECT_WUNLOCK(object);

0 commit comments

Comments
 (0)