From patchwork Wed Jan 11 17:01:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 90952 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1218345qgi; Wed, 11 Jan 2017 09:02:50 -0800 (PST) X-Received: by 10.99.188.2 with SMTP id q2mr12030444pge.34.1484154170223; Wed, 11 Jan 2017 09:02:50 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id 3si6359990pls.10.2017.01.11.09.02.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jan 2017 09:02:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cRMIT-0007Z4-9x; Wed, 11 Jan 2017 17:02:49 +0000 Received: from mail-wj0-x22b.google.com ([2a00:1450:400c:c01::22b]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cRMIP-0007VG-SX for linux-arm-kernel@lists.infradead.org; Wed, 11 Jan 2017 17:02:47 +0000 Received: by mail-wj0-x22b.google.com with SMTP id kq3so61424123wjc.0 for ; Wed, 11 Jan 2017 09:02:26 -0800 (PST) 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=cvSxO0YnJXLU8GfoHkAQ/KLXNz+E/Tx+ozPt63CoWAU=; b=JmMeSirahaPN8tQF90ZWGv+2bzWHYv6NCouvLBhoX8BcyA85NvkVFEvNKMSPwD+3bg 0jPkl/hdh7LjIblwKi67kPkXM59njvjQjALfFlEMruXXkIZCV6tdFvG3fFVJlclYqyFk lKzhnE9wnyLMFvOVJ0Gos5fNGHTW/RUQMEvU8= 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=cvSxO0YnJXLU8GfoHkAQ/KLXNz+E/Tx+ozPt63CoWAU=; b=k3JLLYS8diIyeOsIhAUGFO8YlXyMQAT65/9iHr+0U2p4+FGjc9lJ8XATQnH0Ph7KW9 3lEAfksNItYUPFTelNz4YIVx89vrO26nkvUp+tVYXvnMe7P7Xc5hBK5GJsfNq3aCQNWw wU1Qb+uJMOwnr6cFXknQFLuL9URawRUAbEHeXO+WdfNLfsddiZmEIHi2rcBCyp/iDdU1 f7XYilZrhj4/xsjYOMFfazP9z2yhT30VPGpifhv4F6JJI+ecpUcO7qJpSdY0YaC+ySJH AFu6Q9sdV+Ny32WaO7O5wJB6sTNvtOReR7L49obaa5xpfdQYW4B88cKHERnruUmGV2hs Y0/g== X-Gm-Message-State: AIkVDXKpfQG/lnx5ru/gj013kgPi6Fc43zlLr5T+lvmQlnn7ayT16rcHfUnnPtHAAays2m8o X-Received: by 10.194.146.228 with SMTP id tf4mr5998840wjb.183.1484154145426; Wed, 11 Jan 2017 09:02:25 -0800 (PST) Received: from localhost.localdomain ([160.167.203.25]) by smtp.gmail.com with ESMTPSA id o132sm9873491wmo.17.2017.01.11.09.02.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jan 2017 09:02:24 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 1/5] ARM: wire up HWCAP2 feature bits to the CPU modalias Date: Wed, 11 Jan 2017 17:01:54 +0000 Message-Id: <1484154118-22139-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484154118-22139-1-git-send-email-ard.biesheuvel@linaro.org> References: <1484154118-22139-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170111_090246_088372_6BE08AF5 X-CRM114-Status: GOOD ( 15.42 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c01:0:0:0:22b listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux@armlinux.org.uk, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Wire up the generic support for exposing CPU feature bits via the modalias in /sys/device/system/cpu. This allows udev to automatically load modules for things like crypto algorithms that are implemented using optional instructions. Signed-off-by: Ard Biesheuvel --- arch/arm/Kconfig | 1 + arch/arm/include/asm/cpufeature.h | 32 ++++++++++++++++++++ 2 files changed, 33 insertions(+) -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 5fab553fd03a..3758466365ee 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -21,6 +21,7 @@ config ARM select GENERIC_ALLOCATOR select GENERIC_ATOMIC64 if (CPU_V7M || CPU_V6 || !CPU_32v6K || !AEABI) select GENERIC_CLOCKEVENTS_BROADCAST if SMP + select GENERIC_CPU_AUTOPROBE select GENERIC_EARLY_IOREMAP select GENERIC_IDLE_POLL_SETUP select GENERIC_IRQ_PROBE diff --git a/arch/arm/include/asm/cpufeature.h b/arch/arm/include/asm/cpufeature.h new file mode 100644 index 000000000000..134bd4c63d53 --- /dev/null +++ b/arch/arm/include/asm/cpufeature.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2017 Linaro Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __ASM_CPUFEATURE_H +#define __ASM_CPUFEATURE_H + +#include + +/* + * Due to the fact that ELF_HWCAP is a 32-bit type on ARM, and given the number + * of optional CPU features it defines, ARM's CPU capability bits have been + * distributed over separate elf_hwcap and elf_hwcap2 variables, each of which + * covers a subset of the available CPU features. + * + * Currently, only a few of those are suitable for automatic module loading + * (which is the primary use case of this facility) and those happen to be all + * covered by HWCAP2. So let's only expose those via the CPU modalias for now. + */ +#define MAX_CPU_FEATURES (8 * sizeof(elf_hwcap2)) +#define cpu_feature(x) ilog2(HWCAP2_ ## x) + +static inline bool cpu_have_feature(unsigned int num) +{ + return elf_hwcap2 & (1UL << num); +} + +#endif