Move "used FPU status" into new non-atomic thread_info->status field.
A message that is not in the archive (sent off-list or not yet received): 20030310.105659.57012503.davem@redhat.com.suse.lists.linux.kernel
A message that is not in the archive (sent off-list or not yet received): Pine.LNX.4.44.0303101119220.2240-100000@home.transmeta.com.suse.lists.linux.kernel
Quoted 3 lines · Linus Torvalds
(Now, in _practice_ all processes on the machine tends to use the same rounding and exception control, so the "random" state wasn't actually very random, and would not lead to problems. It's a security issue, though).
Oh it does. Together with Marcus Meissner I just tracked down a 32bit emulation problem on x86-64 with Wine today. The program running in Wine would randomly crash on a flds with an floating point exception.
Turned out the 32bit ptrace unlazy FPU path shared two lines too many with with the 32bit signal FPU saving path and was resetting the used_fpu flag. Result was that the FPU state of the child could be reinitialized in some circumstances on ptrace accesses. Wine actually does use ptrace between the Wine server and the emulated process for some complicated calls. It did one unlucky ptrace and then the FPCR was at the linux defaults again - program crashed.
-Andi
From: Andi Kleen <[email protected]>
Date: 10 Mar 2003 22:01:17 +0100
Turned out the 32bit ptrace unlazy FPU path shared two lines too many with with the 32bit signal FPU saving path and was resetting the used_fpu flag. Result was that the FPU state of the child could be reinitialized in some circumstances on ptrace accesses.
So what it depended upon was the FP control register state, not the state of the individual FPU registers, across fork() right?
Quoted 8 lines · David S. Miller
Turned out the 32bit ptrace unlazy FPU path shared two lines too many with with the 32bit signal FPU saving path and was resetting the
used_fpuflag. Result was that the FPU state of the child could be reinitialized in some circumstances on ptrace accesses.So what it depended upon was the FP control register state, not the state of the individual FPU registers, across
fork()right?
Yes. The IA32 ABI says the FPU registers are clobbered in a function call. And fork is a function call. Same with the SSE registers.
Unfortunately it is much more expensive to save individual registers (SSE and x87 stack) than to just save everything using FXSAVE. FXSAVE uses lazy saving and saves only the x87 registers that are actually uses.
For SSE registers it may make sense, but then FXSAVE does that already too and you always have to handle the x87 register stack too.
I doubt it would be a good idea to not use FXSAVE on i386. The microcode can do a better job here because it has more information. In addition it also promises to handle future new Intel registers transparently.
x86-64 ABIs have similar semantics.
-Andi