1108 }
1109
1110 return (pte);
1111 }
1112
1113 /*
1114 * Duplicate address translations of the parent to the child.
1115 * This function really isn't used anymore.
1116 */
1117 /*ARGSUSED*/
1118 int
1119 hat_dup(hat_t *old, hat_t *new, caddr_t addr, size_t len, uint_t flag)
1120 {
1121 ASSERT((uintptr_t)addr < kernelbase);
1122 ASSERT(new != kas.a_hat);
1123 ASSERT(old != kas.a_hat);
1124 return (0);
1125 }
1126
1127 /*
1128 * Allocate any hat resources required for a process being swapped in.
1129 */
1130 /*ARGSUSED*/
1131 void
1132 hat_swapin(hat_t *hat)
1133 {
1134 /* do nothing - we let everything fault back in */
1135 }
1136
1137 /*
1138 * Unload all translations associated with an address space of a process
1139 * that is being swapped out.
1140 */
1141 void
1142 hat_swapout(hat_t *hat)
1143 {
1144 uintptr_t vaddr = (uintptr_t)0;
1145 uintptr_t eaddr = _userlimit;
1146 htable_t *ht = NULL;
1147 level_t l;
1148
1149 XPV_DISALLOW_MIGRATE();
1150 /*
1151 * We can't just call hat_unload(hat, 0, _userlimit...) here, because
1152 * seg_spt and shared pagetables can't be swapped out.
1153 * Take a look at segspt_shmswapout() - it's a big no-op.
1154 *
1155 * Instead we'll walk through all the address space and unload
1156 * any mappings which we are sure are not shared, not locked.
1157 */
1158 ASSERT(IS_PAGEALIGNED(vaddr));
1159 ASSERT(IS_PAGEALIGNED(eaddr));
1160 ASSERT(AS_LOCK_HELD(hat->hat_as, &hat->hat_as->a_lock));
1161 if ((uintptr_t)hat->hat_as->a_userlimit < eaddr)
1162 eaddr = (uintptr_t)hat->hat_as->a_userlimit;
1163
1164 while (vaddr < eaddr) {
1165 (void) htable_walk(hat, &ht, &vaddr, eaddr);
1166 if (ht == NULL)
1167 break;
1168
1169 ASSERT(!IN_VA_HOLE(vaddr));
1170
1171 /*
1172 * If the page table is shared skip its entire range.
1173 */
1174 l = ht->ht_level;
1175 if (ht->ht_flags & HTABLE_SHARED_PFN) {
1176 vaddr = ht->ht_vaddr + LEVEL_SIZE(l + 1);
1177 htable_release(ht);
1178 ht = NULL;
1179 continue;
1180 }
1181
1182 /*
1183 * If the page table has no locked entries, unload this one.
1184 */
1185 if (ht->ht_lock_cnt == 0)
1186 hat_unload(hat, (caddr_t)vaddr, LEVEL_SIZE(l),
1187 HAT_UNLOAD_UNMAP);
1188
1189 /*
1190 * If we have a level 0 page table with locked entries,
1191 * skip the entire page table, otherwise skip just one entry.
1192 */
1193 if (ht->ht_lock_cnt > 0 && l == 0)
1194 vaddr = ht->ht_vaddr + LEVEL_SIZE(1);
1195 else
1196 vaddr += LEVEL_SIZE(l);
1197 }
1198 if (ht)
1199 htable_release(ht);
1200
1201 /*
1202 * We're in swapout because the system is low on memory, so
1203 * go back and flush all the htables off the cached list.
1204 */
1205 htable_purge_hat(hat);
1206 XPV_ALLOW_MIGRATE();
1207 }
1208
1209 /*
1210 * returns number of bytes that have valid mappings in hat.
1211 */
1212 size_t
1213 hat_get_mapped_size(hat_t *hat)
1214 {
1215 size_t total = 0;
1216 int l;
1217
1218 for (l = 0; l <= mmu.max_page_level; l++)
1219 total += (hat->hat_pages_mapped[l] << LEVEL_SHIFT(l));
1220 total += hat->hat_ism_pgcnt;
1221
1222 return (total);
1223 }
1224
1225 /*
1226 * enable/disable collection of stats for hat.
1227 */
1228 int
1229 hat_stats_enable(hat_t *hat)
|
1108 }
1109
1110 return (pte);
1111 }
1112
1113 /*
1114 * Duplicate address translations of the parent to the child.
1115 * This function really isn't used anymore.
1116 */
1117 /*ARGSUSED*/
1118 int
1119 hat_dup(hat_t *old, hat_t *new, caddr_t addr, size_t len, uint_t flag)
1120 {
1121 ASSERT((uintptr_t)addr < kernelbase);
1122 ASSERT(new != kas.a_hat);
1123 ASSERT(old != kas.a_hat);
1124 return (0);
1125 }
1126
1127 /*
1128 * returns number of bytes that have valid mappings in hat.
1129 */
1130 size_t
1131 hat_get_mapped_size(hat_t *hat)
1132 {
1133 size_t total = 0;
1134 int l;
1135
1136 for (l = 0; l <= mmu.max_page_level; l++)
1137 total += (hat->hat_pages_mapped[l] << LEVEL_SHIFT(l));
1138 total += hat->hat_ism_pgcnt;
1139
1140 return (total);
1141 }
1142
1143 /*
1144 * enable/disable collection of stats for hat.
1145 */
1146 int
1147 hat_stats_enable(hat_t *hat)
|