xref: /linux/arch/x86/um/setjmp_64.S (revision 03ab8e6297acd1bc0eedaa050e2a1635c576fd11)
1b2441318SGreg Kroah-Hartman/* SPDX-License-Identifier: GPL-2.0 */
25c48b108SAl Viro#
35c48b108SAl Viro# arch/x86_64/setjmp.S
45c48b108SAl Viro#
55c48b108SAl Viro# setjmp/longjmp for the x86-64 architecture
65c48b108SAl Viro#
75c48b108SAl Viro
85c48b108SAl Viro#
95c48b108SAl Viro# The jmp_buf is assumed to contain the following, in order:
105c48b108SAl Viro#	%rbx
115c48b108SAl Viro#	%rsp (post-return)
125c48b108SAl Viro#	%rbp
135c48b108SAl Viro#	%r12
145c48b108SAl Viro#	%r13
155c48b108SAl Viro#	%r14
165c48b108SAl Viro#	%r15
175c48b108SAl Viro#	<return address>
185c48b108SAl Viro#
195c48b108SAl Viro
205c48b108SAl Viro	.text
215c48b108SAl Viro	.align 4
22f44f1e7dSFlorian Fainelli	.globl kernel_setjmp
23f44f1e7dSFlorian Fainelli	.type kernel_setjmp, @function
24f44f1e7dSFlorian Fainellikernel_setjmp:
255c48b108SAl Viro	pop  %rsi			# Return address, and adjust the stack
265c48b108SAl Viro	xorl %eax,%eax			# Return value
275c48b108SAl Viro	movq %rbx,(%rdi)
285c48b108SAl Viro	movq %rsp,8(%rdi)		# Post-return %rsp!
295c48b108SAl Viro	push %rsi			# Make the call/return stack happy
305c48b108SAl Viro	movq %rbp,16(%rdi)
315c48b108SAl Viro	movq %r12,24(%rdi)
325c48b108SAl Viro	movq %r13,32(%rdi)
335c48b108SAl Viro	movq %r14,40(%rdi)
345c48b108SAl Viro	movq %r15,48(%rdi)
355c48b108SAl Viro	movq %rsi,56(%rdi)		# Return address
36*f94909ceSPeter Zijlstra	RET
375c48b108SAl Viro
38f44f1e7dSFlorian Fainelli	.size kernel_setjmp,.-kernel_setjmp
395c48b108SAl Viro
405c48b108SAl Viro	.text
415c48b108SAl Viro	.align 4
42f44f1e7dSFlorian Fainelli	.globl kernel_longjmp
43f44f1e7dSFlorian Fainelli	.type kernel_longjmp, @function
44f44f1e7dSFlorian Fainellikernel_longjmp:
455c48b108SAl Viro	movl %esi,%eax			# Return value (int)
465c48b108SAl Viro	movq (%rdi),%rbx
475c48b108SAl Viro	movq 8(%rdi),%rsp
485c48b108SAl Viro	movq 16(%rdi),%rbp
495c48b108SAl Viro	movq 24(%rdi),%r12
505c48b108SAl Viro	movq 32(%rdi),%r13
515c48b108SAl Viro	movq 40(%rdi),%r14
525c48b108SAl Viro	movq 48(%rdi),%r15
535c48b108SAl Viro	jmp *56(%rdi)
545c48b108SAl Viro
55f44f1e7dSFlorian Fainelli	.size kernel_longjmp,.-kernel_longjmp
56