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:	Sat, 4 Apr 2015 12:11:55 +0200
From:	Quentin Casasnovas <quentin.casasnovas@...cle.com>
To:	Borislav Petkov <bp@...en8.de>
Cc:	Quentin Casasnovas <quentin.casasnovas@...cle.com>,
	X86 ML <x86@...nel.org>, LKML <linux-kernel@...r.kernel.org>,
	"H. Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...nel.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Oleg Nesterov <oleg@...hat.com>,
	Andy Lutomirski <luto@...capital.net>
Subject: Re: [PATCH] x86/xsave: Robustify and merge macros

On Sat, Apr 04, 2015 at 11:25:36AM +0200, Borislav Petkov wrote:
> On Sat, Apr 04, 2015 at 10:36:11AM +0200, Quentin Casasnovas wrote:
> > Since all of these are compile time constants, could we not use the safe
> > variant on that same page?  Not that I'm too worried about the signed right
> > shift but heh that would be portable and should not impact performance
> > anyway, so no added value in using the optimized version is there?
> 
> Seems to work with the experimental diff below. I need to do
> 
> 	-(-(x < y))
> 
> with the last term though as we're working with s32s.
> 
> ---
> diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
> index 44a1fc5439d3..2cb6da2716bf 100644
> --- a/arch/x86/include/asm/alternative-asm.h
> +++ b/arch/x86/include/asm/alternative-asm.h
> @@ -53,14 +53,14 @@
>   * Shamelessly stolen and adapted from:
>   * http://graphics.stanford.edu/~seander/bithacks.html#IntegerMinOrMax
>   */
> -#define alt_max_short(a,b)	(((a) - (((a) - (b)) & (((a) - (b)) >> 15))) & 0xffff)
> +#define alt_max_short(a, b)	((a) ^ (((a) ^ (b)) & -(-((a) < (b)))))
>

So I'm not claiming I've spent the time to fully understand this macro but
it looks like it's doing the right thing on my dummy tests:

  http://pastebin.com/DDhtZQgX

Did you also change it in the alternative.h file BTW?

>  .macro ALTERNATIVE_2 oldinstr, newinstr1, feature1, newinstr2, feature2
>  140:
>  	\oldinstr
>  141:
> -	.skip -((alt_max_short(new_len1, new_len2) - old_len) > 0) * \
> -		(alt_max_short(new_len1, new_len2) - old_len),0x90
> +	.skip -((alt_max_short(new_len1, new_len2) - (old_len)) > 0) * \
> +		(alt_max_short(new_len1, new_len2) - (old_len)),0x90
>  142:

Good catch for the missing parenthesis!

> > 
> > Looks good to me and I find it much easier to understand here :)
> > 
> 
> Cool. Please give it more critical staring as we're under time pressure
> here.
> 

So I _think_ it's OK but it would be re-assuring if somebody else could
have a look as well just in case.. :)

Do you have a cleaned up version of the patch you're planning to apply on
top of tip/master instead of just snippets?  This way we can hammer it with
different calls to ALTERNATIVE_2 and alternative_2 to check it's good?
I'll have to leave soonish though..

Quentin
--
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