17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5843e1988Sjohnlev * Common Development and Distribution License (the "License"). 6843e1988Sjohnlev * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22f6e214c7SGavin Maltby * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 23*3f11de9dSSara Hartse * Copyright (c) 2016 by Delphix. All rights reserved. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_PANIC_H 277c478bd9Sstevel@tonic-gate #define _SYS_PANIC_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #if !defined(_ASM) 307c478bd9Sstevel@tonic-gate #include <sys/types.h> 317c478bd9Sstevel@tonic-gate #include <sys/thread.h> 327c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h> 337c478bd9Sstevel@tonic-gate #endif /* !_ASM */ 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #ifdef __cplusplus 367c478bd9Sstevel@tonic-gate extern "C" { 377c478bd9Sstevel@tonic-gate #endif 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifdef _LP64 407c478bd9Sstevel@tonic-gate #define PANICSTKSIZE 16384 417c478bd9Sstevel@tonic-gate #else 427c478bd9Sstevel@tonic-gate #define PANICSTKSIZE 8192 437c478bd9Sstevel@tonic-gate #endif 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate #define PANICBUFSIZE 8192 46f6e214c7SGavin Maltby #define PANICBUFVERS 2 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate #define PANICNVNAMELEN 16 497c478bd9Sstevel@tonic-gate 50f6e214c7SGavin Maltby #define STACK_BUF_SIZE 2048 51f6e214c7SGavin Maltby #define SUMMARY_MAGIC 0xdead0d8a 52f6e214c7SGavin Maltby 537c478bd9Sstevel@tonic-gate /* 547c478bd9Sstevel@tonic-gate * Panicbuf Format: 557c478bd9Sstevel@tonic-gate * 567c478bd9Sstevel@tonic-gate * The kernel records the formatted panic message and an optional array of 577c478bd9Sstevel@tonic-gate * name/value pairs into panicbuf[], a fixed-size buffer which is saved in 587c478bd9Sstevel@tonic-gate * the crash dump and, on some platforms, is persistent across reboots. 597c478bd9Sstevel@tonic-gate * The initial part of the buffer is a struct of type panic_data_t, which 607c478bd9Sstevel@tonic-gate * includes a version number for identifying the format of subsequent data. 617c478bd9Sstevel@tonic-gate * 627c478bd9Sstevel@tonic-gate * The pd_msgoff word identifies the byte offset into panicbuf[] at which the 637c478bd9Sstevel@tonic-gate * null-terminated panic message is located. This is followed by an optional 647c478bd9Sstevel@tonic-gate * variable-sized array of panic_nv_t items, which are used to record CPU 657c478bd9Sstevel@tonic-gate * register values. The number of items in pd_nvdata is computed as follows: 667c478bd9Sstevel@tonic-gate * 677c478bd9Sstevel@tonic-gate * (pd_msgoff - (sizeof (panic_data_t) - sizeof (panic_nv_t))) / 687c478bd9Sstevel@tonic-gate * sizeof (panic_nv_t); 697c478bd9Sstevel@tonic-gate * 707c478bd9Sstevel@tonic-gate * In addition to panicbuf, debuggers can access the panic_* variables shown 717c478bd9Sstevel@tonic-gate * below to determine more information about the initiator of the panic. 727c478bd9Sstevel@tonic-gate */ 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate #if !defined(_ASM) 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate typedef struct panic_nv { 777c478bd9Sstevel@tonic-gate char pnv_name[PANICNVNAMELEN]; /* String name */ 787c478bd9Sstevel@tonic-gate uint64_t pnv_value; /* Value */ 797c478bd9Sstevel@tonic-gate } panic_nv_t; 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate typedef struct panic_data { 827c478bd9Sstevel@tonic-gate uint32_t pd_version; /* Version number of panic_data_t */ 837c478bd9Sstevel@tonic-gate uint32_t pd_msgoff; /* Message byte offset in panicbuf */ 84f6e214c7SGavin Maltby char pd_uuid[36 + 1]; /* image uuid */ 857c478bd9Sstevel@tonic-gate panic_nv_t pd_nvdata[1]; /* Array of named data */ 867c478bd9Sstevel@tonic-gate } panic_data_t; 877c478bd9Sstevel@tonic-gate 88f6e214c7SGavin Maltby typedef struct summary_dump { 89f6e214c7SGavin Maltby uint32_t sd_magic; /* magic number */ 90f6e214c7SGavin Maltby uint32_t sd_ssum; /* checsksum32(stack buffer) */ 91f6e214c7SGavin Maltby /* 92f6e214c7SGavin Maltby * stack buffer and other summary data follow here -- see 93f6e214c7SGavin Maltby * dump_summary() 94f6e214c7SGavin Maltby */ 95f6e214c7SGavin Maltby } summary_dump_t; 96f6e214c7SGavin Maltby 977c478bd9Sstevel@tonic-gate #if defined(_KERNEL) 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate /* 1007c478bd9Sstevel@tonic-gate * Kernel macros for adding information to pd_nvdata[]. PANICNVGET() returns 1017c478bd9Sstevel@tonic-gate * a panic_nv_t pointer (pnv) after the end of the existing data, PANICNVADD() 1027c478bd9Sstevel@tonic-gate * modifies the current item and increments pnv, and PANICNVSET() rewrites 1037c478bd9Sstevel@tonic-gate * pd_msgoff to indicate the end of pd_nvdata[]. 1047c478bd9Sstevel@tonic-gate */ 1057c478bd9Sstevel@tonic-gate #define PANICNVGET(pdp) \ 1067c478bd9Sstevel@tonic-gate ((pdp)->pd_nvdata + (((pdp)->pd_msgoff - \ 1077c478bd9Sstevel@tonic-gate (sizeof (panic_data_t) - sizeof (panic_nv_t))) / sizeof (panic_nv_t))) 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate #define PANICNVADD(pnv, n, v) \ 1107c478bd9Sstevel@tonic-gate { \ 1117c478bd9Sstevel@tonic-gate (void) strncpy((pnv)->pnv_name, (n), PANICNVNAMELEN); \ 1127c478bd9Sstevel@tonic-gate (pnv)->pnv_value = (uint64_t)(v); (pnv)++; \ 1137c478bd9Sstevel@tonic-gate } 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate #define PANICNVSET(pdp, pnv) \ 1167c478bd9Sstevel@tonic-gate (pdp)->pd_msgoff = (uint32_t)((char *)(pnv) - (char *)(pdp)); 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate /* 1197c478bd9Sstevel@tonic-gate * Kernel panic data; preserved in crash dump for debuggers. 1207c478bd9Sstevel@tonic-gate */ 1217c478bd9Sstevel@tonic-gate #pragma align 8(panicbuf) 1227c478bd9Sstevel@tonic-gate extern char panicbuf[PANICBUFSIZE]; 1237c478bd9Sstevel@tonic-gate extern kthread_t *panic_thread; 1247c478bd9Sstevel@tonic-gate extern cpu_t panic_cpu; 1257c478bd9Sstevel@tonic-gate extern hrtime_t panic_hrtime; 1267c478bd9Sstevel@tonic-gate extern timespec_t panic_hrestime; 1277c478bd9Sstevel@tonic-gate 128843e1988Sjohnlev /* 129843e1988Sjohnlev * Forward declarations for types: 130843e1988Sjohnlev */ 131843e1988Sjohnlev struct panic_trap_info; 132843e1988Sjohnlev struct regs; 133843e1988Sjohnlev 1347c478bd9Sstevel@tonic-gate /* 1357c478bd9Sstevel@tonic-gate * Miscellaneous state variables defined in or used by the panic code: 1367c478bd9Sstevel@tonic-gate */ 1377c478bd9Sstevel@tonic-gate extern char *panic_bootstr; 1387c478bd9Sstevel@tonic-gate extern int panic_bootfcn; 1397c478bd9Sstevel@tonic-gate extern int panic_forced; 1407c478bd9Sstevel@tonic-gate extern int halt_on_panic; 1417c478bd9Sstevel@tonic-gate extern int nopanicdebug; 1427c478bd9Sstevel@tonic-gate extern int do_polled_io; 1437c478bd9Sstevel@tonic-gate extern int obpdebug; 1447c478bd9Sstevel@tonic-gate extern int in_sync; 1457c478bd9Sstevel@tonic-gate extern int panic_quiesce; 1467c478bd9Sstevel@tonic-gate extern int panic_dump; 147843e1988Sjohnlev extern int64_t panic_lbolt64; 148843e1988Sjohnlev extern label_t panic_regs; 149843e1988Sjohnlev extern struct regs *panic_reg; 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate /* 1527c478bd9Sstevel@tonic-gate * Panic functions called from the common panic code which must be 1537c478bd9Sstevel@tonic-gate * implemented by architecture or platform-specific code: 1547c478bd9Sstevel@tonic-gate */ 1557c478bd9Sstevel@tonic-gate extern void panic_saveregs(panic_data_t *, struct regs *); 156843e1988Sjohnlev extern void panic_savetrap(panic_data_t *, struct panic_trap_info *); 157843e1988Sjohnlev extern void panic_showtrap(struct panic_trap_info *); 1587c478bd9Sstevel@tonic-gate extern void panic_stopcpus(cpu_t *, kthread_t *, int); 1597c478bd9Sstevel@tonic-gate extern void panic_enter_hw(int); 1607c478bd9Sstevel@tonic-gate extern void panic_quiesce_hw(panic_data_t *); 1617c478bd9Sstevel@tonic-gate extern void panic_dump_hw(int); 1627c478bd9Sstevel@tonic-gate extern int panic_trigger(int *); 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1657c478bd9Sstevel@tonic-gate #endif /* !_ASM */ 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1687c478bd9Sstevel@tonic-gate } 1697c478bd9Sstevel@tonic-gate #endif 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate #endif /* _SYS_PANIC_H */ 172