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:	Wed, 6 Apr 2016 11:37:37 +0100
From:	One Thousand Gnomes <gnomes@...rguk.ukuu.org.uk>
To:	Borislav Petkov <bp@...e.de>
Cc:	zengzhaoxiu@....com, tglx@...utronix.de, mingo@...hat.com,
	hpa@...or.com, dvlasenk@...hat.com, akpm@...ux-foundation.org,
	dvyukov@...gle.com, keescook@...omium.org,
	linux-kernel@...r.kernel.org, Zhaoxiu Zeng <zhaoxiu.zeng@...il.com>
Subject: Re: [PATCH v2 10/30] Add x86-specific parity functions

On Wed, 6 Apr 2016 12:13:00 +0200
Borislav Petkov <bp@...e.de> wrote:

> On Wed, Apr 06, 2016 at 05:14:45PM +0800, zengzhaoxiu@....com wrote:
> > From: Zhaoxiu Zeng <zhaoxiu.zeng@...il.com>
> > 
> > Use alternatives, lifted from arch_hweight
> > 
> > Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@...il.com>
> > ---
> >  arch/x86/include/asm/arch_hweight.h |   5 ++
> >  arch/x86/include/asm/arch_parity.h  | 102 ++++++++++++++++++++++++++++++++++++
> >  arch/x86/include/asm/bitops.h       |   4 +-
> >  arch/x86/lib/Makefile               |   8 +++
> >  arch/x86/lib/parity.c               |  32 ++++++++++++
> >  5 files changed, 150 insertions(+), 1 deletion(-)
> >  create mode 100644 arch/x86/include/asm/arch_parity.h
> >  create mode 100644 arch/x86/lib/parity.c  
> 
> ...
> 
> > +static __always_inline unsigned int __arch_parity32(unsigned int w)
> > +{
> > +	unsigned int res;
> > +
> > +	asm(ALTERNATIVE("call __sw_parity32", POPCNT32 "; and $1, %0", X86_FEATURE_POPCNT)
> > +		: "="REG_OUT (res)
> > +		: REG_IN (w)
> > +		: "cc");  
> 
> So why all that churn instead of simply doing:
> 
> static __always_inline unsigned int __arch_parity32(unsigned int w)
> {
> 	return hweight32(w) & 1;
> }
> 
> Ditto for the 64-bit version.

Even that would still be wrong for the smaller parity values. The CPU
supports 8bit parity directly going back to the 8086 so the
implementation for 8bit and I think 16bit is still wrong.

Alan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ