From patchwork Sun Mar 26 18:49:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 96018 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp923015qgd; Sun, 26 Mar 2017 11:56:24 -0700 (PDT) X-Received: by 10.99.250.17 with SMTP id y17mr20380377pgh.5.1490554583940; Sun, 26 Mar 2017 11:56:23 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 61si10147965plq.107.2017.03.26.11.56.23; Sun, 26 Mar 2017 11:56:23 -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; dkim=pass header.i=@linaro.org; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751506AbdCZS4C (ORCPT + 1 other); Sun, 26 Mar 2017 14:56:02 -0400 Received: from mail-wr0-f182.google.com ([209.85.128.182]:33206 "EHLO mail-wr0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751483AbdCZS4A (ORCPT ); Sun, 26 Mar 2017 14:56:00 -0400 Received: by mail-wr0-f182.google.com with SMTP id w43so16016566wrb.0 for ; Sun, 26 Mar 2017 11:55:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VdkIvsTwbgXxAYHMuTXhiLV1n1H/VFk4nQPtKm9k7UM=; b=Z6U5lR1n55Tdw1MBtoVsHa8zuEIx3ZEQ2qOcMqDqHUlX/uVW+959Odq+Con/cw0sX6 PcytkGqIP5AfYouE6TAASyPBiqvmA+wgBtZMXcutcNk+awd7eiRyqCjLwMgcL3klLpbv l3MeXH7qRiEMcwvAPPR+F0A9RH3bpoT9rE8DI= 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=VdkIvsTwbgXxAYHMuTXhiLV1n1H/VFk4nQPtKm9k7UM=; b=d1z9CPzfpZyMFMKVpxTLz38pcBp/cpjQORAiWqrftyMV/z7lFOoEgu8SFYD8Toy5eQ arf1Rjva8fBnZvdQY+kYrXjg3S9YurYgy/kj2/vZc09/42GAMwS2cVSCqh6jnlAPdrqL 8d1OgDPtWT3Gk06J0UhQzgbNuf90P6y8JQbb3lHPpxYDoMPFfUFGaBHoE9V1SiURP0hT JEAsMpiDj28wtxxsGqP/WN3NUovPi1tMEbxYpnULmSpCbBTeisTE4n9sM1vvLC899fe0 FBW+QISZawRdE8VuEbtMrnJ1dFJGIc5sDp0Am20X0Dl6PrhsUrFwAoP4FVQeMl8EuXl3 Ri8Q== X-Gm-Message-State: AFeK/H3qliWehzbthBVZpGQStTAG5iXKb4jF31JwteadIqwwMPc0jkTJ3BxuoMQ+qkIwqR3v X-Received: by 10.28.194.7 with SMTP id s7mr6183762wmf.136.1490554161125; Sun, 26 Mar 2017 11:49:21 -0700 (PDT) Received: from localhost.localdomain ([196.81.160.3]) by smtp.gmail.com with ESMTPSA id i133sm11362112wmg.26.2017.03.26.11.49.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 Mar 2017 11:49:20 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au Cc: nico@linaro.org, ebiggers3@gmail.com, Ard Biesheuvel Subject: [PATCH 3/7] crypto: aes/x86 - eliminate set_key() handling for IRQ context Date: Sun, 26 Mar 2017 19:49:04 +0100 Message-Id: <1490554148-10953-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490554148-10953-1-git-send-email-ard.biesheuvel@linaro.org> References: <1490554148-10953-1-git-send-email-ard.biesheuvel@linaro.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The crypto API does not allow setkey() to be used in interrupt context, and so the fallback to crypto_aes_expand_key() is dead code which can be eliminated. This removes a dependency on crypto_aes_expand_key() which will be fulfilled by another driver after a subsequent patch. Signed-off-by: Ard Biesheuvel --- arch/x86/crypto/aesni-intel_glue.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c index 93de8ea51548..f6bdd0ec96da 100644 --- a/arch/x86/crypto/aesni-intel_glue.c +++ b/arch/x86/crypto/aesni-intel_glue.c @@ -300,13 +300,13 @@ static int aes_set_key_common(struct crypto_tfm *tfm, void *raw_ctx, return -EINVAL; } - if (!irq_fpu_usable()) - err = crypto_aes_expand_key(ctx, in_key, key_len); - else { - kernel_fpu_begin(); - err = aesni_set_key(ctx, in_key, key_len); - kernel_fpu_end(); - } + /* crypto API forbids setkey() in interrupt context */ + if (WARN_ON(!irq_fpu_usable())) + return -EBUSY; + + kernel_fpu_begin(); + err = aesni_set_key(ctx, in_key, key_len); + kernel_fpu_end(); return err; }