Commit 595e0d66 authored by Niels Möller's avatar Niels Möller
Browse files

Check for x86_64 sha_ni extension.

parent d4417d99
2018-02-05 Niels Möller <nisse@lysator.liu.se>
* fat-x86_64.c (get_x86_features): Check for sha_ni extension.
* x86_64/fat/cpuid.asm: Clear %ecx input to cpuid instruction.
2018-02-01 Nikos Mavrogiannopoulos <nmav@redhat.com> 2018-02-01 Nikos Mavrogiannopoulos <nmav@redhat.com>
* gcm.c (gcm_fill): New function, for use with _ctr_crypt16. * gcm.c (gcm_fill): New function, for use with _ctr_crypt16.
......
...@@ -52,6 +52,7 @@ struct x86_features ...@@ -52,6 +52,7 @@ struct x86_features
{ {
enum x86_vendor { X86_OTHER, X86_INTEL, X86_AMD } vendor; enum x86_vendor { X86_OTHER, X86_INTEL, X86_AMD } vendor;
int have_aesni; int have_aesni;
int have_sha_ni;
}; };
#define SKIP(s, slen, literal, llen) \ #define SKIP(s, slen, literal, llen) \
...@@ -66,6 +67,7 @@ get_x86_features (struct x86_features *features) ...@@ -66,6 +67,7 @@ get_x86_features (struct x86_features *features)
const char *s; const char *s;
features->vendor = X86_OTHER; features->vendor = X86_OTHER;
features->have_aesni = 0; features->have_aesni = 0;
features->have_sha_ni = 0;
s = secure_getenv (ENV_OVERRIDE); s = secure_getenv (ENV_OVERRIDE);
if (s) if (s)
...@@ -84,6 +86,8 @@ get_x86_features (struct x86_features *features) ...@@ -84,6 +86,8 @@ get_x86_features (struct x86_features *features)
} }
else if (MATCH (s, length, "aesni", 5)) else if (MATCH (s, length, "aesni", 5))
features->have_aesni = 1; features->have_aesni = 1;
else if (MATCH (s, length, "sha_ni", 6))
features->have_sha_ni = 1;
if (!sep) if (!sep)
break; break;
s = sep + 1; s = sep + 1;
...@@ -100,6 +104,10 @@ get_x86_features (struct x86_features *features) ...@@ -100,6 +104,10 @@ get_x86_features (struct x86_features *features)
_nettle_cpuid (1, cpuid_data); _nettle_cpuid (1, cpuid_data);
if (cpuid_data[2] & 0x02000000) if (cpuid_data[2] & 0x02000000)
features->have_aesni = 1; features->have_aesni = 1;
_nettle_cpuid (7, cpuid_data);
if (cpuid_data[1] & 0x20000000)
features->have_sha_ni = 1;
} }
} }
...@@ -135,9 +143,10 @@ fat_init (void) ...@@ -135,9 +143,10 @@ fat_init (void)
{ {
const char * const vendor_names[3] = const char * const vendor_names[3] =
{ "other", "intel", "amd" }; { "other", "intel", "amd" };
fprintf (stderr, "libnettle: cpu features: vendor:%s%s\n", fprintf (stderr, "libnettle: cpu features: vendor:%s%s%s\n",
vendor_names[features.vendor], vendor_names[features.vendor],
features.have_aesni ? ",aesni" : ""); features.have_aesni ? ",aesni" : "",
features.have_sha_ni ? ",sha_ni" : "");
} }
if (features.have_aesni) if (features.have_aesni)
{ {
......
...@@ -45,6 +45,7 @@ PROLOGUE(_nettle_cpuid) ...@@ -45,6 +45,7 @@ PROLOGUE(_nettle_cpuid)
push %rbx push %rbx
movl %edi, %eax movl %edi, %eax
xorl %ecx, %ecx C Information we need use ecx = 0
cpuid cpuid
mov %eax, (%rsi) mov %eax, (%rsi)
mov %ebx, 4(%rsi) mov %ebx, 4(%rsi)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment