1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #ifndef _ASM_POWERPC_EXCEPTION_H
3 #define _ASM_POWERPC_EXCEPTION_H
5 * Extracted from head_64.S
12 * Adapted for Power Macintosh by Paul Mackerras.
13 * Low-level exception handlers and MMU support
14 * rewritten by Paul Mackerras.
15 * Copyright (C) 1996 Paul Mackerras.
17 * Adapted for 64bit PowerPC by Dave Engebretsen, Peter Bergner, and
18 * Mike Corrigan {engebret|bergner|mikejc}@us.ibm.com
20 * This file contains the low-level support and setup for the
21 * PowerPC-64 platform, including trap and interrupt dispatch.
24 * The following macros define the code that appears as
25 * the prologue to each of the exception handlers. They
26 * are split into two parts to allow a single kernel binary
27 * to be used for pSeries and iSeries.
29 * We make as much of the exception code common between native
30 * exception handlers (including pSeries LPAR) and iSeries LPAR
31 * implementations as possible.
33 #include <asm/feature-fixups.h>
35 /* PACA save area size in u64 units (exgen, exmc, etc) */
38 /* PACA save area offsets */
52 * maximum recursive depth of MCE exceptions
54 #define MAX_MCE_DEPTH 4
58 #define STF_ENTRY_BARRIER_SLOT \
59 STF_ENTRY_BARRIER_FIXUP_SECTION; \
64 #define STF_EXIT_BARRIER_SLOT \
65 STF_EXIT_BARRIER_FIXUP_SECTION; \
73 #define ENTRY_FLUSH_SLOT \
74 ENTRY_FLUSH_FIXUP_SECTION; \
79 #define SCV_ENTRY_FLUSH_SLOT \
80 SCV_ENTRY_FLUSH_FIXUP_SECTION; \
86 * r10 must be free to use, r13 must be paca
88 #define INTERRUPT_TO_KERNEL \
89 STF_ENTRY_BARRIER_SLOT; \
93 * r10, ctr must be free to use, r13 must be paca
95 #define SCV_INTERRUPT_TO_KERNEL \
96 STF_ENTRY_BARRIER_SLOT; \
100 * Macros for annotating the expected destination of (h)rfid
102 * The nop instructions allow us to insert one or more instructions to flush the
103 * L1-D cache when returning to userspace or a guest.
105 * powerpc relies on return from interrupt/syscall being context synchronising
106 * (which hrfid, rfid, and rfscv are) to support ARCH_HAS_MEMBARRIER_SYNC_CORE
107 * without additional synchronisation instructions.
109 * soft-masked interrupt replay does not include a context-synchronising rfid,
110 * but those always return to kernel, the sync is only required when returning
113 #define RFI_FLUSH_SLOT \
114 RFI_FLUSH_FIXUP_SECTION; \
119 #define RFI_TO_KERNEL \
122 #define RFI_TO_USER \
123 STF_EXIT_BARRIER_SLOT; \
128 #define RFI_TO_USER_OR_KERNEL \
129 STF_EXIT_BARRIER_SLOT; \
134 #define RFI_TO_GUEST \
135 STF_EXIT_BARRIER_SLOT; \
140 #define HRFI_TO_KERNEL \
143 #define HRFI_TO_USER \
144 STF_EXIT_BARRIER_SLOT; \
147 b hrfi_flush_fallback
149 #define HRFI_TO_USER_OR_KERNEL \
150 STF_EXIT_BARRIER_SLOT; \
153 b hrfi_flush_fallback
155 #define HRFI_TO_GUEST \
156 STF_EXIT_BARRIER_SLOT; \
159 b hrfi_flush_fallback
161 #define HRFI_TO_UNKNOWN \
162 STF_EXIT_BARRIER_SLOT; \
165 b hrfi_flush_fallback
167 #define RFSCV_TO_USER \
168 STF_EXIT_BARRIER_SLOT; \
171 b rfscv_flush_fallback
173 #else /* __ASSEMBLY__ */
174 /* Prototype for function defined in exceptions-64s.S */
175 void do_uaccess_flush(void);
176 #endif /* __ASSEMBLY__ */
178 #endif /* _ASM_POWERPC_EXCEPTION_H */