Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sat, 24 Oct 2015 02:33:34 +0200
From: magnum <john.magnum@...hmail.com>
To: john-dev@...ts.openwall.com
Subject: Re: Re: "Illegal instruction" error on

On 2015-10-24 01:07, magnum wrote:
> I'll see if I can figure out how to check for AVX2 and beat Solar to
> it... it oughta be better than Sudoku.

I think/hope I did it right. Seems to work. Here's the asm diff.

magnum

diff --git a/src/x86-64.S b/src/x86-64.S
index bcf5fc0..9912b4a 100644
--- a/src/x86-64.S
+++ b/src/x86-64.S
@@ -1636,11 +1636,12 @@ DES_bs_crypt_plain_loop:
 	ret
 #endif
 
-#if defined(CPU_REQ_AVX) || defined(CPU_REQ_XOP)
+#if defined(CPU_REQ_AVX2) || defined(CPU_REQ_AVX) || defined(CPU_REQ_XOP)
 /*
  * CPU detection.
  */
 
+#define CF_AVX2				$0x00000020
 #define CF_XSAVE_OSXSAVE_AVX		$0x1C000000
 #define CF_XOP				$0x00000800
 
@@ -1652,6 +1653,18 @@ DES_bs_crypt_plain_loop:
 .globl CPU_detect
 CPU_detect:
 	pushq %rbx
+#ifdef CPU_REQ_AVX2
+	xorl %eax,%eax
+	cpuid
+	movl $7,%edx
+	cmpl %edx,%eax
+	jl CPU_detect_fail
+	xchgl %edx,%eax
+	cpuid
+	andl CF_AVX2,%ebx
+	cmpl CF_AVX2,%ebx
+	jne CPU_detect_fail
+#else
 	movl $1,%eax
 	cpuid
 	andl CF_XSAVE_OSXSAVE_AVX,%ecx
@@ -1673,6 +1686,7 @@ CPU_detect:
 	testl CF_XOP,%ecx
 	jz CPU_detect_fail
 #endif
+#endif
 	movl $1,%eax
 	popq %rbx
 	ret

Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ