3 *
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 (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2016 Joyent, Inc.
24 */
25
26 #include <sys/types.h>
27 #include <sys/t_lock.h>
28 #include <sys/param.h>
29 #include <sys/sysmacros.h>
30 #include <sys/tuneable.h>
31 #include <sys/systm.h>
32 #include <sys/vm.h>
33 #include <sys/kmem.h>
34 #include <sys/vmem.h>
35 #include <sys/mman.h>
36 #include <sys/cmn_err.h>
37 #include <sys/debug.h>
38 #include <sys/dumphdr.h>
39 #include <sys/bootconf.h>
40 #include <sys/lgrp.h>
41 #include <vm/seg_kmem.h>
42 #include <vm/hat.h>
43 #include <vm/page.h>
808 seg->s_ops = &segkmem_ops;
809 seg->s_data = &zvp;
810 kas.a_size += seg->s_size;
811 return (0);
812 }
813
814 int
815 segkmem_create(struct seg *seg)
816 {
817 ASSERT(seg->s_as == &kas && RW_WRITE_HELD(&kas.a_lock));
818 seg->s_ops = &segkmem_ops;
819 seg->s_data = &kvp;
820 kas.a_size += seg->s_size;
821 return (0);
822 }
823
824 /*ARGSUSED*/
825 page_t *
826 segkmem_page_create(void *addr, size_t size, int vmflag, void *arg)
827 {
828 struct seg kseg;
829 int pgflags;
830 struct vnode *vp = arg;
831
832 if (vp == NULL)
833 vp = &kvp;
834
835 kseg.s_as = &kas;
836 pgflags = PG_EXCL;
837
838 if (segkmem_reloc == 0 || (vmflag & VM_NORELOC))
839 pgflags |= PG_NORELOC;
840 if ((vmflag & VM_NOSLEEP) == 0)
841 pgflags |= PG_WAIT;
842 if (vmflag & VM_PANIC)
843 pgflags |= PG_PANIC;
844 if (vmflag & VM_PUSHPAGE)
845 pgflags |= PG_PUSHPAGE;
846 if (vmflag & VM_NORMALPRI) {
847 ASSERT(vmflag & VM_NOSLEEP);
848 pgflags |= PG_NORMALPRI;
849 }
850
851 return (page_create_va(vp, (u_offset_t)(uintptr_t)addr, size,
852 pgflags, &kseg, addr));
853 }
854
855 /*
856 * Allocate pages to back the virtual address range [addr, addr + size).
|
3 *
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 (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2019 Joyent, Inc.
24 */
25
26 #include <sys/types.h>
27 #include <sys/t_lock.h>
28 #include <sys/param.h>
29 #include <sys/sysmacros.h>
30 #include <sys/tuneable.h>
31 #include <sys/systm.h>
32 #include <sys/vm.h>
33 #include <sys/kmem.h>
34 #include <sys/vmem.h>
35 #include <sys/mman.h>
36 #include <sys/cmn_err.h>
37 #include <sys/debug.h>
38 #include <sys/dumphdr.h>
39 #include <sys/bootconf.h>
40 #include <sys/lgrp.h>
41 #include <vm/seg_kmem.h>
42 #include <vm/hat.h>
43 #include <vm/page.h>
808 seg->s_ops = &segkmem_ops;
809 seg->s_data = &zvp;
810 kas.a_size += seg->s_size;
811 return (0);
812 }
813
814 int
815 segkmem_create(struct seg *seg)
816 {
817 ASSERT(seg->s_as == &kas && RW_WRITE_HELD(&kas.a_lock));
818 seg->s_ops = &segkmem_ops;
819 seg->s_data = &kvp;
820 kas.a_size += seg->s_size;
821 return (0);
822 }
823
824 /*ARGSUSED*/
825 page_t *
826 segkmem_page_create(void *addr, size_t size, int vmflag, void *arg)
827 {
828 struct seg kseg = { 0 };
829 int pgflags = PG_EXCL;
830 struct vnode *vp = arg;
831
832 if (vp == NULL)
833 vp = &kvp;
834
835 kseg.s_as = &kas;
836
837 if (segkmem_reloc == 0 || (vmflag & VM_NORELOC))
838 pgflags |= PG_NORELOC;
839 if ((vmflag & VM_NOSLEEP) == 0)
840 pgflags |= PG_WAIT;
841 if (vmflag & VM_PANIC)
842 pgflags |= PG_PANIC;
843 if (vmflag & VM_PUSHPAGE)
844 pgflags |= PG_PUSHPAGE;
845 if (vmflag & VM_NORMALPRI) {
846 ASSERT(vmflag & VM_NOSLEEP);
847 pgflags |= PG_NORMALPRI;
848 }
849
850 return (page_create_va(vp, (u_offset_t)(uintptr_t)addr, size,
851 pgflags, &kseg, addr));
852 }
853
854 /*
855 * Allocate pages to back the virtual address range [addr, addr + size).
|