From patchwork Mon Feb 27 12:38:25 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: 9593079 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 1061E604AB for ; Mon, 27 Feb 2017 12:42:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 051CB282ED for ; Mon, 27 Feb 2017 12:42:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAB30283ED; Mon, 27 Feb 2017 12:42:36 +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 7EEC7282ED for ; Mon, 27 Feb 2017 12:42:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751512AbdB0Mjt (ORCPT ); Mon, 27 Feb 2017 07:39:49 -0500 Received: from mail-qk0-f170.google.com ([209.85.220.170]:36364 "EHLO mail-qk0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751385AbdB0Miy (ORCPT ); Mon, 27 Feb 2017 07:38:54 -0500 Received: by mail-qk0-f170.google.com with SMTP id n186so18429450qkb.3 for ; Mon, 27 Feb 2017 04:38:53 -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=U4xQs+TzEPNNvTUJx52+A0aFcXl5Xb3265dj7Rp9CTA=; b=uYXIRCiKMRGRB5iFWdOw4SuToa72NyPtLanQquJqCHMHUQWeLkYL64Nx/YCdzlimGk eO+ghKAYZihHLO92WiFoSWQHInkiPsSRO+Br1CbhOI4shubGey+HsXCdbXYTgMdWbfnm Ccs8uWieApbC9XxS5fryVauLU6pS0j5qMUIQXBYnbH/K/kyojgoAwU3JAwY7Q1+XmXt7 jiqYR4JD/pFVJ6Nojt8kl/nHYleIna2Pog0XuM9sHoPlvNfWOQhbr1kb1VKreNsJmGfV fnx9fenkO8ZpMEKwAWjEEfsXp0FIX/cvGbWpYS9JeCpD2xbqGgv/PwxjmN6tjgACuUT5 ciLQ== 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=U4xQs+TzEPNNvTUJx52+A0aFcXl5Xb3265dj7Rp9CTA=; b=LERN9a0srjPtCcsxKVyh2YbrVZBHGabNkwWo+oLzW0xsHEJlNfVr4S+ko3fZ/aucwn 8UyVwoiyPagVcY5ok6cFi73UPHCTrN2pE0s/gszUy0oNk5JG0oYnGuM14fw7taiVdfZU 8mYD0+dm/TYlQ4C4A36iVykRCOWeZlzMbqKqwHczwCLbhX+VJjVCfMx+mWmTl1zi4kDj w1h7oV7HSvMtm7Pqhj9v6uw4WXYyDUTMSRXwzg6G4xl7pbwNxy1eGte0DI2uauSd1ZBJ z0ep33eZyrxoqfH17WZXXqGPcUP2dlwQoA58N2I1ExNv1gbR4yP7yNbzkwqqHF0+/zoX lFvA== X-Gm-Message-State: AMke39nkJjlW+zATLwOXI1rZUz4kv9Wc+wWIWntv9gJ/6d6WhXHj6T2auWgP3tQpMTTUBG5x X-Received: by 10.237.49.195 with SMTP id 61mr16278221qth.82.1488199133050; Mon, 27 Feb 2017 04:38:53 -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 136sm10307106qkg.34.2017.02.27.04.38.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Feb 2017 04:38:52 -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 v2 1/2] crypto: cbc - Propagate NEED_FALLBACK bit Date: Mon, 27 Feb 2017 09:38:25 -0300 Message-Id: <1488199106-16061-2-git-send-email-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488199106-16061-1-git-send-email-marcelo.cerri@canonical.com> References: <1488199106-16061-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_cbc -> cbc(p8_aes) -> aes-generic However p8_aes will always delegate its calls to aes-generic. With this patch, p8_aes_cbc will be able to use cbc(aes-generic) directly as its fallback. The same applies to aes_s390. Signed-off-by: Marcelo Henrique Cerri --- crypto/cbc.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/crypto/cbc.c b/crypto/cbc.c index bc160a3..b761b1f 100644 --- a/crypto/cbc.c +++ b/crypto/cbc.c @@ -10,6 +10,7 @@ * */ +#include #include #include #include @@ -108,8 +109,10 @@ static void crypto_cbc_free(struct skcipher_instance *inst) static int crypto_cbc_create(struct crypto_template *tmpl, struct rtattr **tb) { struct skcipher_instance *inst; + struct crypto_attr_type *algt; struct crypto_spawn *spawn; struct crypto_alg *alg; + u32 mask; int err; err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_SKCIPHER); @@ -120,8 +123,16 @@ static int crypto_cbc_create(struct crypto_template *tmpl, struct rtattr **tb) if (!inst) return -ENOMEM; - alg = crypto_get_attr_alg(tb, CRYPTO_ALG_TYPE_CIPHER, - CRYPTO_ALG_TYPE_MASK); + algt = crypto_get_attr_type(tb); + err = PTR_ERR(algt); + if (IS_ERR(algt)) + goto err_free_inst; + + mask = CRYPTO_ALG_TYPE_MASK | + crypto_requires_off(algt->type, algt->mask, + CRYPTO_ALG_NEED_FALLBACK); + + alg = crypto_get_attr_alg(tb, CRYPTO_ALG_TYPE_CIPHER, mask); err = PTR_ERR(alg); if (IS_ERR(alg)) goto err_free_inst;