1.\" $OpenBSD: kvm.3,v 1.9 2013/08/14 08:39:25 jmc Exp $ 2.\" $NetBSD: kvm.3,v 1.2 1996/03/18 22:33:11 thorpej Exp $ 3.\" 4.\" Copyright (c) 1992, 1993 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" This code is derived from software developed by the Computer Systems 8.\" Engineering group at Lawrence Berkeley Laboratory under DARPA contract 9.\" BG 91-66 and contributed to Berkeley. 10.\" 11.\" Redistribution and use in source and binary forms, with or without 12.\" modification, are permitted provided that the following conditions 13.\" are met: 14.\" 1. Redistributions of source code must retain the above copyright 15.\" notice, this list of conditions and the following disclaimer. 16.\" 2. Redistributions in binary form must reproduce the above copyright 17.\" notice, this list of conditions and the following disclaimer in the 18.\" documentation and/or other materials provided with the distribution. 19.\" 3. Neither the name of the University nor the names of its contributors 20.\" may be used to endorse or promote products derived from this software 21.\" without specific prior written permission. 22.\" 23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" SUCH DAMAGE. 34.\" 35.\" @(#)kvm.3 8.1 (Berkeley) 6/4/93 36.\" 37.Dd $Mdocdate: August 14 2013 $ 38.Dt KVM 3 39.Os 40.Sh NAME 41.Nm kvm 42.Nd kernel memory interface 43.Sh DESCRIPTION 44The 45.Nm kvm 46library provides a uniform interface for accessing kernel virtual memory 47images, including live systems and crash dumps. 48Access to live systems is via 49.Pa /dev/mem 50while crash dumps can be examined via the core file generated by 51.Xr savecore 8 . 52The interface behaves identically in both cases. 53Memory can be read and written, kernel symbol addresses can be 54looked up efficiently, and information about user processes can 55be gathered. 56.Pp 57.Fn kvm_open 58is first called to obtain a descriptor for all subsequent calls. 59.Sh FILES 60.Bl -tag -width /dev/mem -compact 61.It Pa /dev/mem 62interface to physical memory 63.El 64.Sh SEE ALSO 65.Xr kvm_geterr 3 , 66.Xr kvm_getloadavg 3 , 67.Xr kvm_getprocs 3 , 68.Xr kvm_nlist 3 , 69.Xr kvm_open 3 , 70.Xr kvm_read 3 71.Sh STANDARDS 72The kvm interface was first introduced in SunOS. 73A considerable 74number of programs have been developed that use this interface, 75making backward compatibility highly desirable. 76In most respects, the Sun kvm interface is consistent and clean. 77Accordingly, the generic portion of the interface (i.e., 78.Fn kvm_open , 79.Fn kvm_close , 80.Fn kvm_read , 81.Fn kvm_write , 82and 83.Fn kvm_nlist ) 84has been incorporated into the 85.Bx 86interface. 87Indeed, many kvm 88applications (i.e., debuggers and statistical monitors) use only 89this subset of the interface. 90.Pp 91The process interface was not kept. 92This is not a portability 93issue since any code that manipulates processes is inherently 94machine dependent. 95.Pp 96Finally, the Sun kvm error reporting semantics are poorly defined. 97The library can be configured either to print errors to stderr automatically, 98or to print no error messages at all. 99In the latter case, the nature of the error cannot be determined. 100To overcome this, the 101.Bx 102interface includes a 103routine, 104.Xr kvm_geterr 3 , 105to return (not print out) the error message 106corresponding to the most recent error condition on the 107given descriptor. 108