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
8 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
10 * Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP
11 * Copyright (C) 1996 Cort Dougan <cort@cs.nmt.edu>
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) */
39 * maximum recursive depth of MCE exceptions
41 #define MAX_MCE_DEPTH 4
45 #define STF_ENTRY_BARRIER_SLOT \
46 STF_ENTRY_BARRIER_FIXUP_SECTION; \
51 #define STF_EXIT_BARRIER_SLOT \
52 STF_EXIT_BARRIER_FIXUP_SECTION; \
60 #define ENTRY_FLUSH_SLOT \
61 ENTRY_FLUSH_FIXUP_SECTION; \
67 * r10 must be free to use, r13 must be paca
69 #define INTERRUPT_TO_KERNEL \
70 STF_ENTRY_BARRIER_SLOT; \
74 * Macros for annotating the expected destination of (h)rfid
76 * The nop instructions allow us to insert one or more instructions to flush the
77 * L1-D cache when returning to userspace or a guest.
79 * powerpc relies on return from interrupt/syscall being context synchronising
80 * (which hrfid, rfid, and rfscv are) to support ARCH_HAS_MEMBARRIER_SYNC_CORE
81 * without additional synchronisation instructions.
83 * soft-masked interrupt replay does not include a context-synchronising rfid,
84 * but those always return to kernel, the sync is only required when returning
87 #define RFI_FLUSH_SLOT \
88 RFI_FLUSH_FIXUP_SECTION; \
93 #define RFI_TO_KERNEL \
97 STF_EXIT_BARRIER_SLOT; \
102 #define RFI_TO_USER_OR_KERNEL \
103 STF_EXIT_BARRIER_SLOT; \
108 #define RFI_TO_GUEST \
109 STF_EXIT_BARRIER_SLOT; \
114 #define HRFI_TO_KERNEL \
117 #define HRFI_TO_USER \
118 STF_EXIT_BARRIER_SLOT; \
121 b hrfi_flush_fallback
123 #define HRFI_TO_USER_OR_KERNEL \
124 STF_EXIT_BARRIER_SLOT; \
127 b hrfi_flush_fallback
129 #define HRFI_TO_GUEST \
130 STF_EXIT_BARRIER_SLOT; \
133 b hrfi_flush_fallback
135 #define HRFI_TO_UNKNOWN \
136 STF_EXIT_BARRIER_SLOT; \
139 b hrfi_flush_fallback
141 #define RFSCV_TO_USER \
142 STF_EXIT_BARRIER_SLOT; \
145 b rfscv_flush_fallback
147 #else /* __ASSEMBLY__ */
148 /* Prototype for function defined in exceptions-64s.S */
149 void do_uaccess_flush(void);
150 #endif /* __ASSEMBLY__ */
152 #endif /* _ASM_POWERPC_EXCEPTION_H */