Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 #ifndef _ASM_POWERPC_EXCEPTION_H
0003 #define _ASM_POWERPC_EXCEPTION_H
0004 /*
0005  * Extracted from head_64.S
0006  *
0007  *  PowerPC version
0008  *    Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
0009  *
0010  *  Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP
0011  *    Copyright (C) 1996 Cort Dougan <cort@cs.nmt.edu>
0012  *  Adapted for Power Macintosh by Paul Mackerras.
0013  *  Low-level exception handlers and MMU support
0014  *  rewritten by Paul Mackerras.
0015  *    Copyright (C) 1996 Paul Mackerras.
0016  *
0017  *  Adapted for 64bit PowerPC by Dave Engebretsen, Peter Bergner, and
0018  *    Mike Corrigan {engebret|bergner|mikejc}@us.ibm.com
0019  *
0020  *  This file contains the low-level support and setup for the
0021  *  PowerPC-64 platform, including trap and interrupt dispatch.
0022  */
0023 /*
0024  * The following macros define the code that appears as
0025  * the prologue to each of the exception handlers.  They
0026  * are split into two parts to allow a single kernel binary
0027  * to be used for pSeries and iSeries.
0028  *
0029  * We make as much of the exception code common between native
0030  * exception handlers (including pSeries LPAR) and iSeries LPAR
0031  * implementations as possible.
0032  */
0033 #include <asm/feature-fixups.h>
0034 
0035 /* PACA save area size in u64 units (exgen, exmc, etc) */
0036 #define EX_SIZE     10
0037 
0038 /* PACA save area offsets */
0039 #define EX_R9       0
0040 #define EX_R10      8
0041 #define EX_R11      16
0042 #define EX_R12      24
0043 #define EX_R13      32
0044 #define EX_DAR      40
0045 #define EX_DSISR    48
0046 #define EX_CCR      52
0047 #define EX_CFAR     56
0048 #define EX_PPR      64
0049 #define EX_CTR      72
0050 
0051 /*
0052  * maximum recursive depth of MCE exceptions
0053  */
0054 #define MAX_MCE_DEPTH   4
0055 
0056 #ifdef __ASSEMBLY__
0057 
0058 #define STF_ENTRY_BARRIER_SLOT                      \
0059     STF_ENTRY_BARRIER_FIXUP_SECTION;                \
0060     nop;                                \
0061     nop;                                \
0062     nop
0063 
0064 #define STF_EXIT_BARRIER_SLOT                       \
0065     STF_EXIT_BARRIER_FIXUP_SECTION;                 \
0066     nop;                                \
0067     nop;                                \
0068     nop;                                \
0069     nop;                                \
0070     nop;                                \
0071     nop
0072 
0073 #define ENTRY_FLUSH_SLOT                        \
0074     ENTRY_FLUSH_FIXUP_SECTION;                  \
0075     nop;                                \
0076     nop;                                \
0077     nop;
0078 
0079 #define SCV_ENTRY_FLUSH_SLOT                        \
0080     SCV_ENTRY_FLUSH_FIXUP_SECTION;                  \
0081     nop;                                \
0082     nop;                                \
0083     nop;
0084 
0085 /*
0086  * r10 must be free to use, r13 must be paca
0087  */
0088 #define INTERRUPT_TO_KERNEL                     \
0089     STF_ENTRY_BARRIER_SLOT;                     \
0090     ENTRY_FLUSH_SLOT
0091 
0092 /*
0093  * r10, ctr must be free to use, r13 must be paca
0094  */
0095 #define SCV_INTERRUPT_TO_KERNEL                     \
0096     STF_ENTRY_BARRIER_SLOT;                     \
0097     SCV_ENTRY_FLUSH_SLOT
0098 
0099 /*
0100  * Macros for annotating the expected destination of (h)rfid
0101  *
0102  * The nop instructions allow us to insert one or more instructions to flush the
0103  * L1-D cache when returning to userspace or a guest.
0104  *
0105  * powerpc relies on return from interrupt/syscall being context synchronising
0106  * (which hrfid, rfid, and rfscv are) to support ARCH_HAS_MEMBARRIER_SYNC_CORE
0107  * without additional synchronisation instructions.
0108  *
0109  * soft-masked interrupt replay does not include a context-synchronising rfid,
0110  * but those always return to kernel, the sync is only required when returning
0111  * to user.
0112  */
0113 #define RFI_FLUSH_SLOT                          \
0114     RFI_FLUSH_FIXUP_SECTION;                    \
0115     nop;                                \
0116     nop;                                \
0117     nop
0118 
0119 #define RFI_TO_KERNEL                           \
0120     rfid
0121 
0122 #define RFI_TO_USER                         \
0123     STF_EXIT_BARRIER_SLOT;                      \
0124     RFI_FLUSH_SLOT;                         \
0125     rfid;                               \
0126     b   rfi_flush_fallback
0127 
0128 #define RFI_TO_USER_OR_KERNEL                       \
0129     STF_EXIT_BARRIER_SLOT;                      \
0130     RFI_FLUSH_SLOT;                         \
0131     rfid;                               \
0132     b   rfi_flush_fallback
0133 
0134 #define RFI_TO_GUEST                            \
0135     STF_EXIT_BARRIER_SLOT;                      \
0136     RFI_FLUSH_SLOT;                         \
0137     rfid;                               \
0138     b   rfi_flush_fallback
0139 
0140 #define HRFI_TO_KERNEL                          \
0141     hrfid
0142 
0143 #define HRFI_TO_USER                            \
0144     STF_EXIT_BARRIER_SLOT;                      \
0145     RFI_FLUSH_SLOT;                         \
0146     hrfid;                              \
0147     b   hrfi_flush_fallback
0148 
0149 #define HRFI_TO_USER_OR_KERNEL                      \
0150     STF_EXIT_BARRIER_SLOT;                      \
0151     RFI_FLUSH_SLOT;                         \
0152     hrfid;                              \
0153     b   hrfi_flush_fallback
0154 
0155 #define HRFI_TO_GUEST                           \
0156     STF_EXIT_BARRIER_SLOT;                      \
0157     RFI_FLUSH_SLOT;                         \
0158     hrfid;                              \
0159     b   hrfi_flush_fallback
0160 
0161 #define HRFI_TO_UNKNOWN                         \
0162     STF_EXIT_BARRIER_SLOT;                      \
0163     RFI_FLUSH_SLOT;                         \
0164     hrfid;                              \
0165     b   hrfi_flush_fallback
0166 
0167 #define RFSCV_TO_USER                           \
0168     STF_EXIT_BARRIER_SLOT;                      \
0169     RFI_FLUSH_SLOT;                         \
0170     RFSCV;                              \
0171     b   rfscv_flush_fallback
0172 
0173 #else /* __ASSEMBLY__ */
0174 /* Prototype for function defined in exceptions-64s.S */
0175 void do_uaccess_flush(void);
0176 #endif /* __ASSEMBLY__ */
0177 
0178 #endif  /* _ASM_POWERPC_EXCEPTION_H */