Thu Mar 5 02:14:53 2020 UTC ()
Retire tlbpid_t (u_short):

- PID (ctx, ASID) is 8-bit length, not half word.
- For struct pmap, no need to use integer types smaller than word as
  pm_ctx because of alignment.
- For ppc4xx_tlb_enter(), we need word-length storage for pid (and msr).

XXX
Better to rewrite pmap module with more suggestive integer types rather
than char, int, long, and so on.


(rin)
diff -r1.83 -r1.84 src/sys/arch/powerpc/ibm4xx/pmap.c
diff -r1.19 -r1.20 src/sys/arch/powerpc/include/ibm4xx/pmap.h
diff -r1.5 -r1.6 src/sys/arch/powerpc/include/ibm4xx/tlb.h

cvs diff -r1.83 -r1.84 src/sys/arch/powerpc/ibm4xx/pmap.c (expand / switch to unified diff)

--- src/sys/arch/powerpc/ibm4xx/pmap.c 2020/03/05 01:35:00 1.83
+++ src/sys/arch/powerpc/ibm4xx/pmap.c 2020/03/05 02:14:52 1.84
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pmap.c,v 1.83 2020/03/05 01:35:00 rin Exp $ */ 1/* $NetBSD: pmap.c,v 1.84 2020/03/05 02:14:52 rin Exp $ */
2 2
3/* 3/*
4 * Copyright 2001 Wasabi Systems, Inc. 4 * Copyright 2001 Wasabi Systems, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc. 7 * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -57,27 +57,27 @@ @@ -57,27 +57,27 @@
57 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 57 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
58 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 58 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
59 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 59 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
60 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 60 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 61 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
62 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 62 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
63 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 63 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
64 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 64 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
65 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 65 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
66 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 66 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
67 */ 67 */
68 68
69#include <sys/cdefs.h> 69#include <sys/cdefs.h>
70__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.83 2020/03/05 01:35:00 rin Exp $"); 70__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.84 2020/03/05 02:14:52 rin Exp $");
71 71
72#include <sys/param.h> 72#include <sys/param.h>
73#include <sys/cpu.h> 73#include <sys/cpu.h>
74#include <sys/device.h> 74#include <sys/device.h>
75#include <sys/kmem.h> 75#include <sys/kmem.h>
76#include <sys/pool.h> 76#include <sys/pool.h>
77#include <sys/proc.h> 77#include <sys/proc.h>
78#include <sys/queue.h> 78#include <sys/queue.h>
79#include <sys/systm.h> 79#include <sys/systm.h>
80 80
81#include <uvm/uvm.h> 81#include <uvm/uvm.h>
82 82
83#include <machine/powerpc.h> 83#include <machine/powerpc.h>
@@ -1283,28 +1283,27 @@ ppc4xx_tlb_find_victim(void) @@ -1283,28 +1283,27 @@ ppc4xx_tlb_find_victim(void)
1283 /* Found it! */ 1283 /* Found it! */
1284 return (tlbnext); 1284 return (tlbnext);
1285 } 1285 }
1286 } else { 1286 } else {
1287 tlb_info[tlbnext].ti_flags = (flags & ~TLBF_REF); 1287 tlb_info[tlbnext].ti_flags = (flags & ~TLBF_REF);
1288 } 1288 }
1289 } 1289 }
1290} 1290}
1291 1291
1292void 1292void
1293ppc4xx_tlb_enter(int ctx, vaddr_t va, u_int pte) 1293ppc4xx_tlb_enter(int ctx, vaddr_t va, u_int pte)
1294{ 1294{
1295 u_long th, tl, idx; 1295 u_long th, tl, idx;
1296 tlbpid_t pid; 1296 int msr, pid;
1297 u_short msr; 
1298 paddr_t pa; 1297 paddr_t pa;
1299 int sz; 1298 int sz;
1300 1299
1301 tlbenter_ev.ev_count++; 1300 tlbenter_ev.ev_count++;
1302 1301
1303 sz = (pte & TTE_SZ_MASK) >> TTE_SZ_SHIFT; 1302 sz = (pte & TTE_SZ_MASK) >> TTE_SZ_SHIFT;
1304 pa = (pte & TTE_RPN_MASK(sz)); 1303 pa = (pte & TTE_RPN_MASK(sz));
1305 th = (va & TLB_EPN_MASK) | (sz << TLB_SIZE_SHFT) | TLB_VALID; 1304 th = (va & TLB_EPN_MASK) | (sz << TLB_SIZE_SHFT) | TLB_VALID;
1306 tl = (pte & ~TLB_RPN_MASK) | pa; 1305 tl = (pte & ~TLB_RPN_MASK) | pa;
1307 tl |= ppc4xx_tlbflags(va, pa); 1306 tl |= ppc4xx_tlbflags(va, pa);
1308 1307
1309 idx = ppc4xx_tlb_find_victim(); 1308 idx = ppc4xx_tlb_find_victim();
1310 1309

cvs diff -r1.19 -r1.20 src/sys/arch/powerpc/include/ibm4xx/pmap.h (expand / switch to unified diff)

--- src/sys/arch/powerpc/include/ibm4xx/pmap.h 2019/07/17 08:39:03 1.19
+++ src/sys/arch/powerpc/include/ibm4xx/pmap.h 2020/03/05 02:14:53 1.20
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pmap.h,v 1.19 2019/07/17 08:39:03 skrll Exp $ */ 1/* $NetBSD: pmap.h,v 1.20 2020/03/05 02:14:53 rin Exp $ */
2 2
3/* 3/*
4 * Copyright 2001 Wasabi Systems, Inc. 4 * Copyright 2001 Wasabi Systems, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc. 7 * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -133,27 +133,27 @@ @@ -133,27 +133,27 @@
133 133
134 134
135/*  135/*
136 * Extra flags to pass to pmap_enter() -- make sure they don't conflict 136 * Extra flags to pass to pmap_enter() -- make sure they don't conflict
137 * w/PMAP_CANFAIL or PMAP_WIRED 137 * w/PMAP_CANFAIL or PMAP_WIRED
138 */ 138 */
139#define PME_NOCACHE 0x1000000 139#define PME_NOCACHE 0x1000000
140#define PME_WRITETHROUG 0x2000000 140#define PME_WRITETHROUG 0x2000000
141 141
142/* 142/*
143 * Pmap stuff 143 * Pmap stuff
144 */ 144 */
145struct pmap { 145struct pmap {
146 volatile tlbpid_t pm_ctx; /* PID to identify PMAP's entries in TLB */ 146 volatile int pm_ctx; /* PID to identify PMAP's entries in TLB */
147 int pm_refs; /* ref count */ 147 int pm_refs; /* ref count */
148 struct pmap_statistics pm_stats; /* pmap statistics */ 148 struct pmap_statistics pm_stats; /* pmap statistics */
149 volatile u_int *pm_ptbl[STSZ]; /* Array of 64 pointers to page tables. */ 149 volatile u_int *pm_ptbl[STSZ]; /* Array of 64 pointers to page tables. */
150}; 150};
151 151
152#ifdef _KERNEL 152#ifdef _KERNEL
153#define PMAP_GROWKERNEL 153#define PMAP_GROWKERNEL
154 154
155#define PMAP_ATTR_REF 0x1 155#define PMAP_ATTR_REF 0x1
156#define PMAP_ATTR_CHG 0x2 156#define PMAP_ATTR_CHG 0x2
157 157
158#define pmap_clear_modify(pg) (pmap_check_attr((pg), PMAP_ATTR_CHG, 1)) 158#define pmap_clear_modify(pg) (pmap_check_attr((pg), PMAP_ATTR_CHG, 1))
159#define pmap_clear_reference(pg)(pmap_check_attr((pg), PMAP_ATTR_REF, 1)) 159#define pmap_clear_reference(pg)(pmap_check_attr((pg), PMAP_ATTR_REF, 1))

cvs diff -r1.5 -r1.6 src/sys/arch/powerpc/include/ibm4xx/tlb.h (expand / switch to unified diff)

--- src/sys/arch/powerpc/include/ibm4xx/tlb.h 2018/04/19 21:50:07 1.5
+++ src/sys/arch/powerpc/include/ibm4xx/tlb.h 2020/03/05 02:14:53 1.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tlb.h,v 1.5 2018/04/19 21:50:07 christos Exp $ */ 1/* $NetBSD: tlb.h,v 1.6 2020/03/05 02:14:53 rin Exp $ */
2 2
3/* 3/*
4 * Copyright 2001 Wasabi Systems, Inc. 4 * Copyright 2001 Wasabi Systems, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc. 7 * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -79,27 +79,26 @@ @@ -79,27 +79,26 @@
79#define TLB_G 0x00000001 /* Guarded */ 79#define TLB_G 0x00000001 /* Guarded */
80 80
81#define TLB_ZONE(z) (((z) << TLB_ZSEL_SHFT) & TLB_ZSEL_MASK) 81#define TLB_ZONE(z) (((z) << TLB_ZSEL_SHFT) & TLB_ZSEL_MASK)
82 82
83/* We only need two zones for kernel and user-level processes */ 83/* We only need two zones for kernel and user-level processes */
84#define TLB_SU_ZONE 0 /* Kernel-only access controlled permission bits in TLB */ 84#define TLB_SU_ZONE 0 /* Kernel-only access controlled permission bits in TLB */
85#define TLB_U_ZONE 1 /* Access always controlled by permission bits in TLB entry */ 85#define TLB_U_ZONE 1 /* Access always controlled by permission bits in TLB entry */
86 86
87#define TLB_HI(epn,size,flags) (((epn)&TLB_EPN_MASK)|(((size)<<TLB_SIZE_SHFT)&TLB_SIZE_MASK)|(flags)) 87#define TLB_HI(epn,size,flags) (((epn)&TLB_EPN_MASK)|(((size)<<TLB_SIZE_SHFT)&TLB_SIZE_MASK)|(flags))
88#define TLB_LO(rpn,zone,flags) (((rpn)&TLB_RPN_MASK)|(((zone)<<TLB_ZSEL_SHFT)&TLB_ZSEL_MASK)|(flags)) 88#define TLB_LO(rpn,zone,flags) (((rpn)&TLB_RPN_MASK)|(((zone)<<TLB_ZSEL_SHFT)&TLB_ZSEL_MASK)|(flags))
89 89
90#ifndef _LOCORE 90#ifndef _LOCORE
91 91
92typedef u_short tlbpid_t; 
93typedef struct tlb_s { 92typedef struct tlb_s {
94 u_int tlb_hi; 93 u_int tlb_hi;
95 u_int tlb_lo; 94 u_int tlb_lo;
96} tlb_t; 95} tlb_t;
97 96
98struct pmap; 97struct pmap;
99 98
100void ppc4xx_tlb_enter(int, vaddr_t, u_int); 99void ppc4xx_tlb_enter(int, vaddr_t, u_int);
101void ppc4xx_tlb_flush(vaddr_t, int); 100void ppc4xx_tlb_flush(vaddr_t, int);
102void ppc4xx_tlb_flush_all(void); 101void ppc4xx_tlb_flush_all(void);
103void ppc4xx_tlb_init(void); 102void ppc4xx_tlb_init(void);
104int ppc4xx_tlb_new_pid(struct pmap *); 103int ppc4xx_tlb_new_pid(struct pmap *);
105void ppc4xx_tlb_reserve(paddr_t, vaddr_t, size_t, int); 104void ppc4xx_tlb_reserve(paddr_t, vaddr_t, size_t, int);