6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #pragma ident "%Z%%M% %I% %E% SMI"
27
28 #include <sys/types.h>
29 #include <sys/systm.h>
30 #include <sys/archsystm.h>
31 #include <sys/machsystm.h>
32 #include <sys/t_lock.h>
33 #include <sys/vmem.h>
34 #include <sys/mman.h>
35 #include <sys/vm.h>
36 #include <sys/cpu.h>
37 #include <sys/cmn_err.h>
38 #include <sys/cpuvar.h>
39 #include <sys/atomic.h>
40 #include <vm/as.h>
41 #include <vm/hat.h>
42 #include <vm/as.h>
43 #include <vm/page.h>
44 #include <vm/seg.h>
45 #include <vm/seg_kmem.h>
46 #include <vm/seg_kpm.h>
47 #include <vm/hat_sfmmu.h>
172 color = addr_to_vcolor(mmu_ptob(pp->p_pagenum));
173 }
174 }
175
176 } else {
177 /*
178 * For physical caches, we can pick any address we want.
179 */
180 color = 0;
181 }
182
183 start = color;
184 do {
185 for (nset = 0; nset < nsets; nset++) {
186 index = clsettoarray(color, nset);
187 va = ppmap_vaddrs[index];
188 if (va != NULL) {
189 #ifdef PPDEBUG
190 align_hits[color]++;
191 #endif /* PPDEBUG */
192 if (casptr(&ppmap_vaddrs[index],
193 va, NULL) == va) {
194 hat_memload(kas.a_hat, va, pp,
195 vprot | HAT_NOSYNC,
196 HAT_LOAD_LOCK);
197 return (va);
198 }
199 }
200 }
201 /*
202 * first pick didn't succeed, try another
203 */
204 if (++color == ppmap_pages)
205 color = 0;
206 } while (color != start);
207
208 #ifdef PPDEBUG
209 ppalloc_noslot++;
210 #endif /* PPDEBUG */
211
212 /*
302 if ((vcolor == -1) &&
303 (pp_consistent_coloring & strict_flag))
304 return (NULL);
305 /* else keep the current vcolor of the page */
306 } else {
307 vcolor = -1;
308 }
309
310 if (vcolor != -1) {
311 va += MMU_PAGESIZE * vcolor;
312 start = vcolor;
313 stride = ppmap_pages; /* number of colors */
314 myslot += vcolor;
315 } else {
316 start = 0;
317 stride = 1;
318 }
319
320 for (i = start; i < pp_slots; i += stride) {
321 if (*myslot == NULL) {
322 if (casptr(myslot, NULL, va) == NULL)
323 break;
324 }
325 myslot += stride;
326 va += MMU_PAGESIZE * stride;
327 }
328
329 if (i >= pp_slots) {
330 PP_STAT_ADD(ploadfail);
331 return (NULL);
332 }
333
334 ASSERT(vcolor == -1 || addr_to_vcolor(va) == vcolor);
335
336 /*
337 * Now we have a slot we can use, make the tte.
338 */
339 tte.tte_inthi = TTE_VALID_INT | TTE_PFN_INTHI(pp->p_pagenum);
340 tte.tte_intlo = TTE_PFN_INTLO(pp->p_pagenum) | TTE_CP_INT |
341 TTE_CV_INT | TTE_PRIV_INT | TTE_LCK_INT | prot;
342
|
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #include <sys/types.h>
27 #include <sys/systm.h>
28 #include <sys/archsystm.h>
29 #include <sys/machsystm.h>
30 #include <sys/t_lock.h>
31 #include <sys/vmem.h>
32 #include <sys/mman.h>
33 #include <sys/vm.h>
34 #include <sys/cpu.h>
35 #include <sys/cmn_err.h>
36 #include <sys/cpuvar.h>
37 #include <sys/atomic.h>
38 #include <vm/as.h>
39 #include <vm/hat.h>
40 #include <vm/as.h>
41 #include <vm/page.h>
42 #include <vm/seg.h>
43 #include <vm/seg_kmem.h>
44 #include <vm/seg_kpm.h>
45 #include <vm/hat_sfmmu.h>
170 color = addr_to_vcolor(mmu_ptob(pp->p_pagenum));
171 }
172 }
173
174 } else {
175 /*
176 * For physical caches, we can pick any address we want.
177 */
178 color = 0;
179 }
180
181 start = color;
182 do {
183 for (nset = 0; nset < nsets; nset++) {
184 index = clsettoarray(color, nset);
185 va = ppmap_vaddrs[index];
186 if (va != NULL) {
187 #ifdef PPDEBUG
188 align_hits[color]++;
189 #endif /* PPDEBUG */
190 if (atomic_cas_ptr(&ppmap_vaddrs[index],
191 va, NULL) == va) {
192 hat_memload(kas.a_hat, va, pp,
193 vprot | HAT_NOSYNC,
194 HAT_LOAD_LOCK);
195 return (va);
196 }
197 }
198 }
199 /*
200 * first pick didn't succeed, try another
201 */
202 if (++color == ppmap_pages)
203 color = 0;
204 } while (color != start);
205
206 #ifdef PPDEBUG
207 ppalloc_noslot++;
208 #endif /* PPDEBUG */
209
210 /*
300 if ((vcolor == -1) &&
301 (pp_consistent_coloring & strict_flag))
302 return (NULL);
303 /* else keep the current vcolor of the page */
304 } else {
305 vcolor = -1;
306 }
307
308 if (vcolor != -1) {
309 va += MMU_PAGESIZE * vcolor;
310 start = vcolor;
311 stride = ppmap_pages; /* number of colors */
312 myslot += vcolor;
313 } else {
314 start = 0;
315 stride = 1;
316 }
317
318 for (i = start; i < pp_slots; i += stride) {
319 if (*myslot == NULL) {
320 if (atomic_cas_ptr(myslot, NULL, va) == NULL)
321 break;
322 }
323 myslot += stride;
324 va += MMU_PAGESIZE * stride;
325 }
326
327 if (i >= pp_slots) {
328 PP_STAT_ADD(ploadfail);
329 return (NULL);
330 }
331
332 ASSERT(vcolor == -1 || addr_to_vcolor(va) == vcolor);
333
334 /*
335 * Now we have a slot we can use, make the tte.
336 */
337 tte.tte_inthi = TTE_VALID_INT | TTE_PFN_INTHI(pp->p_pagenum);
338 tte.tte_intlo = TTE_PFN_INTLO(pp->p_pagenum) | TTE_CP_INT |
339 TTE_CV_INT | TTE_PRIV_INT | TTE_LCK_INT | prot;
340
|