xref: /linux/arch/powerpc/include/asm/exception-64s.h (revision a0502434bb02876d6c9b41d78a8db3a0b766f682)
1 #ifndef _ASM_POWERPC_EXCEPTION_H
2 #define _ASM_POWERPC_EXCEPTION_H
3 /*
4  * Extracted from head_64.S
5  *
6  *  PowerPC version
7  *    Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
8  *
9  *  Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP
10  *    Copyright (C) 1996 Cort Dougan <cort@cs.nmt.edu>
11  *  Adapted for Power Macintosh by Paul Mackerras.
12  *  Low-level exception handlers and MMU support
13  *  rewritten by Paul Mackerras.
14  *    Copyright (C) 1996 Paul Mackerras.
15  *
16  *  Adapted for 64bit PowerPC by Dave Engebretsen, Peter Bergner, and
17  *    Mike Corrigan {engebret|bergner|mikejc}@us.ibm.com
18  *
19  *  This file contains the low-level support and setup for the
20  *  PowerPC-64 platform, including trap and interrupt dispatch.
21  *
22  *  This program is free software; you can redistribute it and/or
23  *  modify it under the terms of the GNU General Public License
24  *  as published by the Free Software Foundation; either version
25  *  2 of the License, or (at your option) any later version.
26  */
27 /*
28  * The following macros define the code that appears as
29  * the prologue to each of the exception handlers.  They
30  * are split into two parts to allow a single kernel binary
31  * to be used for pSeries and iSeries.
32  *
33  * We make as much of the exception code common between native
34  * exception handlers (including pSeries LPAR) and iSeries LPAR
35  * implementations as possible.
36  */
37 #include <asm/feature-fixups.h>
38 
39 /* PACA save area offsets (exgen, exmc, etc) */
40 #define EX_R9		0
41 #define EX_R10		8
42 #define EX_R11		16
43 #define EX_R12		24
44 #define EX_R13		32
45 #define EX_DAR		40
46 #define EX_DSISR	48
47 #define EX_CCR		52
48 #define EX_CFAR		56
49 #define EX_PPR		64
50 #if defined(CONFIG_RELOCATABLE)
51 #define EX_CTR		72
52 #define EX_SIZE		10	/* size in u64 units */
53 #else
54 #define EX_SIZE		9	/* size in u64 units */
55 #endif
56 
57 /*
58  * maximum recursive depth of MCE exceptions
59  */
60 #define MAX_MCE_DEPTH	4
61 
62 /*
63  * EX_R3 is only used by the bad_stack handler. bad_stack reloads and
64  * saves DAR from SPRN_DAR, and EX_DAR is not used. So EX_R3 can overlap
65  * with EX_DAR.
66  */
67 #define EX_R3		EX_DAR
68 
69 #ifdef __ASSEMBLY__
70 
71 #define STF_ENTRY_BARRIER_SLOT						\
72 	STF_ENTRY_BARRIER_FIXUP_SECTION;				\
73 	nop;								\
74 	nop;								\
75 	nop
76 
77 #define STF_EXIT_BARRIER_SLOT						\
78 	STF_EXIT_BARRIER_FIXUP_SECTION;					\
79 	nop;								\
80 	nop;								\
81 	nop;								\
82 	nop;								\
83 	nop;								\
84 	nop
85 
86 /*
87  * r10 must be free to use, r13 must be paca
88  */
89 #define INTERRUPT_TO_KERNEL						\
90 	STF_ENTRY_BARRIER_SLOT
91 
92 /*
93  * Macros for annotating the expected destination of (h)rfid
94  *
95  * The nop instructions allow us to insert one or more instructions to flush the
96  * L1-D cache when returning to userspace or a guest.
97  */
98 #define RFI_FLUSH_SLOT							\
99 	RFI_FLUSH_FIXUP_SECTION;					\
100 	nop;								\
101 	nop;								\
102 	nop
103 
104 #define RFI_TO_KERNEL							\
105 	rfid
106 
107 #define RFI_TO_USER							\
108 	STF_EXIT_BARRIER_SLOT;						\
109 	RFI_FLUSH_SLOT;							\
110 	rfid;								\
111 	b	rfi_flush_fallback
112 
113 #define RFI_TO_USER_OR_KERNEL						\
114 	STF_EXIT_BARRIER_SLOT;						\
115 	RFI_FLUSH_SLOT;							\
116 	rfid;								\
117 	b	rfi_flush_fallback
118 
119 #define RFI_TO_GUEST							\
120 	STF_EXIT_BARRIER_SLOT;						\
121 	RFI_FLUSH_SLOT;							\
122 	rfid;								\
123 	b	rfi_flush_fallback
124 
125 #define HRFI_TO_KERNEL							\
126 	hrfid
127 
128 #define HRFI_TO_USER							\
129 	STF_EXIT_BARRIER_SLOT;						\
130 	RFI_FLUSH_SLOT;							\
131 	hrfid;								\
132 	b	hrfi_flush_fallback
133 
134 #define HRFI_TO_USER_OR_KERNEL						\
135 	STF_EXIT_BARRIER_SLOT;						\
136 	RFI_FLUSH_SLOT;							\
137 	hrfid;								\
138 	b	hrfi_flush_fallback
139 
140 #define HRFI_TO_GUEST							\
141 	STF_EXIT_BARRIER_SLOT;						\
142 	RFI_FLUSH_SLOT;							\
143 	hrfid;								\
144 	b	hrfi_flush_fallback
145 
146 #define HRFI_TO_UNKNOWN							\
147 	STF_EXIT_BARRIER_SLOT;						\
148 	RFI_FLUSH_SLOT;							\
149 	hrfid;								\
150 	b	hrfi_flush_fallback
151 
152 #endif /* __ASSEMBLY__ */
153 
154 #endif	/* _ASM_POWERPC_EXCEPTION_H */
155