From patchwork Sun May 21 10:23:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 100241 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp1009619qge; Sun, 21 May 2017 03:23:57 -0700 (PDT) X-Received: by 10.98.157.83 with SMTP id i80mr19467663pfd.166.1495362237456; Sun, 21 May 2017 03:23:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495362237; cv=none; d=google.com; s=arc-20160816; b=04N5FYY7XUUChtZ5ZTfpCcVeAfpm3TLhrr3ZabUOV+EcnDCby4ada4/UucRK4KeCXH v/U6hf04Wb9ti5WIC7RyTtdqC+4MeRsE/dU1TpBrpxofRZ4FlxMCPdBSXkyslZyLvbRq fIT7jms8MIzRyB7CrGSdli/VKtYdsajeBSJI3RcZ5H7tYDUCmNivxLroBktxDeMfyg/J j6GHubGtdcjCQ3kLjYnELD2A0JqXS0xB7qCaOCc8ogJjP5B0efA48G/MHj0htQt46pyK jow5BhZCBumlalaETtWgkjUHUqRqelKDRWiCNPZz4vbbkObqPdvSCcbeYRhVorj3BdGU wcKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=tIhXXZitwFbq0MPGAZ6/t9pj8i+vDL+dWwBhTKwu+p8=; b=rKQFZptvz5mo4ux1ejGv8ynCQjNTwLbTLKIP2A+PSa+32LkoYqQWSwoJozRXuemvTf thTrQ2sbQvMVi7MbeBojX+GIFo5IkyePpdXSE+p3lteudRiYQEBk8Gnztbsc0S30v2pg UXgbwYSaOqTGMR2Wg4QcUiIDJv0XtbEPRMzOLl3rfmxc544OyuuTeB3TUikAvrvSwc8a up9WBFl9s1n8Tvcu2mi/VbyqYC1FtMUcChGDZ2nSgkc5Ank6rQwgaJDoBvCMWWuwXOVr PCI2IaXJWZuo0c59HbIdBUtWW5FCq8+twGzym7jSAsJASNGXIKevFCx0cvhcqOArfGFh h+Ww== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 61si13414632plr.23.2017.05.21.03.23.57; Sun, 21 May 2017 03:23:57 -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 S1752646AbdEUKXz (ORCPT + 1 other); Sun, 21 May 2017 06:23:55 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:38890 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752678AbdEUKXy (ORCPT ); Sun, 21 May 2017 06:23:54 -0400 Received: by mail-wm0-f47.google.com with SMTP id e127so2373716wmg.1 for ; Sun, 21 May 2017 03:23:53 -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=tIhXXZitwFbq0MPGAZ6/t9pj8i+vDL+dWwBhTKwu+p8=; b=SxRj0o76L7GGUSHBu/irUbJkK3OVlRNPIq0XQEcKoPG1QWQtB+3XZ0h3k8LBwluC4g O4obIkW3VhoXSML2yNMDELv3aN5z1fmkTlvNYRo2z8udnkefMHYFUm/WpTbREKsmh/ip UBtd5RGsSugTKWmFI3+j7XAd3ySdpfuLu2QF8= 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=tIhXXZitwFbq0MPGAZ6/t9pj8i+vDL+dWwBhTKwu+p8=; b=RzsoIPQpROSLnR7BxoMg3dh1vP/8xQIBaYYfR0vWj51t4umDLaPmqca25CnsVRto3U 3jIzodho/bCQ8jarFT07C0i/SW5AR+OCYp0zVQXvABhe/EvXUzF2gRnMISQiscMv4Br/ blbpCGQC3YB+0lvM67NYfiVBFxIjqOOu00gPQH9zrwC9hgRHuqZq3QyW6XxLzOzS5UyM C5FU7kZJ0bS0p8omHcRUDQXbNjDlvvHnDKLnBeIl2yU04fipbhAlxPzdv4onNRVnUAcU cINAx4pxqi/i4JxOS1N1EQkTmiwMYvddPbW84PiX6yiTOvinp2vxfr0jXe1lZue+ZIaB LNwg== X-Gm-Message-State: AODbwcBs83wx5JXLKcQSN/IddhRV52om3BiF1R6+nJ7KCjhxPRHrzpm1 Rg91tpHU9BNqinTO X-Received: by 10.223.135.216 with SMTP id c24mr8071946wrc.109.1495362232646; Sun, 21 May 2017 03:23:52 -0700 (PDT) Received: from localhost.localdomain ([105.129.238.81]) by smtp.gmail.com with ESMTPSA id y60sm13381366wrb.39.2017.05.21.03.23.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 21 May 2017 03:23:51 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel Subject: [PATCH 3/5] crypto: arm/sha1-ce - enable module autoloading based on CPU feature bits Date: Sun, 21 May 2017 10:23:38 +0000 Message-Id: <1495362220-30044-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495362220-30044-1-git-send-email-ard.biesheuvel@linaro.org> References: <1495362220-30044-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 Make the module autoloadable by tying it to the CPU feature bit that describes whether the optional instructions it relies on are implemented by the current CPU. Signed-off-by: Ard Biesheuvel --- arch/arm/crypto/sha1-ce-glue.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/arch/arm/crypto/sha1-ce-glue.c b/arch/arm/crypto/sha1-ce-glue.c index 80bc2fcd241a..555f72b5e659 100644 --- a/arch/arm/crypto/sha1-ce-glue.c +++ b/arch/arm/crypto/sha1-ce-glue.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -82,8 +83,6 @@ static struct shash_alg alg = { static int __init sha1_ce_mod_init(void) { - if (!(elf_hwcap2 & HWCAP2_SHA1)) - return -ENODEV; return crypto_register_shash(&alg); } @@ -92,5 +91,5 @@ static void __exit sha1_ce_mod_fini(void) crypto_unregister_shash(&alg); } -module_init(sha1_ce_mod_init); +module_cpu_feature_match(SHA1, sha1_ce_mod_init); module_exit(sha1_ce_mod_fini);