|
12 | 12 | #if !defined(__APPLE__)
|
13 | 13 | #define TPIDR2_SYMBOL SYMBOL_NAME(__aarch64_has_sme_and_tpidr2_el0)
|
14 | 14 | #define TPIDR2_SYMBOL_OFFSET :lo12:SYMBOL_NAME(__aarch64_has_sme_and_tpidr2_el0)
|
| 15 | +#define CPU_FEATS_SYMBOL SYMBOL_NAME(__aarch64_cpu_features) |
| 16 | +#define CPU_FEATS_SYMBOL_OFFSET :lo12:SYMBOL_NAME(__aarch64_cpu_features) |
15 | 17 | #else
|
16 | 18 | // MachO requires @page/@pageoff directives because the global is defined
|
17 | 19 | // in a different file. Otherwise this file may fail to build.
|
18 | 20 | #define TPIDR2_SYMBOL SYMBOL_NAME(__aarch64_has_sme_and_tpidr2_el0)@page
|
19 | 21 | #define TPIDR2_SYMBOL_OFFSET SYMBOL_NAME(__aarch64_has_sme_and_tpidr2_el0)@pageoff
|
| 22 | +#define CPU_FEATS_SYMBOL SYMBOL_NAME(__aarch64_cpu_features)@page |
| 23 | +#define CPU_FEATS_SYMBOL_OFFSET SYMBOL_NAME(__aarch64_cpu_features)@pageoff |
20 | 24 | #endif
|
21 | 25 |
|
22 | 26 | .arch armv9-a+sme
|
@@ -180,6 +184,46 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_za_disable)
|
180 | 184 | ret
|
181 | 185 | END_COMPILERRT_OUTLINE_FUNCTION(__arm_za_disable)
|
182 | 186 |
|
| 187 | +DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_get_current_vg) |
| 188 | + .variant_pcs __arm_get_current_vg |
| 189 | + BTI_C |
| 190 | + |
| 191 | + stp x29, x30, [sp, #-16]! |
| 192 | + .cfi_def_cfa_offset 16 |
| 193 | + mov x29, sp |
| 194 | + .cfi_def_cfa w29, 16 |
| 195 | + .cfi_offset w30, -8 |
| 196 | + .cfi_offset w29, -16 |
| 197 | + adrp x17, CPU_FEATS_SYMBOL |
| 198 | + ldr w17, [x17, CPU_FEATS_SYMBOL_OFFSET] |
| 199 | + tbnz w17, #30, 0f |
| 200 | + adrp x16, TPIDR2_SYMBOL |
| 201 | + ldrb w16, [x16, TPIDR2_SYMBOL_OFFSET] |
| 202 | + cbz w16, 1f |
| 203 | +0: |
| 204 | + mov x18, x1 |
| 205 | + bl __arm_sme_state |
| 206 | + mov x1, x18 |
| 207 | + and x17, x17, #0x40000000 |
| 208 | + bfxil x17, x0, #0, #1 |
| 209 | + cbz x17, 1f |
| 210 | + cntd x0 |
| 211 | + .cfi_def_cfa wsp, 16 |
| 212 | + ldp x29, x30, [sp], #16 |
| 213 | + .cfi_def_cfa_offset 0 |
| 214 | + .cfi_restore w30 |
| 215 | + .cfi_restore w29 |
| 216 | + ret |
| 217 | +1: |
| 218 | + mov x0, xzr |
| 219 | + .cfi_def_cfa wsp, 16 |
| 220 | + ldp x29, x30, [sp], #16 |
| 221 | + .cfi_def_cfa_offset 0 |
| 222 | + .cfi_restore w30 |
| 223 | + .cfi_restore w29 |
| 224 | + ret |
| 225 | +END_COMPILERRT_OUTLINE_FUNCTION(__arm_get_current_vg) |
| 226 | + |
183 | 227 | NO_EXEC_STACK_DIRECTIVE
|
184 | 228 |
|
185 | 229 | // GNU property note for BTI and PAC
|
|
0 commit comments