exception-64s.h 3.48 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
#ifndef _ASM_POWERPC_EXCEPTION_H
#define _ASM_POWERPC_EXCEPTION_H
/*
 * Extracted from head_64.S
 *
 *  PowerPC version
 *    Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
 *
 *  Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP
 *    Copyright (C) 1996 Cort Dougan <cort@cs.nmt.edu>
 *  Adapted for Power Macintosh by Paul Mackerras.
 *  Low-level exception handlers and MMU support
 *  rewritten by Paul Mackerras.
 *    Copyright (C) 1996 Paul Mackerras.
 *
 *  Adapted for 64bit PowerPC by Dave Engebretsen, Peter Bergner, and
 *    Mike Corrigan {engebret|bergner|mikejc}@us.ibm.com
 *
 *  This file contains the low-level support and setup for the
 *  PowerPC-64 platform, including trap and interrupt dispatch.
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version
 *  2 of the License, or (at your option) any later version.
 */
/*
 * The following macros define the code that appears as
 * the prologue to each of the exception handlers.  They
 * are split into two parts to allow a single kernel binary
 * to be used for pSeries and iSeries.
 *
 * We make as much of the exception code common between native
 * exception handlers (including pSeries LPAR) and iSeries LPAR
 * implementations as possible.
 */
37
#include <asm/feature-fixups.h>
38

39
/* PACA save area size in u64 units (exgen, exmc, etc) */
40
#if defined(CONFIG_RELOCATABLE)
41
#define EX_SIZE		10
42
#else
43
#define EX_SIZE		9
44
#endif
45

46 47 48 49 50
/*
 * maximum recursive depth of MCE exceptions
 */
#define MAX_MCE_DEPTH	4

51 52 53 54 55 56 57
/*
 * EX_R3 is only used by the bad_stack handler. bad_stack reloads and
 * saves DAR from SPRN_DAR, and EX_DAR is not used. So EX_R3 can overlap
 * with EX_DAR.
 */
#define EX_R3		EX_DAR

58 59
#ifdef __ASSEMBLY__

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
#define STF_ENTRY_BARRIER_SLOT						\
	STF_ENTRY_BARRIER_FIXUP_SECTION;				\
	nop;								\
	nop;								\
	nop

#define STF_EXIT_BARRIER_SLOT						\
	STF_EXIT_BARRIER_FIXUP_SECTION;					\
	nop;								\
	nop;								\
	nop;								\
	nop;								\
	nop;								\
	nop

/*
 * r10 must be free to use, r13 must be paca
 */
#define INTERRUPT_TO_KERNEL						\
	STF_ENTRY_BARRIER_SLOT

81 82 83 84 85 86 87 88 89 90 91
/*
 * Macros for annotating the expected destination of (h)rfid
 *
 * The nop instructions allow us to insert one or more instructions to flush the
 * L1-D cache when returning to userspace or a guest.
 */
#define RFI_FLUSH_SLOT							\
	RFI_FLUSH_FIXUP_SECTION;					\
	nop;								\
	nop;								\
	nop
92 93 94 95 96

#define RFI_TO_KERNEL							\
	rfid

#define RFI_TO_USER							\
97
	STF_EXIT_BARRIER_SLOT;						\
98 99 100
	RFI_FLUSH_SLOT;							\
	rfid;								\
	b	rfi_flush_fallback
101 102

#define RFI_TO_USER_OR_KERNEL						\
103
	STF_EXIT_BARRIER_SLOT;						\
104 105 106
	RFI_FLUSH_SLOT;							\
	rfid;								\
	b	rfi_flush_fallback
107 108

#define RFI_TO_GUEST							\
109
	STF_EXIT_BARRIER_SLOT;						\
110 111 112
	RFI_FLUSH_SLOT;							\
	rfid;								\
	b	rfi_flush_fallback
113 114 115 116 117

#define HRFI_TO_KERNEL							\
	hrfid

#define HRFI_TO_USER							\
118
	STF_EXIT_BARRIER_SLOT;						\
119 120 121
	RFI_FLUSH_SLOT;							\
	hrfid;								\
	b	hrfi_flush_fallback
122 123

#define HRFI_TO_USER_OR_KERNEL						\
124
	STF_EXIT_BARRIER_SLOT;						\
125 126 127
	RFI_FLUSH_SLOT;							\
	hrfid;								\
	b	hrfi_flush_fallback
128 129

#define HRFI_TO_GUEST							\
130
	STF_EXIT_BARRIER_SLOT;						\
131 132 133
	RFI_FLUSH_SLOT;							\
	hrfid;								\
	b	hrfi_flush_fallback
134 135

#define HRFI_TO_UNKNOWN							\
136
	STF_EXIT_BARRIER_SLOT;						\
137 138 139
	RFI_FLUSH_SLOT;							\
	hrfid;								\
	b	hrfi_flush_fallback
140

141 142
#endif /* __ASSEMBLY__ */

143
#endif	/* _ASM_POWERPC_EXCEPTION_H */