1 #ifndef __ASM_POWERPC_FEATURE_FIXUPS_H 2 #define __ASM_POWERPC_FEATURE_FIXUPS_H 3 4 #include <asm/asm-const.h> 5 6 /* 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 10 * 2 of the License, or (at your option) any later version. 11 */ 12 13 /* 14 * Feature section common macros 15 * 16 * Note that the entries now contain offsets between the table entry 17 * and the code rather than absolute code pointers in order to be 18 * useable with the vdso shared library. There is also an assumption 19 * that values will be negative, that is, the fixup table has to be 20 * located after the code it fixes up. 21 */ 22 #if defined(CONFIG_PPC64) && !defined(__powerpc64__) 23 /* 64 bits kernel, 32 bits code (ie. vdso32) */ 24 #define FTR_ENTRY_LONG .8byte 25 #define FTR_ENTRY_OFFSET .long 0xffffffff; .long 26 #elif defined(CONFIG_PPC64) 27 #define FTR_ENTRY_LONG .8byte 28 #define FTR_ENTRY_OFFSET .8byte 29 #else 30 #define FTR_ENTRY_LONG .long 31 #define FTR_ENTRY_OFFSET .long 32 #endif 33 34 #define START_FTR_SECTION(label) label##1: 35 36 #define FTR_SECTION_ELSE_NESTED(label) \ 37 label##2: \ 38 .pushsection __ftr_alt_##label,"a"; \ 39 .align 2; \ 40 label##3: 41 42 #define MAKE_FTR_SECTION_ENTRY(msk, val, label, sect) \ 43 label##4: \ 44 .popsection; \ 45 .pushsection sect,"a"; \ 46 .align 3; \ 47 label##5: \ 48 FTR_ENTRY_LONG msk; \ 49 FTR_ENTRY_LONG val; \ 50 FTR_ENTRY_OFFSET label##1b-label##5b; \ 51 FTR_ENTRY_OFFSET label##2b-label##5b; \ 52 FTR_ENTRY_OFFSET label##3b-label##5b; \ 53 FTR_ENTRY_OFFSET label##4b-label##5b; \ 54 .ifgt (label##4b- label##3b)-(label##2b- label##1b); \ 55 .error "Feature section else case larger than body"; \ 56 .endif; \ 57 .popsection; 58 59 60 /* CPU feature dependent sections */ 61 #define BEGIN_FTR_SECTION_NESTED(label) START_FTR_SECTION(label) 62 #define BEGIN_FTR_SECTION START_FTR_SECTION(97) 63 64 #define END_FTR_SECTION_NESTED(msk, val, label) \ 65 FTR_SECTION_ELSE_NESTED(label) \ 66 MAKE_FTR_SECTION_ENTRY(msk, val, label, __ftr_fixup) 67 68 #define END_FTR_SECTION(msk, val) \ 69 END_FTR_SECTION_NESTED(msk, val, 97) 70 71 #define END_FTR_SECTION_NESTED_IFSET(msk, label) \ 72 END_FTR_SECTION_NESTED((msk), (msk), label) 73 74 #define END_FTR_SECTION_IFSET(msk) END_FTR_SECTION((msk), (msk)) 75 #define END_FTR_SECTION_IFCLR(msk) END_FTR_SECTION((msk), 0) 76 77 /* CPU feature sections with alternatives, use BEGIN_FTR_SECTION to start */ 78 #define FTR_SECTION_ELSE FTR_SECTION_ELSE_NESTED(97) 79 #define ALT_FTR_SECTION_END_NESTED(msk, val, label) \ 80 MAKE_FTR_SECTION_ENTRY(msk, val, label, __ftr_fixup) 81 #define ALT_FTR_SECTION_END_NESTED_IFSET(msk, label) \ 82 ALT_FTR_SECTION_END_NESTED(msk, msk, label) 83 #define ALT_FTR_SECTION_END_NESTED_IFCLR(msk, label) \ 84 ALT_FTR_SECTION_END_NESTED(msk, 0, label) 85 #define ALT_FTR_SECTION_END(msk, val) \ 86 ALT_FTR_SECTION_END_NESTED(msk, val, 97) 87 #define ALT_FTR_SECTION_END_IFSET(msk) \ 88 ALT_FTR_SECTION_END_NESTED_IFSET(msk, 97) 89 #define ALT_FTR_SECTION_END_IFCLR(msk) \ 90 ALT_FTR_SECTION_END_NESTED_IFCLR(msk, 97) 91 92 /* MMU feature dependent sections */ 93 #define BEGIN_MMU_FTR_SECTION_NESTED(label) START_FTR_SECTION(label) 94 #define BEGIN_MMU_FTR_SECTION START_FTR_SECTION(97) 95 96 #define END_MMU_FTR_SECTION_NESTED(msk, val, label) \ 97 FTR_SECTION_ELSE_NESTED(label) \ 98 MAKE_FTR_SECTION_ENTRY(msk, val, label, __mmu_ftr_fixup) 99 100 #define END_MMU_FTR_SECTION(msk, val) \ 101 END_MMU_FTR_SECTION_NESTED(msk, val, 97) 102 103 #define END_MMU_FTR_SECTION_NESTED_IFSET(msk, label) \ 104 END_MMU_FTR_SECTION_NESTED((msk), (msk), label) 105 106 #define END_MMU_FTR_SECTION_IFSET(msk) END_MMU_FTR_SECTION((msk), (msk)) 107 #define END_MMU_FTR_SECTION_IFCLR(msk) END_MMU_FTR_SECTION((msk), 0) 108 109 /* MMU feature sections with alternatives, use BEGIN_FTR_SECTION to start */ 110 #define MMU_FTR_SECTION_ELSE_NESTED(label) FTR_SECTION_ELSE_NESTED(label) 111 #define MMU_FTR_SECTION_ELSE MMU_FTR_SECTION_ELSE_NESTED(97) 112 #define ALT_MMU_FTR_SECTION_END_NESTED(msk, val, label) \ 113 MAKE_FTR_SECTION_ENTRY(msk, val, label, __mmu_ftr_fixup) 114 #define ALT_MMU_FTR_SECTION_END_NESTED_IFSET(msk, label) \ 115 ALT_MMU_FTR_SECTION_END_NESTED(msk, msk, label) 116 #define ALT_MMU_FTR_SECTION_END_NESTED_IFCLR(msk, label) \ 117 ALT_MMU_FTR_SECTION_END_NESTED(msk, 0, label) 118 #define ALT_MMU_FTR_SECTION_END(msk, val) \ 119 ALT_MMU_FTR_SECTION_END_NESTED(msk, val, 97) 120 #define ALT_MMU_FTR_SECTION_END_IFSET(msk) \ 121 ALT_MMU_FTR_SECTION_END_NESTED_IFSET(msk, 97) 122 #define ALT_MMU_FTR_SECTION_END_IFCLR(msk) \ 123 ALT_MMU_FTR_SECTION_END_NESTED_IFCLR(msk, 97) 124 125 /* Firmware feature dependent sections */ 126 #define BEGIN_FW_FTR_SECTION_NESTED(label) START_FTR_SECTION(label) 127 #define BEGIN_FW_FTR_SECTION START_FTR_SECTION(97) 128 129 #define END_FW_FTR_SECTION_NESTED(msk, val, label) \ 130 FTR_SECTION_ELSE_NESTED(label) \ 131 MAKE_FTR_SECTION_ENTRY(msk, val, label, __fw_ftr_fixup) 132 133 #define END_FW_FTR_SECTION(msk, val) \ 134 END_FW_FTR_SECTION_NESTED(msk, val, 97) 135 136 #define END_FW_FTR_SECTION_IFSET(msk) END_FW_FTR_SECTION((msk), (msk)) 137 #define END_FW_FTR_SECTION_IFCLR(msk) END_FW_FTR_SECTION((msk), 0) 138 139 /* Firmware feature sections with alternatives */ 140 #define FW_FTR_SECTION_ELSE_NESTED(label) FTR_SECTION_ELSE_NESTED(label) 141 #define FW_FTR_SECTION_ELSE FTR_SECTION_ELSE_NESTED(97) 142 #define ALT_FW_FTR_SECTION_END_NESTED(msk, val, label) \ 143 MAKE_FTR_SECTION_ENTRY(msk, val, label, __fw_ftr_fixup) 144 #define ALT_FW_FTR_SECTION_END_NESTED_IFSET(msk, label) \ 145 ALT_FW_FTR_SECTION_END_NESTED(msk, msk, label) 146 #define ALT_FW_FTR_SECTION_END_NESTED_IFCLR(msk, label) \ 147 ALT_FW_FTR_SECTION_END_NESTED(msk, 0, label) 148 #define ALT_FW_FTR_SECTION_END(msk, val) \ 149 ALT_FW_FTR_SECTION_END_NESTED(msk, val, 97) 150 #define ALT_FW_FTR_SECTION_END_IFSET(msk) \ 151 ALT_FW_FTR_SECTION_END_NESTED_IFSET(msk, 97) 152 #define ALT_FW_FTR_SECTION_END_IFCLR(msk) \ 153 ALT_FW_FTR_SECTION_END_NESTED_IFCLR(msk, 97) 154 155 #ifndef __ASSEMBLY__ 156 157 #define ASM_FTR_IF(section_if, section_else, msk, val) \ 158 stringify_in_c(BEGIN_FTR_SECTION) \ 159 section_if "; " \ 160 stringify_in_c(FTR_SECTION_ELSE) \ 161 section_else "; " \ 162 stringify_in_c(ALT_FTR_SECTION_END((msk), (val))) 163 164 #define ASM_FTR_IFSET(section_if, section_else, msk) \ 165 ASM_FTR_IF(section_if, section_else, (msk), (msk)) 166 167 #define ASM_FTR_IFCLR(section_if, section_else, msk) \ 168 ASM_FTR_IF(section_if, section_else, (msk), 0) 169 170 #define ASM_MMU_FTR_IF(section_if, section_else, msk, val) \ 171 stringify_in_c(BEGIN_MMU_FTR_SECTION) \ 172 section_if "; " \ 173 stringify_in_c(MMU_FTR_SECTION_ELSE) \ 174 section_else "; " \ 175 stringify_in_c(ALT_MMU_FTR_SECTION_END((msk), (val))) 176 177 #define ASM_MMU_FTR_IFSET(section_if, section_else, msk) \ 178 ASM_MMU_FTR_IF(section_if, section_else, (msk), (msk)) 179 180 #define ASM_MMU_FTR_IFCLR(section_if, section_else, msk) \ 181 ASM_MMU_FTR_IF(section_if, section_else, (msk), 0) 182 183 #endif /* __ASSEMBLY__ */ 184 185 /* LWSYNC feature sections */ 186 #define START_LWSYNC_SECTION(label) label##1: 187 #define MAKE_LWSYNC_SECTION_ENTRY(label, sect) \ 188 label##2: \ 189 .pushsection sect,"a"; \ 190 .align 2; \ 191 label##3: \ 192 FTR_ENTRY_OFFSET label##1b-label##3b; \ 193 .popsection; 194 195 #define STF_ENTRY_BARRIER_FIXUP_SECTION \ 196 953: \ 197 .pushsection __stf_entry_barrier_fixup,"a"; \ 198 .align 2; \ 199 954: \ 200 FTR_ENTRY_OFFSET 953b-954b; \ 201 .popsection; 202 203 #define STF_EXIT_BARRIER_FIXUP_SECTION \ 204 955: \ 205 .pushsection __stf_exit_barrier_fixup,"a"; \ 206 .align 2; \ 207 956: \ 208 FTR_ENTRY_OFFSET 955b-956b; \ 209 .popsection; 210 211 #define RFI_FLUSH_FIXUP_SECTION \ 212 951: \ 213 .pushsection __rfi_flush_fixup,"a"; \ 214 .align 2; \ 215 952: \ 216 FTR_ENTRY_OFFSET 951b-952b; \ 217 .popsection; 218 219 #define NOSPEC_BARRIER_FIXUP_SECTION \ 220 953: \ 221 .pushsection __barrier_nospec_fixup,"a"; \ 222 .align 2; \ 223 954: \ 224 FTR_ENTRY_OFFSET 953b-954b; \ 225 .popsection; 226 227 #define START_BTB_FLUSH_SECTION \ 228 955: \ 229 230 #define END_BTB_FLUSH_SECTION \ 231 956: \ 232 .pushsection __btb_flush_fixup,"a"; \ 233 .align 2; \ 234 957: \ 235 FTR_ENTRY_OFFSET 955b-957b; \ 236 FTR_ENTRY_OFFSET 956b-957b; \ 237 .popsection; 238 239 #ifndef __ASSEMBLY__ 240 #include <linux/types.h> 241 242 extern long stf_barrier_fallback; 243 extern long __start___stf_entry_barrier_fixup, __stop___stf_entry_barrier_fixup; 244 extern long __start___stf_exit_barrier_fixup, __stop___stf_exit_barrier_fixup; 245 extern long __start___rfi_flush_fixup, __stop___rfi_flush_fixup; 246 extern long __start___barrier_nospec_fixup, __stop___barrier_nospec_fixup; 247 extern long __start__btb_flush_fixup, __stop__btb_flush_fixup; 248 249 void apply_feature_fixups(void); 250 void setup_feature_keys(void); 251 #endif 252 253 #endif /* __ASM_POWERPC_FEATURE_FIXUPS_H */ 254