xref: /onnv-gate/usr/src/uts/common/sys/dumphdr.h (revision 12967:ab9ae749152f)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
53446Smrj  * Common Development and Distribution License (the "License").
63446Smrj  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
2212640SDave.Plauger@Sun.COM  * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate #ifndef _SYS_DUMPHDR_H
260Sstevel@tonic-gate #define	_SYS_DUMPHDR_H
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #include <sys/types.h>
290Sstevel@tonic-gate #include <sys/param.h>
300Sstevel@tonic-gate #include <sys/utsname.h>
310Sstevel@tonic-gate #include <sys/log.h>
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #ifdef	__cplusplus
340Sstevel@tonic-gate extern "C" {
350Sstevel@tonic-gate #endif
360Sstevel@tonic-gate 
370Sstevel@tonic-gate /*
380Sstevel@tonic-gate  * The dump header describes the contents of a crash dump.  Two headers
390Sstevel@tonic-gate  * are written out: one at the beginning of the dump, and the other at
400Sstevel@tonic-gate  * the very end of the dump device.  The terminal header is at a known
410Sstevel@tonic-gate  * location (end of device) so we can always find it.  The initial header
420Sstevel@tonic-gate  * is redundant, but helps savecore(1M) determine whether the dump has been
430Sstevel@tonic-gate  * overwritten by swap activity.  See dumpadm(1M) for dump configuration.
440Sstevel@tonic-gate  */
450Sstevel@tonic-gate #define	DUMP_MAGIC	0xdefec8edU		/* dump magic number */
46*12967Sgavin.maltby@oracle.com #define	DUMP_VERSION	10			/* version of this dumphdr */
470Sstevel@tonic-gate #define	DUMP_WORDSIZE	(sizeof (long) * NBBY)	/* word size (32 or 64) */
480Sstevel@tonic-gate #define	DUMP_PANICSIZE	200			/* Max panic string copied */
490Sstevel@tonic-gate #define	DUMP_COMPRESS_RATIO	2		/* conservative; usually 2.5+ */
500Sstevel@tonic-gate #define	DUMP_OFFSET	65536			/* pad at start/end of dev */
510Sstevel@tonic-gate #define	DUMP_LOGSIZE	(2 * LOG_HIWAT)		/* /dev/log message save area */
520Sstevel@tonic-gate #define	DUMP_ERPTSIZE   (P2ROUNDUP(	\
530Sstevel@tonic-gate 	(ERPT_DATA_SZ / 2) *		\
540Sstevel@tonic-gate 	(ERPT_EVCH_MAX +		\
550Sstevel@tonic-gate 	ERPT_MAX_ERRS * ERPT_HIWAT),	\
560Sstevel@tonic-gate 	DUMP_OFFSET))				/* ereport save area */
57*12967Sgavin.maltby@oracle.com #define	DUMP_SUMMARYSIZE (P2ROUNDUP(    \
58*12967Sgavin.maltby@oracle.com 	(STACK_BUF_SIZE +	       \
59*12967Sgavin.maltby@oracle.com 	sizeof (summary_dump_t) + 1024), \
60*12967Sgavin.maltby@oracle.com 	DUMP_OFFSET))				/* summary save area */
610Sstevel@tonic-gate 
620Sstevel@tonic-gate typedef struct dumphdr {
630Sstevel@tonic-gate 	uint32_t dump_magic;		/* magic number */
640Sstevel@tonic-gate 	uint32_t dump_version;		/* version number */
650Sstevel@tonic-gate 	uint32_t dump_flags;		/* flags; see below */
660Sstevel@tonic-gate 	uint32_t dump_wordsize;		/* 32 or 64 */
670Sstevel@tonic-gate 	offset_t dump_start;		/* starting offset on dump device */
680Sstevel@tonic-gate 	offset_t dump_ksyms;		/* offset of compressed symbol table */
690Sstevel@tonic-gate 	offset_t dump_pfn;		/* offset of pfn table for all pages */
700Sstevel@tonic-gate 	offset_t dump_map;		/* offset of page translation map */
710Sstevel@tonic-gate 	offset_t dump_data;		/* offset of actual dump data */
720Sstevel@tonic-gate 	struct utsname dump_utsname;	/* copy of utsname structure */
730Sstevel@tonic-gate 	char	dump_platform[SYS_NMLN]; /* platform name (uname -i) */
740Sstevel@tonic-gate 	char	dump_panicstring[DUMP_PANICSIZE]; /* copy of panicstr */
750Sstevel@tonic-gate 	time_t	dump_crashtime;		/* time of crash */
760Sstevel@tonic-gate 	long	dump_pageshift;		/* log2(pagesize) */
770Sstevel@tonic-gate 	long	dump_pagesize;		/* pagesize */
780Sstevel@tonic-gate 	long	dump_hashmask;		/* page translation hash mask */
790Sstevel@tonic-gate 	long	dump_nvtop;		/* number of vtop table entries */
800Sstevel@tonic-gate 	pgcnt_t	dump_npages;		/* number of data pages */
810Sstevel@tonic-gate 	size_t	dump_ksyms_size;	/* kernel symbol table size */
820Sstevel@tonic-gate 	size_t	dump_ksyms_csize;	/* compressed symbol table size */
83*12967Sgavin.maltby@oracle.com 	uint32_t dump_fm_panic;		/* initiated from fm subsystems */
84*12967Sgavin.maltby@oracle.com 	char	dump_uuid[36 + 1];	/* os image uuid */
850Sstevel@tonic-gate } dumphdr_t;
860Sstevel@tonic-gate 
870Sstevel@tonic-gate /*
880Sstevel@tonic-gate  * Values for dump_flags
890Sstevel@tonic-gate  */
900Sstevel@tonic-gate #define	DF_VALID	0x00000001	/* Dump is valid (savecore clears) */
910Sstevel@tonic-gate #define	DF_COMPLETE	0x00000002	/* All pages present as configured */
920Sstevel@tonic-gate #define	DF_LIVE		0x00000004	/* Dump was taken on a live system */
9310843SDave.Plauger@Sun.COM #define	DF_COMPRESSED	0x00000008	/* Dump is compressed */
940Sstevel@tonic-gate #define	DF_KERNEL	0x00010000	/* Contains kernel pages only */
950Sstevel@tonic-gate #define	DF_ALL		0x00020000	/* Contains all pages */
960Sstevel@tonic-gate #define	DF_CURPROC	0x00040000	/* Contains kernel + cur proc pages */
970Sstevel@tonic-gate #define	DF_CONTENT	0xffff0000	/* The set of all dump content flags */
980Sstevel@tonic-gate 
990Sstevel@tonic-gate /*
1000Sstevel@tonic-gate  * Dump translation map hash table entry.
1010Sstevel@tonic-gate  */
1020Sstevel@tonic-gate typedef struct dump_map {
1030Sstevel@tonic-gate 	offset_t	dm_first;
1040Sstevel@tonic-gate 	offset_t	dm_next;
1050Sstevel@tonic-gate 	offset_t	dm_data;
1060Sstevel@tonic-gate 	struct as	*dm_as;
1070Sstevel@tonic-gate 	uintptr_t	dm_va;
1080Sstevel@tonic-gate } dump_map_t;
1090Sstevel@tonic-gate 
1100Sstevel@tonic-gate /*
1110Sstevel@tonic-gate  * Dump translation map hash function.
1120Sstevel@tonic-gate  */
1130Sstevel@tonic-gate #define	DUMP_HASH(dhp, as, va)	\
1140Sstevel@tonic-gate 	((((uintptr_t)(as) >> 3) + ((va) >> (dhp)->dump_pageshift)) & \
1150Sstevel@tonic-gate 	(dhp)->dump_hashmask)
1160Sstevel@tonic-gate 
11710843SDave.Plauger@Sun.COM /*
11810843SDave.Plauger@Sun.COM  * Encoding of the csize word used to provide meta information
11910843SDave.Plauger@Sun.COM  * between dumpsys and savecore.
12010843SDave.Plauger@Sun.COM  *
12110843SDave.Plauger@Sun.COM  *	tag	size
12210843SDave.Plauger@Sun.COM  *	1-4095	1..dump_maxcsize	stream block
12310843SDave.Plauger@Sun.COM  *	0	1..pagesize		one lzjb page
12410843SDave.Plauger@Sun.COM  *	0	0			marks end of data
12510843SDave.Plauger@Sun.COM  */
12610843SDave.Plauger@Sun.COM typedef uint32_t dumpcsize_t;
12710843SDave.Plauger@Sun.COM 
12810843SDave.Plauger@Sun.COM #define	DUMP_MAX_TAG		(0xfffU)
12910843SDave.Plauger@Sun.COM #define	DUMP_MAX_CSIZE		(0xfffffU)
13010843SDave.Plauger@Sun.COM #define	DUMP_SET_TAG(w, v)	(((w) & DUMP_MAX_CSIZE) | ((v) << 20))
13110843SDave.Plauger@Sun.COM #define	DUMP_GET_TAG(w)		(((w) >> 20) & DUMP_MAX_TAG)
13210843SDave.Plauger@Sun.COM #define	DUMP_SET_CSIZE(w, v)	\
13310843SDave.Plauger@Sun.COM 	(((w) & (DUMP_MAX_TAG << 20)) | ((v) & DUMP_MAX_CSIZE))
13410843SDave.Plauger@Sun.COM #define	DUMP_GET_CSIZE(w)	((w) & DUMP_MAX_CSIZE)
13510843SDave.Plauger@Sun.COM 
13610843SDave.Plauger@Sun.COM typedef struct dumpstreamhdr {
13710843SDave.Plauger@Sun.COM 	char		stream_magic[8];	/* "StrmHdr" */
13810843SDave.Plauger@Sun.COM 	pgcnt_t		stream_pagenum;		/* starting pfn */
13910843SDave.Plauger@Sun.COM 	pgcnt_t		stream_npages;		/* uncompressed size */
14010843SDave.Plauger@Sun.COM } dumpstreamhdr_t;
14110843SDave.Plauger@Sun.COM 
14210843SDave.Plauger@Sun.COM #define	DUMP_STREAM_MAGIC	"StrmHdr"
14310843SDave.Plauger@Sun.COM 
14410843SDave.Plauger@Sun.COM /* The number of helpers is limited by the number of stream tags. */
14510843SDave.Plauger@Sun.COM #define	DUMP_MAX_NHELPER	DUMP_MAX_TAG
14610843SDave.Plauger@Sun.COM 
14710843SDave.Plauger@Sun.COM /*
14810843SDave.Plauger@Sun.COM  * The dump data header is placed after the dumphdr in the compressed
14910843SDave.Plauger@Sun.COM  * image. It is not needed after savecore runs and the data pages have
15010843SDave.Plauger@Sun.COM  * been decompressed.
15110843SDave.Plauger@Sun.COM  */
15210843SDave.Plauger@Sun.COM typedef struct dumpdatahdr {
15310843SDave.Plauger@Sun.COM 	uint32_t dump_datahdr_magic;	/* data header presence */
15410843SDave.Plauger@Sun.COM 	uint32_t dump_datahdr_version;	/* data header version */
15510843SDave.Plauger@Sun.COM 	uint64_t dump_data_csize;	/* compressed data size */
15610843SDave.Plauger@Sun.COM 	uint32_t dump_maxcsize;		/* compressed data max block size */
15710843SDave.Plauger@Sun.COM 	uint32_t dump_maxrange;		/* max number of pages per range */
15810843SDave.Plauger@Sun.COM 	uint16_t dump_nstreams;		/* number of compression streams */
15910843SDave.Plauger@Sun.COM 	uint16_t dump_clevel;		/* compression level (0-9) */
16010843SDave.Plauger@Sun.COM 	uint32_t dump_metrics;		/* size of metrics data */
16110843SDave.Plauger@Sun.COM } dumpdatahdr_t;
16210843SDave.Plauger@Sun.COM 
16310843SDave.Plauger@Sun.COM #define	DUMP_DATAHDR_MAGIC	('d' << 24 | 'h' << 16 | 'd' << 8 | 'r')
16410843SDave.Plauger@Sun.COM 
16510843SDave.Plauger@Sun.COM #define	DUMP_DATAHDR_VERSION	1
16610843SDave.Plauger@Sun.COM #define	DUMP_CLEVEL_LZJB	1	/* parallel lzjb compression */
16710843SDave.Plauger@Sun.COM #define	DUMP_CLEVEL_BZIP2	2	/* parallel bzip2 level 1 */
16810843SDave.Plauger@Sun.COM 
1690Sstevel@tonic-gate #ifdef _KERNEL
1700Sstevel@tonic-gate 
1710Sstevel@tonic-gate extern kmutex_t dump_lock;
1720Sstevel@tonic-gate extern struct vnode *dumpvp;
1730Sstevel@tonic-gate extern u_offset_t dumpvp_size;
1740Sstevel@tonic-gate extern struct dumphdr *dumphdr;
1750Sstevel@tonic-gate extern int dump_conflags;
1760Sstevel@tonic-gate extern char *dumppath;
1770Sstevel@tonic-gate 
1780Sstevel@tonic-gate extern int dump_timeout;
1790Sstevel@tonic-gate extern int dump_timeleft;
1805084Sjohnlev extern int dump_ioerr;
1810Sstevel@tonic-gate extern int sync_timeout;
1820Sstevel@tonic-gate extern int sync_timeleft;
1830Sstevel@tonic-gate 
1840Sstevel@tonic-gate extern int dumpinit(struct vnode *, char *, int);
1850Sstevel@tonic-gate extern void dumpfini(void);
1860Sstevel@tonic-gate extern void dump_resize(void);
1870Sstevel@tonic-gate extern void dump_page(pfn_t);
1880Sstevel@tonic-gate extern void dump_addpage(struct as *, void *, pfn_t);
1890Sstevel@tonic-gate extern void dumpsys(void);
19010843SDave.Plauger@Sun.COM extern void dumpsys_helper(void);
19112640SDave.Plauger@Sun.COM extern void dumpsys_helper_nw(void);
1920Sstevel@tonic-gate extern void dump_messages(void);
1930Sstevel@tonic-gate extern void dump_ereports(void);
1940Sstevel@tonic-gate extern void dumpvp_write(const void *, size_t);
1956423Sgw25295 extern int dumpvp_resize(void);
1963446Smrj extern int dump_plat_addr(void);
1973446Smrj extern void dump_plat_pfn(void);
1983446Smrj extern int dump_plat_data(void *);
199*12967Sgavin.maltby@oracle.com extern int dump_set_uuid(const char *);
200*12967Sgavin.maltby@oracle.com extern const char *dump_get_uuid(void);
2010Sstevel@tonic-gate 
20210843SDave.Plauger@Sun.COM /*
20310843SDave.Plauger@Sun.COM  * Define a CPU count threshold that determines when to employ
20412931SDave.Plauger@Sun.COM  * bzip2. This value is defined per-platform.
20510843SDave.Plauger@Sun.COM  */
20612931SDave.Plauger@Sun.COM extern uint_t dump_plat_mincpu_default;
20710843SDave.Plauger@Sun.COM 
20810843SDave.Plauger@Sun.COM #define	DUMP_PLAT_SUN4U_MINCPU		51
20910843SDave.Plauger@Sun.COM #define	DUMP_PLAT_SUN4U_OPL_MINCPU	8
21010843SDave.Plauger@Sun.COM #define	DUMP_PLAT_SUN4V_MINCPU		128
21110843SDave.Plauger@Sun.COM #define	DUMP_PLAT_X86_64_MINCPU		11
21210843SDave.Plauger@Sun.COM #define	DUMP_PLAT_X86_32_MINCPU		0
21310843SDave.Plauger@Sun.COM 
21410843SDave.Plauger@Sun.COM /*
21512931SDave.Plauger@Sun.COM  * Override the per-platform default by setting this variable with
21612931SDave.Plauger@Sun.COM  * /etc/system.  The value 0 disables parallelism, and the old format
21712931SDave.Plauger@Sun.COM  * dump is produced.
21812931SDave.Plauger@Sun.COM  */
21912931SDave.Plauger@Sun.COM extern uint_t dump_plat_mincpu;
22012931SDave.Plauger@Sun.COM 
22112931SDave.Plauger@Sun.COM /*
22210843SDave.Plauger@Sun.COM  * Pages may be stolen at dump time. Prevent the pages from ever being
22310843SDave.Plauger@Sun.COM  * allocated while dump is running.
22410843SDave.Plauger@Sun.COM  */
22510843SDave.Plauger@Sun.COM #define	IS_DUMP_PAGE(pp) (dump_check_used && dump_test_used((pp)->p_pagenum))
22610843SDave.Plauger@Sun.COM 
22710843SDave.Plauger@Sun.COM extern int dump_test_used(pfn_t);
22810843SDave.Plauger@Sun.COM extern int dump_check_used;
22910843SDave.Plauger@Sun.COM 
2300Sstevel@tonic-gate #endif /* _KERNEL */
2310Sstevel@tonic-gate 
2320Sstevel@tonic-gate #ifdef	__cplusplus
2330Sstevel@tonic-gate }
2340Sstevel@tonic-gate #endif
2350Sstevel@tonic-gate 
2360Sstevel@tonic-gate #endif	/* _SYS_DUMPHDR_H */
237