From patchwork Thu Jul 18 13:50:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 169208 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2435139ilk; Thu, 18 Jul 2019 06:50:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5ItIiQzFv4s2e0aR9rm7meYJ5G8mam28RhKOASkghU13ZRlK/18yaF7ViXvMQwFUAwyqd X-Received: by 2002:a63:1f1f:: with SMTP id f31mr47281357pgf.353.1563457838065; Thu, 18 Jul 2019 06:50:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563457838; cv=none; d=google.com; s=arc-20160816; b=r/oXHzx0aw1HPdgb0iNQys3IfIz/7UdMICoZCjvmHIIuqcm/6Qjk6spWz5e39IH/0B YtFsn9DRlu0RDiuxLFL47HaZqMPNGActso/sf7iW0Qbpp7eFq3+OMAUaCrHXhFuKulAj B0Rjg+oNvyp0n4QiMoZMhaIJ2N4dkrkSkmIG+evQxh8zm4jHsuMi1MyxAYjjXBEU4nLV tVEakMpGbrU4R03AtCdhBglfPcCq8vUkz3ORk/YMJ1jmnBWS7Cm6uNWRq0/SPpDp5BJl o/Lc4wynPuysMCanavLUZE0h8QjkC6jiSyll6jjKH4OKP794DUVddvwR8D3AosPcSQ2Z Nccw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=0MPEuYUfwm77zpjIS5n8nGkY6EuDpKZuosx9HcU7sNo=; b=Ri5mQsU3VZDLnzA0R7W87drZrBBFq4jrplWM/s+GmHQhUPNJux+QwAchRFDOjgqTow eAmKvZ/0oZZEk8CPGY7m9BOJRcgZow14DSpVb2wQy4WrKny4C40ikJXxjl+t80qyU9IH nOdETPMCJBEkwy6hHP/j3DxLR7ip05vgHOT6cmDdxY+oVl0ba8xFPv/wTqswEXqaXwwU /hfEcypNdVm+7Pxzhm2117hiKxnjk1hjFGf8xyR+Pjjn9ztbKgYMWw9FVJsu+Gy6lVgc Rv1L6A9dD6yUorKUoWJe2t9CUsu7W+bVfZ0SlS2asoh5KUkDu8oa5kXTyY9yvvE6qQvu v1Ig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s13si1189184pfe.140.2019.07.18.06.50.37; Thu, 18 Jul 2019 06:50:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390350AbfGRNug (ORCPT + 3 others); Thu, 18 Jul 2019 09:50:36 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:56811 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727892AbfGRNuf (ORCPT ); Thu, 18 Jul 2019 09:50:35 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1MBlpC-1hiZQe46Xs-00C92P; Thu, 18 Jul 2019 15:50:21 +0200 From: Arnd Bergmann To: Herbert Xu , "David S. Miller" Cc: Arnd Bergmann , Ondrej Mosnacek , Ard Biesheuvel , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH] crypto: aegis: fix badly optimized clang output Date: Thu, 18 Jul 2019 15:50:04 +0200 Message-Id: <20190718135017.2493006-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:uwVqefWDs4o63p6iE6Irj25ryb6bdvtC7Hrf93yaHtWNB3UyaJp 4OkfB2kFOY5aXDuTVLHY0gjWaXZSUkd3hdU7IXfyQfGDuBfNtrAcmaozeItDwwk75ge58G1 sBfVJ6df5mTpV5Y8kgpJ0tPbdf/YlMfhVkrn+9yxYQAHpRDwi5aDbittwSsgXq836kuLfO6 atp6LgcOt/SEcndX4E/nQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:aCIrsaK3jkM=:ZKGmbmo1TdnpLnjvQ7TKLR UK81lUNUbJPH6N3UzauZAmgjkh8XdIXJfHlA2yxaBZzaQbahE13aQU30plQa8EoM4NcHktAFu BUo1N5DZRWhcPq/pKVsolC5wrOu+Vknahoism+3/CG/QZEWno0G4XuiVW9G+2TL3erKB06AuV MIzkPjX1BEtl2PAg5AcrNJX76hAt9fcMTIdZweDC1+uxgEPYaRvAe8qCSRU+ODacG89bmlRgc urdUX2XmkHq9ZVppXO6zqwXsmJ4fMdqhTTf+mWJf/pgBP/oDacehSNQsQSVTlQVNgaYWbeJeZ NZrwJGaQ0PwcIwFcHoUpMMQvc0HQVtD1Ks5mybVvvNE454pggdn21V2drwBY/dWWKEKhOIOp2 RXbyfy2JFwvjzyQ8a3s7gcvYcvrftA8rwk8MVtcNoMITl9+vHJpqARtMOuHduPjK8styPiOwP rzrfdqasn4dgnKvRD66DQgKxAN/dc9HJL0gyYl1RjAw2WIO6W16rERZu1pqnLrh3O4ifiAOl+ /vWjCU54+pwusGnbn3yox0/vQwpOY8vHJ8zcmSOuTPIwv3I4Te0NnwpSiVZqXwu+EmzR2geNb mfcsvg2dhNFODniKVonHEPqOjwIGS2kTAD7VVIpi520lhplRTZbXOVLW/abWpyW/u9AtZBnKT LoyJ7SIEpUDk5tdJdw0k/STEE3V7OZVaAW3OnNSLyjehfTJt7elnuWaxP0uuy9cap+zntpV8P hM0gm+T/uxbOZLVE18lo0/HPejnoQkbgy0IMcw== Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Clang sometimes makes very different inlining decisions from gcc. In case of the aegis crypto algorithms, it decides to turn the innermost primitives (and, xor, ...) into separate functions but inline most of the rest. This results in a huge amount of variables spilled on the stack, leading to rather slow execution as well as kernel stack usage beyond the 32-bit warning limit when CONFIG_KASAN is enabled: crypto/aegis256.c:123:13: warning: stack frame size of 648 bytes in function 'crypto_aegis256_encrypt_chunk' [-Wframe-larger-than=] crypto/aegis256.c:366:13: warning: stack frame size of 1264 bytes in function 'crypto_aegis256_crypt' [-Wframe-larger-than=] crypto/aegis256.c:187:13: warning: stack frame size of 656 bytes in function 'crypto_aegis256_decrypt_chunk' [-Wframe-larger-than=] crypto/aegis128l.c:135:13: warning: stack frame size of 832 bytes in function 'crypto_aegis128l_encrypt_chunk' [-Wframe-larger-than=] crypto/aegis128l.c:415:13: warning: stack frame size of 1480 bytes in function 'crypto_aegis128l_crypt' [-Wframe-larger-than=] crypto/aegis128l.c:218:13: warning: stack frame size of 848 bytes in function 'crypto_aegis128l_decrypt_chunk' [-Wframe-larger-than=] crypto/aegis128.c:116:13: warning: stack frame size of 584 bytes in function 'crypto_aegis128_encrypt_chunk' [-Wframe-larger-than=] crypto/aegis128.c:351:13: warning: stack frame size of 1064 bytes in function 'crypto_aegis128_crypt' [-Wframe-larger-than=] crypto/aegis128.c:177:13: warning: stack frame size of 592 bytes in function 'crypto_aegis128_decrypt_chunk' [-Wframe-larger-than=] Forcing the primitives to all get inlined avoids the issue and the resulting code is similar to what gcc produces. Signed-off-by: Arnd Bergmann --- crypto/aegis.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.20.0 Acked-by: Nick Desaulniers diff --git a/crypto/aegis.h b/crypto/aegis.h index 41a3090cda8e..efed7251c49d 100644 --- a/crypto/aegis.h +++ b/crypto/aegis.h @@ -34,21 +34,21 @@ static const union aegis_block crypto_aegis_const[2] = { } }, }; -static void crypto_aegis_block_xor(union aegis_block *dst, +static __always_inline void crypto_aegis_block_xor(union aegis_block *dst, const union aegis_block *src) { dst->words64[0] ^= src->words64[0]; dst->words64[1] ^= src->words64[1]; } -static void crypto_aegis_block_and(union aegis_block *dst, +static __always_inline void crypto_aegis_block_and(union aegis_block *dst, const union aegis_block *src) { dst->words64[0] &= src->words64[0]; dst->words64[1] &= src->words64[1]; } -static void crypto_aegis_aesenc(union aegis_block *dst, +static __always_inline void crypto_aegis_aesenc(union aegis_block *dst, const union aegis_block *src, const union aegis_block *key) {