diff options
author | Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> | 2006-03-31 05:30:25 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-31 15:18:52 -0500 |
commit | 3feb88562d149f078319e5a1b2f7acaa10251a5c (patch) | |
tree | 73fb00f0ecb9ed0c4cf8eec24c84253ce9620464 /arch/um/os-Linux/sys-i386 | |
parent | 54d8d3b5a0ce1cdbad1d3154c9ea9732d394e9c7 (diff) |
[PATCH] uml: check for differences in host support
If running on a host not supporting TLS (for instance 2.4) we should report
that cleanly to the user, instead of printing not comprehensible "error 5" for
that.
Additionally, i386 and x86_64 support different ranges for
user_desc->entry_number, and we must account for that; we couldn't pass
ourselves -1 because we need to override previously existing TLS descriptors
which glibc has possibly set, so test at startup the range to use.
x86 and x86_64 existing ranges are hardcoded.
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Acked-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/os-Linux/sys-i386')
-rw-r--r-- | arch/um/os-Linux/sys-i386/Makefile | 2 | ||||
-rw-r--r-- | arch/um/os-Linux/sys-i386/tls.c | 33 |
2 files changed, 34 insertions, 1 deletions
diff --git a/arch/um/os-Linux/sys-i386/Makefile b/arch/um/os-Linux/sys-i386/Makefile index 340ef26f5944..b3213613c41c 100644 --- a/arch/um/os-Linux/sys-i386/Makefile +++ b/arch/um/os-Linux/sys-i386/Makefile | |||
@@ -3,7 +3,7 @@ | |||
3 | # Licensed under the GPL | 3 | # Licensed under the GPL |
4 | # | 4 | # |
5 | 5 | ||
6 | obj-$(CONFIG_MODE_SKAS) = registers.o | 6 | obj-$(CONFIG_MODE_SKAS) = registers.o tls.o |
7 | 7 | ||
8 | USER_OBJS := $(obj-y) | 8 | USER_OBJS := $(obj-y) |
9 | 9 | ||
diff --git a/arch/um/os-Linux/sys-i386/tls.c b/arch/um/os-Linux/sys-i386/tls.c new file mode 100644 index 000000000000..ba21f0e04a2f --- /dev/null +++ b/arch/um/os-Linux/sys-i386/tls.c | |||
@@ -0,0 +1,33 @@ | |||
1 | #include <linux/unistd.h> | ||
2 | #include "sysdep/tls.h" | ||
3 | #include "user_util.h" | ||
4 | |||
5 | static _syscall1(int, get_thread_area, user_desc_t *, u_info); | ||
6 | |||
7 | /* Checks whether host supports TLS, and sets *tls_min according to the value | ||
8 | * valid on the host. | ||
9 | * i386 host have it == 6; x86_64 host have it == 12, for i386 emulation. */ | ||
10 | void check_host_supports_tls(int *supports_tls, int *tls_min) { | ||
11 | /* Values for x86 and x86_64.*/ | ||
12 | int val[] = {GDT_ENTRY_TLS_MIN_I386, GDT_ENTRY_TLS_MIN_X86_64}; | ||
13 | int i; | ||
14 | |||
15 | for (i = 0; i < ARRAY_SIZE(val); i++) { | ||
16 | user_desc_t info; | ||
17 | info.entry_number = val[i]; | ||
18 | |||
19 | if (get_thread_area(&info) == 0) { | ||
20 | *tls_min = val[i]; | ||
21 | *supports_tls = 1; | ||
22 | return; | ||
23 | } else { | ||
24 | if (errno == EINVAL) | ||
25 | continue; | ||
26 | else if (errno == ENOSYS) | ||
27 | *supports_tls = 0; | ||
28 | return; | ||
29 | } | ||
30 | } | ||
31 | |||
32 | *supports_tls = 0; | ||
33 | } | ||