diff options
author | Jeff Dike <jdike@addtoit.com> | 2008-02-05 01:30:44 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-05 12:44:26 -0500 |
commit | 4bdf8bc4a15d4540d71db9fa01955db5edcf89ec (patch) | |
tree | 9df4b5960104a8143b00af27ae6474145c36c0b1 /arch | |
parent | ee56314b79039b669396ee04aac3e342cd2e5a1f (diff) |
uml: borrow const.h techniques
Suggested by Geert Uytterhoeven - use const.h to get constants that are usable
in both C and assembly. I can't include it directly since this code can't
include kernel headers. const.h is also for numeric constants that can be
typed by tacking a "UL" or similar on the end. The constants here have to be
typed by casting them.
So, the relevant parts of const.h are copied here and modified in order to
allow the constants to be uncasted in assembly and casted in C.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/um/include/as-layout.h | 34 | ||||
-rw-r--r-- | arch/um/sys-i386/stub.S | 8 | ||||
-rw-r--r-- | arch/um/sys-x86_64/stub.S | 8 |
3 files changed, 29 insertions, 21 deletions
diff --git a/arch/um/include/as-layout.h b/arch/um/include/as-layout.h index a5cdf953e04a..2b859e020ac6 100644 --- a/arch/um/include/as-layout.h +++ b/arch/um/include/as-layout.h | |||
@@ -10,23 +10,31 @@ | |||
10 | #include "kern_constants.h" | 10 | #include "kern_constants.h" |
11 | 11 | ||
12 | /* | 12 | /* |
13 | * Assembly doesn't want any casting, but C does, so define these | 13 | * Stolen from linux/const.h, which can't be directly included since |
14 | * without casts here, and define new symbols with casts inside the C | 14 | * this is used in userspace code, which has no access to the kernel |
15 | * section. | 15 | * headers. Changed to be suitable for adding casts to the start, |
16 | * rather than "UL" to the end. | ||
16 | */ | 17 | */ |
17 | #define ASM_STUB_CODE (UML_CONFIG_TOP_ADDR - 2 * UM_KERN_PAGE_SIZE) | ||
18 | #define ASM_STUB_DATA (UML_CONFIG_TOP_ADDR - UM_KERN_PAGE_SIZE) | ||
19 | #define ASM_STUB_START ASM_STUB_CODE | ||
20 | 18 | ||
21 | /* | 19 | /* Some constant macros are used in both assembler and |
22 | * This file is included by the assembly stubs, which just want the | 20 | * C code. Therefore we cannot annotate them always with |
23 | * definitions above. | 21 | * 'UL' and other type specifiers unilaterally. We |
22 | * use the following macros to deal with this. | ||
24 | */ | 23 | */ |
25 | #ifndef __ASSEMBLY__ | ||
26 | 24 | ||
27 | #define STUB_CODE ((unsigned long) ASM_STUB_CODE) | 25 | #ifdef __ASSEMBLY__ |
28 | #define STUB_DATA ((unsigned long) ASM_STUB_DATA) | 26 | #define _AC(X, Y) (Y) |
29 | #define STUB_START ((unsigned long) ASM_STUB_START) | 27 | #else |
28 | #define __AC(X, Y) (X (Y)) | ||
29 | #define _AC(X, Y) __AC(X, Y) | ||
30 | #endif | ||
31 | |||
32 | #define STUB_CODE _AC((unsigned long), \ | ||
33 | UML_CONFIG_TOP_ADDR - 2 * UM_KERN_PAGE_SIZE) | ||
34 | #define STUB_DATA _AC((unsigned long), UML_CONFIG_TOP_ADDR - UM_KERN_PAGE_SIZE) | ||
35 | #define STUB_START _AC(, STUB_CODE) | ||
36 | |||
37 | #ifndef __ASSEMBLY__ | ||
30 | 38 | ||
31 | #include "sysdep/ptrace.h" | 39 | #include "sysdep/ptrace.h" |
32 | 40 | ||
diff --git a/arch/um/sys-i386/stub.S b/arch/um/sys-i386/stub.S index e730772c401b..7699e89f660f 100644 --- a/arch/um/sys-i386/stub.S +++ b/arch/um/sys-i386/stub.S | |||
@@ -7,7 +7,7 @@ | |||
7 | .globl batch_syscall_stub | 7 | .globl batch_syscall_stub |
8 | batch_syscall_stub: | 8 | batch_syscall_stub: |
9 | /* load pointer to first operation */ | 9 | /* load pointer to first operation */ |
10 | mov $(ASM_STUB_DATA+8), %esp | 10 | mov $(STUB_DATA+8), %esp |
11 | 11 | ||
12 | again: | 12 | again: |
13 | /* load length of additional data */ | 13 | /* load length of additional data */ |
@@ -15,12 +15,12 @@ again: | |||
15 | 15 | ||
16 | /* if(length == 0) : end of list */ | 16 | /* if(length == 0) : end of list */ |
17 | /* write possible 0 to header */ | 17 | /* write possible 0 to header */ |
18 | mov %eax, ASM_STUB_DATA+4 | 18 | mov %eax, STUB_DATA+4 |
19 | cmpl $0, %eax | 19 | cmpl $0, %eax |
20 | jz done | 20 | jz done |
21 | 21 | ||
22 | /* save current pointer */ | 22 | /* save current pointer */ |
23 | mov %esp, ASM_STUB_DATA+4 | 23 | mov %esp, STUB_DATA+4 |
24 | 24 | ||
25 | /* skip additional data */ | 25 | /* skip additional data */ |
26 | add %eax, %esp | 26 | add %eax, %esp |
@@ -46,7 +46,7 @@ again: | |||
46 | 46 | ||
47 | done: | 47 | done: |
48 | /* save return value */ | 48 | /* save return value */ |
49 | mov %eax, ASM_STUB_DATA | 49 | mov %eax, STUB_DATA |
50 | 50 | ||
51 | /* stop */ | 51 | /* stop */ |
52 | int3 | 52 | int3 |
diff --git a/arch/um/sys-x86_64/stub.S b/arch/um/sys-x86_64/stub.S index 4afe204a6af7..568768763155 100644 --- a/arch/um/sys-x86_64/stub.S +++ b/arch/um/sys-x86_64/stub.S | |||
@@ -8,18 +8,18 @@ syscall_stub: | |||
8 | /* We don't have 64-bit constants, so this constructs the address | 8 | /* We don't have 64-bit constants, so this constructs the address |
9 | * we need. | 9 | * we need. |
10 | */ | 10 | */ |
11 | movq $(ASM_STUB_DATA >> 32), %rbx | 11 | movq $(STUB_DATA >> 32), %rbx |
12 | salq $32, %rbx | 12 | salq $32, %rbx |
13 | movq $(ASM_STUB_DATA & 0xffffffff), %rcx | 13 | movq $(STUB_DATA & 0xffffffff), %rcx |
14 | or %rcx, %rbx | 14 | or %rcx, %rbx |
15 | movq %rax, (%rbx) | 15 | movq %rax, (%rbx) |
16 | int3 | 16 | int3 |
17 | 17 | ||
18 | .globl batch_syscall_stub | 18 | .globl batch_syscall_stub |
19 | batch_syscall_stub: | 19 | batch_syscall_stub: |
20 | mov $(ASM_STUB_DATA >> 32), %rbx | 20 | mov $(STUB_DATA >> 32), %rbx |
21 | sal $32, %rbx | 21 | sal $32, %rbx |
22 | mov $(ASM_STUB_DATA & 0xffffffff), %rax | 22 | mov $(STUB_DATA & 0xffffffff), %rax |
23 | or %rax, %rbx | 23 | or %rax, %rbx |
24 | /* load pointer to first operation */ | 24 | /* load pointer to first operation */ |
25 | mov %rbx, %rsp | 25 | mov %rbx, %rsp |