1*108b671bSjsg.\" $OpenBSD: kvm_dump.3,v 1.13 2023/01/04 10:59:34 jsg Exp $ 215f0ebb0Sderaadt.\" $NetBSD: kvm_dump.3,v 1.1 1996/03/18 21:11:12 leo Exp $ 315f0ebb0Sderaadt.\" 415f0ebb0Sderaadt.\" Copyright (c) 1996 Leo Weppelman 515f0ebb0Sderaadt.\" All rights reserved. 615f0ebb0Sderaadt.\" 715f0ebb0Sderaadt.\" Redistribution and use in source and binary forms, with or without 815f0ebb0Sderaadt.\" modification, are permitted provided that the following conditions 915f0ebb0Sderaadt.\" are met: 1015f0ebb0Sderaadt.\" 1. Redistributions of source code must retain the above copyright 1115f0ebb0Sderaadt.\" notice, this list of conditions and the following disclaimer. 1215f0ebb0Sderaadt.\" 2. Redistributions in binary form must reproduce the above copyright 1315f0ebb0Sderaadt.\" notice, this list of conditions and the following disclaimer in the 1415f0ebb0Sderaadt.\" documentation and/or other materials provided with the distribution. 1515f0ebb0Sderaadt.\" 1615f0ebb0Sderaadt.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1715f0ebb0Sderaadt.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1815f0ebb0Sderaadt.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1915f0ebb0Sderaadt.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2015f0ebb0Sderaadt.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2115f0ebb0Sderaadt.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2215f0ebb0Sderaadt.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2315f0ebb0Sderaadt.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2415f0ebb0Sderaadt.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2515f0ebb0Sderaadt.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2615f0ebb0Sderaadt.\" 2715f0ebb0Sderaadt.\" 28*108b671bSjsg.Dd $Mdocdate: January 4 2023 $ 29d04ba2ccSjmc.Dt KVM_DUMP_MKHEADER 3 3015f0ebb0Sderaadt.Os 3115f0ebb0Sderaadt.Sh NAME 3215f0ebb0Sderaadt.Nm kvm_dump_mkheader , 3315f0ebb0Sderaadt.Nm kvm_dump_wrtheader , 3415f0ebb0Sderaadt.Nm kvm_dump_inval 3531592a35Sjmc.Nd crash dump support functions 3615f0ebb0Sderaadt.Sh SYNOPSIS 3786f9d4cdStedu.In kvm.h 3815f0ebb0Sderaadt.Ft int 3915f0ebb0Sderaadt.Fn kvm_dump_mkheader "kvm_t *kd" "off_t dump_off" 4015f0ebb0Sderaadt.Ft int 4115f0ebb0Sderaadt.Fn kvm_dump_wrtheader "kvm_t *kd" "FILE *fp" "int dumpsize" 4215f0ebb0Sderaadt.Ft int 4315f0ebb0Sderaadt.Fn kvm_dump_inval "kvm_t *kd" 4415f0ebb0Sderaadt.Sh DESCRIPTION 4515f0ebb0SderaadtFirst note that the functions described here were designed to be used by 4615f0ebb0Sderaadt.Xr savecore 8 . 4715f0ebb0Sderaadt.Pp 4815f0ebb0SderaadtThe function 4915f0ebb0Sderaadt.Fn kvm_dump_mkheader 5015f0ebb0Sderaadtchecks if the physical memory file associated with 5115f0ebb0Sderaadt.Fa kd 5231592a35Sjmccontains a valid crash dump header as generated by a dumping kernel. 532bb07095SaaronWhen a valid header is found, 5415f0ebb0Sderaadt.Fn kvm_dump_mkheader 5531592a35Sjmcinitializes the internal kvm data structures as if a crash dump generated by 5615f0ebb0Sderaadtthe 5715f0ebb0Sderaadt.Xr savecore 8 582bb07095Saaronprogram was opened. 592bb07095SaaronThis has the intentional side effect of enabling the 6015f0ebb0Sderaadtaddress translation machinery. 6115f0ebb0Sderaadt.Pp 6215f0ebb0SderaadtA call to 6315f0ebb0Sderaadt.Fn kvm_dump_mkheader 6415f0ebb0Sderaadtwill most likely be followed by a call to 6515f0ebb0Sderaadt.Fn kvm_dump_wrtheader . 662bb07095SaaronThis function takes care of generating the generic header, the 672bb07095Saaron.Dv CORE_CPU 682bb07095Saaronsection and the section header of the 692bb07095Saaron.Dv CORE_DATA 702bb07095Saaronsection. 712bb07095SaaronThe data is written to the file pointed at by 7215f0ebb0Sderaadt.Fa fp . 7315f0ebb0SderaadtThe 7415f0ebb0Sderaadt.Fa dumpsize 755c481315Saaronargument is only used to properly set the segment size of the 762bb07095Saaron.Dv CORE_DATA 772bb07095Saaronsection. 782bb07095SaaronNote that this function assumes that 7915f0ebb0Sderaadt.Fa fp 802bb07095Saaronis positioned at file location 0. 812bb07095SaaronThis function will not seek and therefore allows 8215f0ebb0Sderaadt.Fa fp 8315f0ebb0Sderaadtto be a file pointer obtained by 8415f0ebb0Sderaadt.Fn zopen . 8515f0ebb0Sderaadt.Pp 8615f0ebb0SderaadtThe 8715f0ebb0Sderaadt.Fn kvm_dump_inval 8815f0ebb0Sderaadtfunction clears the magic number in the physical memory file associated with 8915f0ebb0Sderaadt.Fa kd . 9015f0ebb0SderaadtThe address translations must be enabled for this to work (thus assuming 9115f0ebb0Sderaadtthat 925c481315Saaron.Fn kvm_dump_mkheader 9315f0ebb0Sderaadtwas called earlier in the sequence). 9415f0ebb0Sderaadt.Sh RETURN VALUES 952bb07095SaaronAll functions return 0 on success, \-1 on failure. 962bb07095SaaronIn the case of failure, 9715f0ebb0Sderaadt.Xr kvm_geterr 3 9815f0ebb0Sderaadtcan be used to retrieve the cause of the error. 99cdafad35Sjmc.Sh SEE ALSO 100cdafad35Sjmc.Xr kvm 3 10115f0ebb0Sderaadt.Sh HISTORY 102ea2542f8SmpechThese functions first appeared in 103ea2542f8Smpech.Nx 1.1a . 104