Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3feb8856 authored by Paolo 'Blaisorblade' Giarrusso's avatar Paolo 'Blaisorblade' Giarrusso Committed by Linus Torvalds
Browse files

[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: default avatarPaolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Acked-by: default avatarJeff Dike <jdike@addtoit.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 54d8d3b5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -173,6 +173,7 @@ extern int os_fchange_dir(int fd);
extern void os_early_checks(void);
extern int can_do_skas(void);
extern void os_check_bugs(void);
extern void check_host_supports_tls(int *supports_tls, int *tls_min);

/* Make sure they are clear when running in TT mode. Required by
 * SEGV_MAYBE_FIXABLE */
+4 −0
Original line number Diff line number Diff line
@@ -25,4 +25,8 @@ typedef struct um_dup_user_desc {
typedef struct user_desc user_desc_t;

# endif /* __KERNEL__ */

#define GDT_ENTRY_TLS_MIN_I386 6
#define GDT_ENTRY_TLS_MIN_X86_64 12

#endif /* _SYSDEP_TLS_H */
+3 −0
Original line number Diff line number Diff line
@@ -8,6 +8,9 @@

#include "sysdep/ptrace.h"

/* Copied from kernel.h */
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))

#define CATCH_EINTR(expr) while ((errno = 0, ((expr) < 0)) && (errno == EINTR))

extern int mode_tt;
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
# Licensed under the GPL
#

obj-$(CONFIG_MODE_SKAS) = registers.o
obj-$(CONFIG_MODE_SKAS) = registers.o tls.o

USER_OBJS := $(obj-y)

+33 −0
Original line number Diff line number Diff line
#include <linux/unistd.h>
#include "sysdep/tls.h"
#include "user_util.h"

static _syscall1(int, get_thread_area, user_desc_t *, u_info);

/* Checks whether host supports TLS, and sets *tls_min according to the value
 * valid on the host.
 * i386 host have it == 6; x86_64 host have it == 12, for i386 emulation. */
void check_host_supports_tls(int *supports_tls, int *tls_min) {
	/* Values for x86 and x86_64.*/
	int val[] = {GDT_ENTRY_TLS_MIN_I386, GDT_ENTRY_TLS_MIN_X86_64};
	int i;

	for (i = 0; i < ARRAY_SIZE(val); i++) {
		user_desc_t info;
		info.entry_number = val[i];

		if (get_thread_area(&info) == 0) {
			*tls_min = val[i];
			*supports_tls = 1;
			return;
		} else {
			if (errno == EINVAL)
				continue;
			else if (errno == ENOSYS)
				*supports_tls = 0;
				return;
		}
	}

	*supports_tls = 0;
}
Loading