17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 52ba723d8Smec * Common Development and Distribution License (the "License"). 62ba723d8Smec * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*a98e9dbfSaguzovsk * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _VM_SEG_SPT_H 277c478bd9Sstevel@tonic-gate #define _VM_SEG_SPT_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 327c478bd9Sstevel@tonic-gate extern "C" { 337c478bd9Sstevel@tonic-gate #endif 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #ifndef _ASM 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #include <sys/types.h> 387c478bd9Sstevel@tonic-gate #include <sys/t_lock.h> 397c478bd9Sstevel@tonic-gate #include <sys/lgrp.h> 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate /* 427c478bd9Sstevel@tonic-gate * Passed data when creating spt segment. 437c478bd9Sstevel@tonic-gate */ 447c478bd9Sstevel@tonic-gate struct segspt_crargs { 457c478bd9Sstevel@tonic-gate struct seg *seg_spt; 467c478bd9Sstevel@tonic-gate struct anon_map *amp; 477c478bd9Sstevel@tonic-gate uint_t prot; 487c478bd9Sstevel@tonic-gate uint_t flags; 497c478bd9Sstevel@tonic-gate uint_t szc; 507c478bd9Sstevel@tonic-gate }; 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate typedef struct spt_data { 537c478bd9Sstevel@tonic-gate struct vnode *spt_vp; 547c478bd9Sstevel@tonic-gate struct anon_map *spt_amp; 557c478bd9Sstevel@tonic-gate size_t spt_realsize; 567c478bd9Sstevel@tonic-gate struct page **spt_ppa; 577c478bd9Sstevel@tonic-gate ushort_t *spt_ppa_lckcnt; 587c478bd9Sstevel@tonic-gate uint_t spt_prot; 597c478bd9Sstevel@tonic-gate kmutex_t spt_lock; 607c478bd9Sstevel@tonic-gate size_t spt_pcachecnt; /* # of times in pcache */ 617c478bd9Sstevel@tonic-gate uint_t spt_flags; /* Dynamic ISM or regular ISM */ 622ba723d8Smec kcondvar_t spt_cv; 632ba723d8Smec ushort_t spt_gen; /* only updated for DISM */ 647c478bd9Sstevel@tonic-gate /* 657c478bd9Sstevel@tonic-gate * Initial memory allocation policy 667c478bd9Sstevel@tonic-gate * used during pre-allocation done in shmat() 677c478bd9Sstevel@tonic-gate */ 687c478bd9Sstevel@tonic-gate lgrp_mem_policy_info_t spt_policy_info; 697c478bd9Sstevel@tonic-gate } spt_data_t; 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate /* 727c478bd9Sstevel@tonic-gate * Private data for spt_shm segment. 737c478bd9Sstevel@tonic-gate */ 747c478bd9Sstevel@tonic-gate typedef struct shm_data { 757c478bd9Sstevel@tonic-gate struct as *shm_sptas; 767c478bd9Sstevel@tonic-gate struct anon_map *shm_amp; 77*a98e9dbfSaguzovsk spgcnt_t shm_softlockcnt; /* # outstanding lock operations */ 787c478bd9Sstevel@tonic-gate struct seg *shm_sptseg; /* pointer to spt segment */ 797c478bd9Sstevel@tonic-gate char *shm_vpage; /* indicating locked pages */ 807c478bd9Sstevel@tonic-gate spgcnt_t shm_lckpgs; /* # of locked pages per attached seg */ 817c478bd9Sstevel@tonic-gate /* 827c478bd9Sstevel@tonic-gate * Memory allocation policy after shmat() 837c478bd9Sstevel@tonic-gate */ 847c478bd9Sstevel@tonic-gate lgrp_mem_policy_info_t shm_policy_info; 85*a98e9dbfSaguzovsk kmutex_t shm_segfree_syncmtx; /* barrier lock for segspt_shmfree() */ 867c478bd9Sstevel@tonic-gate } shm_data_t; 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate #define DISM_PG_LOCKED 0x1 /* DISM page is locked */ 897c478bd9Sstevel@tonic-gate #define DISM_PPA_CHANGED 0x2 /* DISM new lock, need to rebuild ppa */ 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate #define DISM_LOCK_MAX 0xfffe /* max number of locks per DISM page */ 927c478bd9Sstevel@tonic-gate #endif 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate #ifdef _KERNEL 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate #ifndef _ASM 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate /* 997c478bd9Sstevel@tonic-gate * Functions used in shm.c to call ISM. 1007c478bd9Sstevel@tonic-gate */ 1017c478bd9Sstevel@tonic-gate int sptcreate(size_t size, struct seg **sptseg, struct anon_map *amp, 1027c478bd9Sstevel@tonic-gate uint_t prot, uint_t flags, uint_t szc); 1037c478bd9Sstevel@tonic-gate void sptdestroy(struct as *, struct anon_map *); 1047c478bd9Sstevel@tonic-gate int segspt_shmattach(struct seg *, caddr_t *); 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate #define isspt(sp) ((sp)->shm_sptinfo ? (sp)->shm_sptinfo->sptas : NULL) 1077c478bd9Sstevel@tonic-gate #define spt_locked(a) ((a) & SHM_SHARE_MMU) 1087c478bd9Sstevel@tonic-gate #define spt_pageable(a) ((a) & SHM_PAGEABLE) 1097c478bd9Sstevel@tonic-gate #define spt_invalid(a) (spt_locked((a)) && spt_pageable((a))) 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate /* 1127c478bd9Sstevel@tonic-gate * This can be applied to a segment with seg->s_ops == &segspt_shmops 1137c478bd9Sstevel@tonic-gate * to determine the real size of the ISM segment. 1147c478bd9Sstevel@tonic-gate */ 1157c478bd9Sstevel@tonic-gate #define spt_realsize(seg) (((struct spt_data *)(((struct shm_data *)\ 1167c478bd9Sstevel@tonic-gate ((seg)->s_data))->shm_sptseg->s_data))->spt_realsize) 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate /* 1197c478bd9Sstevel@tonic-gate * This can be applied to a segment with seg->s_ops == &segspt_ops 1207c478bd9Sstevel@tonic-gate * to determine the flags of the {D}ISM segment. 1217c478bd9Sstevel@tonic-gate */ 1227c478bd9Sstevel@tonic-gate #define spt_flags(seg) (((struct spt_data *)((seg)->s_data))->spt_flags) 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate /* 1257c478bd9Sstevel@tonic-gate * For large page support 1267c478bd9Sstevel@tonic-gate */ 1277c478bd9Sstevel@tonic-gate extern int segvn_anypgsz; 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate #endif 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate /* 1327c478bd9Sstevel@tonic-gate * In a 64-bit address space, we'll try to put ISM segments between 1337c478bd9Sstevel@tonic-gate * PREDISM_BASE and PREDISM_BOUND. The HAT may use these constants to 1347c478bd9Sstevel@tonic-gate * predict that a VA is contained by an ISM segment, which may optimize 1357c478bd9Sstevel@tonic-gate * translation. The range must _only_ be treated as advisory; ISM segments 1367c478bd9Sstevel@tonic-gate * may fall outside of the range, and non-ISM segments may be contained 1377c478bd9Sstevel@tonic-gate * within the range. 1387c478bd9Sstevel@tonic-gate * In order to avoid collision between ISM/DISM addresses with e.g. 1397c478bd9Sstevel@tonic-gate * process heap addresses we will try to put ISM/DISM segments above 1407c478bd9Sstevel@tonic-gate * PREDISM_1T_BASESHIFT (1T). 1417c478bd9Sstevel@tonic-gate * The HAT is still expecting that any VA larger than PREDISM_BASESHIFT 1427c478bd9Sstevel@tonic-gate * may belong to ISM/DISM (so on tlb miss it will probe first for 4M 1437c478bd9Sstevel@tonic-gate * translation) 1447c478bd9Sstevel@tonic-gate */ 1457c478bd9Sstevel@tonic-gate #define PREDISM_BASESHIFT 33 1467c478bd9Sstevel@tonic-gate #define PREDISM_1T_BASESHIFT 40 1477c478bd9Sstevel@tonic-gate #define PREDISM_BASE ((uintptr_t)1 << PREDISM_BASESHIFT) 1487c478bd9Sstevel@tonic-gate #define PREDISM_1T_BASE ((uintptr_t)1 << PREDISM_1T_BASESHIFT) 1497c478bd9Sstevel@tonic-gate #define PREDISM_BOUND ((uintptr_t)1 << 63) 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1547c478bd9Sstevel@tonic-gate } 1557c478bd9Sstevel@tonic-gate #endif 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate #endif /* _VM_SEG_SPT_H */ 158