From patchwork Mon Feb 27 01:03:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 9592611 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6C1AD604AB for ; Mon, 27 Feb 2017 01:32:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E90928173 for ; Mon, 27 Feb 2017 01:32:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53021283E1; Mon, 27 Feb 2017 01:32:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AFA128173 for ; Mon, 27 Feb 2017 01:32:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751246AbdB0BcB (ORCPT ); Sun, 26 Feb 2017 20:32:01 -0500 Received: from mail-qk0-f171.google.com ([209.85.220.171]:35202 "EHLO mail-qk0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751117AbdB0BcB (ORCPT ); Sun, 26 Feb 2017 20:32:01 -0500 Received: by mail-qk0-f171.google.com with SMTP id u188so76517007qkc.2 for ; Sun, 26 Feb 2017 17:32:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5CGjrFjqlFh6nvHnbhxd5C5j88pinMs+WrJCY3HP2Jk=; b=Kk2/2fChCwzKoGIAEI7AnlbGAZUQdZSHf+eM96PQXTlKfxICUmZ5PNRM84WQjLP18P FZMcFchutPnFAdHDS35tm/D/cnqdfYgP8tlnZd0wkE3GonkUjfEVDF8IWxfPPSa99ru2 SQggenlTj3jBlC7N1KcyIb/Qo2/pZAoJ8b+/PvCxkdDhcN0SUlIyjWmIWJxVAYJQu/jM o2L8wLmUOFJETJgTHQcmNuhyIaHb9FCyQcMk08d3rnKuDldsC/btpbTC3iPZxZ2sujL/ ZSyKYhnaKB8Fi9z5vqiZnYZU1Z1MhKkXGvWBzH8kyO9UpLHH2loUAxIRJoS/H3+q2RGb giJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5CGjrFjqlFh6nvHnbhxd5C5j88pinMs+WrJCY3HP2Jk=; b=gStUzIOvKtbkiFdOkFGuNHJygwnAFODXZY5nZ37yzrzyKdQs8vibCTfmMtRNicoa0p cNFJQ2L/Xij79Y3Bmy0Rhytb2ePOyvlNoBjuh55YrZTvKMPKDkl7ipvvYu2dCL/pyJcv mSvRwLbpOrz+LWIrUI69CY4tqsZ1O7mRjeQBEORFkX83ghFKspEwvkdpnpLrhMhEr6r/ tBaANxC2eUc69V1jeIcV2Vx7wN6TySndeWFUQDmyUJIDpUnWUqANivnuH9ANFXzoJnAg BP+YSpLyeaJ2kEh5h9IK5/HMfajb93ySsLXDuA9lIyiCuloqblJXQwduq8Rma83iR8n4 iFZQ== X-Gm-Message-State: AMke39lwcWF9xqwguA8pZu5Ilyvfq7bi0WAKSrAFN5+7ZLbNxF8eyAzYp/t+90peaXsvXYAA X-Received: by 10.200.52.135 with SMTP id w7mr13306904qtb.136.1488157430321; Sun, 26 Feb 2017 17:03:50 -0800 (PST) Received: from localhost.localdomain (201-68-147-134.dsl.telesp.net.br. [201.68.147.134]) by smtp.gmail.com with ESMTPSA id x125sm9503495qkd.17.2017.02.26.17.03.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 Feb 2017 17:03:49 -0800 (PST) From: Marcelo Henrique Cerri To: Herbert Xu Cc: "David S. Miller" , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Marcelo Henrique Cerri Subject: [PATCH 2/2] crypto: ctr - Propagate NEED_FALLBACK bit Date: Sun, 26 Feb 2017 22:03:19 -0300 Message-Id: <1488157399-3587-3-git-send-email-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488157399-3587-1-git-send-email-marcelo.cerri@canonical.com> References: <1488157399-3587-1-git-send-email-marcelo.cerri@canonical.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When requesting a fallback algorithm, we should propagate the NEED_FALLBACK bit when search for the underlying algorithm. This will prevents drivers from allocating unnecessary fallbacks that are never called. For instance, currently the vmx-crypto driver will use the following chain of calls when calling the fallback implementation: p8_aes_ctr -> ctr(p8_aes) -> aes-generic However p8_aes will always delegate its calls to aes-generic. With this patch, p8_aes_ctr will be able to use ctr(aes-generic) directly as its fallback. The same applies to aes_s390. Signed-off-by: Marcelo Henrique Cerri --- crypto/ctr.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crypto/ctr.c b/crypto/ctr.c index a4f4a89..3afe21a 100644 --- a/crypto/ctr.c +++ b/crypto/ctr.c @@ -181,15 +181,24 @@ static void crypto_ctr_exit_tfm(struct crypto_tfm *tfm) static struct crypto_instance *crypto_ctr_alloc(struct rtattr **tb) { struct crypto_instance *inst; + struct crypto_attr_type *algt; struct crypto_alg *alg; + u32 mask; int err; err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_BLKCIPHER); if (err) return ERR_PTR(err); - alg = crypto_attr_alg(tb[1], CRYPTO_ALG_TYPE_CIPHER, - CRYPTO_ALG_TYPE_MASK); + algt = crypto_get_attr_type(tb); + if (IS_ERR(algt)) + return PTR_ERR(algt); + + mask = CRYPTO_ALG_TYPE_MASK | + crypto_requires_off(algt->type, algt->mask, + CRYPTO_ALG_NEED_FALLBACK); + + alg = crypto_attr_alg(tb[1], CRYPTO_ALG_TYPE_CIPHER, mask); if (IS_ERR(alg)) return ERR_CAST(alg);