2.6.6-mm5
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 4 lines · [email protected] (Eric W. Biederman) writes:
Currently I know of a safe version that will work on x86 on processors
with sse support. And I how to generate 64bit I/O cycles with using
mmx or x87 registers, but don't know if I can write code that touches the FPU registers that is interrupt safe.
As long as you save/restore cr0 and the FPU registers and do clts interrupts are not a problem. In fact interrupts are even easier that process context, where you need preempt_disable().
-Andi
Quoted 10 lines · Andi Kleen
Quoted 4 lines · [email protected] (Eric W. Biederman) writes:
Currently I know of a safe version that will work on x86 on processors
with sse support. And I how to generate 64bit I/O cycles with using
mmx or x87 registers, but don't know if I can write code that touches the FPU registers that is interrupt safe.As long as you save/restore cr0 and the FPU registers and do clts interrupts are not a problem. In fact interrupts are even easier that process context, where you need
preempt_disable().
The saving and restoring is where things are looking icky.
It does not look like that kernel_fpu_begin() will work safely in an interrupt context.
The generic x86 variant is to do:
fild
fistp
Which works for 64bit values because the floating point registers have a 64bit mantissa.
I suppose I could unconditionally save the x87 floating point registers to a local variable, but that sounds like a terribly expensive operation. At least with kernel_fpu_begin() the floating point save only needs to happen once, per context switch.
With SSE it is easy to save just a single register. For the x87 I don't see how to do that. Beyond the stack based nature of the x87 there is the question if the registers are in mmx mode or not.
I guess a conservative always correct version would be a place to start.
Eric
Quoted 10 lines · Andi Kleen
Quoted 4 lines · [email protected] (Eric W. Biederman) writes:
Currently I know of a safe version that will work on x86 on processors
with sse support. And I how to generate 64bit I/O cycles with using
mmx or x87 registers, but don't know if I can write code that touches the FPU registers that is interrupt safe.As long as you save/restore cr0 and the FPU registers and do clts interrupts are not a problem. In fact interrupts are even easier that process context, where you need
preempt_disable().
Thinking about this some more, I would need to transform every preempt_disable() into a local_irq_disable() if I wanted to save the FP registers to their home in struct task.
It looks to me like the only way to handle all of the x87 and mmx subtleties is to call fsave which takes 108 bytes. That is a lot of stack bytes to eat in irq context, and I suspect it is time consuming, as well.
So I suspect it makes most sense just submit a patch for a sse version
of writeq on x86, and let the drivers that care use that. It does
mean that the drivers that care can't build for pre PentiumIII hardware or must use a work around in generic kernels. So far the cure for that looks much worse than the disease.
Eric