| 1 |
/* Support routine for SME. |
| 2 |
Copyright (C) 2023-2025 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
This file is part of GCC. |
| 5 |
|
| 6 |
GCC is free software; you can redistribute it and/or modify it |
| 7 |
under the terms of the GNU General Public License as published |
| 8 |
by the Free Software Foundation; either version 3, or (at your |
| 9 |
option) any later version. |
| 10 |
|
| 11 |
GCC is distributed in the hope that it will be useful, but WITHOUT |
| 12 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 13 |
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public |
| 14 |
License for more details. |
| 15 |
|
| 16 |
Under Section 7 of GPL version 3, you are granted additional |
| 17 |
permissions described in the GCC Runtime Library Exception, version |
| 18 |
3.1, as published by the Free Software Foundation. |
| 19 |
|
| 20 |
You should have received a copy of the GNU General Public License and |
| 21 |
a copy of the GCC Runtime Library Exception along with this program; |
| 22 |
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 23 |
<http://www.gnu.org/licenses/>. */ |
| 24 |
|
| 25 |
#include "aarch64-asm.h" |
| 26 |
|
| 27 |
/* Disable ZA. Call ABI: |
| 28 |
- Private ZA, streaming-compatible. |
| 29 |
- x0-x13, x19-x29, sp and fp regs are call preserved. |
| 30 |
- Takes no argument. |
| 31 |
- Does not return a value. |
| 32 |
- Can abort on failure (then registers are not preserved). */ |
| 33 |
|
| 34 |
HIDDEN (__aarch64_have_sme) |
| 35 |
|
| 36 |
HIDDEN (__libgcc_arm_tpidr2_save) |
| 37 |
|
| 38 |
variant_pcs (__arm_za_disable) |
| 39 |
|
| 40 |
ENTRY (__arm_za_disable) |
| 41 |
/* Check if SME is available. */ |
| 42 |
adrp x14, __aarch64_have_sme |
| 43 |
ldrb w14, [x14, :lo12:__aarch64_have_sme] |
| 44 |
cbz w14, L(end) |
| 45 |
|
| 46 |
.inst 0xd53bd0ae /* mrs x14, tpidr2_el0 */ |
| 47 |
cbz x14, L(end) |
| 48 |
|
| 49 |
PACIASP |
| 50 |
stp x29, x30, [sp, -16]! |
| 51 |
.cfi_adjust_cfa_offset 16 |
| 52 |
.cfi_rel_offset x29, 0 |
| 53 |
.cfi_rel_offset x30, 8 |
| 54 |
mov x29, sp |
| 55 |
bl __libgcc_arm_tpidr2_save |
| 56 |
.inst 0xd51bd0bf /* msr tpidr2_el0, xzr */ |
| 57 |
.inst 0xd503447f /* smstop za */ |
| 58 |
ldp x29, x30, [sp], 16 |
| 59 |
.cfi_adjust_cfa_offset -16 |
| 60 |
.cfi_restore x29 |
| 61 |
.cfi_restore x30 |
| 62 |
AUTIASP |
| 63 |
L(end): |
| 64 |
ret |
| 65 |
END (__arm_za_disable) |
| 66 |
|
| 67 |
/* Hidden alias used by the unwinder. */ |
| 68 |
.global __libgcc_arm_za_disable |
| 69 |
HIDDEN (__libgcc_arm_za_disable) |
| 70 |
.set __libgcc_arm_za_disable, __arm_za_disable |