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] [day] [month] [year] [list]
Date:	Mon, 8 Aug 2016 21:17:01 +0200
From:	Borislav Petkov <bp@...en8.de>
To:	Jiri Kosina <jikos@...nel.org>
Cc:	Peter Zijlstra <peterz@...radead.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Ville Syrj??l?? <ville.syrjala@...ux.intel.com>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	the arch/x86 maintainers <x86@...nel.org>,
	Borislav Petkov <bp@...e.de>,
	"H . Peter Anvin" <hpa@...or.com>,
	Andy Lutomirski <luto@...capital.net>,
	Brian Gerst <brgerst@...il.com>,
	Denys Vlasenko <dvlasenk@...hat.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...nel.org>
Subject: Re: [PATCH] x86/hweight: Don't clobber %rdi

On Mon, Aug 08, 2016 at 08:53:16PM +0200, Jiri Kosina wrote:
> Ville's patch is the proper thing to do; I still think the comments 
> probably should be removed as they might provide more confusion than help, 
> but that's a separate discussion.

Right, so while trying to debug this with a pen and paper, I found that
adding a subsript to the w variable makes it more understandable. I.e.,
something like this:

	w_1 -= (w >> 1) & 0x55555555;
	w_2 =  (w_1 & 0x33333333) + ((w_1 >> 2) & 0x33333333);

and then you'd have

	movl %eax, %edx				# w
	shrl %edx				# w >>= 1
	andl $0x55555555, %edx			# (w >> 1) & 0x55555555
	subl %edx, %eax				# w_1 = w - ...

	movl %eax, %edx				# w_1
	shrl $2, %eax				# w_1 >>= 2
	andl $0x33333333, %edx			# (w_1 >> 2) & 0x33333333
	andl $0x33333333, %eax			# w_1 &= 0x33333333
	addl %edx, %eax				# w_2 = ... + ...

...

Anyway, something like that. I find that more readable TBH.

Thanks and thanks for confirming Ville's patch fixes it on your box.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ