[PATCH] Use Intel AES instruction set if it exists - v2

Jeremy Allison jra at samba.org
Thu Aug 31 22:29:32 UTC 2017

On Thu, Aug 31, 2017 at 01:32:36PM -0700, Jeremy Allison wrote:
> This is somewhat of a "go faster" switch for Samba
> with SMB1/2/3 signing and encryption.
> Originally developed by Justin @ Netgear this
> adds the Intel AES instruction set code from
> the Linux kernel into third_party (it's GPLv2+
> so the licensing is good).
> The first patch adds the new code to third_party
> and sets the HAVE_AESNI_INTEL config to 1 if found.
> The second patch prepares lib/crypto/aes.c to call
> the AES instructions and the third one adds the
> runtime check (as we may have been compiled on
> a system with Intel AES but be running on a system
> without) to switch us into the hardware AES instructions
> if available. NB. This doesn't change the Heimdal
> aes code, just the code in lib/crypto called by
> smbd and others.
> It's a pretty minimal patchset and hopefully
> pretty easy to understand and review as it
> doesn't change any of the existing crypto
> calls (except to rename their aes key schedule
> variable inside the struct).
> It would be good to get this in as it has been
> found to give up to a 200% performance improvement
> on certain workloads, and some variant of this
> patch is already being included by most Samba
> NAS vendors.
> This will make it available to all, and has been
> sorely needed in stock Samba for a while.
> I've tested with and without HAVE_AESNI_INTEL
> being detected and it compiles and runs in
> both cases.
> I've logged a bug:
> https://bugzilla.samba.org/show_bug.cgi?id=13008
> for this so if it gets in we should be
> able to get this into 4.7.x (for x = 0 or
> greater :-).
> Please review and push if happy !

Second version - Justin pointed out we need the following
change in patch #1 to fix for non-x86 systems.

diff --git a/third_party/aesni-intel/wscript b/third_party/aesni-intel/wscript
index 151892f6889..ee7be031fd0 100644
--- a/third_party/aesni-intel/wscript
+++ b/third_party/aesni-intel/wscript
@@ -5,6 +5,9 @@ def configure(conf):
                conf.DEFINE('HAVE_AESNI_INTEL', 1)
 def build(bld):
+    if not bld.CONFIG_SET('HAVE_AESNI_INTEL'):
+        return

New patchset includes this change.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: intel-aes-master4.patch
Type: text/x-diff
Size: 102195 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20170831/898b8c7a/intel-aes-master4.diff>

More information about the samba-technical mailing list