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 55224Smec * Common Development and Distribution License (the "License"). 65224Smec * 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*6695Saguzovsk * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _VM_SEG_SPT_H 270Sstevel@tonic-gate #define _VM_SEG_SPT_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #ifdef __cplusplus 320Sstevel@tonic-gate extern "C" { 330Sstevel@tonic-gate #endif 340Sstevel@tonic-gate 350Sstevel@tonic-gate #ifndef _ASM 360Sstevel@tonic-gate 370Sstevel@tonic-gate #include <sys/types.h> 380Sstevel@tonic-gate #include <sys/t_lock.h> 390Sstevel@tonic-gate #include <sys/lgrp.h> 400Sstevel@tonic-gate 410Sstevel@tonic-gate /* 420Sstevel@tonic-gate * Passed data when creating spt segment. 430Sstevel@tonic-gate */ 440Sstevel@tonic-gate struct segspt_crargs { 450Sstevel@tonic-gate struct seg *seg_spt; 460Sstevel@tonic-gate struct anon_map *amp; 470Sstevel@tonic-gate uint_t prot; 480Sstevel@tonic-gate uint_t flags; 490Sstevel@tonic-gate uint_t szc; 500Sstevel@tonic-gate }; 510Sstevel@tonic-gate 520Sstevel@tonic-gate typedef struct spt_data { 530Sstevel@tonic-gate struct vnode *spt_vp; 540Sstevel@tonic-gate struct anon_map *spt_amp; 550Sstevel@tonic-gate size_t spt_realsize; 560Sstevel@tonic-gate struct page **spt_ppa; 570Sstevel@tonic-gate ushort_t *spt_ppa_lckcnt; 580Sstevel@tonic-gate uint_t spt_prot; 590Sstevel@tonic-gate kmutex_t spt_lock; 600Sstevel@tonic-gate size_t spt_pcachecnt; /* # of times in pcache */ 610Sstevel@tonic-gate uint_t spt_flags; /* Dynamic ISM or regular ISM */ 625224Smec kcondvar_t spt_cv; 635224Smec ushort_t spt_gen; /* only updated for DISM */ 640Sstevel@tonic-gate /* 650Sstevel@tonic-gate * Initial memory allocation policy 660Sstevel@tonic-gate * used during pre-allocation done in shmat() 670Sstevel@tonic-gate */ 680Sstevel@tonic-gate lgrp_mem_policy_info_t spt_policy_info; 690Sstevel@tonic-gate } spt_data_t; 700Sstevel@tonic-gate 710Sstevel@tonic-gate /* 720Sstevel@tonic-gate * Private data for spt_shm segment. 730Sstevel@tonic-gate */ 740Sstevel@tonic-gate typedef struct shm_data { 750Sstevel@tonic-gate struct as *shm_sptas; 760Sstevel@tonic-gate struct anon_map *shm_amp; 77*6695Saguzovsk spgcnt_t shm_softlockcnt; /* # outstanding lock operations */ 780Sstevel@tonic-gate struct seg *shm_sptseg; /* pointer to spt segment */ 790Sstevel@tonic-gate char *shm_vpage; /* indicating locked pages */ 800Sstevel@tonic-gate spgcnt_t shm_lckpgs; /* # of locked pages per attached seg */ 810Sstevel@tonic-gate /* 820Sstevel@tonic-gate * Memory allocation policy after shmat() 830Sstevel@tonic-gate */ 840Sstevel@tonic-gate lgrp_mem_policy_info_t shm_policy_info; 85*6695Saguzovsk kmutex_t shm_segfree_syncmtx; /* barrier lock for segspt_shmfree() */ 860Sstevel@tonic-gate } shm_data_t; 870Sstevel@tonic-gate 880Sstevel@tonic-gate #define DISM_PG_LOCKED 0x1 /* DISM page is locked */ 890Sstevel@tonic-gate #define DISM_PPA_CHANGED 0x2 /* DISM new lock, need to rebuild ppa */ 900Sstevel@tonic-gate 910Sstevel@tonic-gate #define DISM_LOCK_MAX 0xfffe /* max number of locks per DISM page */ 920Sstevel@tonic-gate #endif 930Sstevel@tonic-gate 940Sstevel@tonic-gate #ifdef _KERNEL 950Sstevel@tonic-gate 960Sstevel@tonic-gate #ifndef _ASM 970Sstevel@tonic-gate 980Sstevel@tonic-gate /* 990Sstevel@tonic-gate * Functions used in shm.c to call ISM. 1000Sstevel@tonic-gate */ 1010Sstevel@tonic-gate int sptcreate(size_t size, struct seg **sptseg, struct anon_map *amp, 1020Sstevel@tonic-gate uint_t prot, uint_t flags, uint_t szc); 1030Sstevel@tonic-gate void sptdestroy(struct as *, struct anon_map *); 1040Sstevel@tonic-gate int segspt_shmattach(struct seg *, caddr_t *); 1050Sstevel@tonic-gate 1060Sstevel@tonic-gate #define isspt(sp) ((sp)->shm_sptinfo ? (sp)->shm_sptinfo->sptas : NULL) 1070Sstevel@tonic-gate #define spt_locked(a) ((a) & SHM_SHARE_MMU) 1080Sstevel@tonic-gate #define spt_pageable(a) ((a) & SHM_PAGEABLE) 1090Sstevel@tonic-gate #define spt_invalid(a) (spt_locked((a)) && spt_pageable((a))) 1100Sstevel@tonic-gate 1110Sstevel@tonic-gate /* 1120Sstevel@tonic-gate * This can be applied to a segment with seg->s_ops == &segspt_shmops 1130Sstevel@tonic-gate * to determine the real size of the ISM segment. 1140Sstevel@tonic-gate */ 1150Sstevel@tonic-gate #define spt_realsize(seg) (((struct spt_data *)(((struct shm_data *)\ 1160Sstevel@tonic-gate ((seg)->s_data))->shm_sptseg->s_data))->spt_realsize) 1170Sstevel@tonic-gate 1180Sstevel@tonic-gate /* 1190Sstevel@tonic-gate * This can be applied to a segment with seg->s_ops == &segspt_ops 1200Sstevel@tonic-gate * to determine the flags of the {D}ISM segment. 1210Sstevel@tonic-gate */ 1220Sstevel@tonic-gate #define spt_flags(seg) (((struct spt_data *)((seg)->s_data))->spt_flags) 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate /* 1250Sstevel@tonic-gate * For large page support 1260Sstevel@tonic-gate */ 1270Sstevel@tonic-gate extern int segvn_anypgsz; 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate #endif 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate /* 1320Sstevel@tonic-gate * In a 64-bit address space, we'll try to put ISM segments between 1330Sstevel@tonic-gate * PREDISM_BASE and PREDISM_BOUND. The HAT may use these constants to 1340Sstevel@tonic-gate * predict that a VA is contained by an ISM segment, which may optimize 1350Sstevel@tonic-gate * translation. The range must _only_ be treated as advisory; ISM segments 1360Sstevel@tonic-gate * may fall outside of the range, and non-ISM segments may be contained 1370Sstevel@tonic-gate * within the range. 1380Sstevel@tonic-gate * In order to avoid collision between ISM/DISM addresses with e.g. 1390Sstevel@tonic-gate * process heap addresses we will try to put ISM/DISM segments above 1400Sstevel@tonic-gate * PREDISM_1T_BASESHIFT (1T). 1410Sstevel@tonic-gate * The HAT is still expecting that any VA larger than PREDISM_BASESHIFT 1420Sstevel@tonic-gate * may belong to ISM/DISM (so on tlb miss it will probe first for 4M 1430Sstevel@tonic-gate * translation) 1440Sstevel@tonic-gate */ 1450Sstevel@tonic-gate #define PREDISM_BASESHIFT 33 1460Sstevel@tonic-gate #define PREDISM_1T_BASESHIFT 40 1470Sstevel@tonic-gate #define PREDISM_BASE ((uintptr_t)1 << PREDISM_BASESHIFT) 1480Sstevel@tonic-gate #define PREDISM_1T_BASE ((uintptr_t)1 << PREDISM_1T_BASESHIFT) 1490Sstevel@tonic-gate #define PREDISM_BOUND ((uintptr_t)1 << 63) 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate #endif /* _KERNEL */ 1520Sstevel@tonic-gate 1530Sstevel@tonic-gate #ifdef __cplusplus 1540Sstevel@tonic-gate } 1550Sstevel@tonic-gate #endif 1560Sstevel@tonic-gate 1570Sstevel@tonic-gate #endif /* _VM_SEG_SPT_H */ 158