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: 100242 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp1009624qge; Sun, 21 May 2017 03:23:59 -0700 (PDT) X-Received: by 10.98.30.129 with SMTP id e123mr19864700pfe.240.1495362239629; Sun, 21 May 2017 03:23:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495362239; cv=none; d=google.com; s=arc-20160816; b=im4AKOan/NxoK2nD6la2QpAA2wT7pWQESCkqfu8hLV7JyqQkOcZJxPBBjnm1Q0DoFA uc7mn31b1W+04WRE/WYJkpORyFIA6mgsGDz0NR5Sny5OkvxLDnFX6uoFy81/Floo9AsR 71rQDPBXtS3pncsaEypi9WQwplYjlo46ct2HByTVk93t1OMMXRM0cry6Ca/U+3So+5Xe 8NLbKxpP1fbtD3LgtyVJYJO/hY9ladC7bWXAj8VhHVF5hcZ2nKhGyuMHQYrI8I/bI4+r v7Dz7nGTYSvHxTHyCEcW6yPReILwL135j36FuDRHQqyVURWgVbMix2+4OSI9ZnMpAJkJ jZNQ== 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=lJQzJQRkC1WqnKvLlCFhgaGpa51TTvChym+4fqf4y84=; b=N+6ucioKphcvZswnIDNICljIVnDCKN+rcpmWJaTFundWMEqows49FV1h1fYkysyy4R D/TDE69FHD39QuXqo9OiWTpHjW8FQdCKdkq375PFsive+nC13KLlhSqAlmAwYcns+6rr QgPkE1uCKL5A+vSNVlLWPnjH+fiaHmOUuS0AZREqJiA39E/o2A38Cke3BuHLtesV+XC5 ElIsgY21dHl6hPGbT2AstHJcQbFtMovO7Ef9+M6/G9IVwC1vYV74wSsLQN9pdNlL+dQy BKA1sBMqyEisyXjGmdmuSXZxo3iuB7+X472Za4Eg3HE2r4B3tWOvckOI5YagrUcQBgrH 0ABQ== 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.59; Sun, 21 May 2017 03:23:59 -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 S1752705AbdEUKX6 (ORCPT + 1 other); 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 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(-) -- 2.7.4 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);