4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
28
29 /*
30 * University Copyright- Copyright (c) 1982, 1986, 1988
31 * The Regents of the University of California
32 * All Rights Reserved
33 *
34 * University Acknowledgment- Portions of this document are derived from
35 * software developed by the University of California, Berkeley, and its
36 * contributors.
37 */
38
39 #ifndef _VM_HAT_H
40 #define _VM_HAT_H
41
42 #include <sys/types.h>
43 #include <sys/t_lock.h>
252 caddr_t hat_kpm_mseg_reuse(struct memseg *);
253 void hat_kpm_delmem_mseg_update(struct memseg *, struct memseg **);
254 void hat_kpm_split_mseg_update(struct memseg *, struct memseg **,
255 struct memseg *, struct memseg *, struct memseg *);
256 void hat_kpm_walk(void (*)(void *, void *, size_t), void *);
257
258 /*
259 * Operations on all translations for a given page(s)
260 *
261 * void hat_page_setattr(pp, flag)
262 * void hat_page_clrattr(pp, flag)
263 * used to set/clr red/mod bits.
264 *
265 * uint hat_page_getattr(pp, flag)
266 * If flag is specified, returns 0 if attribute is disabled
267 * and non zero if enabled. If flag specifes multiple attributs
268 * then returns 0 if ALL atriibutes are disabled. This is an advisory
269 * call.
270 *
271 * int hat_pageunload(pp, forceflag)
272 * unload all translations attached to pp.
273 *
274 * uint_t hat_pagesync(pp, flags)
275 * get hw stats from hardware into page struct and reset hw stats
276 * returns attributes of page
277 *
278 * ulong_t hat_page_getshare(pp)
279 * returns approx number of mappings to this pp. A return of 0 implies
280 * there are no mappings to the page.
281 *
282 * faultcode_t hat_softlock(hat, addr, lenp, ppp, flags);
283 * called to softlock pages for zero copy tcp
284 *
285 * void hat_page_demote(pp);
286 * unload all large mappings to pp and decrease p_szc of all
287 * constituent pages according to the remaining mappings.
288 */
289
290 void hat_page_setattr(struct page *, uint_t);
291 void hat_page_clrattr(struct page *, uint_t);
292 uint_t hat_page_getattr(struct page *, uint_t);
293 int hat_pageunload(struct page *, uint_t);
294 uint_t hat_pagesync(struct page *, uint_t);
295 ulong_t hat_page_getshare(struct page *);
296 int hat_page_checkshare(struct page *, ulong_t);
297 faultcode_t hat_softlock(struct hat *, caddr_t, size_t *,
298 struct page **, uint_t);
299 void hat_page_demote(struct page *);
300
301 /*
302 * Rountine to expose supported HAT features to PIM.
303 */
304 enum hat_features {
305 HAT_SHARED_PT, /* Shared page tables */
306 HAT_DYNAMIC_ISM_UNMAP, /* hat_pageunload() handles ISM pages */
307 HAT_VMODSORT, /* support for VMODSORT flag of vnode */
308 HAT_SHARED_REGIONS /* shared regions support */
309 };
310
311 int hat_supported(enum hat_features, void *);
312
313 /*
443 * Flags for hat_dup
444 *
445 * HAT_DUP_ALL dup entire address space
446 * HAT_DUP_COW dup plus hat_clrattr(..PROT_WRITE) on newas
447 */
448 #define HAT_DUP_ALL 1
449 #define HAT_DUP_COW 2
450 #define HAT_DUP_SRD 3
451
452
453 /*
454 * Flags for hat_map
455 */
456 #define HAT_MAP 0x00
457
458 /*
459 * Flag for hat_pageunload
460 */
461 #define HAT_ADV_PGUNLOAD 0x00
462 #define HAT_FORCE_PGUNLOAD 0x01
463
464 /*
465 * Attributes for hat_page_*attr, hat_setstats and
466 * returned by hat_pagesync.
467 */
468 #define P_MOD 0x1 /* the modified bit */
469 #define P_REF 0x2 /* the referenced bit */
470 #define P_RO 0x4 /* Read only page */
471 #define P_NSH 0x8 /* Not to shuffle v_pages */
472
473 #define hat_ismod(pp) (hat_page_getattr(pp, P_MOD))
474 #define hat_isref(pp) (hat_page_getattr(pp, P_REF))
475 #define hat_isro(pp) (hat_page_getattr(pp, P_RO))
476
477 #define hat_setmod(pp) (hat_page_setattr(pp, P_MOD))
478 #define hat_setmod_only(pp) (hat_page_setattr(pp, P_MOD|P_NSH))
479 #define hat_setref(pp) (hat_page_setattr(pp, P_REF))
480 #define hat_setrefmod(pp) (hat_page_setattr(pp, P_REF|P_MOD))
481
482 #define hat_clrmod(pp) (hat_page_clrattr(pp, P_MOD))
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright 2014 Joyent, Inc. All rights reserved.
25 */
26
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
29
30 /*
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
33 * All Rights Reserved
34 *
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
37 * contributors.
38 */
39
40 #ifndef _VM_HAT_H
41 #define _VM_HAT_H
42
43 #include <sys/types.h>
44 #include <sys/t_lock.h>
253 caddr_t hat_kpm_mseg_reuse(struct memseg *);
254 void hat_kpm_delmem_mseg_update(struct memseg *, struct memseg **);
255 void hat_kpm_split_mseg_update(struct memseg *, struct memseg **,
256 struct memseg *, struct memseg *, struct memseg *);
257 void hat_kpm_walk(void (*)(void *, void *, size_t), void *);
258
259 /*
260 * Operations on all translations for a given page(s)
261 *
262 * void hat_page_setattr(pp, flag)
263 * void hat_page_clrattr(pp, flag)
264 * used to set/clr red/mod bits.
265 *
266 * uint hat_page_getattr(pp, flag)
267 * If flag is specified, returns 0 if attribute is disabled
268 * and non zero if enabled. If flag specifes multiple attributs
269 * then returns 0 if ALL atriibutes are disabled. This is an advisory
270 * call.
271 *
272 * int hat_pageunload(pp, forceflag)
273 * Unload all translations attached to pp. On x86 the bulk of the work is
274 * done by hat_page_inval.
275 *
276 * void hat_page_inval(pp, pgsz, curhat)
277 * Unload translations attached to pp. If curhat is provided, only the
278 * translation for that process is unloaded, otherwise all are unloaded.
279 *
280 * uint_t hat_pagesync(pp, flags)
281 * get hw stats from hardware into page struct and reset hw stats
282 * returns attributes of page
283 *
284 * ulong_t hat_page_getshare(pp)
285 * returns approx number of mappings to this pp. A return of 0 implies
286 * there are no mappings to the page.
287 *
288 * faultcode_t hat_softlock(hat, addr, lenp, ppp, flags);
289 * called to softlock pages for zero copy tcp
290 *
291 * void hat_page_demote(pp);
292 * unload all large mappings to pp and decrease p_szc of all
293 * constituent pages according to the remaining mappings.
294 */
295
296 void hat_page_setattr(struct page *, uint_t);
297 void hat_page_clrattr(struct page *, uint_t);
298 uint_t hat_page_getattr(struct page *, uint_t);
299 int hat_pageunload(struct page *, uint_t);
300 void hat_page_inval(struct page *, uint_t, struct hat *);
301 uint_t hat_pagesync(struct page *, uint_t);
302 ulong_t hat_page_getshare(struct page *);
303 int hat_page_checkshare(struct page *, ulong_t);
304 faultcode_t hat_softlock(struct hat *, caddr_t, size_t *,
305 struct page **, uint_t);
306 void hat_page_demote(struct page *);
307
308 /*
309 * Rountine to expose supported HAT features to PIM.
310 */
311 enum hat_features {
312 HAT_SHARED_PT, /* Shared page tables */
313 HAT_DYNAMIC_ISM_UNMAP, /* hat_pageunload() handles ISM pages */
314 HAT_VMODSORT, /* support for VMODSORT flag of vnode */
315 HAT_SHARED_REGIONS /* shared regions support */
316 };
317
318 int hat_supported(enum hat_features, void *);
319
320 /*
450 * Flags for hat_dup
451 *
452 * HAT_DUP_ALL dup entire address space
453 * HAT_DUP_COW dup plus hat_clrattr(..PROT_WRITE) on newas
454 */
455 #define HAT_DUP_ALL 1
456 #define HAT_DUP_COW 2
457 #define HAT_DUP_SRD 3
458
459
460 /*
461 * Flags for hat_map
462 */
463 #define HAT_MAP 0x00
464
465 /*
466 * Flag for hat_pageunload
467 */
468 #define HAT_ADV_PGUNLOAD 0x00
469 #define HAT_FORCE_PGUNLOAD 0x01
470 #define HAT_CURPROC_PGUNLOAD 0x02
471
472 /*
473 * Attributes for hat_page_*attr, hat_setstats and
474 * returned by hat_pagesync.
475 */
476 #define P_MOD 0x1 /* the modified bit */
477 #define P_REF 0x2 /* the referenced bit */
478 #define P_RO 0x4 /* Read only page */
479 #define P_NSH 0x8 /* Not to shuffle v_pages */
480
481 #define hat_ismod(pp) (hat_page_getattr(pp, P_MOD))
482 #define hat_isref(pp) (hat_page_getattr(pp, P_REF))
483 #define hat_isro(pp) (hat_page_getattr(pp, P_RO))
484
485 #define hat_setmod(pp) (hat_page_setattr(pp, P_MOD))
486 #define hat_setmod_only(pp) (hat_page_setattr(pp, P_MOD|P_NSH))
487 #define hat_setref(pp) (hat_page_setattr(pp, P_REF))
488 #define hat_setrefmod(pp) (hat_page_setattr(pp, P_REF|P_MOD))
489
490 #define hat_clrmod(pp) (hat_page_clrattr(pp, P_MOD))
|