Re: [PATCH 2/2] i387: split up <asm/i387.h> into exported andinternal interfaces

From: Linus Torvalds
Date: Tue Feb 28 2012 - 14:26:36 EST


On Tue, Feb 28, 2012 at 11:06 AM, Avi Kivity <avi@xxxxxxxxxx> wrote:
>
> No, the scheduler saves the state into task_struct.  I need it saved
> into the vcpu structure.  We have two fpu states, the user state, and
> the guest state.  APIs that take a task_struct as a parameter, or
> reference current implicitly, aren't going to work.

As far as I can tell, you should do the saving into the vcpu structure
when you actually switch the thing around.

In fact, you can do it these days by just playing around with the
"tsk->thread.fpu.state" pointer, I guess.

But it all boils down to the fact that your code is not just ugly,
it's *buggy*. If you play around with setting TS, you *will* be hit by
interrupts etc that will start to use the FP code that you "don't
use".

And there is no excuse for you touching the host TS. The kernel does
that for you, and does it better. And caches the end result in
TS_USEDFPU (old) or in some variable that you shouldn't look at but
can access with the user_has_fpu() helpers.

Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/