10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*3290Sjohansen * Common Development and Distribution License (the "License").
6*3290Sjohansen * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate /*
22*3290Sjohansen * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
230Sstevel@tonic-gate * Use is subject to license terms.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
260Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
270Sstevel@tonic-gate /* All Rights Reserved */
280Sstevel@tonic-gate
290Sstevel@tonic-gate /*
300Sstevel@tonic-gate * Portions of this source code were derived from Berkeley 4.3 BSD
310Sstevel@tonic-gate * under license from the Regents of the University of California.
320Sstevel@tonic-gate */
330Sstevel@tonic-gate
340Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
350Sstevel@tonic-gate
360Sstevel@tonic-gate /*
370Sstevel@tonic-gate * VM - segment for non-faulting loads.
380Sstevel@tonic-gate */
390Sstevel@tonic-gate
400Sstevel@tonic-gate #include <sys/types.h>
410Sstevel@tonic-gate #include <sys/t_lock.h>
420Sstevel@tonic-gate #include <sys/param.h>
430Sstevel@tonic-gate #include <sys/mman.h>
440Sstevel@tonic-gate #include <sys/errno.h>
450Sstevel@tonic-gate #include <sys/kmem.h>
460Sstevel@tonic-gate #include <sys/cmn_err.h>
470Sstevel@tonic-gate #include <sys/vnode.h>
480Sstevel@tonic-gate #include <sys/proc.h>
490Sstevel@tonic-gate #include <sys/conf.h>
500Sstevel@tonic-gate #include <sys/debug.h>
510Sstevel@tonic-gate #include <sys/archsystm.h>
520Sstevel@tonic-gate #include <sys/lgrp.h>
530Sstevel@tonic-gate
540Sstevel@tonic-gate #include <vm/page.h>
550Sstevel@tonic-gate #include <vm/hat.h>
560Sstevel@tonic-gate #include <vm/as.h>
570Sstevel@tonic-gate #include <vm/seg.h>
580Sstevel@tonic-gate #include <vm/vpage.h>
590Sstevel@tonic-gate
600Sstevel@tonic-gate /*
610Sstevel@tonic-gate * Private seg op routines.
620Sstevel@tonic-gate */
630Sstevel@tonic-gate static int segnf_dup(struct seg *seg, struct seg *newseg);
640Sstevel@tonic-gate static int segnf_unmap(struct seg *seg, caddr_t addr, size_t len);
650Sstevel@tonic-gate static void segnf_free(struct seg *seg);
660Sstevel@tonic-gate static faultcode_t segnf_nomap(void);
670Sstevel@tonic-gate static int segnf_setprot(struct seg *seg, caddr_t addr,
680Sstevel@tonic-gate size_t len, uint_t prot);
690Sstevel@tonic-gate static int segnf_checkprot(struct seg *seg, caddr_t addr,
700Sstevel@tonic-gate size_t len, uint_t prot);
710Sstevel@tonic-gate static void segnf_badop(void);
720Sstevel@tonic-gate static int segnf_nop(void);
730Sstevel@tonic-gate static int segnf_getprot(struct seg *seg, caddr_t addr,
740Sstevel@tonic-gate size_t len, uint_t *protv);
750Sstevel@tonic-gate static u_offset_t segnf_getoffset(struct seg *seg, caddr_t addr);
760Sstevel@tonic-gate static int segnf_gettype(struct seg *seg, caddr_t addr);
770Sstevel@tonic-gate static int segnf_getvp(struct seg *seg, caddr_t addr, struct vnode **vpp);
780Sstevel@tonic-gate static void segnf_dump(struct seg *seg);
790Sstevel@tonic-gate static int segnf_pagelock(struct seg *seg, caddr_t addr, size_t len,
800Sstevel@tonic-gate struct page ***ppp, enum lock_type type, enum seg_rw rw);
810Sstevel@tonic-gate static int segnf_setpagesize(struct seg *seg, caddr_t addr, size_t len,
820Sstevel@tonic-gate uint_t szc);
830Sstevel@tonic-gate static int segnf_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp);
840Sstevel@tonic-gate static lgrp_mem_policy_info_t *segnf_getpolicy(struct seg *seg,
850Sstevel@tonic-gate caddr_t addr);
860Sstevel@tonic-gate
870Sstevel@tonic-gate
880Sstevel@tonic-gate struct seg_ops segnf_ops = {
890Sstevel@tonic-gate segnf_dup,
900Sstevel@tonic-gate segnf_unmap,
910Sstevel@tonic-gate segnf_free,
920Sstevel@tonic-gate (faultcode_t (*)(struct hat *, struct seg *, caddr_t, size_t,
930Sstevel@tonic-gate enum fault_type, enum seg_rw))
940Sstevel@tonic-gate segnf_nomap, /* fault */
950Sstevel@tonic-gate (faultcode_t (*)(struct seg *, caddr_t))
960Sstevel@tonic-gate segnf_nomap, /* faulta */
970Sstevel@tonic-gate segnf_setprot,
980Sstevel@tonic-gate segnf_checkprot,
990Sstevel@tonic-gate (int (*)())segnf_badop, /* kluster */
1000Sstevel@tonic-gate (size_t (*)(struct seg *))NULL, /* swapout */
1010Sstevel@tonic-gate (int (*)(struct seg *, caddr_t, size_t, int, uint_t))
1020Sstevel@tonic-gate segnf_nop, /* sync */
1030Sstevel@tonic-gate (size_t (*)(struct seg *, caddr_t, size_t, char *))
1040Sstevel@tonic-gate segnf_nop, /* incore */
1050Sstevel@tonic-gate (int (*)(struct seg *, caddr_t, size_t, int, int, ulong_t *, size_t))
1060Sstevel@tonic-gate segnf_nop, /* lockop */
1070Sstevel@tonic-gate segnf_getprot,
1080Sstevel@tonic-gate segnf_getoffset,
1090Sstevel@tonic-gate segnf_gettype,
1100Sstevel@tonic-gate segnf_getvp,
1110Sstevel@tonic-gate (int (*)(struct seg *, caddr_t, size_t, uint_t))
1120Sstevel@tonic-gate segnf_nop, /* advise */
1130Sstevel@tonic-gate segnf_dump,
1140Sstevel@tonic-gate segnf_pagelock,
1150Sstevel@tonic-gate segnf_setpagesize,
1160Sstevel@tonic-gate segnf_getmemid,
1170Sstevel@tonic-gate segnf_getpolicy,
1180Sstevel@tonic-gate };
1190Sstevel@tonic-gate
1200Sstevel@tonic-gate /*
1210Sstevel@tonic-gate * vnode and page for the page of zeros we use for the nf mappings.
1220Sstevel@tonic-gate */
1230Sstevel@tonic-gate static kmutex_t segnf_lock;
124*3290Sjohansen static struct vnode nfvp;
125*3290Sjohansen static struct page **nfpp;
1260Sstevel@tonic-gate
1270Sstevel@tonic-gate #define addr_to_vcolor(addr) \
1280Sstevel@tonic-gate (shm_alignment) ? \
1290Sstevel@tonic-gate ((int)(((uintptr_t)(addr) & (shm_alignment - 1)) >> PAGESHIFT)) : 0
1300Sstevel@tonic-gate
1310Sstevel@tonic-gate /*
1320Sstevel@tonic-gate * We try to limit the number of Non-fault segments created.
1330Sstevel@tonic-gate * Non fault segments are created to optimize sparc V9 code which uses
1340Sstevel@tonic-gate * the sparc nonfaulting load ASI (ASI_PRIMARY_NOFAULT).
1350Sstevel@tonic-gate *
1360Sstevel@tonic-gate * There are several reasons why creating too many non-fault segments
1370Sstevel@tonic-gate * could cause problems.
1380Sstevel@tonic-gate *
1390Sstevel@tonic-gate * First, excessive allocation of kernel resources for the seg
1400Sstevel@tonic-gate * structures and the HAT data to map the zero pages.
1410Sstevel@tonic-gate *
1420Sstevel@tonic-gate * Secondly, creating nofault segments actually uses up user virtual
1430Sstevel@tonic-gate * address space. This makes it unavailable for subsequent mmap(0, ...)
1440Sstevel@tonic-gate * calls which use as_gap() to find empty va regions. Creation of too
1450Sstevel@tonic-gate * many nofault segments could thus interfere with the ability of the
1460Sstevel@tonic-gate * runtime linker to load a shared object.
1470Sstevel@tonic-gate */
1480Sstevel@tonic-gate #define MAXSEGFORNF (10000)
1490Sstevel@tonic-gate #define MAXNFSEARCH (5)
1500Sstevel@tonic-gate
1510Sstevel@tonic-gate
1520Sstevel@tonic-gate /*
1530Sstevel@tonic-gate * Must be called from startup()
1540Sstevel@tonic-gate */
1550Sstevel@tonic-gate void
segnf_init()1560Sstevel@tonic-gate segnf_init()
1570Sstevel@tonic-gate {
1580Sstevel@tonic-gate mutex_init(&segnf_lock, NULL, MUTEX_DEFAULT, NULL);
1590Sstevel@tonic-gate }
1600Sstevel@tonic-gate
1610Sstevel@tonic-gate
1620Sstevel@tonic-gate /*
1630Sstevel@tonic-gate * Create a no-fault segment.
1640Sstevel@tonic-gate *
1650Sstevel@tonic-gate * The no-fault segment is not technically necessary, as the code in
1660Sstevel@tonic-gate * nfload() in trap.c will emulate the SPARC instruction and load
1670Sstevel@tonic-gate * a value of zero in the destination register.
1680Sstevel@tonic-gate *
1690Sstevel@tonic-gate * However, this code tries to put a page of zero's at the nofault address
1700Sstevel@tonic-gate * so that subsequent non-faulting loads to the same page will not
1710Sstevel@tonic-gate * trap with a tlb miss.
1720Sstevel@tonic-gate *
1730Sstevel@tonic-gate * In order to help limit the number of segments we merge adjacent nofault
1740Sstevel@tonic-gate * segments into a single segment. If we get a large number of segments
1750Sstevel@tonic-gate * we'll also try to delete a random other nf segment.
1760Sstevel@tonic-gate */
1770Sstevel@tonic-gate /* ARGSUSED */
1780Sstevel@tonic-gate int
segnf_create(struct seg * seg,void * argsp)1790Sstevel@tonic-gate segnf_create(struct seg *seg, void *argsp)
1800Sstevel@tonic-gate {
1810Sstevel@tonic-gate uint_t prot;
1820Sstevel@tonic-gate pgcnt_t vacpgs;
1830Sstevel@tonic-gate u_offset_t off = 0;
1840Sstevel@tonic-gate caddr_t vaddr = NULL;
1850Sstevel@tonic-gate int i, color;
1860Sstevel@tonic-gate struct seg *s1;
1870Sstevel@tonic-gate struct seg *s2;
1880Sstevel@tonic-gate size_t size;
1890Sstevel@tonic-gate struct as *as = seg->s_as;
1900Sstevel@tonic-gate
1910Sstevel@tonic-gate ASSERT(as && AS_WRITE_HELD(as, &as->a_lock));
1920Sstevel@tonic-gate
1930Sstevel@tonic-gate /*
1940Sstevel@tonic-gate * Need a page per virtual color or just 1 if no vac.
1950Sstevel@tonic-gate */
1960Sstevel@tonic-gate mutex_enter(&segnf_lock);
197*3290Sjohansen if (nfpp == NULL) {
1980Sstevel@tonic-gate struct seg kseg;
1990Sstevel@tonic-gate
2000Sstevel@tonic-gate vacpgs = 1;
2010Sstevel@tonic-gate if (shm_alignment > PAGESIZE) {
2020Sstevel@tonic-gate vacpgs = shm_alignment >> PAGESHIFT;
2030Sstevel@tonic-gate }
2040Sstevel@tonic-gate
205*3290Sjohansen nfpp = kmem_alloc(sizeof (*nfpp) * vacpgs, KM_SLEEP);
2060Sstevel@tonic-gate
2070Sstevel@tonic-gate kseg.s_as = &kas;
2080Sstevel@tonic-gate for (i = 0; i < vacpgs; i++, off += PAGESIZE,
2090Sstevel@tonic-gate vaddr += PAGESIZE) {
210*3290Sjohansen nfpp[i] = page_create_va(&nfvp, off, PAGESIZE,
2110Sstevel@tonic-gate PG_WAIT | PG_NORELOC, &kseg, vaddr);
212*3290Sjohansen page_io_unlock(nfpp[i]);
213*3290Sjohansen page_downgrade(nfpp[i]);
214*3290Sjohansen pagezero(nfpp[i], 0, PAGESIZE);
2150Sstevel@tonic-gate }
2160Sstevel@tonic-gate }
2170Sstevel@tonic-gate mutex_exit(&segnf_lock);
2180Sstevel@tonic-gate
2190Sstevel@tonic-gate hat_map(as->a_hat, seg->s_base, seg->s_size, HAT_MAP);
2200Sstevel@tonic-gate
2210Sstevel@tonic-gate /*
2220Sstevel@tonic-gate * s_data can't be NULL because of ASSERTS in the common vm code.
2230Sstevel@tonic-gate */
2240Sstevel@tonic-gate seg->s_ops = &segnf_ops;
2250Sstevel@tonic-gate seg->s_data = seg;
2260Sstevel@tonic-gate seg->s_flags |= S_PURGE;
2270Sstevel@tonic-gate
2280Sstevel@tonic-gate mutex_enter(&as->a_contents);
2290Sstevel@tonic-gate as->a_flags |= AS_NEEDSPURGE;
2300Sstevel@tonic-gate mutex_exit(&as->a_contents);
2310Sstevel@tonic-gate
2320Sstevel@tonic-gate prot = PROT_READ;
2330Sstevel@tonic-gate color = addr_to_vcolor(seg->s_base);
2340Sstevel@tonic-gate if (as != &kas)
2350Sstevel@tonic-gate prot |= PROT_USER;
236*3290Sjohansen hat_memload(as->a_hat, seg->s_base, nfpp[color],
2370Sstevel@tonic-gate prot | HAT_NOFAULT, HAT_LOAD);
2380Sstevel@tonic-gate
2390Sstevel@tonic-gate /*
2400Sstevel@tonic-gate * At this point see if we can concatenate a segment to
2410Sstevel@tonic-gate * a non-fault segment immediately before and/or after it.
2420Sstevel@tonic-gate */
2430Sstevel@tonic-gate if ((s1 = AS_SEGPREV(as, seg)) != NULL &&
2440Sstevel@tonic-gate s1->s_ops == &segnf_ops &&
2450Sstevel@tonic-gate s1->s_base + s1->s_size == seg->s_base) {
2460Sstevel@tonic-gate size = s1->s_size;
2470Sstevel@tonic-gate seg_free(s1);
2480Sstevel@tonic-gate seg->s_base -= size;
2490Sstevel@tonic-gate seg->s_size += size;
2500Sstevel@tonic-gate }
2510Sstevel@tonic-gate
2520Sstevel@tonic-gate if ((s2 = AS_SEGNEXT(as, seg)) != NULL &&
2530Sstevel@tonic-gate s2->s_ops == &segnf_ops &&
2540Sstevel@tonic-gate seg->s_base + seg->s_size == s2->s_base) {
2550Sstevel@tonic-gate size = s2->s_size;
2560Sstevel@tonic-gate seg_free(s2);
2570Sstevel@tonic-gate seg->s_size += size;
2580Sstevel@tonic-gate }
2590Sstevel@tonic-gate
2600Sstevel@tonic-gate /*
2610Sstevel@tonic-gate * if we already have a lot of segments, try to delete some other
2620Sstevel@tonic-gate * nofault segment to reduce the probability of uncontrolled segment
2630Sstevel@tonic-gate * creation.
2640Sstevel@tonic-gate *
2650Sstevel@tonic-gate * the code looks around quickly (no more than MAXNFSEARCH segments
2660Sstevel@tonic-gate * each way) for another NF segment and then deletes it.
2670Sstevel@tonic-gate */
2680Sstevel@tonic-gate if (avl_numnodes(&as->a_segtree) > MAXSEGFORNF) {
2690Sstevel@tonic-gate size = 0;
2700Sstevel@tonic-gate s2 = NULL;
2710Sstevel@tonic-gate s1 = AS_SEGPREV(as, seg);
2720Sstevel@tonic-gate while (size++ < MAXNFSEARCH && s1 != NULL) {
2730Sstevel@tonic-gate if (s1->s_ops == &segnf_ops)
2740Sstevel@tonic-gate s2 = s1;
2750Sstevel@tonic-gate s1 = AS_SEGPREV(s1->s_as, seg);
2760Sstevel@tonic-gate }
2770Sstevel@tonic-gate if (s2 == NULL) {
2780Sstevel@tonic-gate s1 = AS_SEGNEXT(as, seg);
2790Sstevel@tonic-gate while (size-- > 0 && s1 != NULL) {
2800Sstevel@tonic-gate if (s1->s_ops == &segnf_ops)
2810Sstevel@tonic-gate s2 = s1;
2820Sstevel@tonic-gate s1 = AS_SEGNEXT(as, seg);
2830Sstevel@tonic-gate }
2840Sstevel@tonic-gate }
2850Sstevel@tonic-gate if (s2 != NULL)
2860Sstevel@tonic-gate seg_unmap(s2);
2870Sstevel@tonic-gate }
2880Sstevel@tonic-gate
2890Sstevel@tonic-gate return (0);
2900Sstevel@tonic-gate }
2910Sstevel@tonic-gate
2920Sstevel@tonic-gate /*
2930Sstevel@tonic-gate * Never really need "No fault" segments, so they aren't dup'd.
2940Sstevel@tonic-gate */
2950Sstevel@tonic-gate /* ARGSUSED */
2960Sstevel@tonic-gate static int
segnf_dup(struct seg * seg,struct seg * newseg)2970Sstevel@tonic-gate segnf_dup(struct seg *seg, struct seg *newseg)
2980Sstevel@tonic-gate {
2990Sstevel@tonic-gate panic("segnf_dup");
3000Sstevel@tonic-gate return (0);
3010Sstevel@tonic-gate }
3020Sstevel@tonic-gate
3030Sstevel@tonic-gate /*
3040Sstevel@tonic-gate * Split a segment at addr for length len.
3050Sstevel@tonic-gate */
3060Sstevel@tonic-gate static int
segnf_unmap(struct seg * seg,caddr_t addr,size_t len)3070Sstevel@tonic-gate segnf_unmap(struct seg *seg, caddr_t addr, size_t len)
3080Sstevel@tonic-gate {
3090Sstevel@tonic-gate ASSERT(seg->s_as && AS_WRITE_HELD(seg->s_as, &seg->s_as->a_lock));
3100Sstevel@tonic-gate
3110Sstevel@tonic-gate /*
3120Sstevel@tonic-gate * Check for bad sizes.
3130Sstevel@tonic-gate */
3140Sstevel@tonic-gate if (addr < seg->s_base || addr + len > seg->s_base + seg->s_size ||
3150Sstevel@tonic-gate (len & PAGEOFFSET) || ((uintptr_t)addr & PAGEOFFSET)) {
3160Sstevel@tonic-gate cmn_err(CE_PANIC, "segnf_unmap: bad unmap size");
3170Sstevel@tonic-gate }
3180Sstevel@tonic-gate
3190Sstevel@tonic-gate /*
3200Sstevel@tonic-gate * Unload any hardware translations in the range to be taken out.
3210Sstevel@tonic-gate */
3220Sstevel@tonic-gate hat_unload(seg->s_as->a_hat, addr, len, HAT_UNLOAD_UNMAP);
3230Sstevel@tonic-gate
3240Sstevel@tonic-gate if (addr == seg->s_base && len == seg->s_size) {
3250Sstevel@tonic-gate /*
3260Sstevel@tonic-gate * Freeing entire segment.
3270Sstevel@tonic-gate */
3280Sstevel@tonic-gate seg_free(seg);
3290Sstevel@tonic-gate } else if (addr == seg->s_base) {
3300Sstevel@tonic-gate /*
3310Sstevel@tonic-gate * Freeing the beginning of the segment.
3320Sstevel@tonic-gate */
3330Sstevel@tonic-gate seg->s_base += len;
3340Sstevel@tonic-gate seg->s_size -= len;
3350Sstevel@tonic-gate } else if (addr + len == seg->s_base + seg->s_size) {
3360Sstevel@tonic-gate /*
3370Sstevel@tonic-gate * Freeing the end of the segment.
3380Sstevel@tonic-gate */
3390Sstevel@tonic-gate seg->s_size -= len;
3400Sstevel@tonic-gate } else {
3410Sstevel@tonic-gate /*
3420Sstevel@tonic-gate * The section to go is in the middle of the segment, so we
3430Sstevel@tonic-gate * have to cut it into two segments. We shrink the existing
3440Sstevel@tonic-gate * "seg" at the low end, and create "nseg" for the high end.
3450Sstevel@tonic-gate */
3460Sstevel@tonic-gate caddr_t nbase = addr + len;
3470Sstevel@tonic-gate size_t nsize = (seg->s_base + seg->s_size) - nbase;
3480Sstevel@tonic-gate struct seg *nseg;
3490Sstevel@tonic-gate
3500Sstevel@tonic-gate /*
3510Sstevel@tonic-gate * Trim down "seg" before trying to stick "nseg" into the as.
3520Sstevel@tonic-gate */
3530Sstevel@tonic-gate seg->s_size = addr - seg->s_base;
3540Sstevel@tonic-gate nseg = seg_alloc(seg->s_as, nbase, nsize);
3550Sstevel@tonic-gate if (nseg == NULL)
3560Sstevel@tonic-gate cmn_err(CE_PANIC, "segnf_unmap: seg_alloc failed");
3570Sstevel@tonic-gate
3580Sstevel@tonic-gate /*
3590Sstevel@tonic-gate * s_data can't be NULL because of ASSERTs in common VM code.
3600Sstevel@tonic-gate */
3610Sstevel@tonic-gate nseg->s_ops = seg->s_ops;
3620Sstevel@tonic-gate nseg->s_data = nseg;
3630Sstevel@tonic-gate nseg->s_flags |= S_PURGE;
3640Sstevel@tonic-gate mutex_enter(&seg->s_as->a_contents);
3650Sstevel@tonic-gate seg->s_as->a_flags |= AS_NEEDSPURGE;
3660Sstevel@tonic-gate mutex_exit(&seg->s_as->a_contents);
3670Sstevel@tonic-gate }
3680Sstevel@tonic-gate
3690Sstevel@tonic-gate return (0);
3700Sstevel@tonic-gate }
3710Sstevel@tonic-gate
3720Sstevel@tonic-gate /*
3730Sstevel@tonic-gate * Free a segment.
3740Sstevel@tonic-gate */
3750Sstevel@tonic-gate static void
segnf_free(struct seg * seg)3760Sstevel@tonic-gate segnf_free(struct seg *seg)
3770Sstevel@tonic-gate {
3780Sstevel@tonic-gate ASSERT(seg->s_as && AS_WRITE_HELD(seg->s_as, &seg->s_as->a_lock));
3790Sstevel@tonic-gate }
3800Sstevel@tonic-gate
3810Sstevel@tonic-gate /*
3820Sstevel@tonic-gate * No faults allowed on segnf.
3830Sstevel@tonic-gate */
3840Sstevel@tonic-gate static faultcode_t
segnf_nomap(void)3850Sstevel@tonic-gate segnf_nomap(void)
3860Sstevel@tonic-gate {
3870Sstevel@tonic-gate return (FC_NOMAP);
3880Sstevel@tonic-gate }
3890Sstevel@tonic-gate
3900Sstevel@tonic-gate /* ARGSUSED */
3910Sstevel@tonic-gate static int
segnf_setprot(struct seg * seg,caddr_t addr,size_t len,uint_t prot)3920Sstevel@tonic-gate segnf_setprot(struct seg *seg, caddr_t addr, size_t len, uint_t prot)
3930Sstevel@tonic-gate {
3940Sstevel@tonic-gate ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as, &seg->s_as->a_lock));
3950Sstevel@tonic-gate return (EACCES);
3960Sstevel@tonic-gate }
3970Sstevel@tonic-gate
3980Sstevel@tonic-gate /* ARGSUSED */
3990Sstevel@tonic-gate static int
segnf_checkprot(struct seg * seg,caddr_t addr,size_t len,uint_t prot)4000Sstevel@tonic-gate segnf_checkprot(struct seg *seg, caddr_t addr, size_t len, uint_t prot)
4010Sstevel@tonic-gate {
4020Sstevel@tonic-gate uint_t sprot;
4030Sstevel@tonic-gate ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as, &seg->s_as->a_lock));
4040Sstevel@tonic-gate
4050Sstevel@tonic-gate sprot = seg->s_as == &kas ? PROT_READ : PROT_READ|PROT_USER;
4060Sstevel@tonic-gate return ((prot & sprot) == prot ? 0 : EACCES);
4070Sstevel@tonic-gate }
4080Sstevel@tonic-gate
4090Sstevel@tonic-gate static void
segnf_badop(void)4100Sstevel@tonic-gate segnf_badop(void)
4110Sstevel@tonic-gate {
4120Sstevel@tonic-gate panic("segnf_badop");
4130Sstevel@tonic-gate /*NOTREACHED*/
4140Sstevel@tonic-gate }
4150Sstevel@tonic-gate
4160Sstevel@tonic-gate static int
segnf_nop(void)4170Sstevel@tonic-gate segnf_nop(void)
4180Sstevel@tonic-gate {
4190Sstevel@tonic-gate return (0);
4200Sstevel@tonic-gate }
4210Sstevel@tonic-gate
4220Sstevel@tonic-gate static int
segnf_getprot(struct seg * seg,caddr_t addr,size_t len,uint_t * protv)4230Sstevel@tonic-gate segnf_getprot(struct seg *seg, caddr_t addr, size_t len, uint_t *protv)
4240Sstevel@tonic-gate {
4250Sstevel@tonic-gate size_t pgno = seg_page(seg, addr + len) - seg_page(seg, addr) + 1;
4260Sstevel@tonic-gate size_t p;
4270Sstevel@tonic-gate ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as, &seg->s_as->a_lock));
4280Sstevel@tonic-gate
4290Sstevel@tonic-gate for (p = 0; p < pgno; ++p)
4300Sstevel@tonic-gate protv[p] = PROT_READ;
4310Sstevel@tonic-gate return (0);
4320Sstevel@tonic-gate }
4330Sstevel@tonic-gate
4340Sstevel@tonic-gate /* ARGSUSED */
4350Sstevel@tonic-gate static u_offset_t
segnf_getoffset(struct seg * seg,caddr_t addr)4360Sstevel@tonic-gate segnf_getoffset(struct seg *seg, caddr_t addr)
4370Sstevel@tonic-gate {
4380Sstevel@tonic-gate ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as, &seg->s_as->a_lock));
4390Sstevel@tonic-gate
4400Sstevel@tonic-gate return ((u_offset_t)0);
4410Sstevel@tonic-gate }
4420Sstevel@tonic-gate
4430Sstevel@tonic-gate /* ARGSUSED */
4440Sstevel@tonic-gate static int
segnf_gettype(struct seg * seg,caddr_t addr)4450Sstevel@tonic-gate segnf_gettype(struct seg *seg, caddr_t addr)
4460Sstevel@tonic-gate {
4470Sstevel@tonic-gate ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as, &seg->s_as->a_lock));
4480Sstevel@tonic-gate
4490Sstevel@tonic-gate return (MAP_SHARED);
4500Sstevel@tonic-gate }
4510Sstevel@tonic-gate
4520Sstevel@tonic-gate /* ARGSUSED */
4530Sstevel@tonic-gate static int
segnf_getvp(struct seg * seg,caddr_t addr,struct vnode ** vpp)4540Sstevel@tonic-gate segnf_getvp(struct seg *seg, caddr_t addr, struct vnode **vpp)
4550Sstevel@tonic-gate {
4560Sstevel@tonic-gate ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as, &seg->s_as->a_lock));
4570Sstevel@tonic-gate
458*3290Sjohansen *vpp = &nfvp;
4590Sstevel@tonic-gate return (0);
4600Sstevel@tonic-gate }
4610Sstevel@tonic-gate
4620Sstevel@tonic-gate /*
4630Sstevel@tonic-gate * segnf pages are not dumped, so we just return
4640Sstevel@tonic-gate */
4650Sstevel@tonic-gate /* ARGSUSED */
4660Sstevel@tonic-gate static void
segnf_dump(struct seg * seg)4670Sstevel@tonic-gate segnf_dump(struct seg *seg)
4680Sstevel@tonic-gate {}
4690Sstevel@tonic-gate
4700Sstevel@tonic-gate /*ARGSUSED*/
4710Sstevel@tonic-gate static int
segnf_pagelock(struct seg * seg,caddr_t addr,size_t len,struct page *** ppp,enum lock_type type,enum seg_rw rw)4720Sstevel@tonic-gate segnf_pagelock(struct seg *seg, caddr_t addr, size_t len,
4730Sstevel@tonic-gate struct page ***ppp, enum lock_type type, enum seg_rw rw)
4740Sstevel@tonic-gate {
4750Sstevel@tonic-gate return (ENOTSUP);
4760Sstevel@tonic-gate }
4770Sstevel@tonic-gate
4780Sstevel@tonic-gate /*ARGSUSED*/
4790Sstevel@tonic-gate static int
segnf_setpagesize(struct seg * seg,caddr_t addr,size_t len,uint_t szc)4800Sstevel@tonic-gate segnf_setpagesize(struct seg *seg, caddr_t addr, size_t len,
4810Sstevel@tonic-gate uint_t szc)
4820Sstevel@tonic-gate {
4830Sstevel@tonic-gate return (ENOTSUP);
4840Sstevel@tonic-gate }
4850Sstevel@tonic-gate
4860Sstevel@tonic-gate /*ARGSUSED*/
4870Sstevel@tonic-gate static int
segnf_getmemid(struct seg * seg,caddr_t addr,memid_t * memidp)4880Sstevel@tonic-gate segnf_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp)
4890Sstevel@tonic-gate {
4900Sstevel@tonic-gate return (ENODEV);
4910Sstevel@tonic-gate }
4920Sstevel@tonic-gate
4930Sstevel@tonic-gate /*ARGSUSED*/
4940Sstevel@tonic-gate static lgrp_mem_policy_info_t *
segnf_getpolicy(struct seg * seg,caddr_t addr)4950Sstevel@tonic-gate segnf_getpolicy(struct seg *seg, caddr_t addr)
4960Sstevel@tonic-gate {
4970Sstevel@tonic-gate return (NULL);
4980Sstevel@tonic-gate }
499