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]
Message-ID: <56A641FC.1030302@linux.intel.com>
Date:	Mon, 25 Jan 2016 07:40:44 -0800
From:	Dave Hansen <dave.hansen@...ux.intel.com>
To:	Andy Lutomirski <luto@...nel.org>, x86@...nel.org,
	linux-kernel@...r.kernel.org
Cc:	Borislav Petkov <bp@...en8.de>, Fenghua Yu <fenghua.yu@...el.com>,
	Oleg Nesterov <oleg@...hat.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Sai Praneeth Prakhya <sai.praneeth.prakhya@...el.com>,
	yu-cheng yu <yu-cheng.yu@...el.com>,
	Rik van Riel <riel@...hat.com>,
	Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH v2 2/5] x86/fpu: Fix FNSAVE usage in eagerfpu mode

On 01/24/2016 02:38 PM, Andy Lutomirski wrote:
>  	if (fpu->fpregs_active) {
> +		/*
> +		 * Ignore return value -- we don't care if reg state
> +		 * is clobbered.
> +		 */
>  		copy_fpregs_to_fpstate(fpu);
>  	} else {
>  		this_cpu_write(fpu_fpregs_owner_ctx, NULL);
> @@ -189,8 +193,12 @@ void fpu__save(struct fpu *fpu)
>  
>  	preempt_disable();
>  	if (fpu->fpregs_active) {
> -		if (!copy_fpregs_to_fpstate(fpu))
> -			fpregs_deactivate(fpu);
> +		if (!copy_fpregs_to_fpstate(fpu)) {
> +			if (use_eager_fpu())
> +				copy_kernel_to_fpregs(&fpu->state);
> +			else
> +				fpregs_deactivate(fpu);
> +		}
>  	}
>  	preempt_enable();

I wonder if we should just make the

> +			if (use_eager_fpu())
> +				copy_kernel_to_fpregs(&fpu->state);
> +			else
> +				fpregs_deactivate(fpu);

behavior the default _inside_ copy_fpregs_to_fpstate(fpu).  We evidently
got it wrong in 2/3 of the call sites that needed it.  It ends up being
an optimization for FNSAVE (because it allows us to avoid an FRSTOR),
but we only take advantage of that in cases of kernel_fpu_begin/end().

FXSAVE has been around since at _least_ 1999, and I'd expect it to get
used in place of FNSAVE everywhere that it is available.

If we don't want to do that, maybe we should add a "clobber" argument to
copy_fpregs_to_fpstate() for when it's allowed to clobber the register
state.

I just hate putting this logic at all the call sites.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ