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:   Thu, 21 Jun 2018 09:39:28 +0800
From:   Yisheng Xie <xieyisheng1@...wei.com>
To:     Andy Shevchenko <andy.shevchenko@...il.com>
CC:     Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        "David S. Miller" <davem@...emloft.net>,
        Anthony Yznaga <anthony.yznaga@...cle.com>,
        Pavel Tatashin <pasha.tatashin@...cle.com>,
        <sparclinux@...r.kernel.org>,
        Kefeng Wang <wangkefeng.wang@...wei.com>
Subject: [PATCH v4 21/21] sparc64: use match_string() helper

match_string() returns the index of an array for a matching string,
which can be used instead of open coded variant.

As Andy's suggestion, this patch add string literal instead of NULL
for crypto in array of hwcaps and make an additional condition after
match_string() in all users of it.

Cc: "David S. Miller" <davem@...emloft.net>
Cc: Anthony Yznaga <anthony.yznaga@...cle.com>
Cc: Pavel Tatashin <pasha.tatashin@...cle.com>
Cc: sparclinux@...r.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@...wei.com>
---
 arch/sparc/kernel/setup_64.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/arch/sparc/kernel/setup_64.c b/arch/sparc/kernel/setup_64.c
index 7944b3c..6fa0c78 100644
--- a/arch/sparc/kernel/setup_64.c
+++ b/arch/sparc/kernel/setup_64.c
@@ -401,8 +401,7 @@ void __init start_early_boot(void)
 	 */
 	"mul32", "div32", "fsmuld", "v8plus", "popc", "vis", "vis2",
 	"ASIBlkInit", "fmaf", "vis3", "hpc", "random", "trans", "fjfmau",
-	"ima", "cspare", "pause", "cbcond", NULL /*reserved for crypto */,
-	"adp",
+	"ima", "cspare", "pause", "cbcond", "crypto", "adp",
 };

 static const char *crypto_hwcaps[] = {
@@ -418,7 +417,7 @@ void cpucap_info(struct seq_file *m)
 	seq_puts(m, "cpucaps\t\t: ");
 	for (i = 0; i < ARRAY_SIZE(hwcaps); i++) {
 		unsigned long bit = 1UL << i;
-		if (hwcaps[i] && (caps & bit)) {
+		if ((caps & bit) && bit != HWCAP_SPARC_CRYPTO) {
 			seq_printf(m, "%s%s",
 				   printed ? "," : "", hwcaps[i]);
 			printed++;
@@ -472,7 +471,7 @@ static void __init report_hwcaps(unsigned long caps)

 	for (i = 0; i < ARRAY_SIZE(hwcaps); i++) {
 		unsigned long bit = 1UL << i;
-		if (hwcaps[i] && (caps & bit))
+		if ((caps & bit) && bit != HWCAP_SPARC_CRYPTO)
 			report_one_hwcap(&printed, hwcaps[i]);
 	}
 	if (caps & HWCAP_SPARC_CRYPTO)
@@ -504,18 +503,13 @@ static unsigned long __init mdesc_cpu_hwcap_list(void)
 	while (len) {
 		int i, plen;

-		for (i = 0; i < ARRAY_SIZE(hwcaps); i++) {
-			unsigned long bit = 1UL << i;
+		i = match_string(hwcaps, ARRAY_SIZE(hwcaps), prop);
+		if (i >= 0)
+			caps |= 1UL << i;

-			if (hwcaps[i] && !strcmp(prop, hwcaps[i])) {
-				caps |= bit;
-				break;
-			}
-		}
-		for (i = 0; i < ARRAY_SIZE(crypto_hwcaps); i++) {
-			if (!strcmp(prop, crypto_hwcaps[i]))
-				caps |= HWCAP_SPARC_CRYPTO;
-		}
+		i = match_string(crypto_hwcaps, ARRAY_SIZE(crypto_hwcaps), prop);
+		if (i >= 0)
+			caps |= HWCAP_SPARC_CRYPTO;

 		plen = strlen(prop) + 1;
 		prop += plen;
-- 
1.7.12.4


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ