Re: sys/powerpc64: encode PTCR PATS correctly

George Koehler <[email protected]> Sat, 18 Jul 2026 00:29:15 -0400
Newsgroups gmane.os.openbsd.tech
Message-ID <[email protected]>
On Mon, 13 Jul 2026 15:11:33 +0200
Kirill A. Korinsky <[email protected]> wrote:

ok gkoehler@

Your diff works on my POWER9.  Our partition table is 64 kilobytes,
but before diff, we wrongly set its size (PATS field in PCTR) to 128
kilobytes.  The POWER9 manual, 4.9.4 Partition Table Control Register
says, "The POWER9 processor core, however, ignores the value in the
PATS field and only supports a 64 KB partition table."  My POWER9 had
ignored the wrong 128 and used 64, so I never noticed the problem.

The diff is correct, as ffs(PATMEMSZ) is 17 and the diff sets PATSIZE
to 4; the size will be 2 ** (12 + 4) bytes == 64 kilobytes.

--gkoehler

> Index: sys/arch/powerpc64/powerpc64/pmap.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/powerpc64/powerpc64/pmap.c,v
> diff -u -p -r1.66 pmap.c
> --- sys/arch/powerpc64/powerpc64/pmap.c	21 Aug 2025 00:10:21 -0000	1.66
> +++ sys/arch/powerpc64/powerpc64/pmap.c	13 Jul 2026 13:10:39 -0000
> @@ -124,7 +124,7 @@ uint64_t pmap_ptab_mask;
>  struct pate *pmap_pat;
>  
>  #define PATMEMSZ	(64 * 1024)
> -#define PATSIZE		(ffs(PATMEMSZ) - 12)
> +#define PATSIZE		(ffs(PATMEMSZ) - 1 - 12)
>  
>  struct pte_desc {
>  	/* Linked list of phys -> virt entries */
> 
> 
> -- 
> wbr, Kirill