Skip to content

Commit

Permalink
Add longjmp support for Thumb-2
Browse files Browse the repository at this point in the history
When a Thumb-2 kernel is being used, then longjmp must be implemented
using the Thumb-2 instruction set in module/lua/setjmp/setjmp_arm.S.

Original-patch-by: @jsrlabs
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue openzfs#9957
  • Loading branch information
behlendorf committed Feb 7, 2020
1 parent 795699a commit 8268b76
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion module/lua/setjmp/setjmp_arm.S
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,19 @@

#if defined(__arm__) && !defined(__aarch64__)

#if defined(__thumb2__)
#define _FUNC_MODE .code 16; .thumb_func
#else
#define _FUNC_MODE .code 32
#endif

#define ENTRY(x) \
.text; \
.syntax unified; \
.align 2; \
.global x; \
.type x,#function; \
.code 32; \
_FUNC_MODE; \
x:

#define END(x) \
Expand All @@ -49,13 +56,23 @@ x:
* setjump + longjmp
*/
ENTRY(setjmp)
#if defined(__thumb2__)
mov ip, sp
stmia r0, {r4-r12,r14}
#else
stmia r0, {r4-r14}
#endif
mov r0, #0x00000000
RET
END(setjmp)

ENTRY(longjmp)
#if defined(__thumb2__)
ldmia r0, {r4-r12,r14}
mov sp, ip
#else
ldmia r0, {r4-r14}
#endif
mov r0, #0x00000001
RET
END(longjmp)
Expand Down

0 comments on commit 8268b76

Please sign in to comment.