aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/os-Linux/registers.c
diff options
context:
space:
mode:
authorIngo van Lil <inguin@gmx.de>2011-09-14 16:21:23 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2011-09-14 18:09:37 -0700
commitfbfe9c847edf57ac8232aeafb290f272289893a3 (patch)
treeda25f3f4ece74b9fa328ce3884f19ff18eff516d /arch/um/os-Linux/registers.c
parentum: drivers/xterm.c: fix a file descriptor leak (diff)
downloadlinux-dev-fbfe9c847edf57ac8232aeafb290f272289893a3.tar.xz
linux-dev-fbfe9c847edf57ac8232aeafb290f272289893a3.zip
um: Save FPU registers between task switches
Some time ago Jeff prepared 42daba316557 ("uml: stop saving process FP state") for UML to stop saving the process FP state between task switches. The assumption was that since with SKAS0 every guest process runs inside a host process context the host OS will take care of keeping the proper FP state. Unfortunately this is not true for multi-threaded applications, where all guest threads share a single host process context yet all may use the FPU on their own. Although I haven't verified it I suspect things to be even worse in SKAS3 mode where all guest processes run inside a single host process. The patch reintroduces the saving and restoring of the FP context between task switches. [richard@nod.at: Ingo posted this patch in 2009, sadly it was never applied and got lost. Now in 2011 the problem was reported by Gunnar.] Signed-off-by: Ingo van Lil <inguin@gmx.de> Signed-off-by: Richard Weinberger <richard@nod.at> Reported-by: <gunnarlindroth@hotmail.com> Tested-by: <gunnarlindroth@hotmail.com> Cc: Stanislav Meduna <stano@meduna.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/os-Linux/registers.c')
-rw-r--r--arch/um/os-Linux/registers.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/arch/um/os-Linux/registers.c b/arch/um/os-Linux/registers.c
index 830fe6a1518a..b866b9e3bef9 100644
--- a/arch/um/os-Linux/registers.c
+++ b/arch/um/os-Linux/registers.c
@@ -8,6 +8,8 @@
#include <string.h>
#include <sys/ptrace.h>
#include "sysdep/ptrace.h"
+#include "sysdep/ptrace_user.h"
+#include "registers.h"
int save_registers(int pid, struct uml_pt_regs *regs)
{
@@ -32,6 +34,7 @@ int restore_registers(int pid, struct uml_pt_regs *regs)
/* This is set once at boot time and not changed thereafter */
static unsigned long exec_regs[MAX_REG_NR];
+static unsigned long exec_fp_regs[FP_SIZE];
int init_registers(int pid)
{
@@ -42,10 +45,14 @@ int init_registers(int pid)
return -errno;
arch_init_registers(pid);
+ get_fp_registers(pid, exec_fp_regs);
return 0;
}
-void get_safe_registers(unsigned long *regs)
+void get_safe_registers(unsigned long *regs, unsigned long *fp_regs)
{
memcpy(regs, exec_regs, sizeof(exec_regs));
+
+ if (fp_regs)
+ memcpy(fp_regs, exec_fp_regs, sizeof(exec_fp_regs));
}