fix to work * no need to check x29 != NULL. fp may be NULL. * don't break in-use register x5.diff -r1.2 -r1.3 src/lib/libc/arch/aarch64/gen/_setjmp.S
(ryo)
--- src/lib/libc/arch/aarch64/gen/_setjmp.S 2017/11/28 09:06:25 1.2
+++ src/lib/libc/arch/aarch64/gen/_setjmp.S 2017/11/28 13:09:05 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: _setjmp.S,v 1.2 2017/11/28 09:06:25 ryo Exp $ */ | 1 | /* $NetBSD: _setjmp.S,v 1.3 2017/11/28 13:09:05 ryo Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2014 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2014 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Matt Thomas of 3am Software Foundry. | 8 | * by Matt Thomas of 3am Software Foundry. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -73,39 +73,38 @@ ENTRY(_setjmp) | @@ -73,39 +73,38 @@ ENTRY(_setjmp) | |||
73 | 73 | |||
74 | mov x0, xzr | 74 | mov x0, xzr | |
75 | ret | 75 | ret | |
76 | END(_setjmp) | 76 | END(_setjmp) | |
77 | 77 | |||
78 | ENTRY(_longjmp) | 78 | ENTRY(_longjmp) | |
79 | adrp x7, .L_MAGIC | 79 | adrp x7, .L_MAGIC | |
80 | ldr x7, [x7, #:lo12:.L_MAGIC] | 80 | ldr x7, [x7, #:lo12:.L_MAGIC] | |
81 | 81 | |||
82 | ldp x2, x3, [x0, #_JB_MAGIC] | 82 | ldp x2, x3, [x0, #_JB_MAGIC] | |
83 | ldp x4, x5, [x0, #_JB_X29] | 83 | ldp x4, x5, [x0, #_JB_X29] | |
84 | 84 | |||
85 | cbz x3, .Lbotch | 85 | cbz x3, .Lbotch | |
86 | cbz x4, .Lbotch | |||
87 | cbz x5, .Lbotch | 86 | cbz x5, .Lbotch | |
88 | cmp x2, x7 | 87 | cmp x2, x7 | |
89 | b.ne .Lbotch | 88 | b.ne .Lbotch | |
90 | 89 | |||
91 | ldp x19, x20, [x0, #_JB_X19] | 90 | ldp x19, x20, [x0, #_JB_X19] | |
92 | ldp x21, x22, [x0, #_JB_X21] | 91 | ldp x21, x22, [x0, #_JB_X21] | |
93 | ldp x23, x24, [x0, #_JB_X23] | 92 | ldp x23, x24, [x0, #_JB_X23] | |
94 | ldp x25, x26, [x0, #_JB_X25] | 93 | ldp x25, x26, [x0, #_JB_X25] | |
95 | ldp x27, x28, [x0, #_JB_X27] | 94 | ldp x27, x28, [x0, #_JB_X27] | |
96 | 95 | |||
97 | ldr x5, [x0, #_JB_TPIDR] | 96 | ldr x2, [x0, #_JB_TPIDR] | |
98 | msr tpidr_el0, x5 | 97 | msr tpidr_el0, x2 | |
99 | 98 | |||
100 | ldp d8, d9, [x0, #_JB_D8] | 99 | ldp d8, d9, [x0, #_JB_D8] | |
101 | ldp d10, d11, [x0, #_JB_D10] | 100 | ldp d10, d11, [x0, #_JB_D10] | |
102 | ldp d12, d13, [x0, #_JB_D12] | 101 | ldp d12, d13, [x0, #_JB_D12] | |
103 | ldp d14, d15, [x0, #_JB_D14] | 102 | ldp d14, d15, [x0, #_JB_D14] | |
104 | 103 | |||
105 | mov sp, x3 | 104 | mov sp, x3 | |
106 | mov x29, x4 | 105 | mov x29, x4 | |
107 | mov x30, x5 | 106 | mov x30, x5 | |
108 | 107 | |||
109 | mov x0, x1 | 108 | mov x0, x1 | |
110 | ret | 109 | ret | |
111 | 110 |
--- src/lib/libc/arch/aarch64/gen/setjmp.S 2014/08/10 05:47:36 1.1
+++ src/lib/libc/arch/aarch64/gen/setjmp.S 2017/11/28 13:09:05 1.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /*.$NetBSD: setjmp.S,v 1.1 2014/08/10 05:47:36 matt Exp $.*/ | 1 | /*.$NetBSD: setjmp.S,v 1.2 2017/11/28 13:09:05 ryo Exp $.*/ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2014 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2014 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Matt Thomas of 3am Software Foundry. | 8 | * by Matt Thomas of 3am Software Foundry. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -82,37 +82,36 @@ ENTRY(__setjmp14) | @@ -82,37 +82,36 @@ ENTRY(__setjmp14) | |||
82 | mov x0, xzr | 82 | mov x0, xzr | |
83 | ret | 83 | ret | |
84 | END(__setjmp14) | 84 | END(__setjmp14) | |
85 | 85 | |||
86 | ENTRY(__longjmp14) | 86 | ENTRY(__longjmp14) | |
87 | adrp x7, .L_MAGIC | 87 | adrp x7, .L_MAGIC | |
88 | ldr x7, [x7, #:lo12:.L_MAGIC] | 88 | ldr x7, [x7, #:lo12:.L_MAGIC] | |
89 | ldp x2, x3, [x0, #_JB_MAGIC] | 89 | ldp x2, x3, [x0, #_JB_MAGIC] | |
90 | cmp x2, x7 | 90 | cmp x2, x7 | |
91 | b.ne .Lbotch | 91 | b.ne .Lbotch | |
92 | 92 | |||
93 | ldp x4, x5, [x0, #_JB_X29] | 93 | ldp x4, x5, [x0, #_JB_X29] | |
94 | cbz x3, .Lbotch | 94 | cbz x3, .Lbotch | |
95 | cbz x4, .Lbotch | |||
96 | cbz x5, .Lbotch | 95 | cbz x5, .Lbotch | |
97 | 96 | |||
98 | ldp x19, x20, [x0, #_JB_X19] | 97 | ldp x19, x20, [x0, #_JB_X19] | |
99 | ldp x21, x22, [x0, #_JB_X21] | 98 | ldp x21, x22, [x0, #_JB_X21] | |
100 | ldp x23, x24, [x0, #_JB_X23] | 99 | ldp x23, x24, [x0, #_JB_X23] | |
101 | ldp x25, x26, [x0, #_JB_X25] | 100 | ldp x25, x26, [x0, #_JB_X25] | |
102 | ldp x27, x28, [x0, #_JB_X27] | 101 | ldp x27, x28, [x0, #_JB_X27] | |
103 | 102 | |||
104 | ldr x5, [x0, #_JB_TPIDR] | 103 | ldr x2, [x0, #_JB_TPIDR] | |
105 | msr tpidr_el0, x5 | 104 | msr tpidr_el0, x2 | |
106 | 105 | |||
107 | ldp d8, d9, [x0, #_JB_D8] | 106 | ldp d8, d9, [x0, #_JB_D8] | |
108 | ldp d10, d11, [x0, #_JB_D10] | 107 | ldp d10, d11, [x0, #_JB_D10] | |
109 | ldp d12, d13, [x0, #_JB_D12] | 108 | ldp d12, d13, [x0, #_JB_D12] | |
110 | ldp d14, d15, [x0, #_JB_D14] | 109 | ldp d14, d15, [x0, #_JB_D14] | |
111 | 110 | |||
112 | sub sp, x3, #32 | 111 | sub sp, x3, #32 | |
113 | 112 | |||
114 | stp x4, x5, [sp, #16] | 113 | stp x4, x5, [sp, #16] | |
115 | str x1, [sp, #8] | 114 | str x1, [sp, #8] | |
116 | add x29, sp, #16 | 115 | add x29, sp, #16 | |
117 | 116 | |||
118 | mov x2, #0 | 117 | mov x2, #0 |