xref: /freebsd/share/man/man9/vslock.9 (revision 3078531de10dcae44b253a35125c949ff4235284)
1.\"	$NetBSD: vslock.9,v 1.1 1996/06/15 20:47:29 pk Exp $
2.\"
3.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Paul Kranenburg.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
22.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.\" $FreeBSD$
31.\"
32.Dd August 29, 2012
33.Dt VSLOCK 9
34.Os
35.Sh NAME
36.Nm vslock ,
37.Nm vsunlock
38.Nd lock/unlock user space addresses in memory
39.Sh SYNOPSIS
40.In sys/param.h
41.In sys/proc.h
42.In vm/vm.h
43.In vm/vm_extern.h
44.Ft int
45.Fn vslock "void *addr" "size_t len"
46.Ft void
47.Fn vsunlock "void *addr" "size_t len"
48.Sh DESCRIPTION
49The
50.Fn vslock
51and
52.Fn vsunlock
53functions respectively lock and unlock a range of
54addresses belonging to the currently running process into memory.
55The actual amount of memory locked is a multiple of the machine's page size.
56The starting page number is computed by truncating
57.Fa addr
58to the nearest preceding page boundary, and by rounding up
59.Fa addr +
60.Fa len
61to the next page boundary.
62The process context to use for this operation is taken from the
63global variable
64.Va curproc .
65.Sh RETURN VALUES
66The
67.Fn vslock
68function will return 0 on success, otherwise it will return
69one of the errors listed below.
70.Sh ERRORS
71The
72.Fn vslock
73function will fail if:
74.Bl -tag -width Er
75.It Bq Er EINVAL
76The
77.Fa addr
78and
79.Fa len
80parameters specify a memory range that wraps around the end of the
81machine address space.
82.It Bq Er ENOMEM
83The size of the specified address range exceeds the system
84limit on locked memory.
85.It Bq Er EFAULT
86Some portion of the indicated address range is not allocated.
87There was an error faulting/mapping a page.
88.El
89