.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * sha1-ce-core.S - SHA-1 secure hash using ARMv8 Crypto Extensions |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2014 Linaro Ltd <ard.biesheuvel@linaro.org> |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License version 2 as |
---|
8 | | - * published by the Free Software Foundation. |
---|
9 | 6 | */ |
---|
10 | 7 | |
---|
11 | 8 | #include <linux/linkage.h> |
---|
.. | .. |
---|
65 | 62 | .endm |
---|
66 | 63 | |
---|
67 | 64 | /* |
---|
68 | | - * void sha1_ce_transform(struct sha1_ce_state *sst, u8 const *src, |
---|
69 | | - * int blocks) |
---|
| 65 | + * int sha1_ce_transform(struct sha1_ce_state *sst, u8 const *src, |
---|
| 66 | + * int blocks) |
---|
70 | 67 | */ |
---|
71 | | -ENTRY(sha1_ce_transform) |
---|
72 | | - frame_push 3 |
---|
73 | | - |
---|
74 | | - mov x19, x0 |
---|
75 | | - mov x20, x1 |
---|
76 | | - mov x21, x2 |
---|
77 | | - |
---|
| 68 | +SYM_FUNC_START(sha1_ce_transform) |
---|
78 | 69 | /* load round constants */ |
---|
79 | | -0: loadrc k0.4s, 0x5a827999, w6 |
---|
| 70 | + loadrc k0.4s, 0x5a827999, w6 |
---|
80 | 71 | loadrc k1.4s, 0x6ed9eba1, w6 |
---|
81 | 72 | loadrc k2.4s, 0x8f1bbcdc, w6 |
---|
82 | 73 | loadrc k3.4s, 0xca62c1d6, w6 |
---|
83 | 74 | |
---|
84 | 75 | /* load state */ |
---|
85 | | - ld1 {dgav.4s}, [x19] |
---|
86 | | - ldr dgb, [x19, #16] |
---|
| 76 | + ld1 {dgav.4s}, [x0] |
---|
| 77 | + ldr dgb, [x0, #16] |
---|
87 | 78 | |
---|
88 | 79 | /* load sha1_ce_state::finalize */ |
---|
89 | 80 | ldr_l w4, sha1_ce_offsetof_finalize, x4 |
---|
90 | | - ldr w4, [x19, x4] |
---|
| 81 | + ldr w4, [x0, x4] |
---|
91 | 82 | |
---|
92 | 83 | /* load input */ |
---|
93 | | -1: ld1 {v8.4s-v11.4s}, [x20], #64 |
---|
94 | | - sub w21, w21, #1 |
---|
| 84 | +0: ld1 {v8.4s-v11.4s}, [x1], #64 |
---|
| 85 | + sub w2, w2, #1 |
---|
95 | 86 | |
---|
96 | 87 | CPU_LE( rev32 v8.16b, v8.16b ) |
---|
97 | 88 | CPU_LE( rev32 v9.16b, v9.16b ) |
---|
98 | 89 | CPU_LE( rev32 v10.16b, v10.16b ) |
---|
99 | 90 | CPU_LE( rev32 v11.16b, v11.16b ) |
---|
100 | 91 | |
---|
101 | | -2: add t0.4s, v8.4s, k0.4s |
---|
| 92 | +1: add t0.4s, v8.4s, k0.4s |
---|
102 | 93 | mov dg0v.16b, dgav.16b |
---|
103 | 94 | |
---|
104 | 95 | add_update c, ev, k0, 8, 9, 10, 11, dgb |
---|
.. | .. |
---|
129 | 120 | add dgbv.2s, dgbv.2s, dg1v.2s |
---|
130 | 121 | add dgav.4s, dgav.4s, dg0v.4s |
---|
131 | 122 | |
---|
132 | | - cbz w21, 3f |
---|
133 | | - |
---|
134 | | - if_will_cond_yield_neon |
---|
135 | | - st1 {dgav.4s}, [x19] |
---|
136 | | - str dgb, [x19, #16] |
---|
137 | | - do_cond_yield_neon |
---|
| 123 | + cbz w2, 2f |
---|
| 124 | + cond_yield 3f, x5, x6 |
---|
138 | 125 | b 0b |
---|
139 | | - endif_yield_neon |
---|
140 | | - |
---|
141 | | - b 1b |
---|
142 | 126 | |
---|
143 | 127 | /* |
---|
144 | 128 | * Final block: add padding and total bit count. |
---|
145 | 129 | * Skip if the input size was not a round multiple of the block size, |
---|
146 | 130 | * the padding is handled by the C code in that case. |
---|
147 | 131 | */ |
---|
148 | | -3: cbz x4, 4f |
---|
| 132 | +2: cbz x4, 3f |
---|
149 | 133 | ldr_l w4, sha1_ce_offsetof_count, x4 |
---|
150 | | - ldr x4, [x19, x4] |
---|
| 134 | + ldr x4, [x0, x4] |
---|
151 | 135 | movi v9.2d, #0 |
---|
152 | 136 | mov x8, #0x80000000 |
---|
153 | 137 | movi v10.2d, #0 |
---|
.. | .. |
---|
156 | 140 | mov x4, #0 |
---|
157 | 141 | mov v11.d[0], xzr |
---|
158 | 142 | mov v11.d[1], x7 |
---|
159 | | - b 2b |
---|
| 143 | + b 1b |
---|
160 | 144 | |
---|
161 | 145 | /* store new state */ |
---|
162 | | -4: st1 {dgav.4s}, [x19] |
---|
163 | | - str dgb, [x19, #16] |
---|
164 | | - frame_pop |
---|
| 146 | +3: st1 {dgav.4s}, [x0] |
---|
| 147 | + str dgb, [x0, #16] |
---|
| 148 | + mov w0, w2 |
---|
165 | 149 | ret |
---|
166 | | -ENDPROC(sha1_ce_transform) |
---|
| 150 | +SYM_FUNC_END(sha1_ce_transform) |
---|