From patchwork Sun May 21 10:23:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 9738941 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 E8C6560326 for ; Sun, 21 May 2017 10:23:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB02328607 for ; Sun, 21 May 2017 10:23:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF90128622; Sun, 21 May 2017 10:23:59 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham 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 7E6AB28607 for ; Sun, 21 May 2017 10:23:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752705AbdEUKX6 (ORCPT ); Sun, 21 May 2017 06:23:58 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:37049 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752678AbdEUKX4 (ORCPT ); Sun, 21 May 2017 06:23:56 -0400 Received: by mail-wm0-f42.google.com with SMTP id d127so117726436wmf.0 for ; Sun, 21 May 2017 03:23:56 -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=lJQzJQRkC1WqnKvLlCFhgaGpa51TTvChym+4fqf4y84=; b=ARJ0bCiVCm4qhjpDOPd0KJgbQpLeY1uf+BO++W2Q4DlJ8mqZSc4CyeeqQTWX6GciN7 kfTjI93ICxsT/wBc/kqQ1/4bHzfLw1zH1Mvasbsvla9BdQDUjLtZeJidyXO/qyRzOXNi kEtvBcqfuwrMN+2sjw416sDoBd18BV5BTqSA4= 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=lJQzJQRkC1WqnKvLlCFhgaGpa51TTvChym+4fqf4y84=; b=XAt08OyIxjSO0FiRqrRF5OTQkyhB0cY6h2sSmUnUZvtYWr46RfwZZGcwVRgqFsbIIF 46ZVFalZBZBQBjPxFM7azcjUcsQv86C9oJ0YGW+OniDEB0lJwK5rcRqzB9zZPDiznuPO TZi4YOSve0LB5PS0XFt65whphyn+Yt2dyKJwfU2AlOPvziuv+zikpZVIooyZVtXu3iLt jFHrh94eqbD96J/kX0YBA+pTNkgw7WbTcSaLOdzhhsKX+JlO9VlYhjQUE0kC46G7VbCd U9BFi75tNCp94YNAFU1komKYaMtWl+55a0P/WGy14RweB3DNFYvyEesBFV5171ZpJ2cx nyGQ== X-Gm-Message-State: AODbwcC6gnWi+cbuMMnPJsEl2NyzbEjfb+SWIab/YOX1nOMUSCYk6jQ8 rH6gOVbUpKS7Sl8/ X-Received: by 10.223.163.21 with SMTP id c21mr7687115wrb.38.1495362234758; Sun, 21 May 2017 03:23:54 -0700 (PDT) Received: from localhost.localdomain ([105.129.238.81]) by smtp.gmail.com with ESMTPSA id y60sm13381366wrb.39.2017.05.21.03.23.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 21 May 2017 03:23:53 -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 4/5] crypto: arm/sha2-ce - enable module autoloading based on CPU feature bits Date: Sun, 21 May 2017 10:23:39 +0000 Message-Id: <1495362220-30044-5-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 X-Virus-Scanned: ClamAV using ClamSMTP 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/sha2-ce-glue.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/arm/crypto/sha2-ce-glue.c b/arch/arm/crypto/sha2-ce-glue.c index 0755b2d657f3..df4dcef054ae 100644 --- a/arch/arm/crypto/sha2-ce-glue.c +++ b/arch/arm/crypto/sha2-ce-glue.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -100,8 +101,6 @@ static struct shash_alg algs[] = { { static int __init sha2_ce_mod_init(void) { - if (!(elf_hwcap2 & HWCAP2_SHA2)) - return -ENODEV; return crypto_register_shashes(algs, ARRAY_SIZE(algs)); } @@ -110,5 +109,5 @@ static void __exit sha2_ce_mod_fini(void) crypto_unregister_shashes(algs, ARRAY_SIZE(algs)); } -module_init(sha2_ce_mod_init); +module_cpu_feature_match(SHA2, sha2_ce_mod_init); module_exit(sha2_ce_mod_fini);