1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016 by Delphix. All rights reserved.
* Copyright 2019 Joyent, Inc.
*/
#ifndef _SYS_DUMPHDR_H
#define _SYS_DUMPHDR_H
#include <sys/types.h>
#include <sys/param.h>
#include <sys/utsname.h>
#include <sys/log.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* The dump header describes the contents of a crash dump. Two headers
* are written out: one at the beginning of the dump, and the other at
* the very end of the dump device. The terminal header is at a known
* location (end of device) so we can always find it. The initial header
* is redundant, but helps savecore(1M) determine whether the dump has been
* overwritten by swap activity. See dumpadm(1M) for dump configuration.
*/
#define DUMP_MAGIC 0xdefec8edU /* dump magic number */
#define DUMP_VERSION 10 /* version of this dumphdr */
#define DUMP_WORDSIZE (sizeof (long) * NBBY) /* word size (32 or 64) */
#define DUMP_PANICSIZE 200 /* Max panic string copied */
#define DUMP_COMPRESS_RATIO 2 /* conservative; usually 2.5+ */
#define DUMP_OFFSET 65536 /* pad at start/end of dev */
#define DUMP_LOGSIZE (2 * LOG_HIWAT) /* /dev/log message save area */
#define DUMP_ERPTSIZE (P2ROUNDUP( \
(ERPT_DATA_SZ / 2) * \
(ERPT_EVCH_MAX + \
ERPT_MAX_ERRS * ERPT_HIWAT), \
DUMP_OFFSET)) /* ereport save area */
#define DUMP_SUMMARYSIZE (P2ROUNDUP( \
(STACK_BUF_SIZE + \
sizeof (summary_dump_t) + 1024), \
DUMP_OFFSET)) /* summary save area */
#define DUMP_CRYPT_KEYLEN 32 /* byte len for crypto key */
#define DUMP_CRYPT_NONCELEN 8 /* byte len for nonce */
#define DUMP_CRYPT_HMACLEN 64 /* byte len for HMAC */
#define DUMP_CRYPT_BLOCKSHIFT 6 /* 64-byte blocks */
#define DUMP_CRYPT_ALGO_NONE 0 /* dump not encrypted */
#define DUMP_CRYPT_ALGO_CHACHA20 1 /* ChaCha20 */
#if DUMP_OFFSET & ((1 << DUMP_CRYPT_BLOCKSHIFT) - 1)
#error DUMP_OFFSET not DUMP_CRYPT_BLOCKSHIFT aligned
#endif
#if DUMP_LOGSIZE & ((1 << DUMP_CRYPT_BLOCKSHIFT) - 1)
#error DUMP_LOGSIZE not DUMP_CRYPT_BLOCKSHIFT aligned
#endif
typedef struct dumphdr {
uint32_t dump_magic; /* magic number */
uint32_t dump_version; /* version number */
uint32_t dump_flags; /* flags; see below */
uint32_t dump_wordsize; /* 32 or 64 */
offset_t dump_start; /* starting offset on dump device */
offset_t dump_ksyms; /* offset of compressed symbol table */
offset_t dump_pfn; /* offset of pfn table for all pages */
offset_t dump_map; /* offset of page translation map */
offset_t dump_data; /* offset of actual dump data */
struct utsname dump_utsname; /* copy of utsname structure */
char dump_platform[SYS_NMLN]; /* platform name (uname -i) */
char dump_panicstring[DUMP_PANICSIZE]; /* copy of panicstr */
time_t dump_crashtime; /* time of crash */
long dump_pageshift; /* log2(pagesize) */
long dump_pagesize; /* pagesize */
long dump_hashmask; /* page translation hash mask */
long dump_nvtop; /* number of vtop table entries */
pgcnt_t dump_npages; /* number of data pages */
size_t dump_ksyms_size; /* kernel symbol table size */
size_t dump_ksyms_csize; /* compressed symbol table size */
uint32_t dump_fm_panic; /* initiated from fm subsystems */
char dump_uuid[36 + 1]; /* os image uuid */
} dumphdr_t;
/*
* If DF_ENCRYPTED is set, this header will be found after the dumphdr.
*/
typedef struct dump_crypt {
uint8_t dump_crypt_algo; /* encryption algorithm */
uint8_t dump_crypt_hmac[DUMP_CRYPT_HMACLEN]; /* HMAC for crypto key */
uint8_t dump_crypt_nonce[DUMP_CRYPT_NONCELEN]; /* encryption none */
} dump_crypt_t;
/*
* Values for dump_flags
*/
#define DF_VALID 0x00000001 /* Dump is valid (savecore clears) */
#define DF_COMPLETE 0x00000002 /* All pages present as configured */
#define DF_LIVE 0x00000004 /* Dump was taken on a live system */
#define DF_COMPRESSED 0x00000008 /* Dump is compressed */
#define DF_ENCRYPTED 0x00000010 /* Dump is encrypted */
#define DF_KERNEL 0x00010000 /* Contains kernel pages only */
#define DF_ALL 0x00020000 /* Contains all pages */
#define DF_CURPROC 0x00040000 /* Contains kernel + cur proc pages */
#define DF_CONTENT 0xffff0000 /* The set of all dump content flags */
/*
* Dump translation map hash table entry.
*/
typedef struct dump_map {
offset_t dm_first;
offset_t dm_next;
offset_t dm_data;
struct as *dm_as;
uintptr_t dm_va;
} dump_map_t;
/*
* Dump translation map hash function.
*/
#define DUMP_HASH(dhp, as, va) \
((((uintptr_t)(as) >> 3) + ((va) >> (dhp)->dump_pageshift)) & \
(dhp)->dump_hashmask)
/*
* Encoding of the csize word used to provide meta information
* between dumpsys and savecore.
*
* tag size
* 1-4095 1..dump_maxcsize stream block
* 0 1..pagesize one lzjb page
* 0 0 marks end of data
*/
typedef uint32_t dumpcsize_t;
#define DUMP_MAX_TAG (0xfffU)
#define DUMP_MAX_CSIZE (0xfffffU)
#define DUMP_SET_TAG(w, v) (((w) & DUMP_MAX_CSIZE) | ((v) << 20))
#define DUMP_GET_TAG(w) (((w) >> 20) & DUMP_MAX_TAG)
#define DUMP_SET_CSIZE(w, v) \
(((w) & (DUMP_MAX_TAG << 20)) | ((v) & DUMP_MAX_CSIZE))
#define DUMP_GET_CSIZE(w) ((w) & DUMP_MAX_CSIZE)
typedef struct dumpstreamhdr {
char stream_magic[8]; /* "StrmHdr" */
pgcnt_t stream_pagenum; /* starting pfn */
pgcnt_t stream_npages; /* uncompressed size */
} dumpstreamhdr_t;
#define DUMP_STREAM_MAGIC "StrmHdr"
/* The number of helpers is limited by the number of stream tags. */
#define DUMP_MAX_NHELPER DUMP_MAX_TAG
/*
* The dump data header is placed after the dumphdr in the compressed
* image. It is not needed after savecore runs and the data pages have
* been decompressed.
*/
typedef struct dumpdatahdr {
uint32_t dump_datahdr_magic; /* data header presence */
uint32_t dump_datahdr_version; /* data header version */
uint64_t dump_data_csize; /* compressed data size */
uint32_t dump_maxcsize; /* compressed data max block size */
uint32_t dump_maxrange; /* max number of pages per range */
uint16_t dump_nstreams; /* number of compression streams */
uint16_t dump_clevel; /* compression level (0-9) */
uint32_t dump_metrics; /* size of metrics data */
} dumpdatahdr_t;
#define DUMP_DATAHDR_MAGIC ('d' << 24 | 'h' << 16 | 'd' << 8 | 'r')
#define DUMP_DATAHDR_VERSION 1
#define DUMP_CLEVEL_LZJB 1 /* parallel lzjb compression */
#define DUMP_CLEVEL_BZIP2 2 /* parallel bzip2 level 1 */
#ifdef _KERNEL
extern kmutex_t dump_lock;
extern struct vnode *dumpvp;
extern u_offset_t dumpvp_size;
extern struct dumphdr *dumphdr;
extern int dump_conflags;
extern char *dumppath;
extern uint8_t dump_crypt_key[DUMP_CRYPT_KEYLEN];
extern uint8_t dump_crypt_nonce[DUMP_CRYPT_NONCELEN];
extern int dump_timeout;
extern int dump_timeleft;
extern int dump_ioerr;
extern int dumpinit(struct vnode *, char *, int);
extern void dumpfini(void);
extern void dump_resize(void);
extern void dump_page(pfn_t);
extern void dump_addpage(struct as *, void *, pfn_t);
extern void dumpsys(void);
extern void dumpsys_helper(void);
extern void dumpsys_helper_nw(void);
extern void dump_messages(void);
extern void dump_ereports(void);
extern void dumpvp_write(const void *, size_t);
extern int dumpvp_resize(void);
extern int dump_plat_addr(void);
extern void dump_plat_pfn(void);
extern int dump_plat_data(void *);
extern int dump_set_uuid(const char *);
extern const char *dump_get_uuid(void);
/*
* Define a CPU count threshold that determines when to employ
* bzip2. This value is defined per-platform.
*/
extern uint_t dump_plat_mincpu_default;
#define DUMP_PLAT_SUN4U_MINCPU 0
#define DUMP_PLAT_SUN4U_OPL_MINCPU 0
#define DUMP_PLAT_SUN4V_MINCPU 0
#define DUMP_PLAT_X86_64_MINCPU 0
#define DUMP_PLAT_X86_32_MINCPU 0
/*
* Override the per-platform default by setting this variable with
* /etc/system. The value 0 disables parallelism, and the old format
* dump is produced.
*/
extern uint_t dump_plat_mincpu;
/*
* Pages may be stolen at dump time. Prevent the pages from ever being
* allocated while dump is running.
*/
#define IS_DUMP_PAGE(pp) (dump_check_used && dump_test_used((pp)->p_pagenum))
extern int dump_test_used(pfn_t);
extern int dump_check_used;
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_DUMPHDR_H */
|