lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 19 Feb 2012 14:44:31 -0800
From:	"H. Peter Anvin" <hpa@...or.com>
To:	Linus Torvalds <torvalds@...ux-foundation.org>
CC:	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>, x86@...nel.org,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] i387: support lazy restore of FPU state

On 02/19/2012 02:37 PM, Linus Torvalds wrote:
> 
>  - on *every* task switch from task A, we write A->thread.fpu.last_cpu, 
>    whether we owned the FPU or not. And we only write a real CPU number in 
>    the case where we owned it, and the FPU save left the state untouched 
>    in the FPU.
> 
>  - so when we switch into task A next time, comparing the current CPU 
>    number with that 'last_cpu' field inarguably says "when I last switched 
>    out, I really saved it on this CPU"
> 
>    That, together with verifying that the per-cpu "fpu_owner_task" matches 
>    "task A", guarantees that the state is really valid. Because we will 
>    clear (or set to another task) fpu_owner_task if it ever gets 
>    switched to anything else.
> 
> But somebody should really validate this. Think through all the 
> kernel_fpu_begin() etc cases. I think it looks pretty obvious, and it 
> really does seem to work and improve task switching, but...
> 

I think your logic is correct but suboptimal.

What would make more sense to me is that we write last_cpu when we
*load* the state.  After all, if you didn't load the state you couldn't
have modified it.  In kernel_fpu_begin, *if* we end up flushing the
state, we should set last_cpu to -1 indicating that *no* CPU currently
owns the state -- after all, even on this CPU we would now have to
reload the state from memory.

Does that make sense?

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ