1 /* Copyright (c) 2018, Google Inc.
2 *
3 * Permission to use, copy, modify, and/or distribute this software for any
4 * purpose with or without fee is hereby granted, provided that the above
5 * copyright notice and this permission notice appear in all copies.
6 *
7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14
15 #include <gtest/gtest.h>
16 #include <gtest/gtest-spi.h>
17
18 #include <openssl/rand.h>
19
20 #include "test/abi_test.h"
21
22
23 static bool test_function_ok;
TestFunction(int a1,int a2,int a3,int a4,int a5,int a6,int a7,int a8)24 static int TestFunction(int a1, int a2, int a3, int a4, int a5, int a6, int a7,
25 int a8) {
26 test_function_ok = a1 == 1 || a2 == 2 || a3 == 3 || a4 == 4 || a5 == 5 ||
27 a6 == 6 || a7 == 7 || a8 == 8;
28 return 42;
29 }
30
TEST(ABITest,SanityCheck)31 TEST(ABITest, SanityCheck) {
32 EXPECT_NE(0, CHECK_ABI_NO_UNWIND(strcmp, "hello", "world"));
33
34 test_function_ok = false;
35 EXPECT_EQ(42, CHECK_ABI_SEH(TestFunction, 1, 2, 3, 4, 5, 6, 7, 8));
36 EXPECT_TRUE(test_function_ok);
37
38 #if defined(SUPPORTS_ABI_TEST)
39 abi_test::internal::CallerState state;
40 RAND_bytes(reinterpret_cast<uint8_t *>(&state), sizeof(state));
41 crypto_word_t argv[] = {
42 1, 2, 3, 4, 5, 6, 7, 8,
43 };
44 CHECK_ABI_SEH(abi_test_trampoline,
45 reinterpret_cast<crypto_word_t>(TestFunction), &state, argv, 8,
46 0 /* no breakpoint */);
47
48 #if defined(OPENSSL_X86_64)
49 if (abi_test::UnwindTestsEnabled()) {
50 EXPECT_NONFATAL_FAILURE(CHECK_ABI_SEH(abi_test_bad_unwind_wrong_register),
51 "was not recovered");
52 EXPECT_NONFATAL_FAILURE(CHECK_ABI_SEH(abi_test_bad_unwind_temporary),
53 "was not recovered");
54
55 CHECK_ABI_NO_UNWIND(abi_test_bad_unwind_wrong_register);
56 CHECK_ABI_NO_UNWIND(abi_test_bad_unwind_temporary);
57
58 #if defined(OPENSSL_WINDOWS)
59 // The invalid epilog makes Windows believe the epilog starts later than it
60 // actually does. As a result, immediately after the popq, it does not
61 // realize the stack has been unwound and repeats the work.
62 EXPECT_NONFATAL_FAILURE(CHECK_ABI_SEH(abi_test_bad_unwind_epilog),
63 "unwound past starting frame");
64 CHECK_ABI_NO_UNWIND(abi_test_bad_unwind_epilog);
65 #endif // OPENSSL_WINDOWS
66 }
67 #endif // OPENSSL_X86_64
68 #endif // SUPPORTS_ABI_TEST
69 }
70
71 #if defined(OPENSSL_X86_64) && defined(SUPPORTS_ABI_TEST)
72 extern "C" {
73 void abi_test_clobber_rax(void);
74 void abi_test_clobber_rbx(void);
75 void abi_test_clobber_rcx(void);
76 void abi_test_clobber_rdx(void);
77 void abi_test_clobber_rsi(void);
78 void abi_test_clobber_rdi(void);
79 void abi_test_clobber_rbp(void);
80 void abi_test_clobber_r8(void);
81 void abi_test_clobber_r9(void);
82 void abi_test_clobber_r10(void);
83 void abi_test_clobber_r11(void);
84 void abi_test_clobber_r12(void);
85 void abi_test_clobber_r13(void);
86 void abi_test_clobber_r14(void);
87 void abi_test_clobber_r15(void);
88 void abi_test_clobber_xmm0(void);
89 void abi_test_clobber_xmm1(void);
90 void abi_test_clobber_xmm2(void);
91 void abi_test_clobber_xmm3(void);
92 void abi_test_clobber_xmm4(void);
93 void abi_test_clobber_xmm5(void);
94 void abi_test_clobber_xmm6(void);
95 void abi_test_clobber_xmm7(void);
96 void abi_test_clobber_xmm8(void);
97 void abi_test_clobber_xmm9(void);
98 void abi_test_clobber_xmm10(void);
99 void abi_test_clobber_xmm11(void);
100 void abi_test_clobber_xmm12(void);
101 void abi_test_clobber_xmm13(void);
102 void abi_test_clobber_xmm14(void);
103 void abi_test_clobber_xmm15(void);
104 } // extern "C"
105
TEST(ABITest,X86_64)106 TEST(ABITest, X86_64) {
107 // abi_test_trampoline hides unsaved registers from the caller, so we can
108 // safely call the abi_test_clobber_* functions below.
109 abi_test::internal::CallerState state;
110 RAND_bytes(reinterpret_cast<uint8_t *>(&state), sizeof(state));
111 CHECK_ABI_NO_UNWIND(abi_test_trampoline,
112 reinterpret_cast<crypto_word_t>(abi_test_clobber_rbx),
113 &state, nullptr, 0, 0 /* no breakpoint */);
114
115 CHECK_ABI_NO_UNWIND(abi_test_clobber_rax);
116 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_rbx),
117 "rbx was not restored after return");
118 CHECK_ABI_NO_UNWIND(abi_test_clobber_rcx);
119 CHECK_ABI_NO_UNWIND(abi_test_clobber_rdx);
120 #if defined(OPENSSL_WINDOWS)
121 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_rdi),
122 "rdi was not restored after return");
123 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_rsi),
124 "rsi was not restored after return");
125 #else
126 CHECK_ABI_NO_UNWIND(abi_test_clobber_rdi);
127 CHECK_ABI_NO_UNWIND(abi_test_clobber_rsi);
128 #endif
129 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_rbp),
130 "rbp was not restored after return");
131 CHECK_ABI_NO_UNWIND(abi_test_clobber_r8);
132 CHECK_ABI_NO_UNWIND(abi_test_clobber_r9);
133 CHECK_ABI_NO_UNWIND(abi_test_clobber_r10);
134 CHECK_ABI_NO_UNWIND(abi_test_clobber_r11);
135 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r12),
136 "r12 was not restored after return");
137 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r13),
138 "r13 was not restored after return");
139 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r14),
140 "r14 was not restored after return");
141 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r15),
142 "r15 was not restored after return");
143
144 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm0);
145 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm1);
146 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm2);
147 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm3);
148 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm4);
149 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm5);
150 #if defined(OPENSSL_WINDOWS)
151 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm6),
152 "xmm6 was not restored after return");
153 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm7),
154 "xmm7 was not restored after return");
155 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm8),
156 "xmm8 was not restored after return");
157 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm9),
158 "xmm9 was not restored after return");
159 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm10),
160 "xmm10 was not restored after return");
161 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm11),
162 "xmm11 was not restored after return");
163 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm12),
164 "xmm12 was not restored after return");
165 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm13),
166 "xmm13 was not restored after return");
167 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm14),
168 "xmm14 was not restored after return");
169 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm15),
170 "xmm15 was not restored after return");
171 #else
172 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm6);
173 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm7);
174 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm8);
175 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm9);
176 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm10);
177 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm11);
178 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm12);
179 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm13);
180 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm14);
181 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm15);
182 #endif
183
184 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_set_direction_flag),
185 "Direction flag set after return");
186 EXPECT_EQ(0, abi_test_get_and_clear_direction_flag())
187 << "CHECK_ABI did not insulate the caller from direction flag errors";
188 }
189 #endif // OPENSSL_X86_64 && SUPPORTS_ABI_TEST
190
191 #if defined(OPENSSL_X86) && defined(SUPPORTS_ABI_TEST)
192 extern "C" {
193 void abi_test_clobber_eax(void);
194 void abi_test_clobber_ebx(void);
195 void abi_test_clobber_ecx(void);
196 void abi_test_clobber_edx(void);
197 void abi_test_clobber_esi(void);
198 void abi_test_clobber_edi(void);
199 void abi_test_clobber_ebp(void);
200 void abi_test_clobber_xmm0(void);
201 void abi_test_clobber_xmm1(void);
202 void abi_test_clobber_xmm2(void);
203 void abi_test_clobber_xmm3(void);
204 void abi_test_clobber_xmm4(void);
205 void abi_test_clobber_xmm5(void);
206 void abi_test_clobber_xmm6(void);
207 void abi_test_clobber_xmm7(void);
208 } // extern "C"
209
TEST(ABITest,X86)210 TEST(ABITest, X86) {
211 // abi_test_trampoline hides unsaved registers from the caller, so we can
212 // safely call the abi_test_clobber_* functions below.
213 abi_test::internal::CallerState state;
214 RAND_bytes(reinterpret_cast<uint8_t *>(&state), sizeof(state));
215 CHECK_ABI_NO_UNWIND(abi_test_trampoline,
216 reinterpret_cast<crypto_word_t>(abi_test_clobber_ebx),
217 &state, nullptr, 0, 0 /* no breakpoint */);
218
219 CHECK_ABI_NO_UNWIND(abi_test_clobber_eax);
220 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_ebx),
221 "ebx was not restored after return");
222 CHECK_ABI_NO_UNWIND(abi_test_clobber_ecx);
223 CHECK_ABI_NO_UNWIND(abi_test_clobber_edx);
224 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_edi),
225 "edi was not restored after return");
226 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_esi),
227 "esi was not restored after return");
228 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_ebp),
229 "ebp was not restored after return");
230
231 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm0);
232 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm1);
233 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm2);
234 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm3);
235 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm4);
236 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm5);
237 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm6);
238 CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm7);
239
240 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_set_direction_flag),
241 "Direction flag set after return");
242 EXPECT_EQ(0, abi_test_get_and_clear_direction_flag())
243 << "CHECK_ABI did not insulate the caller from direction flag errors";
244 }
245 #endif // OPENSSL_X86 && SUPPORTS_ABI_TEST
246
247 #if defined(OPENSSL_ARM) && defined(SUPPORTS_ABI_TEST)
248 extern "C" {
249 void abi_test_clobber_r0(void);
250 void abi_test_clobber_r1(void);
251 void abi_test_clobber_r2(void);
252 void abi_test_clobber_r3(void);
253 void abi_test_clobber_r4(void);
254 void abi_test_clobber_r5(void);
255 void abi_test_clobber_r6(void);
256 void abi_test_clobber_r7(void);
257 void abi_test_clobber_r8(void);
258 void abi_test_clobber_r9(void);
259 void abi_test_clobber_r10(void);
260 void abi_test_clobber_r11(void);
261 void abi_test_clobber_r12(void);
262 // r13, r14, and r15, are sp, lr, and pc, respectively.
263
264 void abi_test_clobber_d0(void);
265 void abi_test_clobber_d1(void);
266 void abi_test_clobber_d2(void);
267 void abi_test_clobber_d3(void);
268 void abi_test_clobber_d4(void);
269 void abi_test_clobber_d5(void);
270 void abi_test_clobber_d6(void);
271 void abi_test_clobber_d7(void);
272 void abi_test_clobber_d8(void);
273 void abi_test_clobber_d9(void);
274 void abi_test_clobber_d10(void);
275 void abi_test_clobber_d11(void);
276 void abi_test_clobber_d12(void);
277 void abi_test_clobber_d13(void);
278 void abi_test_clobber_d14(void);
279 void abi_test_clobber_d15(void);
280 } // extern "C"
281
TEST(ABITest,ARM)282 TEST(ABITest, ARM) {
283 // abi_test_trampoline hides unsaved registers from the caller, so we can
284 // safely call the abi_test_clobber_* functions below.
285 abi_test::internal::CallerState state;
286 RAND_bytes(reinterpret_cast<uint8_t *>(&state), sizeof(state));
287 CHECK_ABI_NO_UNWIND(abi_test_trampoline,
288 reinterpret_cast<crypto_word_t>(abi_test_clobber_r4),
289 &state, nullptr, 0, 0 /* no breakpoint */);
290
291 CHECK_ABI_NO_UNWIND(abi_test_clobber_r0);
292 CHECK_ABI_NO_UNWIND(abi_test_clobber_r1);
293 CHECK_ABI_NO_UNWIND(abi_test_clobber_r2);
294 CHECK_ABI_NO_UNWIND(abi_test_clobber_r3);
295 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r4),
296 "r4 was not restored after return");
297 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r5),
298 "r5 was not restored after return");
299 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r6),
300 "r6 was not restored after return");
301 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r7),
302 "r7 was not restored after return");
303 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r8),
304 "r8 was not restored after return");
305 #if defined(OPENSSL_APPLE)
306 CHECK_ABI_NO_UNWIND(abi_test_clobber_r9);
307 #else
308 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r9),
309 "r9 was not restored after return");
310 #endif
311 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r10),
312 "r10 was not restored after return");
313 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r11),
314 "r11 was not restored after return");
315 CHECK_ABI_NO_UNWIND(abi_test_clobber_r12);
316
317 CHECK_ABI_NO_UNWIND(abi_test_clobber_d0);
318 CHECK_ABI_NO_UNWIND(abi_test_clobber_d1);
319 CHECK_ABI_NO_UNWIND(abi_test_clobber_d2);
320 CHECK_ABI_NO_UNWIND(abi_test_clobber_d3);
321 CHECK_ABI_NO_UNWIND(abi_test_clobber_d4);
322 CHECK_ABI_NO_UNWIND(abi_test_clobber_d5);
323 CHECK_ABI_NO_UNWIND(abi_test_clobber_d6);
324 CHECK_ABI_NO_UNWIND(abi_test_clobber_d7);
325 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d8),
326 "d8 was not restored after return");
327 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d9),
328 "d9 was not restored after return");
329 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d10),
330 "d10 was not restored after return");
331 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d11),
332 "d11 was not restored after return");
333 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d12),
334 "d12 was not restored after return");
335 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d13),
336 "d13 was not restored after return");
337 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d14),
338 "d14 was not restored after return");
339 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d15),
340 "d15 was not restored after return");
341 }
342 #endif // OPENSSL_ARM && SUPPORTS_ABI_TEST
343
344
345 #if defined(OPENSSL_AARCH64) && defined(SUPPORTS_ABI_TEST)
346 extern "C" {
347 void abi_test_clobber_x0(void);
348 void abi_test_clobber_x1(void);
349 void abi_test_clobber_x2(void);
350 void abi_test_clobber_x3(void);
351 void abi_test_clobber_x4(void);
352 void abi_test_clobber_x5(void);
353 void abi_test_clobber_x6(void);
354 void abi_test_clobber_x7(void);
355 void abi_test_clobber_x8(void);
356 void abi_test_clobber_x9(void);
357 void abi_test_clobber_x10(void);
358 void abi_test_clobber_x11(void);
359 void abi_test_clobber_x12(void);
360 void abi_test_clobber_x13(void);
361 void abi_test_clobber_x14(void);
362 void abi_test_clobber_x15(void);
363 void abi_test_clobber_x16(void);
364 void abi_test_clobber_x17(void);
365 // x18 is the platform register and off limits.
366 void abi_test_clobber_x19(void);
367 void abi_test_clobber_x20(void);
368 void abi_test_clobber_x21(void);
369 void abi_test_clobber_x22(void);
370 void abi_test_clobber_x23(void);
371 void abi_test_clobber_x24(void);
372 void abi_test_clobber_x25(void);
373 void abi_test_clobber_x26(void);
374 void abi_test_clobber_x27(void);
375 void abi_test_clobber_x28(void);
376 void abi_test_clobber_x29(void);
377
378 void abi_test_clobber_d0(void);
379 void abi_test_clobber_d1(void);
380 void abi_test_clobber_d2(void);
381 void abi_test_clobber_d3(void);
382 void abi_test_clobber_d4(void);
383 void abi_test_clobber_d5(void);
384 void abi_test_clobber_d6(void);
385 void abi_test_clobber_d7(void);
386 void abi_test_clobber_d8(void);
387 void abi_test_clobber_d9(void);
388 void abi_test_clobber_d10(void);
389 void abi_test_clobber_d11(void);
390 void abi_test_clobber_d12(void);
391 void abi_test_clobber_d13(void);
392 void abi_test_clobber_d14(void);
393 void abi_test_clobber_d15(void);
394 void abi_test_clobber_d16(void);
395 void abi_test_clobber_d17(void);
396 void abi_test_clobber_d18(void);
397 void abi_test_clobber_d19(void);
398 void abi_test_clobber_d20(void);
399 void abi_test_clobber_d21(void);
400 void abi_test_clobber_d22(void);
401 void abi_test_clobber_d23(void);
402 void abi_test_clobber_d24(void);
403 void abi_test_clobber_d25(void);
404 void abi_test_clobber_d26(void);
405 void abi_test_clobber_d27(void);
406 void abi_test_clobber_d28(void);
407 void abi_test_clobber_d29(void);
408 void abi_test_clobber_d30(void);
409 void abi_test_clobber_d31(void);
410
411 void abi_test_clobber_v8_upper(void);
412 void abi_test_clobber_v9_upper(void);
413 void abi_test_clobber_v10_upper(void);
414 void abi_test_clobber_v11_upper(void);
415 void abi_test_clobber_v12_upper(void);
416 void abi_test_clobber_v13_upper(void);
417 void abi_test_clobber_v14_upper(void);
418 void abi_test_clobber_v15_upper(void);
419 } // extern "C"
420
TEST(ABITest,AArch64)421 TEST(ABITest, AArch64) {
422 // abi_test_trampoline hides unsaved registers from the caller, so we can
423 // safely call the abi_test_clobber_* functions below.
424 abi_test::internal::CallerState state;
425 RAND_bytes(reinterpret_cast<uint8_t *>(&state), sizeof(state));
426 CHECK_ABI_NO_UNWIND(abi_test_trampoline,
427 reinterpret_cast<crypto_word_t>(abi_test_clobber_x19),
428 &state, nullptr, 0, 0 /* no breakpoint */);
429
430 CHECK_ABI_NO_UNWIND(abi_test_clobber_x0);
431 CHECK_ABI_NO_UNWIND(abi_test_clobber_x1);
432 CHECK_ABI_NO_UNWIND(abi_test_clobber_x2);
433 CHECK_ABI_NO_UNWIND(abi_test_clobber_x3);
434 CHECK_ABI_NO_UNWIND(abi_test_clobber_x4);
435 CHECK_ABI_NO_UNWIND(abi_test_clobber_x5);
436 CHECK_ABI_NO_UNWIND(abi_test_clobber_x6);
437 CHECK_ABI_NO_UNWIND(abi_test_clobber_x7);
438 CHECK_ABI_NO_UNWIND(abi_test_clobber_x8);
439 CHECK_ABI_NO_UNWIND(abi_test_clobber_x9);
440 CHECK_ABI_NO_UNWIND(abi_test_clobber_x10);
441 CHECK_ABI_NO_UNWIND(abi_test_clobber_x11);
442 CHECK_ABI_NO_UNWIND(abi_test_clobber_x12);
443 CHECK_ABI_NO_UNWIND(abi_test_clobber_x13);
444 CHECK_ABI_NO_UNWIND(abi_test_clobber_x14);
445 CHECK_ABI_NO_UNWIND(abi_test_clobber_x15);
446 CHECK_ABI_NO_UNWIND(abi_test_clobber_x16);
447 CHECK_ABI_NO_UNWIND(abi_test_clobber_x17);
448
449 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x19),
450 "x19 was not restored after return");
451 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x20),
452 "x20 was not restored after return");
453 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x21),
454 "x21 was not restored after return");
455 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x22),
456 "x22 was not restored after return");
457 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x23),
458 "x23 was not restored after return");
459 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x24),
460 "x24 was not restored after return");
461 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x25),
462 "x25 was not restored after return");
463 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x26),
464 "x26 was not restored after return");
465 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x27),
466 "x27 was not restored after return");
467 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x28),
468 "x28 was not restored after return");
469 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x29),
470 "x29 was not restored after return");
471
472 CHECK_ABI_NO_UNWIND(abi_test_clobber_d0);
473 CHECK_ABI_NO_UNWIND(abi_test_clobber_d1);
474 CHECK_ABI_NO_UNWIND(abi_test_clobber_d2);
475 CHECK_ABI_NO_UNWIND(abi_test_clobber_d3);
476 CHECK_ABI_NO_UNWIND(abi_test_clobber_d4);
477 CHECK_ABI_NO_UNWIND(abi_test_clobber_d5);
478 CHECK_ABI_NO_UNWIND(abi_test_clobber_d6);
479 CHECK_ABI_NO_UNWIND(abi_test_clobber_d7);
480 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d8),
481 "d8 was not restored after return");
482 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d9),
483 "d9 was not restored after return");
484 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d10),
485 "d10 was not restored after return");
486 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d11),
487 "d11 was not restored after return");
488 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d12),
489 "d12 was not restored after return");
490 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d13),
491 "d13 was not restored after return");
492 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d14),
493 "d14 was not restored after return");
494 EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d15),
495 "d15 was not restored after return");
496 CHECK_ABI_NO_UNWIND(abi_test_clobber_d16);
497 CHECK_ABI_NO_UNWIND(abi_test_clobber_d18);
498 CHECK_ABI_NO_UNWIND(abi_test_clobber_d19);
499 CHECK_ABI_NO_UNWIND(abi_test_clobber_d20);
500 CHECK_ABI_NO_UNWIND(abi_test_clobber_d21);
501 CHECK_ABI_NO_UNWIND(abi_test_clobber_d22);
502 CHECK_ABI_NO_UNWIND(abi_test_clobber_d23);
503 CHECK_ABI_NO_UNWIND(abi_test_clobber_d24);
504 CHECK_ABI_NO_UNWIND(abi_test_clobber_d25);
505 CHECK_ABI_NO_UNWIND(abi_test_clobber_d26);
506 CHECK_ABI_NO_UNWIND(abi_test_clobber_d27);
507 CHECK_ABI_NO_UNWIND(abi_test_clobber_d28);
508 CHECK_ABI_NO_UNWIND(abi_test_clobber_d29);
509 CHECK_ABI_NO_UNWIND(abi_test_clobber_d30);
510 CHECK_ABI_NO_UNWIND(abi_test_clobber_d31);
511
512 // The lower halves of v8-v15 (accessed as d8-d15) must be preserved, but not
513 // the upper halves.
514 CHECK_ABI_NO_UNWIND(abi_test_clobber_v8_upper);
515 CHECK_ABI_NO_UNWIND(abi_test_clobber_v9_upper);
516 CHECK_ABI_NO_UNWIND(abi_test_clobber_v10_upper);
517 CHECK_ABI_NO_UNWIND(abi_test_clobber_v11_upper);
518 CHECK_ABI_NO_UNWIND(abi_test_clobber_v12_upper);
519 CHECK_ABI_NO_UNWIND(abi_test_clobber_v13_upper);
520 CHECK_ABI_NO_UNWIND(abi_test_clobber_v14_upper);
521 CHECK_ABI_NO_UNWIND(abi_test_clobber_v15_upper);
522 }
523 #endif // OPENSSL_AARCH64 && SUPPORTS_ABI_TEST
524