Index: lib/libc/sys/mincore.2 =================================================================== --- lib/libc/sys/mincore.2 +++ lib/libc/sys/mincore.2 @@ -28,7 +28,7 @@ .\" @(#)mincore.2 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd January 7, 2019 +.Dd August 23, 2020 .Dt MINCORE 2 .Os .Sh NAME @@ -73,10 +73,20 @@ Page has been referenced. .It Dv MINCORE_MODIFIED_OTHER Page has been modified. +.It Dv MINCORE_PSIND(i) +Page is part of a large +.Pq Dq super +page with size given by index +.Dv i +in the array returned by +.Xr getpagesizes 3 . .It Dv MINCORE_SUPER Page is part of a large .Pq Dq super page. +In particular, one of the +.Dv MINCORE_PSIND() +values is set. .El .Pp The information returned by @@ -122,7 +132,8 @@ .Xr mprotect 2 , .Xr msync 2 , .Xr munmap 2 , -.Xr getpagesize 3 +.Xr getpagesize 3 , +.Xr getpagesizes 3 .Sh HISTORY The .Fn mincore Index: sys/amd64/amd64/pmap.c =================================================================== --- sys/amd64/amd64/pmap.c +++ sys/amd64/amd64/pmap.c @@ -9325,16 +9325,15 @@ pte = *pdpe; pa = ((pte & PG_PS_PDP_FRAME) | (addr & PDPMASK)) & PG_FRAME; - val = MINCORE_SUPER; + val = MINCORE_PSIND(2); } else { pdep = pmap_pde(pmap, addr); if (pdep != NULL && (*pdep & PG_V) != 0) { if ((*pdep & PG_PS) != 0) { pte = *pdep; - /* Compute the physical address of the 4KB page. */ pa = ((pte & PG_PS_FRAME) | (addr & PDRMASK)) & PG_FRAME; - val = MINCORE_SUPER; + val = MINCORE_PSIND(1); } else { pte = *pmap_pde_to_pte(pdep, addr); pa = pte & PG_FRAME; Index: sys/arm/arm/pmap-v6.c =================================================================== --- sys/arm/arm/pmap-v6.c +++ sys/arm/arm/pmap-v6.c @@ -6237,7 +6237,7 @@ if (pte1_is_section(pte1)) { pa = trunc_page(pte1_pa(pte1) | (addr & PTE1_OFFSET)); managed = pte1_is_managed(pte1); - val = MINCORE_SUPER | MINCORE_INCORE; + val = MINCORE_PSIND(1) | MINCORE_INCORE; if (pte1_is_dirty(pte1)) val |= MINCORE_MODIFIED | MINCORE_MODIFIED_OTHER; if (pte1 & PTE1_A) Index: sys/arm64/arm64/pmap.c =================================================================== --- sys/arm64/arm64/pmap.c +++ sys/arm64/arm64/pmap.c @@ -5946,7 +5946,7 @@ managed = (tpte & ATTR_SW_MANAGED) != 0; val = MINCORE_INCORE; if (lvl != 3) - val |= MINCORE_SUPER; + val |= MINCORE_PSIND(3 - lvl); if ((managed && pmap_pte_dirty(pmap, tpte)) || (!managed && (tpte & ATTR_S1_AP_RW_BIT) == ATTR_S1_AP(ATTR_S1_AP_RW))) val |= MINCORE_MODIFIED | MINCORE_MODIFIED_OTHER; Index: sys/i386/i386/pmap.c =================================================================== --- sys/i386/i386/pmap.c +++ sys/i386/i386/pmap.c @@ -5761,7 +5761,7 @@ /* Compute the physical address of the 4KB page. */ pa = ((pde & PG_PS_FRAME) | (addr & PDRMASK)) & PG_FRAME; - val = MINCORE_SUPER; + val = MINCORE_PSIND(1); } else { pte = pmap_pte_ufast(pmap, addr, pde); pa = pte & PG_FRAME; Index: sys/powerpc/aim/mmu_radix.c =================================================================== --- sys/powerpc/aim/mmu_radix.c +++ sys/powerpc/aim/mmu_radix.c @@ -5704,7 +5704,7 @@ /* Compute the physical address of the 4KB page. */ pa = ((*l3ep & PG_PS_FRAME) | (addr & L3_PAGE_MASK)) & PG_FRAME; - val = MINCORE_SUPER; + val = MINCORE_PSIND(1); } else { pte = *pmap_l3e_to_pte(l3ep, addr); pa = pte & PG_FRAME; Index: sys/riscv/riscv/pmap.c =================================================================== --- sys/riscv/riscv/pmap.c +++ sys/riscv/riscv/pmap.c @@ -4221,7 +4221,7 @@ if (l2 != NULL && ((tpte = pmap_load(l2)) & PTE_V) != 0) { if ((tpte & PTE_RWX) != 0) { pa = PTE_TO_PHYS(tpte) | (addr & L2_OFFSET); - val = MINCORE_INCORE | MINCORE_SUPER; + val = MINCORE_INCORE | MINCORE_PSIND(1); } else { l3 = pmap_l2_to_l3(l2, addr); tpte = pmap_load(l3); Index: sys/sys/mman.h =================================================================== --- sys/sys/mman.h +++ sys/sys/mman.h @@ -179,7 +179,12 @@ #define MINCORE_MODIFIED 0x4 /* Page has been modified by us */ #define MINCORE_REFERENCED_OTHER 0x8 /* Page has been referenced */ #define MINCORE_MODIFIED_OTHER 0x10 /* Page has been modified */ -#define MINCORE_SUPER 0x20 /* Page is a "super" page */ +#define MINCORE_SUPER 0x60 /* Page is a "super" page */ +#define MINCORE_PSIND(i) (((i) << 5) & MINCORE_SUPER) /* Page size */ + +#if defined(_KERNEL) && defined(MAXPAGESIZES) +_Static_assert(MAXPAGESIZES <= 4, "MINCORE_SUPER too narrow"); +#endif /* * Anonymous object constant for shm_open().