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: <20160327124401.GA7407@ravnborg.org>
Date:	Sun, 27 Mar 2016 14:44:01 +0200
From:	Sam Ravnborg <sam@...nborg.org>
To:	"zhaoxiu.zeng" <zhaoxiu.zeng@...il.com>
Cc:	Denys Vlasenko <dvlasenk@...hat.com>,
	Arnd Bergmann <arnd@...db.de>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Martin Kepplinger <martink@...teo.de>,
	Sasha Levin <sasha.levin@...cle.com>,
	Ingo Molnar <mingo@...nel.org>,
	Yury Norov <yury.norov@...il.com>,
	linux-kernel@...r.kernel.org, linux-arch@...r.kernel.org
Subject: Re: [PATCH 01/31] bitops: add parity functions

Hi Zeng.

Looking through the arch specific implementations of __arch_parity().
Some architectures uses #defines, other uses inline static functions.

Any particular reason that you select one approach over the other
in the different cases?

ia64:
+#define __arch_parity32(x) ((unsigned int) __arch_parity64((x) & 0xfffffffful))
+#define __arch_parity16(x) ((unsigned int) __arch_parity64((x) & 0xfffful))
+#define __arch_parity8(x)  ((unsigned int) __arch_parity64((x) & 0xfful))
+#define __arch_parity4(x)  ((unsigned int) __arch_parity64((x) & 0xful))

tile:
+static inline unsigned int __arch_parity32(unsigned int w)
+{
+	return __builtin_popcount(w) & 1;
+}
+
+static inline unsigned int __arch_parity16(unsigned int w)
+{
+	return __arch_parity32(w & 0xffff);
+}
+
+static inline unsigned int __arch_parity8(unsigned int w)
+{
+	return __arch_parity32(w & 0xff);
+}
+
+static inline unsigned int __arch_parity4(unsigned int w)
+{
+	return __arch_parity32(w & 0xf);
+}

Just two examples.

Adding the parity helpers seems like veny nice simplifications.

A few comments to some of those I looked at.
(I am not subscribed to lkml, so you get it as comments here)

[PATCH 21/31] mtd: use parity16 in ssfdc.c
The original code semes to check that the parity equals the
value of first bit in the address.
This seems lost after the conversion.

[PATCH 20/31] scsi: use parity32 in isci/phy.c
+	if (parity32(phy_cap.all))
 		phy_cap.parity = 1;
Could be written like this - simpler IMO:
	phy_cap.parity = parity32(phy_cap.all);


	Sam

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ