1 /* Copyright (C) 2020-2022 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
25 * ARMv8-a, AArch64, MTE, LP64 ABI.
28 * Address is 16 byte aligned and size is multiple of 16.
29 * Returns the passed pointer.
30 * The memory region may remain untagged if tagging is not enabled.
33 .arch_extension memtag
42 ENTRY (__libc_mtag_tag_region)
46 add dstend, dstin, count
51 tbnz count, 6, L(set96)
53 /* Set 0, 16, 32, or 48 bytes. */
55 add tmp, dstin, tmp, lsl 4
59 stg dstin, [dstend, -16]
64 /* Set 64..96 bytes. Write 64 bytes from the start and
65 32 bytes from the end. */
68 st2g dstin, [dstin, 32]
69 st2g dstin, [dstend, -32]
73 /* Size is > 96 bytes. */
78 #ifndef SKIP_ZVA_CHECK
79 mrs zva_val, dczid_el0
80 and zva_val, zva_val, 31
81 cmp zva_val, 4 /* ZVA size is 64 bytes. */
85 st2g dstin, [dstin, 32]
87 sub count, dstend, dst /* Count is now 64 too large. */
88 sub count, count, 128 /* Adjust count and bias for loop. */
96 st2g dstin, [dstend, -64]
97 st2g dstin, [dstend, -32]
101 sub dst, dstin, 32 /* Dst is biased by -32. */
102 sub count, count, 64 /* Adjust count for loop. */
104 st2g dstin, [dst, 32]
105 st2g dstin, [dst, 64]!
106 subs count, count, 64
108 st2g dstin, [dstend, -64]
109 st2g dstin, [dstend, -32]
112 END (__libc_mtag_tag_region)
113 #endif /* USE_MTAG */