[PATCH 2/2] hwfeatures: add 'all' for disabling all hardware features

Jussi Kivilinna jussi.kivilinna at iki.fi
Mon Dec 5 15:14:58 CET 2016


* .gitignore: Add 'tests/basic-disable-all-hwf'.
* configure.ac: Ditto.
* tests/Makefile.am: Ditto.
* src/hwfeatures.c (_gcry_disable_hw_feature): Match 'all' for
masking all HW features off.
* tests/basic-disable-all-hwf.in: New.
--

Also add new test to run 'basic' with all HWF disable. With current
assembly implementations and build servers using new CPUs, generic
implementations are not being tested enough anymore and compiler
problems might end up unnoticed.

Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
 .gitignore                     |    1 +
 configure.ac                   |    1 +
 src/hwfeatures.c               |   16 +++++++---------
 tests/Makefile.am              |    7 ++++---
 tests/basic-disable-all-hwf.in |    4 ++++
 5 files changed, 17 insertions(+), 12 deletions(-)
 create mode 100644 tests/basic-disable-all-hwf.in

diff --git a/.gitignore b/.gitignore
index 3cd83a2..5d481aa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -73,6 +73,7 @@ tests/ac-data
 tests/ac-schemes
 tests/aeswrap
 tests/basic
+tests/basic-disable-all-hwf
 tests/bench-slope
 tests/benchmark
 tests/curves
diff --git a/configure.ac b/configure.ac
index 7bbf4bd..998264c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2555,6 +2555,7 @@ src/versioninfo.rc
 tests/Makefile
 ])
 AC_CONFIG_FILES([tests/hashtest-256g], [chmod +x tests/hashtest-256g])
+AC_CONFIG_FILES([tests/basic-disable-all-hwf], [chmod +x tests/basic-disable-all-hwf])
 AC_OUTPUT
 
 
diff --git a/src/hwfeatures.c b/src/hwfeatures.c
index 07221e8..99aba34 100644
--- a/src/hwfeatures.c
+++ b/src/hwfeatures.c
@@ -83,6 +83,12 @@ _gcry_disable_hw_feature (const char *name)
 {
   int i;
 
+  if (!strcmp(name, "all"))
+    {
+      disabled_hw_features = ~0;
+      return 0;
+    }
+
   for (i=0; i < DIM (hwflist); i++)
     if (!strcmp (hwflist[i].desc, name))
       {
@@ -159,15 +165,7 @@ parse_hwf_deny_file (void)
       if (!*p || *p == '#')
         continue;
 
-      for (i=0; i < DIM (hwflist); i++)
-        {
-          if (!strcmp (hwflist[i].desc, p))
-            {
-              disabled_hw_features |= hwflist[i].flag;
-              break;
-            }
-        }
-      if (i == DIM (hwflist))
+      if (_gcry_disable_hw_feature (p) == GPG_ERR_INV_NAME)
         {
 #ifdef HAVE_SYSLOG
           syslog (LOG_USER|LOG_WARNING,
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d462f30..f428d7d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -19,14 +19,14 @@
 ## Process this file with automake to produce Makefile.in
 
 tests_bin = \
-        version mpitests t-sexp t-convert \
+	version mpitests t-sexp t-convert \
 	t-mpi-bit t-mpi-point curves t-lock \
 	prime basic keygen pubkey hmac hashtest t-kdf keygrip \
 	fips186-dsa aeswrap pkcs1v2 random dsa-rfc6979 t-ed25519 t-cv25519
 
 tests_bin_last = benchmark bench-slope
 
-tests_sh =
+tests_sh = basic-disable-all-hwf
 
 tests_sh_last = hashtest-256g
 
@@ -58,7 +58,8 @@ noinst_HEADERS = t-common.h
 EXTRA_DIST = README rsa-16k.key cavs_tests.sh cavs_driver.pl \
 	     pkcs1v2-oaep.h pkcs1v2-pss.h pkcs1v2-v15c.h pkcs1v2-v15s.h \
 	     t-ed25519.inp stopwatch.h hashtest-256g.in \
-	     sha3-224.h sha3-256.h sha3-384.h sha3-512.h
+	     sha3-224.h sha3-256.h sha3-384.h sha3-512.h \
+	     basic-disable-all-hwf.in
 
 LDADD = $(standard_ldadd) $(GPG_ERROR_LIBS)
 t_lock_LDADD = $(standard_ldadd) $(GPG_ERROR_MT_LIBS)
diff --git a/tests/basic-disable-all-hwf.in b/tests/basic-disable-all-hwf.in
new file mode 100644
index 0000000..1f0a4de
--- /dev/null
+++ b/tests/basic-disable-all-hwf.in
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+echo "      now running 'basic' test with all hardware features disabled."
+exec ./basic at EXEEXT@ --disable-hwf all




More information about the Gcrypt-devel mailing list