xref: /illumos-gate/usr/src/uts/intel/sys/trap.h (revision f0089e39)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*	Copyright (c) 1990, 1991 UNIX System Laboratories, Inc.	*/
22 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T	*/
23 /*	  All Rights Reserved	*/
24 
25 /*
26  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
27  * Use is subject to license terms.
28  *
29  * Copyright 2018 Joyent, Inc.
30  */
31 
32 #ifndef _SYS_TRAP_H
33 #define	_SYS_TRAP_H
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * Trap type values
41  */
42 
43 #define	T_ZERODIV	0x0	/* #de	divide by 0 error		*/
44 #define	T_SGLSTP	0x1	/* #db	single step			*/
45 #define	T_NMIFLT	0x2	/*	NMI				*/
46 #define	T_BPTFLT	0x3	/* #bp	breakpoint fault, INT3 insn	*/
47 #define	T_OVFLW		0x4	/* #of	INTO overflow fault		*/
48 #define	T_BOUNDFLT	0x5	/* #br	BOUND insn fault		*/
49 #define	T_ILLINST	0x6	/* #ud	invalid opcode fault		*/
50 #define	T_NOEXTFLT	0x7	/* #nm	device not available: x87	*/
51 #define	T_DBLFLT	0x8	/* #df	double fault			*/
52 #define	T_EXTOVRFLT	0x9	/*	[not generated: 386 only]	*/
53 #define	T_TSSFLT	0xa	/* #ts	invalid TSS fault		*/
54 #define	T_SEGFLT	0xb	/* #np	segment not present fault	*/
55 #define	T_STKFLT	0xc	/* #ss	stack fault			*/
56 #define	T_GPFLT		0xd	/* #gp	general protection fault	*/
57 #define	T_PGFLT		0xe	/* #pf	page fault			*/
58 #define	T_RESVTRAP	0xf	/*	reserved			*/
59 #define	T_EXTERRFLT	0x10	/* #mf	x87 FPU error fault		*/
60 #define	T_ALIGNMENT	0x11	/* #ac	alignment check error		*/
61 #define	T_MCE		0x12	/* #mc	machine check exception		*/
62 #define	T_SIMDFPE	0x13	/* #xm	SSE/SSE exception		*/
63 #define	T_DBGENTR	0x14	/*	debugger entry			*/
64 #define	T_INVALTRAP	0x1e	/*	invalid				*/
65 #define	T_ENDPERR	0x21	/*	emulated extension error flt	*/
66 #define	T_ENOEXTFLT	0x20	/*	emulated ext not present	*/
67 #define	T_FASTTRAP	0xd2	/*	fast system call		*/
68 #define	T_SYSCALLINT	0x91	/*	general system call		*/
69 #define	T_DTRACE_RET	0x92	/*	DTrace pid return		*/
70 #define	T_INT80		0x80	/*	int80 handler for linux emulation */
71 #define	T_SOFTINT	0x50fd	/*	pseudo softint trap type	*/
72 
73 /*
74  * Pseudo traps.
75  */
76 #define	T_INTERRUPT		0x100
77 #define	T_FAULT			0x200
78 #define	T_AST			0x400
79 #define	T_SYSCALL		0x180
80 
81 
82 /*
83  *  Values of error code on stack in case of page fault
84  */
85 
86 #define	PF_ERR_MASK	0x01	/* Mask for error bit */
87 #define	PF_ERR_PAGE	0x00	/* page not present */
88 #define	PF_ERR_PROT	0x01	/* protection error */
89 #define	PF_ERR_WRITE	0x02	/* fault caused by write (else read) */
90 #define	PF_ERR_USER	0x04	/* processor was in user mode */
91 				/*	(else supervisor) */
92 #define	PF_ERR_EXEC	0x10	/* attempt to execute a No eXec page (AMD) */
93 				/* or kernel tried to execute a user page  */
94 				/* (Intel SMEP) */
95 
96 /*
97  *  Definitions for fast system call subfunctions
98  */
99 #define	T_FNULL		0	/* Null trap for testing		*/
100 #define	T_FGETFP	1	/* Get emulated FP context		*/
101 #define	T_FSETFP	2	/* Set emulated FP context		*/
102 #define	T_GETHRTIME	3	/* Get high resolution time		*/
103 #define	T_GETHRVTIME	4	/* Get high resolution virtual time	*/
104 #define	T_GETHRESTIME	5	/* Get high resolution time		*/
105 #define	T_GETLGRP	6	/* Get home lgrpid			*/
106 
107 #define	T_LASTFAST	6	/* Last valid subfunction		*/
108 
109 /*
110  * Offsets for an interrupt/trap frame.
111  */
112 #define	T_FRAME_ERR	0
113 #define	T_FRAME_RIP	8
114 #define	T_FRAME_CS	16
115 #define	T_FRAME_RFLAGS	24
116 #define	T_FRAME_RSP	32
117 #define	T_FRAME_SS	40
118 
119 #define	T_FRAMERET_RIP		0
120 #define	T_FRAMERET_CS		8
121 #define	T_FRAMERET_RFLAGS	16
122 #define	T_FRAMERET_RSP		24
123 #define	T_FRAMERET_SS		32
124 
125 #ifdef	__cplusplus
126 }
127 #endif
128 
129 #endif	/* _SYS_TRAP_H */
130