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/head-64.h>
38 #include <asm/feature-fixups.h>
39 
40 /* PACA save area offsets (exgen, exmc, etc) */
41 #define EX_R9		0
42 #define EX_R10		8
43 #define EX_R11		16
44 #define EX_R12		24
45 #define EX_R13		32
46 #define EX_DAR		40
47 #define EX_DSISR	48
48 #define EX_CCR		52
49 #define EX_CFAR		56
50 #define EX_PPR		64
51 #if defined(CONFIG_RELOCATABLE)
52 #define EX_CTR		72
53 #define EX_SIZE		10	/* size in u64 units */
54 #else
55 #define EX_SIZE		9	/* size in u64 units */
56 #endif
57 
58 /*
59  * maximum recursive depth of MCE exceptions
60  */
61 #define MAX_MCE_DEPTH	4
62 
63 /*
64  * EX_R3 is only used by the bad_stack handler. bad_stack reloads and
65  * saves DAR from SPRN_DAR, and EX_DAR is not used. So EX_R3 can overlap
66  * with EX_DAR.
67  */
68 #define EX_R3		EX_DAR
69 
70 #ifdef __ASSEMBLY__
71 
72 #define STF_ENTRY_BARRIER_SLOT						\
73 	STF_ENTRY_BARRIER_FIXUP_SECTION;				\
74 	nop;								\
75 	nop;								\
76 	nop
77 
78 #define STF_EXIT_BARRIER_SLOT						\
79 	STF_EXIT_BARRIER_FIXUP_SECTION;					\
80 	nop;								\
81 	nop;								\
82 	nop;								\
83 	nop;								\
84 	nop;								\
85 	nop
86 
87 /*
88  * r10 must be free to use, r13 must be paca
89  */
90 #define INTERRUPT_TO_KERNEL						\
91 	STF_ENTRY_BARRIER_SLOT
92 
93 /*
94  * Macros for annotating the expected destination of (h)rfid
95  *
96  * The nop instructions allow us to insert one or more instructions to flush the
97  * L1-D cache when returning to userspace or a guest.
98  */
99 #define RFI_FLUSH_SLOT							\
100 	RFI_FLUSH_FIXUP_SECTION;					\
101 	nop;								\
102 	nop;								\
103 	nop
104 
105 #define RFI_TO_KERNEL							\
106 	rfid
107 
108 #define RFI_TO_USER							\
109 	STF_EXIT_BARRIER_SLOT;						\
110 	RFI_FLUSH_SLOT;							\
111 	rfid;								\
112 	b	rfi_flush_fallback
113 
114 #define RFI_TO_USER_OR_KERNEL						\
115 	STF_EXIT_BARRIER_SLOT;						\
116 	RFI_FLUSH_SLOT;							\
117 	rfid;								\
118 	b	rfi_flush_fallback
119 
120 #define RFI_TO_GUEST							\
121 	STF_EXIT_BARRIER_SLOT;						\
122 	RFI_FLUSH_SLOT;							\
123 	rfid;								\
124 	b	rfi_flush_fallback
125 
126 #define HRFI_TO_KERNEL							\
127 	hrfid
128 
129 #define HRFI_TO_USER							\
130 	STF_EXIT_BARRIER_SLOT;						\
131 	RFI_FLUSH_SLOT;							\
132 	hrfid;								\
133 	b	hrfi_flush_fallback
134 
135 #define HRFI_TO_USER_OR_KERNEL						\
136 	STF_EXIT_BARRIER_SLOT;						\
137 	RFI_FLUSH_SLOT;							\
138 	hrfid;								\
139 	b	hrfi_flush_fallback
140 
141 #define HRFI_TO_GUEST							\
142 	STF_EXIT_BARRIER_SLOT;						\
143 	RFI_FLUSH_SLOT;							\
144 	hrfid;								\
145 	b	hrfi_flush_fallback
146 
147 #define HRFI_TO_UNKNOWN							\
148 	STF_EXIT_BARRIER_SLOT;						\
149 	RFI_FLUSH_SLOT;							\
150 	hrfid;								\
151 	b	hrfi_flush_fallback
152 
153 #endif /* __ASSEMBLY__ */
154 
155 #endif	/* _ASM_POWERPC_EXCEPTION_H */
156