From patchwork Tue Jun 18 11:19:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 167140 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4080963ilk; Tue, 18 Jun 2019 04:20:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyaKuVT1YpgnH35qqGA/3YG2UK4qFvIfsIyEndE1MsSMc9Sf9iFU0nJvDXnUIkWBFkaRB0P X-Received: by 2002:a17:90a:1b4a:: with SMTP id q68mr4549761pjq.61.1560856812764; Tue, 18 Jun 2019 04:20:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560856812; cv=none; d=google.com; s=arc-20160816; b=m0YVi0Pz+fvOAv/DgxUO6SllINY3PFkwzQTFHK50949J11KHGKnvqIQuFrbQMzf/oz drZDJHQWH5JcL/taVvbrC3LaU8gCqJwmOwjabN6cf4USnJvaZm0tggtrbry6D7HiJWKK tQMwcY8DYRYHTaFMRBUVutwpSmQM1vH7/P36YClurk0UE1PCEplF4i2XlQCn5ECUuWCS 4mB2qCYMj2Yj0xf8vwtnYdR3YZbDCUsfnBwY5yR08/p9t74kcwFhfQZRtkfZIyzKhMMO kpT6TN965bz5SdFpsyicXndcGs/27bNWhDbOh300OHzMhiqWZO0EMzWbjbAttrHdkfWr 4x6w== 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=wObWrLAuy7siaB3PBObzxjKXhGV2cQzb7mhFx6wBJyk=; b=UzJUP0PgcZ7ieqwiv6NNn5t9K645FWnH6W2OL12yDl9QSPRYgayCCHud/aiPyJ+DQ7 V4ULhd8+ziHiOXHVJ9yd6Fwct7lycy36IrPATnx7MqeC8FzjJcf/jzHPYS+WwZV81mYI Zrem0Gm+aXzEk21gi8KGFZCy2LKFYZJfYba5QF7p1hYKEFWyy8aaZ9oxwWk8cZ6QVzqo Gy8D2TYjUOxPtiy8421IUn2seeOw2sLFbwN+pYF2QhZlUFb9oOGxiQPU5kRS8f7ieF7s i5+z+xvlNRxwnMGBCklYteila0aU3+jf6qw3v8lIUruJdnq8K41N+SVD6qWHHs0NA/2s 91gg== 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 o12si7889550pgs.565.2019.06.18.04.20.12; Tue, 18 Jun 2019 04:20:12 -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 S1729572AbfFRLUL (ORCPT + 3 others); Tue, 18 Jun 2019 07:20:11 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:54111 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729110AbfFRLUK (ORCPT ); Tue, 18 Jun 2019 07:20:10 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.145]) with ESMTPA (Nemesis) id 1N7zJl-1ihrb10qH5-014zfL; Tue, 18 Jun 2019 13:20:00 +0200 From: Arnd Bergmann To: Herbert Xu , "David S. Miller" Cc: Arnd Bergmann , Eric Biggers , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] crypto: serpent - mark __serpent_setkey_sbox noinline Date: Tue, 18 Jun 2019 13:19:42 +0200 Message-Id: <20190618111953.3183723-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:VIWQh7CGc1e7ltY83od0FlOkocpGFJuJKawvgRQ5EwYbCB8I42u 7dpn0qwdoSWNr3+V9YzfMMHU1OpbH+9VYy4ji/hfTL9c6Wq8Lh+d9yDy3ahSKquSfPrDTG8 2h35j5Wt7KmOHdFtds3TtDu0YGLppBaMxodi+EGl9/yHBYi/CozL9FgopJ0565GQr01thZR ghX1zLytq4EqAVWGu8UeQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:Exce4h1rSxc=:NgW1DRQhB2jU9fDRpSqrqZ NkDrx8pqzA+SOEghvSwELrk+k5e28L/lu2Dvb3w08iOS2AQcgAjDVLM5qu8CDynf3unvNWXsG ocV8xs4MiaMcWy1aFIY30PNEClGYcsKB0koAPKDuR5g3lMim4knCt+9nPpzfpWTRyumokvQ1z zL1tNTQ0tABgrEZt1Y0DiO50cFXxKdCJ3vnmt8ogaNf0mp7LLR41hQgKSj2gbt3sVKIcpnoaq +fTdZ25uu/v7TkjVdb2UMtyS+BtWrRsXUDA0FHU1B45G7Q6zaHQjh6ngWUe4TlwG0TjYKY0xt fcelSULF6cE/+BZ47RpnkFIlH5Y2taWPn0SJSid3PC8vKk6LarpRfmZnILQ0jCfG8KffXy9y7 nb+0lxYmR6SwCctbz8RwvL1sitaARBXE6A5rTktbTQV4s3jC8Bfkn3emvU1Q0SLGqj0gbcOle uuFDuSbExWqqeAOCp9mjQtcgQhDFuuWw04Uuj0Rmd3r4DD5fOOplGQk0xF4DOo9+DxvsrMqLq jvmuM4EVvAxhgjw4LqC9IP0RoSm9/lct5arMN8z8KOL/8JivZrA+7VK2X7E6r++Cap1/d+/6p Zzb+A9k/d6Rqj507JIBJVl61YYqLt4+nHU4MaKHoXgqG/h4AfibQ6AClwExY9TRI32M6OQZMr UM74UFE/kM9wqbAy+bZ/BnzfG9Sdlrp/OWbBUokBvkvAPqwJqCQZ5yerxNgStKu/08TBZcCqG GXD3BsGaK9GHy5hwCDdTEktYAI3vnhP9nEPF6g== Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The same bug that gcc hit in the past is apparently now showing up with clang, which decides to inline __serpent_setkey_sbox: crypto/serpent_generic.c:268:5: error: stack frame size of 2112 bytes in function '__serpent_setkey' [-Werror,-Wframe-larger-than=] Marking it 'noinline' reduces the stack usage from 2112 bytes to 192 and 96 bytes, respectively, and seems to generate more useful object code. Fixes: c871c10e4ea7 ("crypto: serpent - improve __serpent_setkey with UBSAN") Signed-off-by: Arnd Bergmann --- v2: style improvements suggested by Eric Biggers --- crypto/serpent_generic.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.20.0 Reviewed-by: Eric Biggers diff --git a/crypto/serpent_generic.c b/crypto/serpent_generic.c index e57757904677..56fa665a4f01 100644 --- a/crypto/serpent_generic.c +++ b/crypto/serpent_generic.c @@ -225,7 +225,13 @@ x4 ^= x2; \ }) -static void __serpent_setkey_sbox(u32 r0, u32 r1, u32 r2, u32 r3, u32 r4, u32 *k) +/* + * both gcc and clang have misoptimized this function in the past, + * producing horrible object code from spilling temporary variables + * on the stack. Forcing this part out of line avoids that. + */ +static noinline void __serpent_setkey_sbox(u32 r0, u32 r1, u32 r2, + u32 r3, u32 r4, u32 *k) { k += 100; S3(r3, r4, r0, r1, r2); store_and_load_keys(r1, r2, r4, r3, 28, 24);