third_party: Add build capability to aesni-intel.
authorJeremy Allison <jra@samba.org>
Wed, 6 Sep 2017 16:58:06 +0000 (09:58 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 7 Sep 2017 00:01:08 +0000 (02:01 +0200)
Minor modifications to code to allow building as a Samba
shared library.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13008

Based on original work by Justin Maggard <jmaggard@netgear.com>

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
third_party/aesni-intel/aesni-intel_asm.c
third_party/aesni-intel/inst-intel.h
third_party/aesni-intel/wscript [new file with mode: 0644]
third_party/wscript

index 383a6f84a060f103c7c43923ad84029e0ce2a9f1..7baf703f338a3ed33519fc34b0a45a96c121e720 100644 (file)
  * (at your option) any later version.
  */
 
-#include <linux/linkage.h>
-#include <asm/inst.h>
-#include <asm/frame.h>
+#define ENTRY(name) \
+       .globl name ; \
+       .align 4,0x90 ; \
+       name:
+#define ENDPROC(name) \
+       .type name, @function ; \
+       .size name, .-name
+
+#define FRAME_BEGIN
+#define FRAME_END
+#define FRAME_OFFSET 0
+
+#include "inst-intel.h"
 
 /*
  * The following macros are used to move an (un)aligned 16 byte value to/from
@@ -2553,11 +2563,9 @@ ENTRY(aesni_cbc_dec)
 ENDPROC(aesni_cbc_dec)
 
 #ifdef __x86_64__
-.pushsection .rodata
 .align 16
 .Lbswap_mask:
        .byte 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
-.popsection
 
 /*
  * _aesni_inc_init:    internal ABI
@@ -2572,7 +2580,7 @@ ENDPROC(aesni_cbc_dec)
  */
 .align 4
 _aesni_inc_init:
-       movaps .Lbswap_mask, BSWAP_MASK
+       movaps .Lbswap_mask(%rip), BSWAP_MASK
        movaps IV, CTR
        PSHUFB_XMM BSWAP_MASK CTR
        mov $1, TCTR_LOW
@@ -2700,12 +2708,12 @@ ENTRY(aesni_xts_crypt8)
        cmpb $0, %cl
        movl $0, %ecx
        movl $240, %r10d
-       leaq _aesni_enc4, %r11
-       leaq _aesni_dec4, %rax
+       leaq _aesni_enc4(%rip), %r11
+       leaq _aesni_dec4(%rip), %rax
        cmovel %r10d, %ecx
        cmoveq %rax, %r11
 
-       movdqa .Lgf128mul_x_ble_mask, GF128MUL_MASK
+       movdqa .Lgf128mul_x_ble_mask(%rip), GF128MUL_MASK
        movups (IVP), IV
 
        mov 480(KEYP), KLEN
index 3e115273ed885110de583ce5b228ad6caf993eec..95978be17e280af8257d8a6694c694a121ae2383 100644 (file)
@@ -5,8 +5,6 @@
 #ifndef X86_ASM_INST_H
 #define X86_ASM_INST_H
 
-#ifdef __ASSEMBLY__
-
 #define REG_NUM_INVALID                100
 
 #define REG_TYPE_R32           0
        MODRM 0xc0 movq_r64_xmm_opd1 movq_r64_xmm_opd2
        .endm
 #endif
-
-#endif
diff --git a/third_party/aesni-intel/wscript b/third_party/aesni-intel/wscript
new file mode 100644 (file)
index 0000000..002ba5d
--- /dev/null
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+
+def configure(conf):
+    if conf.CHECK_CFLAGS('-Wp,-E,-lang-asm', '') and conf.env['SYSTEM_UNAME_MACHINE'] == 'x86_64':
+        conf.DEFINE('HAVE_AESNI_INTEL', 1)
+
+def build(bld):
+    if not bld.CONFIG_SET('HAVE_AESNI_INTEL'):
+        return
+
+    bld.SAMBA_LIBRARY('aesni-intel',
+        source='aesni-intel_asm.c',
+        cflags='-Wp,-E,-lang-asm',
+        private_library=True)
index ad4d6245bbd429820719cac1ce935d1c0d69eb8f..7c2923f611e679f6e3478146d864a0d399d26bde 100644 (file)
@@ -50,6 +50,7 @@ def configure(conf):
     conf.RECURSE('cmocka')
     conf.RECURSE('popt')
     conf.RECURSE('zlib')
+    conf.RECURSE('aesni-intel')
 
 
 def build(bld):
@@ -73,3 +74,4 @@ def build(bld):
     bld.RECURSE('cmocka')
     bld.RECURSE('zlib')
     bld.RECURSE('popt')
+    bld.RECURSE('aesni-intel')