summaryrefslogtreecommitdiff
path: root/lib/accelerated
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2014-07-08 14:02:18 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2014-07-08 14:02:25 +0200
commit53b6f78efe3b7f3bb677fd8dfcec4b34899dae12 (patch)
treef1afb078a5d6e1929ad6416a10b4c4a7b60be688 /lib/accelerated
parentfa5cefcef5ee180a55df475cf20ec84e0f4923a5 (diff)
downloadgnutls-53b6f78efe3b7f3bb677fd8dfcec4b34899dae12.tar.gz
Added option to disable any cpu optimizations
Diffstat (limited to 'lib/accelerated')
-rw-r--r--lib/accelerated/x86/x86-common.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/accelerated/x86/x86-common.c b/lib/accelerated/x86/x86-common.c
index 148f324915..b8b8cf21ea 100644
--- a/lib/accelerated/x86/x86-common.c
+++ b/lib/accelerated/x86/x86-common.c
@@ -61,16 +61,20 @@ unsigned int _gnutls_x86_cpuid_s[3];
/* Our internal bit-string for cpu capabilities. Should be set
* in GNUTLS_CPUID_OVERRIDE */
-#define INTEL_AES_NI 1
-#define INTEL_SSSE3 (1<<1)
-#define INTEL_PCLMUL (1<<2)
-#define VIA_PADLOCK (1<<10)
-#define VIA_PADLOCK_PHE (1<<11)
-#define VIA_PADLOCK_PHE_SHA512 (1<<12)
+#define EMPTY_SET 1
+#define INTEL_AES_NI (1<<1)
+#define INTEL_SSSE3 (1<<2)
+#define INTEL_PCLMUL (1<<3)
+#define VIA_PADLOCK (1<<20)
+#define VIA_PADLOCK_PHE (1<<21)
+#define VIA_PADLOCK_PHE_SHA512 (1<<22)
static void capabilities_to_intel_cpuid(unsigned capabilities)
{
memset(_gnutls_x86_cpuid_s, 0, sizeof(_gnutls_x86_cpuid_s));
+ if (capabilities & EMPTY_SET) {
+ return;
+ }
if (capabilities & INTEL_AES_NI) {
_gnutls_x86_cpuid_s[1] |= bit_AES;
}
@@ -85,6 +89,9 @@ static void capabilities_to_intel_cpuid(unsigned capabilities)
static unsigned capabilities_to_via_edx(unsigned capabilities)
{
memset(_gnutls_x86_cpuid_s, 0, sizeof(_gnutls_x86_cpuid_s));
+ if (capabilities & EMPTY_SET) {
+ return 0;
+ }
if (capabilities & VIA_PADLOCK) { /* edx */
_gnutls_x86_cpuid_s[2] |= via_bit_PADLOCK;
}