Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ./../../../../../../usr/include/vm/as.h
Real path: /usr/include/vm/as.h
Zurück
/* * Copyright (c) 1986, 2023, Oracle and/or its affiliates. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California * All Rights Reserved * * University Acknowledgment- Portions of this document are derived from * software developed by the University of California, Berkeley, and its * contributors. */ #ifndef _VM_AS_H #define _VM_AS_H #include <sys/watchpoint.h> #include <vm/seg.h> #include <vm/faultcode.h> #include <vm/hat.h> #include <sys/avl.h> #include <sys/proc.h> #include <vm/types.h> #include <sys/vnode.h> #ifdef __cplusplus extern "C" { #endif /* * VM - Address spaces. */ typedef struct as_vht as_vht_t; struct flr; typedef struct as_fault_block { void *af_thread; caddr_t af_start; caddr_t af_end; int af_enabled; } as_fault_block_t; /* * Each address space consists of a sorted list of segments * and machine dependent address translation information. * * All the hard work is in the segment drivers and the * hardware address translation code. * * The segment list is represented as an AVL tree. * * The address space lock (a_lock) is a long term lock which serializes * access to certain operations (as_map, as_unmap) and protects the * underlying generic segment data (seg.h) along with some fields in the * address space structure as shown below: * * address space structure segment structure * * a_segtree s_base * a_size s_size * a_lastgap s_link * a_seglast s_ops * s_as * s_data * * The address space contents lock (a_contents) is a short term * lock that protects most of the data in the address space structure. * This lock is always acquired after the "a_lock" in all situations * except while dealing with AS_CLAIMGAP to avoid deadlocks. * * The following fields are protected by this lock: * * a_flags (AS_PAGLCK, AS_CLAIMGAP, etc.) * a_unmapwait * a_seglast * * The address space lock (a_lock) is always held prior to any segment * operation. Some segment drivers use the address space lock to protect * some or all of their segment private data, provided the version of * "a_lock" (read vs. write) is consistent with the use of the data. * * The following fields are protected by the hat layer lock: * * a_vbits * a_hat * a_hrm * * The procfs file system uses * * a_objectdir * a_sizedir * a_entriesdir * a_updatedir (shared with the address layer) * * a_updatedir is updated in the segment layer: it is set when a vnode is * mapped or unmapped from the address space. It is reset when procfs * updates the objectdir. * Procfs generates the objectdir with the a_lock is held as a reader * to prevents updates to the address space and mutual exclusion to the * procfs fields is guaranteed by prlock() on the specific process, * with the exception of vfork() children which are handled in a different * way. */ struct as { kmutex_t a_contents; /* protect certain fields in the structure */ ushort_t a_flags; /* as attributes */ kcondvar_t a_cv; kcondvar_t a_claimgap_cv; /* used by as_rangelock */ uchar_t a_vbits; /* used for collecting statistics */ uchar_t a_updatedir; /* mappings changed, rebuild a_objectdir */ struct hat *a_hat; /* hat structure */ struct hrmstat *a_hrm; /* ref and mod bits */ caddr_t a_userlimit; /* highest allowable address in this as */ struct seg *a_seglast; /* last segment hit on the addr space */ krwlock_t a_lock; /* protects segment related fields */ size_t a_size; /* total size of address space */ struct seg *a_lastgap; /* last seg found by as_gap() w/ AS_HI (mmap) */ struct seg *a_lastgaphl; /* last seg saved in as_gap() either for */ /* AS_HI or AS_LO used in as_addseg() */ avl_tree_t a_segtree; /* segments in this address space. (AVL tree) */ avl_tree_t *a_prunereqtree; /* Tree containing prune requests */ avl_tree_t a_wpage; /* watched pages (procfs) */ avl_tree_t a_rsvdtree; /* reserved segments */ timespec_t a_updatetime; /* time when mappings last changed */ struct probjent *a_objectdir; /* object directory (procfs) */ int a_entriesdir; /* number of the actual valid entries */ int a_sizedir; /* size of object directory */ struct as_callback *a_callbacks; /* callback list */ proc_t *a_proc; /* back pointer to proc */ size_t a_resvsize; /* size of reserved part of address space */ struct flr *a_flr; /* For controlling anonymous allocations */ as_vht_t **a_vnhash; /* hash table of vnodes mapped into this AS */ caddr_t a_start_hole; /* For va_mask */ caddr_t a_end_hole; /* For va_mask */ kmutex_t a_pginfo; /* Protects hatid */ uint_t a_hatid; /* Stores the hatid for addr space */ as_fault_block_t a_fault_block; /* Block fault handling */ struct seg *a_full_seg; /* Dummy segment for the whole AS */ uint64_t a_writers; /* #range lockers */ kmutex_t a_mutex; /* mutex for seg->s_cv */ }; #define AS_COREDUMPING 0x100 #define AS_PAGLCK 0x080 #define AS_CLAIMGAP 0x040 #define AS_UNMAPWAIT 0x020 #define AS_NEEDSPURGE 0x010 /* mostly for seg_nf, see as_purge() */ #define AS_LOCKING 0x008 /* lock process address space */ #define AS_MWNOCACHE 0x004 /* for seg_vn and mvecs */ #define AS_NOUNMAPWAIT 0x002 #define AS_CLEAVING 0x001 /* segvn_cleave() is active */ #define AS_ISCOREDUMPING(as) ((as)->a_flags & AS_COREDUMPING) #define AS_ISPGLCK(as) ((as)->a_flags & AS_PAGLCK) #define AS_ISCLAIMGAP(as) ((as)->a_flags & AS_CLAIMGAP) #define AS_ISUNMAPWAIT(as) ((as)->a_flags & AS_UNMAPWAIT) #define AS_ISNOUNMAPWAIT(as) ((as)->a_flags & AS_NOUNMAPWAIT) #define AS_ISLOCKING(as) ((as)->a_flags & AS_LOCKING) #define AS_ISMWNOCACHE(as) ((as)->a_flags & AS_MWNOCACHE) #define AS_ISCLEAVING(as) ((as)->a_flags & AS_CLEAVING) #define AS_SETCOREDUMPING(as) ((as)->a_flags |= AS_COREDUMPING) #define AS_SETPGLCK(as) ((as)->a_flags |= AS_PAGLCK) #define AS_SETCLAIMGAP(as) ((as)->a_flags |= AS_CLAIMGAP) #define AS_SETUNMAPWAIT(as) ((as)->a_flags |= AS_UNMAPWAIT) #define AS_SETNOUNMAPWAIT(as) ((as)->a_flags |= AS_NOUNMAPWAIT) #define AS_SETLOCKING(as) ((as)->a_flags |= AS_LOCKING) #define AS_SETMWNOCACHE(as) ((as)->a_flags |= AS_MWNOCACHE) #define AS_SETCLEAVING(as) ((as)->a_flags |= AS_CLEAVING) #define AS_CLRPGLCK(as) ((as)->a_flags &= ~AS_PAGLCK) #define AS_CLRCLAIMGAP(as) ((as)->a_flags &= ~AS_CLAIMGAP) #define AS_CLRUNMAPWAIT(as) ((as)->a_flags &= ~AS_UNMAPWAIT) #define AS_CLRNOUNMAPWAIT(as) ((as)->a_flags &= ~AS_NOUNMAPWAIT) #define AS_CLRLOCKING(as) ((as)->a_flags &= ~AS_LOCKING) #define AS_CLRMWNOCACHE(as) ((as)->a_flags &= ~AS_MWNOCACHE) #define AS_CLRCLEAVING(as) ((as)->a_flags &= ~AS_CLEAVING) #define AS_TYPE_64BIT(as) \ (((as)->a_userlimit > (caddr_t)UINT32_MAX) ? 1 : 0) /* * Flags for as_map/as_map_ansegs */ #define AS_MAP_NO_LPOOB ((uint_t)-1) #define AS_MAP_HEAP ((uint_t)-2) #define AS_MAP_STACK ((uint_t)-3) /* * Flags for a_updatedir. */ #define AS_UPDATE_ADD 0x1 /* objectdir vnodes still valid. */ #define AS_UPDATE_DEL 0x2 /* vnodes possibly no longer valid */ /* * The as_callback is the basic structure which supports the ability to * inform clients of specific events pertaining to address space management. * A user calls as_add_callback to register an address space callback * for a range of pages, specifying the events that need to occur. * When as_do_callbacks is called and finds a 'matching' entry, the * callback is called once, and the callback function MUST call * as_delete_callback when all callback activities are complete. * The thread calling as_do_callbacks blocks until the as_delete_callback * is called. This allows for asynchorous events to subside before the * as_do_callbacks thread continues. * * An example of the need for this is a driver which has done long-term * locking of memory. Address space management operations (events) such * as as_free, as_umap, and as_setprot will block indefinitely until the * pertinent memory is unlocked. The callback mechanism provides the * way to inform the driver of the event so that the driver may do the * necessary unlocking. * * The contents of this structure is protected by a_contents lock */ typedef void (*callback_func_t)(struct as *, void *, uint_t); struct as_callback { struct as_callback *ascb_next; /* list link */ uint_t ascb_events; /* event types */ callback_func_t ascb_func; /* callback function */ void *ascb_arg; /* callback argument */ caddr_t ascb_saddr; /* start address */ size_t ascb_len; /* address range */ }; /* * Callback events */ #define AS_FREE_EVENT 0x1 #define AS_SETPROT_EVENT 0x2 #define AS_UNMAP_EVENT 0x4 #define AS_CALLBACK_CALLED ((uint_t)(1U << (8 * sizeof (uint_t) - 1U))) #define AS_UNMAPWAIT_EVENT \ (AS_FREE_EVENT | AS_SETPROT_EVENT | AS_UNMAP_EVENT) #define AS_ALL_EVENT \ (AS_FREE_EVENT | AS_SETPROT_EVENT | AS_UNMAP_EVENT) /* Return code values for as_callback_delete */ enum as_cbdelete_rc { AS_CALLBACK_DELETED, AS_CALLBACK_NOTFOUND, AS_CALLBACK_DELETE_DEFERRED }; /* * Vnode hash table for struct as. This table contains information * on which vnodes are mapped into the address space so that we don't need * to walk the AS to get that information. */ struct as_vht { struct as_vht *vht_next; struct vnode *vht_vp; uintptr_t vht_refcnt; }; #define AS_VNHASHSHIFT 9 #define AS_VNHASHSIZE (1 << AS_VNHASHSHIFT) #define AS_VNHASHINDEX(vp) \ (((((uintptr_t)(vp)) >> VN_SHIFT) ^ \ (((uintptr_t)(vp)) >> (VN_SHIFT + AS_VNHASHSHIFT))) & \ (AS_VNHASHSIZE - 1)) #ifdef _KERNEL /* * Flags for as_gap. */ #define AH_DIR 0x1 /* direction flag mask */ #define AH_LO 0x0 /* find lowest hole */ #define AH_HI 0x1 /* find highest hole */ #define AH_CONTAIN 0x2 /* hole must contain `addr' */ #define AH_NOCACHE 0x4 /* don't cache the hole in lastgap */ #define AH_LOCKED 0x8 /* as lock is already held */ extern struct as kas; /* kernel's address space */ /* * Macros for address space locking. */ #define AS_LOCK_ENTER(as, lock, type) rw_enter((lock), (type)) #define AS_LOCK_EXIT(as, lock) rw_exit((lock)) #define AS_LOCK_DESTROY(as, lock) rw_destroy((lock)) #define AS_LOCK_TRYENTER(as, lock, type) rw_tryenter((lock), (type)) #define AS_LOCK_DOWNGRADE(as, lock) rw_downgrade((lock)) #define AS_LOCK_ENTER_SIG(as, lock, type) rw_enter_sig((lock), (type)) /* * Macros to test lock states. */ #define AS_LOCK_HELD(as, lock) RW_LOCK_HELD((lock)) #define AS_READ_HELD(as, lock) RW_READ_HELD((lock)) #define AS_WRITE_HELD(as, lock) RW_WRITE_HELD((lock)) /* * macros to walk thru segment lists */ #define AS_SEGFIRST(as) avl_first(&(as)->a_segtree) #define AS_SEGNEXT(as, seg) AVL_NEXT(&(as)->a_segtree, (seg)) #define AS_SEGPREV(as, seg) AVL_PREV(&(as)->a_segtree, (seg)) void as_init(void); void as_avlinit(struct as *); struct seg *as_segat(struct as *as, caddr_t addr); void as_rangelock(struct as *as); void as_rangeunlock(struct as *as); struct as *as_alloc(struct proc *p); struct as *as_alloc_model(struct proc *p, model_t m); void as_free(struct as *as); int as_dup(struct as *as, struct proc *forkedproc); struct seg *as_findseg(struct as *as, caddr_t addr, int tail); int as_addseg(struct as *as, struct seg *newseg); struct seg *as_removeseg(struct as *as, struct seg *seg); faultcode_t as_fault(struct hat *hat, struct as *as, caddr_t addr, size_t size, enum fault_type type, enum seg_rw rw); faultcode_t as_faulta(struct as *as, caddr_t addr, size_t size); int as_setprot(struct as *as, caddr_t addr, size_t size, uint_t prot); int as_checkprot(struct as *as, caddr_t addr, size_t size, uint_t prot); void as_setlwpchan(struct as *as, caddr_t addr); int as_unmap(struct as *as, caddr_t addr, size_t size); int as_unmap_impl(struct as *as, caddr_t addr, size_t size, int); int as_map(struct as *as, caddr_t addr, size_t size, int ((*crfp)()), void *argsp); int as_map_locked(struct as *as, caddr_t addr, size_t size, int ((*crfp)()), void *argsp); void as_purge(struct as *as); int as_gap(struct as *as, size_t minlen, caddr_t *basep, size_t *lenp, uint_t flags, caddr_t addr); int as_gap_aligned(struct as *as, size_t minlen, caddr_t *basep, size_t *lenp, uint_t flags, caddr_t addr, size_t align, size_t redzone, size_t off); int as_memory(struct as *as, caddr_t *basep, size_t *lenp); size_t as_swapout(struct as *as); int as_incore(struct as *as, caddr_t addr, size_t size, char *vec, size_t *sizep); int as_ctl(struct as *as, caddr_t addr, size_t size, int func, int attr, uintptr_t arg, ulong_t *lock_map, size_t pos); int as_ctl_entire(struct as *as, int func, int attr, uintptr_t arg); int as_fault_block(struct as *as, caddr_t start, size_t len); void as_fault_unblock(struct as *as, caddr_t start, size_t len); int as_fault_blocked(struct as *as, caddr_t addr, size_t len, enum fault_type type); enum as_lock_mwlist_flags { ALW_LONGTERM = (1 << 0) /* long-lasting locking op */ }; int as_lock_mwlist(struct as *, caddr_t, size_t, enum seg_rw, enum as_lock_mwlist_flags flags, mw_t **, mw_t **); void as_unlock_mwlist(struct as *, mw_t *); int as_pagelock(struct as *as, struct page ***ppp, caddr_t addr, size_t size, enum seg_rw rw); void as_pageunlock(struct as *as, struct page **pp, caddr_t addr, size_t size, enum seg_rw rw); int as_setpagesize(struct as *as, caddr_t addr, size_t size, uint_t szc, boolean_t wait, boolean_t as_lock_held); int as_set_default_lpsize(struct as *as, caddr_t addr, size_t size); void as_setwatch(struct as *as); void as_clearwatch(struct as *as); int as_getadi(struct seg *, caddr_t, size_t, ulong_t *); int as_setadi(struct seg *, caddr_t, size_t, int, ulong_t *, size_t); int as_getmemid(struct as *, caddr_t, memid_t *); int as_add_callback(struct as *, void (*)(), void *, uint_t, caddr_t, size_t, int); uint_t as_delete_callback(struct as *, void *); pgcnt_t as_callback_pages(struct as *, caddr_t, size_t); void as_vht_alloc(struct as *); void as_vht_free(struct as *); void as_vht_hold(struct as *, vnode_t *); void as_vht_rele(struct as *, vnode_t *); void as_create_prunereqtree(struct as *as); void as_destroy_prunereqtree(struct as *as); int as_add_prunereq(struct as *as, caddr_t addr, size_t len, int cmd); void as_remove_prunereq(struct as *as, caddr_t addr, size_t len); prune_node_t *as_find_prunereq(struct as *as, caddr_t addr, int direction); int as_populate_array(struct as *as, caddr_t saddr, size_t len, char *pg_preqs); void as_va_mask_set_exec(struct as *, int); #ifdef __sparc size_t as_adi_metadata(struct as *const as); #else #define as_adi_metadata(as) (0) #endif /* * This #define allows drivers to determine whether as_addrinfo() * is available at compile time. */ #define _AS_ADDRINFO_AVAIL 1 void as_addrinfo(struct as *, const caddr_t, paddr_t *, size_t *, lgrp_id_t *, int *); #endif /* _KERNEL */ #ifdef __cplusplus } #endif #endif /* _VM_AS_H */