[PATCH] uml: add arch_switch_to for newly forked thread

Newly forked threads have no arch_switch_to_skas() called before their first
run, because when schedule() switches to them they're resumed in the body of
thread_wait() inside fork_handler() rather than in switch_threads() in
switch_to_skas().  Compensate this missing call.

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>
diff --git a/arch/um/sys-i386/tls.c b/arch/um/sys-i386/tls.c
index e3c5bc59..2251654 100644
--- a/arch/um/sys-i386/tls.c
+++ b/arch/um/sys-i386/tls.c
@@ -70,8 +70,6 @@
 	return -ESRCH;
 }
 
-#define O_FORCE 1
-
 static inline void clear_user_desc(struct user_desc* info)
 {
 	/* Postcondition: LDT_empty(info) returns true. */
@@ -84,6 +82,8 @@
 	info->seg_not_present = 1;
 }
 
+#define O_FORCE 1
+
 static int load_TLS(int flags, struct task_struct *to)
 {
 	int ret = 0;
@@ -162,7 +162,13 @@
  * SKAS patch. */
 int arch_switch_tls_skas(struct task_struct *from, struct task_struct *to)
 {
-	return load_TLS(O_FORCE, to);
+	/* We have no need whatsoever to switch TLS for kernel threads; beyond
+	 * that, that would also result in us calling os_set_thread_area with
+	 * userspace_pid[cpu] == 0, which gives an error. */
+	if (likely(to->mm))
+		return load_TLS(O_FORCE, to);
+
+	return 0;
 }
 
 int arch_switch_tls_tt(struct task_struct *from, struct task_struct *to)
@@ -324,3 +330,4 @@
 out:
 	return ret;
 }
+