1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _VM_SEG_SPT_H 28 #define _VM_SEG_SPT_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 #ifndef _ASM 37 38 #include <sys/types.h> 39 #include <sys/t_lock.h> 40 #include <sys/lgrp.h> 41 42 /* 43 * Passed data when creating spt segment. 44 */ 45 struct segspt_crargs { 46 struct seg *seg_spt; 47 struct anon_map *amp; 48 uint_t prot; 49 uint_t flags; 50 uint_t szc; 51 }; 52 53 typedef struct spt_data { 54 struct vnode *spt_vp; 55 struct anon_map *spt_amp; 56 size_t spt_realsize; 57 struct page **spt_ppa; 58 ushort_t *spt_ppa_lckcnt; 59 uint_t spt_prot; 60 kmutex_t spt_lock; 61 size_t spt_pcachecnt; /* # of times in pcache */ 62 uint_t spt_flags; /* Dynamic ISM or regular ISM */ 63 /* 64 * Initial memory allocation policy 65 * used during pre-allocation done in shmat() 66 */ 67 lgrp_mem_policy_info_t spt_policy_info; 68 } spt_data_t; 69 70 /* 71 * Private data for spt_shm segment. 72 */ 73 typedef struct shm_data { 74 struct as *shm_sptas; 75 struct anon_map *shm_amp; 76 size_t shm_softlockcnt; /* # outstanding lock operations */ 77 struct seg *shm_sptseg; /* pointer to spt segment */ 78 char *shm_vpage; /* indicating locked pages */ 79 spgcnt_t shm_lckpgs; /* # of locked pages per attached seg */ 80 /* 81 * Memory allocation policy after shmat() 82 */ 83 lgrp_mem_policy_info_t shm_policy_info; 84 } shm_data_t; 85 86 #define DISM_PG_LOCKED 0x1 /* DISM page is locked */ 87 #define DISM_PPA_CHANGED 0x2 /* DISM new lock, need to rebuild ppa */ 88 89 #define DISM_LOCK_MAX 0xfffe /* max number of locks per DISM page */ 90 #endif 91 92 #ifdef _KERNEL 93 94 #ifndef _ASM 95 96 /* 97 * Functions used in shm.c to call ISM. 98 */ 99 int sptcreate(size_t size, struct seg **sptseg, struct anon_map *amp, 100 uint_t prot, uint_t flags, uint_t szc); 101 void sptdestroy(struct as *, struct anon_map *); 102 int segspt_shmattach(struct seg *, caddr_t *); 103 104 #define isspt(sp) ((sp)->shm_sptinfo ? (sp)->shm_sptinfo->sptas : NULL) 105 #define spt_locked(a) ((a) & SHM_SHARE_MMU) 106 #define spt_pageable(a) ((a) & SHM_PAGEABLE) 107 #define spt_invalid(a) (spt_locked((a)) && spt_pageable((a))) 108 109 /* 110 * This can be applied to a segment with seg->s_ops == &segspt_shmops 111 * to determine the real size of the ISM segment. 112 */ 113 #define spt_realsize(seg) (((struct spt_data *)(((struct shm_data *)\ 114 ((seg)->s_data))->shm_sptseg->s_data))->spt_realsize) 115 116 /* 117 * This can be applied to a segment with seg->s_ops == &segspt_ops 118 * to determine the flags of the {D}ISM segment. 119 */ 120 #define spt_flags(seg) (((struct spt_data *)((seg)->s_data))->spt_flags) 121 122 /* 123 * For large page support 124 */ 125 extern int segvn_anypgsz; 126 127 #endif 128 129 /* 130 * In a 64-bit address space, we'll try to put ISM segments between 131 * PREDISM_BASE and PREDISM_BOUND. The HAT may use these constants to 132 * predict that a VA is contained by an ISM segment, which may optimize 133 * translation. The range must _only_ be treated as advisory; ISM segments 134 * may fall outside of the range, and non-ISM segments may be contained 135 * within the range. 136 * In order to avoid collision between ISM/DISM addresses with e.g. 137 * process heap addresses we will try to put ISM/DISM segments above 138 * PREDISM_1T_BASESHIFT (1T). 139 * The HAT is still expecting that any VA larger than PREDISM_BASESHIFT 140 * may belong to ISM/DISM (so on tlb miss it will probe first for 4M 141 * translation) 142 */ 143 #define PREDISM_BASESHIFT 33 144 #define PREDISM_1T_BASESHIFT 40 145 #define PREDISM_BASE ((uintptr_t)1 << PREDISM_BASESHIFT) 146 #define PREDISM_1T_BASE ((uintptr_t)1 << PREDISM_1T_BASESHIFT) 147 #define PREDISM_BOUND ((uintptr_t)1 << 63) 148 149 #endif /* _KERNEL */ 150 151 #ifdef __cplusplus 152 } 153 #endif 154 155 #endif /* _VM_SEG_SPT_H */ 156