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.Dd August 29, 2012 31.Dt VSLOCK 9 32.Os 33.Sh NAME 34.Nm vslock , 35.Nm vsunlock 36.Nd lock/unlock user space addresses in memory 37.Sh SYNOPSIS 38.In sys/param.h 39.In sys/proc.h 40.In vm/vm.h 41.In vm/vm_extern.h 42.Ft int 43.Fn vslock "void *addr" "size_t len" 44.Ft void 45.Fn vsunlock "void *addr" "size_t len" 46.Sh DESCRIPTION 47The 48.Fn vslock 49and 50.Fn vsunlock 51functions respectively lock and unlock a range of 52addresses belonging to the currently running process into memory. 53The actual amount of memory locked is a multiple of the machine's page size. 54The starting page number is computed by truncating 55.Fa addr 56to the nearest preceding page boundary, and by rounding up 57.Fa addr + 58.Fa len 59to the next page boundary. 60The process context to use for this operation is taken from the 61global variable 62.Va curproc . 63.Sh RETURN VALUES 64The 65.Fn vslock 66function will return 0 on success, otherwise it will return 67one of the errors listed below. 68.Sh ERRORS 69The 70.Fn vslock 71function will fail if: 72.Bl -tag -width Er 73.It Bq Er EINVAL 74The 75.Fa addr 76and 77.Fa len 78parameters specify a memory range that wraps around the end of the 79machine address space. 80.It Bq Er ENOMEM 81The size of the specified address range exceeds the system 82limit on locked memory. 83.It Bq Er EFAULT 84Some portion of the indicated address range is not allocated. 85There was an error faulting/mapping a page. 86.El 87