diff options
Diffstat (limited to 'arch/s390/crypto/crypt_s390.h')
-rw-r--r-- | arch/s390/crypto/crypt_s390.h | 204 |
1 files changed, 65 insertions, 139 deletions
diff --git a/arch/s390/crypto/crypt_s390.h b/arch/s390/crypto/crypt_s390.h index efd836c2e4a6..2b137089f625 100644 --- a/arch/s390/crypto/crypt_s390.h +++ b/arch/s390/crypto/crypt_s390.h | |||
@@ -105,63 +105,6 @@ struct crypt_s390_query_status { | |||
105 | }; | 105 | }; |
106 | 106 | ||
107 | /* | 107 | /* |
108 | * Standard fixup and ex_table sections for crypt_s390 inline functions. | ||
109 | * label 0: the s390 crypto operation | ||
110 | * label 1: just after 1 to catch illegal operation exception | ||
111 | * (unsupported model) | ||
112 | * label 6: the return point after fixup | ||
113 | * label 7: set error value if exception _in_ crypto operation | ||
114 | * label 8: set error value if illegal operation exception | ||
115 | * [ret] is the variable to receive the error code | ||
116 | * [ERR] is the error code value | ||
117 | */ | ||
118 | #ifndef CONFIG_64BIT | ||
119 | #define __crypt_s390_fixup \ | ||
120 | ".section .fixup,\"ax\" \n" \ | ||
121 | "7: lhi %0,%h[e1] \n" \ | ||
122 | " bras 1,9f \n" \ | ||
123 | " .long 6b \n" \ | ||
124 | "8: lhi %0,%h[e2] \n" \ | ||
125 | " bras 1,9f \n" \ | ||
126 | " .long 6b \n" \ | ||
127 | "9: l 1,0(1) \n" \ | ||
128 | " br 1 \n" \ | ||
129 | ".previous \n" \ | ||
130 | ".section __ex_table,\"a\" \n" \ | ||
131 | " .align 4 \n" \ | ||
132 | " .long 0b,7b \n" \ | ||
133 | " .long 1b,8b \n" \ | ||
134 | ".previous" | ||
135 | #else /* CONFIG_64BIT */ | ||
136 | #define __crypt_s390_fixup \ | ||
137 | ".section .fixup,\"ax\" \n" \ | ||
138 | "7: lhi %0,%h[e1] \n" \ | ||
139 | " jg 6b \n" \ | ||
140 | "8: lhi %0,%h[e2] \n" \ | ||
141 | " jg 6b \n" \ | ||
142 | ".previous\n" \ | ||
143 | ".section __ex_table,\"a\" \n" \ | ||
144 | " .align 8 \n" \ | ||
145 | " .quad 0b,7b \n" \ | ||
146 | " .quad 1b,8b \n" \ | ||
147 | ".previous" | ||
148 | #endif /* CONFIG_64BIT */ | ||
149 | |||
150 | /* | ||
151 | * Standard code for setting the result of s390 crypto instructions. | ||
152 | * %0: the register which will receive the result | ||
153 | * [result]: the register containing the result (e.g. second operand length | ||
154 | * to compute number of processed bytes]. | ||
155 | */ | ||
156 | #ifndef CONFIG_64BIT | ||
157 | #define __crypt_s390_set_result \ | ||
158 | " lr %0,%[result] \n" | ||
159 | #else /* CONFIG_64BIT */ | ||
160 | #define __crypt_s390_set_result \ | ||
161 | " lgr %0,%[result] \n" | ||
162 | #endif | ||
163 | |||
164 | /* | ||
165 | * Executes the KM (CIPHER MESSAGE) operation of the CPU. | 108 | * Executes the KM (CIPHER MESSAGE) operation of the CPU. |
166 | * @param func: the function code passed to KM; see crypt_s390_km_func | 109 | * @param func: the function code passed to KM; see crypt_s390_km_func |
167 | * @param param: address of parameter block; see POP for details on each func | 110 | * @param param: address of parameter block; see POP for details on each func |
@@ -176,28 +119,24 @@ crypt_s390_km(long func, void* param, u8* dest, const u8* src, long src_len) | |||
176 | { | 119 | { |
177 | register long __func asm("0") = func & CRYPT_S390_FUNC_MASK; | 120 | register long __func asm("0") = func & CRYPT_S390_FUNC_MASK; |
178 | register void* __param asm("1") = param; | 121 | register void* __param asm("1") = param; |
179 | register u8* __dest asm("4") = dest; | ||
180 | register const u8* __src asm("2") = src; | 122 | register const u8* __src asm("2") = src; |
181 | register long __src_len asm("3") = src_len; | 123 | register long __src_len asm("3") = src_len; |
124 | register u8* __dest asm("4") = dest; | ||
182 | int ret; | 125 | int ret; |
183 | 126 | ||
184 | ret = 0; | 127 | asm volatile( |
185 | __asm__ __volatile__ ( | 128 | "0: .insn rre,0xb92e0000,%3,%1 \n" /* KM opcode */ |
186 | "0: .insn rre,0xB92E0000,%1,%2 \n" /* KM opcode */ | ||
187 | "1: brc 1,0b \n" /* handle partial completion */ | 129 | "1: brc 1,0b \n" /* handle partial completion */ |
188 | __crypt_s390_set_result | 130 | " ahi %0,%h7\n" |
189 | "6: \n" | 131 | "2: ahi %0,%h8\n" |
190 | __crypt_s390_fixup | 132 | "3:\n" |
191 | : "+d" (ret), "+a" (__dest), "+a" (__src), | 133 | EX_TABLE(0b,3b) EX_TABLE(1b,2b) |
192 | [result] "+d" (__src_len) | 134 | : "=d" (ret), "+a" (__src), "+d" (__src_len), "+a" (__dest) |
193 | : [e1] "K" (-EFAULT), [e2] "K" (-ENOSYS), "d" (__func), | 135 | : "d" (__func), "a" (__param), "0" (-EFAULT), |
194 | "a" (__param) | 136 | "K" (ENOSYS), "K" (-ENOSYS + EFAULT) : "cc", "memory"); |
195 | : "cc", "memory" | 137 | if (ret < 0) |
196 | ); | 138 | return ret; |
197 | if (ret >= 0 && func & CRYPT_S390_FUNC_MASK){ | 139 | return (func & CRYPT_S390_FUNC_MASK) ? src_len - __src_len : __src_len; |
198 | ret = src_len - ret; | ||
199 | } | ||
200 | return ret; | ||
201 | } | 140 | } |
202 | 141 | ||
203 | /* | 142 | /* |
@@ -215,28 +154,24 @@ crypt_s390_kmc(long func, void* param, u8* dest, const u8* src, long src_len) | |||
215 | { | 154 | { |
216 | register long __func asm("0") = func & CRYPT_S390_FUNC_MASK; | 155 | register long __func asm("0") = func & CRYPT_S390_FUNC_MASK; |
217 | register void* __param asm("1") = param; | 156 | register void* __param asm("1") = param; |
218 | register u8* __dest asm("4") = dest; | ||
219 | register const u8* __src asm("2") = src; | 157 | register const u8* __src asm("2") = src; |
220 | register long __src_len asm("3") = src_len; | 158 | register long __src_len asm("3") = src_len; |
159 | register u8* __dest asm("4") = dest; | ||
221 | int ret; | 160 | int ret; |
222 | 161 | ||
223 | ret = 0; | 162 | asm volatile( |
224 | __asm__ __volatile__ ( | 163 | "0: .insn rre,0xb92f0000,%3,%1 \n" /* KMC opcode */ |
225 | "0: .insn rre,0xB92F0000,%1,%2 \n" /* KMC opcode */ | ||
226 | "1: brc 1,0b \n" /* handle partial completion */ | 164 | "1: brc 1,0b \n" /* handle partial completion */ |
227 | __crypt_s390_set_result | 165 | " ahi %0,%h7\n" |
228 | "6: \n" | 166 | "2: ahi %0,%h8\n" |
229 | __crypt_s390_fixup | 167 | "3:\n" |
230 | : "+d" (ret), "+a" (__dest), "+a" (__src), | 168 | EX_TABLE(0b,3b) EX_TABLE(1b,2b) |
231 | [result] "+d" (__src_len) | 169 | : "=d" (ret), "+a" (__src), "+d" (__src_len), "+a" (__dest) |
232 | : [e1] "K" (-EFAULT), [e2] "K" (-ENOSYS), "d" (__func), | 170 | : "d" (__func), "a" (__param), "0" (-EFAULT), |
233 | "a" (__param) | 171 | "K" (ENOSYS), "K" (-ENOSYS + EFAULT) : "cc", "memory"); |
234 | : "cc", "memory" | 172 | if (ret < 0) |
235 | ); | 173 | return ret; |
236 | if (ret >= 0 && func & CRYPT_S390_FUNC_MASK){ | 174 | return (func & CRYPT_S390_FUNC_MASK) ? src_len - __src_len : __src_len; |
237 | ret = src_len - ret; | ||
238 | } | ||
239 | return ret; | ||
240 | } | 175 | } |
241 | 176 | ||
242 | /* | 177 | /* |
@@ -258,22 +193,19 @@ crypt_s390_kimd(long func, void* param, const u8* src, long src_len) | |||
258 | register long __src_len asm("3") = src_len; | 193 | register long __src_len asm("3") = src_len; |
259 | int ret; | 194 | int ret; |
260 | 195 | ||
261 | ret = 0; | 196 | asm volatile( |
262 | __asm__ __volatile__ ( | 197 | "0: .insn rre,0xb93e0000,%1,%1 \n" /* KIMD opcode */ |
263 | "0: .insn rre,0xB93E0000,%1,%1 \n" /* KIMD opcode */ | 198 | "1: brc 1,0b \n" /* handle partial completion */ |
264 | "1: brc 1,0b \n" /* handle partical completion */ | 199 | " ahi %0,%h6\n" |
265 | __crypt_s390_set_result | 200 | "2: ahi %0,%h7\n" |
266 | "6: \n" | 201 | "3:\n" |
267 | __crypt_s390_fixup | 202 | EX_TABLE(0b,3b) EX_TABLE(1b,2b) |
268 | : "+d" (ret), "+a" (__src), [result] "+d" (__src_len) | 203 | : "=d" (ret), "+a" (__src), "+d" (__src_len) |
269 | : [e1] "K" (-EFAULT), [e2] "K" (-ENOSYS), "d" (__func), | 204 | : "d" (__func), "a" (__param), "0" (-EFAULT), |
270 | "a" (__param) | 205 | "K" (ENOSYS), "K" (-ENOSYS + EFAULT) : "cc", "memory"); |
271 | : "cc", "memory" | 206 | if (ret < 0) |
272 | ); | 207 | return ret; |
273 | if (ret >= 0 && (func & CRYPT_S390_FUNC_MASK)){ | 208 | return (func & CRYPT_S390_FUNC_MASK) ? src_len - __src_len : __src_len; |
274 | ret = src_len - ret; | ||
275 | } | ||
276 | return ret; | ||
277 | } | 209 | } |
278 | 210 | ||
279 | /* | 211 | /* |
@@ -294,22 +226,19 @@ crypt_s390_klmd(long func, void* param, const u8* src, long src_len) | |||
294 | register long __src_len asm("3") = src_len; | 226 | register long __src_len asm("3") = src_len; |
295 | int ret; | 227 | int ret; |
296 | 228 | ||
297 | ret = 0; | 229 | asm volatile( |
298 | __asm__ __volatile__ ( | 230 | "0: .insn rre,0xb93f0000,%1,%1 \n" /* KLMD opcode */ |
299 | "0: .insn rre,0xB93F0000,%1,%1 \n" /* KLMD opcode */ | 231 | "1: brc 1,0b \n" /* handle partial completion */ |
300 | "1: brc 1,0b \n" /* handle partical completion */ | 232 | " ahi %0,%h6\n" |
301 | __crypt_s390_set_result | 233 | "2: ahi %0,%h7\n" |
302 | "6: \n" | 234 | "3:\n" |
303 | __crypt_s390_fixup | 235 | EX_TABLE(0b,3b) EX_TABLE(1b,2b) |
304 | : "+d" (ret), "+a" (__src), [result] "+d" (__src_len) | 236 | : "=d" (ret), "+a" (__src), "+d" (__src_len) |
305 | : [e1] "K" (-EFAULT), [e2] "K" (-ENOSYS), "d" (__func), | 237 | : "d" (__func), "a" (__param), "0" (-EFAULT), |
306 | "a" (__param) | 238 | "K" (ENOSYS), "K" (-ENOSYS + EFAULT) : "cc", "memory"); |
307 | : "cc", "memory" | 239 | if (ret < 0) |
308 | ); | 240 | return ret; |
309 | if (ret >= 0 && func & CRYPT_S390_FUNC_MASK){ | 241 | return (func & CRYPT_S390_FUNC_MASK) ? src_len - __src_len : __src_len; |
310 | ret = src_len - ret; | ||
311 | } | ||
312 | return ret; | ||
313 | } | 242 | } |
314 | 243 | ||
315 | /* | 244 | /* |
@@ -331,22 +260,19 @@ crypt_s390_kmac(long func, void* param, const u8* src, long src_len) | |||
331 | register long __src_len asm("3") = src_len; | 260 | register long __src_len asm("3") = src_len; |
332 | int ret; | 261 | int ret; |
333 | 262 | ||
334 | ret = 0; | 263 | asm volatile( |
335 | __asm__ __volatile__ ( | 264 | "0: .insn rre,0xb91e0000,%1,%1 \n" /* KLAC opcode */ |
336 | "0: .insn rre,0xB91E0000,%5,%5 \n" /* KMAC opcode */ | 265 | "1: brc 1,0b \n" /* handle partial completion */ |
337 | "1: brc 1,0b \n" /* handle partical completion */ | 266 | " ahi %0,%h6\n" |
338 | __crypt_s390_set_result | 267 | "2: ahi %0,%h7\n" |
339 | "6: \n" | 268 | "3:\n" |
340 | __crypt_s390_fixup | 269 | EX_TABLE(0b,3b) EX_TABLE(1b,2b) |
341 | : "+d" (ret), "+a" (__src), [result] "+d" (__src_len) | 270 | : "=d" (ret), "+a" (__src), "+d" (__src_len) |
342 | : [e1] "K" (-EFAULT), [e2] "K" (-ENOSYS), "d" (__func), | 271 | : "d" (__func), "a" (__param), "0" (-EFAULT), |
343 | "a" (__param) | 272 | "K" (ENOSYS), "K" (-ENOSYS + EFAULT) : "cc", "memory"); |
344 | : "cc", "memory" | 273 | if (ret < 0) |
345 | ); | 274 | return ret; |
346 | if (ret >= 0 && func & CRYPT_S390_FUNC_MASK){ | 275 | return (func & CRYPT_S390_FUNC_MASK) ? src_len - __src_len : __src_len; |
347 | ret = src_len - ret; | ||
348 | } | ||
349 | return ret; | ||
350 | } | 276 | } |
351 | 277 | ||
352 | /** | 278 | /** |