-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PATCH] uml: Use klibc setjmp/longjmp
This patch adds an implementation of setjmp and longjmp to UML, allowing access to the inside of a jmpbuf without needing the access macros formerly provided by libc. The implementation is stolen from klibc. I copy the relevant files into arch/um. I have another patch which avoids the copying, but requires klibc be in the tree. setjmp and longjmp users required some tweaking. Includes of <setjmp.h> were removed and includes of the UML longjmp.h were added where necessary. There are also replacements of siglongjmp with UML_LONGJMP which I somehow missed earlier. Signed-off-by: Jeff Dike <jdike@addtoit.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
- Loading branch information
Jeff Dike
authored and
Linus Torvalds
committed
Sep 26, 2006
1 parent
c5c6ba4
commit 13c06be
Showing
14 changed files
with
173 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* arch/i386/include/klibc/archsetjmp.h | ||
*/ | ||
|
||
#ifndef _KLIBC_ARCHSETJMP_H | ||
#define _KLIBC_ARCHSETJMP_H | ||
|
||
struct __jmp_buf { | ||
unsigned int __ebx; | ||
unsigned int __esp; | ||
unsigned int __ebp; | ||
unsigned int __esi; | ||
unsigned int __edi; | ||
unsigned int __eip; | ||
}; | ||
|
||
typedef struct __jmp_buf jmp_buf[1]; | ||
|
||
#endif /* _SETJMP_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* arch/x86_64/include/klibc/archsetjmp.h | ||
*/ | ||
|
||
#ifndef _KLIBC_ARCHSETJMP_H | ||
#define _KLIBC_ARCHSETJMP_H | ||
|
||
struct __jmp_buf { | ||
unsigned long __rbx; | ||
unsigned long __rsp; | ||
unsigned long __rbp; | ||
unsigned long __r12; | ||
unsigned long __r13; | ||
unsigned long __r14; | ||
unsigned long __r15; | ||
unsigned long __rip; | ||
}; | ||
|
||
typedef struct __jmp_buf jmp_buf[1]; | ||
|
||
#endif /* _SETJMP_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# | ||
# arch/i386/setjmp.S | ||
# | ||
# setjmp/longjmp for the i386 architecture | ||
# | ||
|
||
# | ||
# The jmp_buf is assumed to contain the following, in order: | ||
# %ebx | ||
# %esp | ||
# %ebp | ||
# %esi | ||
# %edi | ||
# <return address> | ||
# | ||
|
||
.text | ||
.align 4 | ||
.globl setjmp | ||
.type setjmp, @function | ||
setjmp: | ||
#ifdef _REGPARM | ||
movl %eax,%edx | ||
#else | ||
movl 4(%esp),%edx | ||
#endif | ||
popl %ecx # Return address, and adjust the stack | ||
xorl %eax,%eax # Return value | ||
movl %ebx,(%edx) | ||
movl %esp,4(%edx) # Post-return %esp! | ||
pushl %ecx # Make the call/return stack happy | ||
movl %ebp,8(%edx) | ||
movl %esi,12(%edx) | ||
movl %edi,16(%edx) | ||
movl %ecx,20(%edx) # Return address | ||
ret | ||
|
||
.size setjmp,.-setjmp | ||
|
||
.text | ||
.align 4 | ||
.globl longjmp | ||
.type longjmp, @function | ||
longjmp: | ||
#ifdef _REGPARM | ||
xchgl %eax,%edx | ||
#else | ||
movl 4(%esp),%edx # jmp_ptr address | ||
movl 8(%esp),%eax # Return value | ||
#endif | ||
movl (%edx),%ebx | ||
movl 4(%edx),%esp | ||
movl 8(%edx),%ebp | ||
movl 12(%edx),%esi | ||
movl 16(%edx),%edi | ||
jmp *20(%edx) | ||
|
||
.size longjmp,.-longjmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# | ||
# arch/x86_64/setjmp.S | ||
# | ||
# setjmp/longjmp for the x86-64 architecture | ||
# | ||
|
||
# | ||
# The jmp_buf is assumed to contain the following, in order: | ||
# %rbx | ||
# %rsp (post-return) | ||
# %rbp | ||
# %r12 | ||
# %r13 | ||
# %r14 | ||
# %r15 | ||
# <return address> | ||
# | ||
|
||
.text | ||
.align 4 | ||
.globl setjmp | ||
.type setjmp, @function | ||
setjmp: | ||
pop %rsi # Return address, and adjust the stack | ||
xorl %eax,%eax # Return value | ||
movq %rbx,(%rdi) | ||
movq %rsp,8(%rdi) # Post-return %rsp! | ||
push %rsi # Make the call/return stack happy | ||
movq %rbp,16(%rdi) | ||
movq %r12,24(%rdi) | ||
movq %r13,32(%rdi) | ||
movq %r14,40(%rdi) | ||
movq %r15,48(%rdi) | ||
movq %rsi,56(%rdi) # Return address | ||
ret | ||
|
||
.size setjmp,.-setjmp | ||
|
||
.text | ||
.align 4 | ||
.globl longjmp | ||
.type longjmp, @function | ||
longjmp: | ||
movl %esi,%eax # Return value (int) | ||
movq (%rdi),%rbx | ||
movq 8(%rdi),%rsp | ||
movq 16(%rdi),%rbp | ||
movq 24(%rdi),%r12 | ||
movq 32(%rdi),%r13 | ||
movq 40(%rdi),%r14 | ||
movq 48(%rdi),%r15 | ||
jmp *56(%rdi) | ||
|
||
.size longjmp,.-longjmp |