130 lines · plain
1#include "../assembly.h"2 3.arch armv8-a+sme24 5// For Apple platforms at the moment, we just call abort() directly6// after stopping SM mode unconditionally.7.p2align 28DEFINE_COMPILERRT_PRIVATE_FUNCTION(do_abort)9.cfi_startproc10 .variant_pcs SYMBOL_NAME(do_abort)11 stp x29, x30, [sp, #-32]!12 .cfi_def_cfa_offset 3213 .cfi_offset w30, -2414 .cfi_offset w29, -3215 smstop sm16 bl SYMBOL_NAME(abort)17.cfi_endproc18END_COMPILERRT_FUNCTION(do_abort)19 20DEFINE_COMPILERRT_FUNCTION(__arm_tpidr2_save)21 // If TPIDR2_EL0 is null, the subroutine does nothing.22 mrs x16, TPIDR2_EL023 cbz x16, 1f24 25 // If any of the reserved bytes in the first 16 bytes of the TPIDR2 block are26 // nonzero, the subroutine [..] aborts in some platform-defined manner.27 ldrh w14, [x16, #10]28 cbnz w14, 2f29 ldr w14, [x16, #12]30 cbnz w14, 2f31 32 // If za_save_buffer is NULL, the subroutine does nothing.33 ldr x14, [x16]34 cbz x14, 1f35 36 // If num_za_save_slices is zero, the subroutine does nothing.37 ldrh w14, [x16, #8]38 cbz x14, 1f39 40 mov x15, xzr41 ldr x16, [x16]420:43 str za[w15,0], [x16]44 addsvl x16, x16, #145 add x15, x15, #146 cmp x14, x1547 b.ne 0b481:49 ret502:51 b SYMBOL_NAME(do_abort)52END_COMPILERRT_FUNCTION(__arm_tpidr2_save)53 54.p2align 255DEFINE_COMPILERRT_FUNCTION(__arm_za_disable)56.cfi_startproc57 // Otherwise, the subroutine behaves as if it did the following:58 // * Call __arm_tpidr2_save.59 stp x29, x30, [sp, #-16]!60 .cfi_def_cfa_offset 1661 mov x29, sp62 .cfi_def_cfa w29, 1663 .cfi_offset w30, -864 .cfi_offset w29, -1665 bl SYMBOL_NAME(__arm_tpidr2_save)66 67 // * Set TPIDR2_EL0 to null.68 msr TPIDR2_EL0, xzr69 70 // * Set PSTATE.ZA to 0.71 smstop za72 73 .cfi_def_cfa wsp, 1674 ldp x29, x30, [sp], #1675 .cfi_def_cfa_offset 076 .cfi_restore w3077 .cfi_restore w29780:79 ret80.cfi_endproc81END_COMPILERRT_FUNCTION(__arm_za_disable)82 83.p2align 284DEFINE_COMPILERRT_FUNCTION(__arm_tpidr2_restore)85.cfi_startproc86 .variant_pcs SYMBOL_NAME(__arm_tpidr2_restore)87 // If TPIDR2_EL0 is nonnull, the subroutine aborts in some platform-specific88 // manner.89 mrs x14, TPIDR2_EL090 cbnz x14, 2f91 92 // If any of the reserved bytes in the first 16 bytes of BLK are nonzero,93 // the subroutine [..] aborts in some platform-defined manner.94 ldrh w14, [x0, #10]95 cbnz w14, 2f96 ldr w14, [x0, #12]97 cbnz w14, 2f98 99 // If BLK.za_save_buffer is NULL, the subroutine does nothing.100 ldr x16, [x0]101 cbz x16, 1f102 103 // If BLK.num_za_save_slices is zero, the subroutine does nothing.104 ldrh w14, [x0, #8]105 cbz x14, 1f106 107 mov x15, xzr1080:109 ldr za[w15,0], [x16]110 addsvl x16, x16, #1111 add x15, x15, #1112 cmp x14, x15113 b.ne 0b1141:115 ret1162:117 b SYMBOL_NAME(do_abort)118.cfi_endproc119END_COMPILERRT_FUNCTION(__arm_tpidr2_restore)120 121.p2align 2122DEFINE_COMPILERRT_FUNCTION(__arm_sme_state)123 .variant_pcs SYMBOL_NAME(__arm_sme_state)124 orr x0, x0, #0xC000000000000000125 mrs x16, SVCR126 bfxil x0, x16, #0, #2127 mrs x1, TPIDR2_EL0128 ret129END_COMPILERRT_FUNCTION(__arm_sme_state)130