1 /* SPDX-License-Identifier: GPL-2.0-or-later * 1 2 #ifndef __ASM_POWERPC_FEATURE_FIXUPS_H 3 #define __ASM_POWERPC_FEATURE_FIXUPS_H 4 5 #include <asm/asm-const.h> 6 7 /* 8 */ 9 10 /* 11 * Feature section common macros 12 * 13 * Note that the entries now contain offsets b 14 * and the code rather than absolute code poin 15 * useable with the vdso shared library. There 16 * that values will be negative, that is, the 17 * located after the code it fixes up. 18 */ 19 #if defined(CONFIG_PPC64) && !defined(__powerp 20 /* 64 bits kernel, 32 bits code (ie. vdso32) * 21 #define FTR_ENTRY_LONG .8byte 22 #define FTR_ENTRY_OFFSET .long 0xffffff 23 #elif defined(CONFIG_PPC64) 24 #define FTR_ENTRY_LONG .8byte 25 #define FTR_ENTRY_OFFSET .8byte 26 #else 27 #define FTR_ENTRY_LONG .long 28 #define FTR_ENTRY_OFFSET .long 29 #endif 30 31 #define START_FTR_SECTION(label) label# 32 33 #define FTR_SECTION_ELSE_NESTED(label) 34 label##2: 35 .pushsection __ftr_alt_##label,"a"; 36 .align 2; 37 label##3: 38 39 40 #ifndef CONFIG_CC_IS_CLANG 41 #define CHECK_ALT_SIZE(else_size, body_size) 42 .ifgt (else_size) - (body_size); 43 .error "Feature section else case larg 44 .endif; 45 #else 46 /* 47 * If we use the ifgt syntax above, clang's as 48 * expression being non-absolute when the code 49 * statement. 50 * As a workaround use an .org directive that 51 * instructions are smaller than the body, but 52 */ 53 #define CHECK_ALT_SIZE(else_size, body_size) 54 .org . + ((else_size) > (body_size)); 55 #endif 56 57 #define MAKE_FTR_SECTION_ENTRY(msk, val, label 58 label##4: 59 .popsection; 60 .pushsection sect,"a"; 61 .align 3; 62 label##5: 63 FTR_ENTRY_LONG msk; 64 FTR_ENTRY_LONG val; 65 FTR_ENTRY_OFFSET label##1b-label##5b; 66 FTR_ENTRY_OFFSET label##2b-label##5b; 67 FTR_ENTRY_OFFSET label##3b-label##5b; 68 FTR_ENTRY_OFFSET label##4b-label##5b; 69 CHECK_ALT_SIZE((label##4b-label##3b), 70 .popsection; 71 72 73 /* CPU feature dependent sections */ 74 #define BEGIN_FTR_SECTION_NESTED(label) START_ 75 #define BEGIN_FTR_SECTION START_ 76 77 #define END_FTR_SECTION_NESTED(msk, val, label 78 FTR_SECTION_ELSE_NESTED(label) 79 MAKE_FTR_SECTION_ENTRY(msk, val, label 80 81 #define END_FTR_SECTION(msk, val) 82 END_FTR_SECTION_NESTED(msk, val, 97) 83 84 #define END_FTR_SECTION_NESTED_IFSET(msk, labe 85 END_FTR_SECTION_NESTED((msk), (msk), l 86 87 #define END_FTR_SECTION_IFSET(msk) END_FT 88 #define END_FTR_SECTION_IFCLR(msk) END_FT 89 90 /* CPU feature sections with alternatives, use 91 #define FTR_SECTION_ELSE FTR_SECTION_EL 92 #define ALT_FTR_SECTION_END_NESTED(msk, val, l 93 MAKE_FTR_SECTION_ENTRY(msk, val, label 94 #define ALT_FTR_SECTION_END_NESTED_IFSET(msk, 95 ALT_FTR_SECTION_END_NESTED(msk, msk, l 96 #define ALT_FTR_SECTION_END_NESTED_IFCLR(msk, 97 ALT_FTR_SECTION_END_NESTED(msk, 0, lab 98 #define ALT_FTR_SECTION_END(msk, val) \ 99 ALT_FTR_SECTION_END_NESTED(msk, val, 9 100 #define ALT_FTR_SECTION_END_IFSET(msk) \ 101 ALT_FTR_SECTION_END_NESTED_IFSET(msk, 102 #define ALT_FTR_SECTION_END_IFCLR(msk) \ 103 ALT_FTR_SECTION_END_NESTED_IFCLR(msk, 104 105 /* MMU feature dependent sections */ 106 #define BEGIN_MMU_FTR_SECTION_NESTED(label) 107 #define BEGIN_MMU_FTR_SECTION 108 109 #define END_MMU_FTR_SECTION_NESTED(msk, val, l 110 FTR_SECTION_ELSE_NESTED(label) 111 MAKE_FTR_SECTION_ENTRY(msk, val, label 112 113 #define END_MMU_FTR_SECTION(msk, val) 114 END_MMU_FTR_SECTION_NESTED(msk, val, 9 115 116 #define END_MMU_FTR_SECTION_NESTED_IFSET(msk, 117 END_MMU_FTR_SECTION_NESTED((msk), (msk 118 119 #define END_MMU_FTR_SECTION_NESTED_IFCLR(msk, 120 END_MMU_FTR_SECTION_NESTED((msk), 0, l 121 122 #define END_MMU_FTR_SECTION_IFSET(msk) END_MM 123 #define END_MMU_FTR_SECTION_IFCLR(msk) END_MM 124 125 /* MMU feature sections with alternatives, use 126 #define MMU_FTR_SECTION_ELSE_NESTED(label) 127 #define MMU_FTR_SECTION_ELSE MMU_FTR_SECTIO 128 #define ALT_MMU_FTR_SECTION_END_NESTED(msk, va 129 MAKE_FTR_SECTION_ENTRY(msk, val, label 130 #define ALT_MMU_FTR_SECTION_END_NESTED_IFSET(m 131 ALT_MMU_FTR_SECTION_END_NESTED(msk, ms 132 #define ALT_MMU_FTR_SECTION_END_NESTED_IFCLR(m 133 ALT_MMU_FTR_SECTION_END_NESTED(msk, 0, 134 #define ALT_MMU_FTR_SECTION_END(msk, val) 135 ALT_MMU_FTR_SECTION_END_NESTED(msk, va 136 #define ALT_MMU_FTR_SECTION_END_IFSET(msk) 137 ALT_MMU_FTR_SECTION_END_NESTED_IFSET(m 138 #define ALT_MMU_FTR_SECTION_END_IFCLR(msk) 139 ALT_MMU_FTR_SECTION_END_NESTED_IFCLR(m 140 141 /* Firmware feature dependent sections */ 142 #define BEGIN_FW_FTR_SECTION_NESTED(label) 143 #define BEGIN_FW_FTR_SECTION 144 145 #define END_FW_FTR_SECTION_NESTED(msk, val, la 146 FTR_SECTION_ELSE_NESTED(label) 147 MAKE_FTR_SECTION_ENTRY(msk, val, label 148 149 #define END_FW_FTR_SECTION(msk, val) 150 END_FW_FTR_SECTION_NESTED(msk, val, 97 151 152 #define END_FW_FTR_SECTION_IFSET(msk) END_FW 153 #define END_FW_FTR_SECTION_IFCLR(msk) END_FW 154 155 /* Firmware feature sections with alternatives 156 #define FW_FTR_SECTION_ELSE_NESTED(label) 157 #define FW_FTR_SECTION_ELSE FTR_SECTION_EL 158 #define ALT_FW_FTR_SECTION_END_NESTED(msk, val 159 MAKE_FTR_SECTION_ENTRY(msk, val, label 160 #define ALT_FW_FTR_SECTION_END_NESTED_IFSET(ms 161 ALT_FW_FTR_SECTION_END_NESTED(msk, msk 162 #define ALT_FW_FTR_SECTION_END_NESTED_IFCLR(ms 163 ALT_FW_FTR_SECTION_END_NESTED(msk, 0, 164 #define ALT_FW_FTR_SECTION_END(msk, val) 165 ALT_FW_FTR_SECTION_END_NESTED(msk, val 166 #define ALT_FW_FTR_SECTION_END_IFSET(msk) 167 ALT_FW_FTR_SECTION_END_NESTED_IFSET(ms 168 #define ALT_FW_FTR_SECTION_END_IFCLR(msk) 169 ALT_FW_FTR_SECTION_END_NESTED_IFCLR(ms 170 171 #ifndef __ASSEMBLY__ 172 173 #define ASM_FTR_IF(section_if, section_else, m 174 stringify_in_c(BEGIN_FTR_SECTION) 175 section_if "; " 176 stringify_in_c(FTR_SECTION_ELSE) 177 section_else "; " 178 stringify_in_c(ALT_FTR_SECTION_END((ms 179 180 #define ASM_FTR_IFSET(section_if, section_else 181 ASM_FTR_IF(section_if, section_else, ( 182 183 #define ASM_FTR_IFCLR(section_if, section_else 184 ASM_FTR_IF(section_if, section_else, ( 185 186 #define ASM_MMU_FTR_IF(section_if, section_els 187 stringify_in_c(BEGIN_MMU_FTR_SECTION) 188 section_if "; " 189 stringify_in_c(MMU_FTR_SECTION_ELSE) 190 section_else "; " 191 stringify_in_c(ALT_MMU_FTR_SECTION_END 192 193 #define ASM_MMU_FTR_IFSET(section_if, section_ 194 ASM_MMU_FTR_IF(section_if, section_els 195 196 #define ASM_MMU_FTR_IFCLR(section_if, section_ 197 ASM_MMU_FTR_IF(section_if, section_els 198 199 #endif /* __ASSEMBLY__ */ 200 201 /* LWSYNC feature sections */ 202 #define START_LWSYNC_SECTION(label) label# 203 #define MAKE_LWSYNC_SECTION_ENTRY(label, sect) 204 label##2: 205 .pushsection sect,"a"; 206 .align 2; 207 label##3: 208 FTR_ENTRY_OFFSET label##1b-label##3b; 209 .popsection; 210 211 #define STF_ENTRY_BARRIER_FIXUP_SECTION 212 953: 213 .pushsection __stf_entry_barrier_fixup 214 .align 2; 215 954: 216 FTR_ENTRY_OFFSET 953b-954b; 217 .popsection; 218 219 #define STF_EXIT_BARRIER_FIXUP_SECTION 220 955: 221 .pushsection __stf_exit_barrier_fixup, 222 .align 2; 223 956: 224 FTR_ENTRY_OFFSET 955b-956b; 225 .popsection; 226 227 #define UACCESS_FLUSH_FIXUP_SECTION 228 959: 229 .pushsection __uaccess_flush_fixup,"a" 230 .align 2; 231 960: 232 FTR_ENTRY_OFFSET 959b-960b; 233 .popsection; 234 235 #define ENTRY_FLUSH_FIXUP_SECTION 236 957: 237 .pushsection __entry_flush_fixup,"a"; 238 .align 2; 239 958: 240 FTR_ENTRY_OFFSET 957b-958b; 241 .popsection; 242 243 #define SCV_ENTRY_FLUSH_FIXUP_SECTION 244 957: 245 .pushsection __scv_entry_flush_fixup," 246 .align 2; 247 958: 248 FTR_ENTRY_OFFSET 957b-958b; 249 .popsection; 250 251 #define RFI_FLUSH_FIXUP_SECTION 252 951: 253 .pushsection __rfi_flush_fixup,"a"; 254 .align 2; 255 952: 256 FTR_ENTRY_OFFSET 951b-952b; 257 .popsection; 258 259 #define NOSPEC_BARRIER_FIXUP_SECTION 260 953: 261 .pushsection __barrier_nospec_fixup,"a 262 .align 2; 263 954: 264 FTR_ENTRY_OFFSET 953b-954b; 265 .popsection; 266 267 #define START_BTB_FLUSH_SECTION 268 955: 269 270 #define END_BTB_FLUSH_SECTION 271 956: 272 .pushsection __btb_flush_fixup,"a"; 273 .align 2; 274 957: 275 FTR_ENTRY_OFFSET 955b-957b; 276 FTR_ENTRY_OFFSET 956b-957b; 277 .popsection; 278 279 #ifndef __ASSEMBLY__ 280 #include <linux/types.h> 281 282 extern long stf_barrier_fallback; 283 extern long entry_flush_fallback; 284 extern long scv_entry_flush_fallback; 285 extern long __start___stf_entry_barrier_fixup, 286 extern long __start___stf_exit_barrier_fixup, 287 extern long __start___uaccess_flush_fixup, __s 288 extern long __start___entry_flush_fixup, __sto 289 extern long __start___scv_entry_flush_fixup, _ 290 extern long __start___rfi_flush_fixup, __stop_ 291 extern long __start___barrier_nospec_fixup, __ 292 extern long __start__btb_flush_fixup, __stop__ 293 294 extern bool static_key_feature_checks_initiali 295 296 void apply_feature_fixups(void); 297 void update_mmu_feature_fixups(unsigned long m 298 void setup_feature_keys(void); 299 #endif 300 301 #endif /* __ASM_POWERPC_FEATURE_FIXUPS_H */ 302
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.