Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2439049ybx; Fri, 8 Nov 2019 04:25:36 -0800 (PST) X-Google-Smtp-Source: APXvYqwP8vst5vngegILkJQYkTpYjUD7OJntSv93ItvRHntfVvSLnUqXSBrAyjc4n34ib/rr9LKH X-Received: by 2002:a05:6402:1816:: with SMTP id g22mr9876653edy.76.1573215935882; Fri, 08 Nov 2019 04:25:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573215935; cv=none; d=google.com; s=arc-20160816; b=aZlE2UMHIltokEqLHW+V4m1FtUmql/3Tgc0yyCno68cTzd9230b1fvmJ0C7gyBGo1W tIsafxYsOrK1242PO2w73RDpBDTu2yv1sFYNSGFW+3YeYuKVnnDQFE+pZHZ1HLQvXgid lbXdR8HrcHGk3znIGpOtWaI0lkGZZf6lrSs/OD2qBsbc1sPK5DVi0PHIeYg8MnlxYllG bRhUN3W8CWvpBGwovIM0yeyhNsuZgJZHyOswLzH9tmJ26iuSGlzr5LAiVFz3jk9wBYy8 EL9FdHqpD26RvLPgi39WRIz70S6VyqfD5Zh3vHFWIxFC95jiYl/YBDxaYvlU6DFUYhZe oI+w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5HdLZRVlRAsvN0m2AlQRNZY7/V2LRht3UHzHOAM49R8=; b=zpY0i2hlUkApJhP/DPmL/zT9Gjfl1aQvxrEFNAJ3P4zTXHXAedJyjGUm8QcwKYYFGl Ha2Fdzdttv0rVH9Tq+kyBoIBpo6/bAtcp3M2DsHTxUoX4u7eYHYy14w/vViSeXG62Y7U PCgTVFEFdDo2J4lBrGyyiHLdvwsUSz1pgo/sxGK0pyQyER04nB4xA9FtGhk6mSzKkNWC VCtYOiBpIqU+FIFJQ5qM5XU0kkQcY48t0L2Ieai/eOJxkA+FwIbjH5Gk4cAqjGLngHHO sdOjP7qxLZ9P8ekd72DnPQrex18Af6xi8olipbJ1uvKJB8FGzNolNUJYLeN0+TfINWpn dh1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="A/oYi8qF"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p17si3877267ejm.4.2019.11.08.04.25.12; Fri, 08 Nov 2019 04:25:35 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b="A/oYi8qF"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732550AbfKHMY0 (ORCPT + 99 others); Fri, 8 Nov 2019 07:24:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:38720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732457AbfKHMY0 (ORCPT ); Fri, 8 Nov 2019 07:24:26 -0500 Received: from localhost.localdomain (laubervilliers-657-1-83-120.w92-154.abo.wanadoo.fr [92.154.90.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 98B9721924; Fri, 8 Nov 2019 12:24:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573215865; bh=2JrP8gPhfgYcRdWTz9spSaAHplwvwGOJpDI7tez+vlM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A/oYi8qF3W9MaTRgQsCcfx/MwJOiYmBwHNtD4KYSDq6v6eEkRUGsXf4gjoKErJKLP HR2OPSBgaUelCViE+eCEJZmxmdAKmeAQvigrJ8sXzU4rsIH8yxpAQwByqrCgz9bjgv 2YIMa6ev8X+PtAWbfEuKjuyreJZdFaUt+aZehOmE= From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: Ard Biesheuvel , Herbert Xu , David Miller , "Jason A . Donenfeld" , Samuel Neves , Arnd Bergmann , Eric Biggers , Andy Lutomirski , Martin Willi , Rene van Dorst , David Sterba Subject: [PATCH v5 29/34] crypto: lib/curve25519 - work around Clang stack spilling issue Date: Fri, 8 Nov 2019 13:22:35 +0100 Message-Id: <20191108122240.28479-30-ardb@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191108122240.28479-1-ardb@kernel.org> References: <20191108122240.28479-1-ardb@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Arnd reports that the 32-bit generic library code for Curve25119 ends up using an excessive amount of stack space when built with Clang: lib/crypto/curve25519-fiat32.c:756:6: error: stack frame size of 1384 bytes in function 'curve25519_generic' [-Werror,-Wframe-larger-than=] Let's give some hints to the compiler regarding which routines should not be inlined, to prevent it from running out of registers and spilling to the stack. The resulting code performs identically under both GCC and Clang, and makes the warning go away. Suggested-by: Arnd Bergmann Signed-off-by: Ard Biesheuvel --- lib/crypto/curve25519-fiat32.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/crypto/curve25519-fiat32.c b/lib/crypto/curve25519-fiat32.c index 1c455207341d..2fde0ec33dbd 100644 --- a/lib/crypto/curve25519-fiat32.c +++ b/lib/crypto/curve25519-fiat32.c @@ -223,7 +223,7 @@ static __always_inline void fe_1(fe *h) h->v[0] = 1; } -static void fe_add_impl(u32 out[10], const u32 in1[10], const u32 in2[10]) +static noinline void fe_add_impl(u32 out[10], const u32 in1[10], const u32 in2[10]) { { const u32 x20 = in1[9]; { const u32 x21 = in1[8]; @@ -266,7 +266,7 @@ static __always_inline void fe_add(fe_loose *h, const fe *f, const fe *g) fe_add_impl(h->v, f->v, g->v); } -static void fe_sub_impl(u32 out[10], const u32 in1[10], const u32 in2[10]) +static noinline void fe_sub_impl(u32 out[10], const u32 in1[10], const u32 in2[10]) { { const u32 x20 = in1[9]; { const u32 x21 = in1[8]; @@ -309,7 +309,7 @@ static __always_inline void fe_sub(fe_loose *h, const fe *f, const fe *g) fe_sub_impl(h->v, f->v, g->v); } -static void fe_mul_impl(u32 out[10], const u32 in1[10], const u32 in2[10]) +static noinline void fe_mul_impl(u32 out[10], const u32 in1[10], const u32 in2[10]) { { const u32 x20 = in1[9]; { const u32 x21 = in1[8]; @@ -441,7 +441,7 @@ fe_mul_tll(fe *h, const fe_loose *f, const fe_loose *g) fe_mul_impl(h->v, f->v, g->v); } -static void fe_sqr_impl(u32 out[10], const u32 in1[10]) +static noinline void fe_sqr_impl(u32 out[10], const u32 in1[10]) { { const u32 x17 = in1[9]; { const u32 x18 = in1[8]; @@ -619,7 +619,7 @@ static __always_inline void fe_invert(fe *out, const fe *z) * * Preconditions: b in {0,1} */ -static __always_inline void fe_cswap(fe *f, fe *g, unsigned int b) +static noinline void fe_cswap(fe *f, fe *g, unsigned int b) { unsigned i; b = 0 - b; -- 2.20.1