From patchwork Tue Mar 4 01:10:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 25632 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f200.google.com (mail-ve0-f200.google.com [209.85.128.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9B68120540 for ; Tue, 4 Mar 2014 01:11:04 +0000 (UTC) Received: by mail-ve0-f200.google.com with SMTP id oy12sf7077850veb.7 for ; Mon, 03 Mar 2014 17:11:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id:cc :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=PieEYoUaNwONfnAlCMIyidy+N8NwVlm8QqbLWmSjq3E=; b=kiBQJeyqiZqYizCK33dS1JgDKUoSh03UU9jDM12p1+dimr/ATqzqbo/n7c4EuWCH04 3ryu9nB5wedmD5x693oInzgFN1x3FTaoRU8C3e7xNfZeyFoBKxKebYGdS//hixweoEEA LAW19U+5UOx5BWwCy4HkDHxheeClqmAchVPG4OzUQpk0fgZU3Uaf9QI2HjQBuEsyi8b4 VDNqeUPLw5C1eOQfBNN/shzTYd8vatnzQdAHkkxpqtAmJADfYJ/bRrRWMfrtzheEh1iE 3iqlTwIsqOrhcvK5a8AgNVduw7NV97Rbk4dyldIkeqBfE9Q+05H8ljY0F6oZvbMqxmcL aInQ== X-Gm-Message-State: ALoCoQk+y+zkgPBM/xvz77L9R7apiBh39e1TjVciQN7tp+9OHZ+CuHj5n6pTtkBHXmYJHRrgQYn4 X-Received: by 10.52.187.41 with SMTP id fp9mr1099407vdc.5.1393895464105; Mon, 03 Mar 2014 17:11:04 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.84.239 with SMTP id l102ls2469286qgd.5.gmail; Mon, 03 Mar 2014 17:11:04 -0800 (PST) X-Received: by 10.52.250.236 with SMTP id zf12mr1638678vdc.9.1393895463986; Mon, 03 Mar 2014 17:11:03 -0800 (PST) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id n15si5351213vcy.27.2014.03.03.17.11.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Mar 2014 17:11:03 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id sa20so4573927veb.36 for ; Mon, 03 Mar 2014 17:11:03 -0800 (PST) X-Received: by 10.221.55.133 with SMTP id vy5mr19658711vcb.17.1393895463893; Mon, 03 Mar 2014 17:11:03 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.130.193 with SMTP id u1csp92306vcs; Mon, 3 Mar 2014 17:11:03 -0800 (PST) X-Received: by 10.194.216.68 with SMTP id oo4mr10942033wjc.79.1393895462979; Mon, 03 Mar 2014 17:11:02 -0800 (PST) Received: from casper.infradead.org (casper.infradead.org. [2001:770:15f::2]) by mx.google.com with ESMTPS id k6si13124349wja.131.2014.03.03.17.11.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Mar 2014 17:11:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:770:15f::2 as permitted sender) client-ip=2001:770:15f::2; Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WKdse-0001fr-E1; Tue, 04 Mar 2014 01:10:48 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WKdsc-0002Ya-6f; Tue, 04 Mar 2014 01:10:46 +0000 Received: from mail-pd0-f178.google.com ([209.85.192.178]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WKdsX-0002Y7-KU for linux-arm-kernel@lists.infradead.org; Tue, 04 Mar 2014 01:10:43 +0000 Received: by mail-pd0-f178.google.com with SMTP id x10so4444453pdj.9 for ; Mon, 03 Mar 2014 17:10:16 -0800 (PST) X-Received: by 10.68.224.195 with SMTP id re3mr22870107pbc.93.1393895416660; Mon, 03 Mar 2014 17:10:16 -0800 (PST) Received: from ards-macbook-pro.local (z88l218.static.ctm.net. [202.175.88.218]) by mx.google.com with ESMTPSA id it4sm41078895pbc.39.2014.03.03.17.10.13 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Mar 2014 17:10:15 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH] arm64: enable generic CPU feature modalias matching for this architecture Date: Tue, 4 Mar 2014 09:10:04 +0800 Message-Id: <1393895404-14776-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140303_201041_759025_8854E091 X-CRM114-Status: GOOD ( 16.53 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.192.178 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] Cc: Ard Biesheuvel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 This enables support for the generic CPU feature modalias implementation that wires up optional CPU features to udev based module autoprobing. A file is provided that maps CPU feature numbers to elf_hwcap bits, which is the standard way on arm64 to advertise optional CPU features both internally and to user space. Signed-off-by: Ard Biesheuvel --- The generic part of this code was pulled by Greg-KH into driver-core and has been sitting in -next for about 2 weeks, so it is expected to be merged in 3.15. http://git.kernel.org/cgit/linux/kernel/git/gregkh/driver-core.git/commit/?h=driver-core-next&id=67bad2fdb754 This is a soft prerequisite for the crypto patches that enable v8 Crypto Extensions in the kernel, as it allows those modules to be loaded automatically based on the presence of the extensions. The modalias advertised by the CPU looks something like cpu:type:aarch64:features:,0001,0002,0003 The modalias match entry in, e.g., the AES module would look like cpu:type:*:features:*0003* arch/arm64/Kconfig | 1 + arch/arm64/include/asm/cpufeature.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 arch/arm64/include/asm/cpufeature.h diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 27bbcfc7202a..3d27a1c4e4ad 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -16,6 +16,7 @@ config ARM64 select DCACHE_WORD_ACCESS select GENERIC_CLOCKEVENTS select GENERIC_CLOCKEVENTS_BROADCAST if SMP + select GENERIC_CPU_AUTOPROBE select GENERIC_IOMAP select GENERIC_IRQ_PROBE select GENERIC_IRQ_SHOW diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h new file mode 100644 index 000000000000..019e4fe24d56 --- /dev/null +++ b/arch/arm64/include/asm/cpufeature.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2014 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 + +/* + * In the arm64 world (as in the ARM world), elf_hwcap is used both internally + * in the kernel and for user space to keep track of which optional features + * are supported by the current system. So let's map feature 'x' to HWCAP_x. + * Note that HWCAP_x constants are bit fields so we need to take the log. + */ + +#define MAX_CPU_FEATURES (8 * sizeof(elf_hwcap)) +#define cpu_feature(x) ilog2(HWCAP_ ## x) + +static inline bool cpu_have_feature(unsigned int num) +{ + return !!(elf_hwcap & (1UL << num)); +} + +#endif