Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1362)

Unified Diff: crypto/nss_util.cc

Issue 79283002: crypto: disable NSS AES-NI support when AVX is disabled by OS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/cpu.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/nss_util.cc
diff --git a/crypto/nss_util.cc b/crypto/nss_util.cc
index 3ecedf63a48fd51aa73652fdb0725a0e42c46fec..24a2d36e6d7edc3f3c3874221ebe584586a1b413 100644
--- a/crypto/nss_util.cc
+++ b/crypto/nss_util.cc
@@ -12,6 +12,7 @@
#include <prinit.h>
#include <prtime.h>
#include <secmod.h>
+#include <stdlib.h>
#if defined(OS_LINUX)
#include <linux/nfs_fs.h>
@@ -23,6 +24,7 @@
#include <vector>
+#include "base/cpu.h"
#include "base/debug/alias.h"
#include "base/debug/stack_trace.h"
#include "base/environment.h"
@@ -432,6 +434,8 @@ class NSSInitSingleton {
// other threads from accessing until the constructor is done.
thread_checker_.DetachFromThread();
+ DisableAESNIIfNeeded();
+
EnsureNSPRInit();
// We *must* have NSS >= 3.14.3.
@@ -624,6 +628,18 @@ class NSSInitSingleton {
return db_slot;
}
+ static void DisableAESNIIfNeeded() {
+ base::CPU cpu;
+
+ if (cpu.has_avx_hardware() && !cpu.has_avx()) {
+ // Some versions of NSS have a bug that causes AVX instructions to be
+ // used without testing whether XSAVE is enabled by the operating system.
+ // In order to work around this, we disable AES-NI in NSS when we find
+ // that |has_avx()| is false (which includes the XSAVE test).
Ryan Sleevi 2013/11/20 21:46:28 Let's include an NSS version check (or softoken ve
wtc 2013/11/21 21:03:43 In this particular case, it is enough to check the
+ setenv("NSS_DISABLE_HW_AES", "1", 1 /* overwrite */);
+ }
+ }
+
// If this is set to true NSS is forced to be initialized without a DB.
static bool force_nodb_init_;
« no previous file with comments | « base/cpu.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698