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: 3758141 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8EE909F382 for ; Tue, 4 Mar 2014 01:11:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AF289203E5 for ; Tue, 4 Mar 2014 01:10:59 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 96E13203E3 for ; Tue, 4 Mar 2014 01:10:58 +0000 (UTC) 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-0001fs-Hw; 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-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=tLpG8OSaLLwo/r1iJyewCrEmm6DRtWkdh2d2icwRNy4=; b=L58XQJdbU9itMc8c6x9PYv/MrosgFlY7U+7A2fK4HXjEdtBR/FarTGp8Xh9UpkQ8xY mz+ZFiyNjiTQNtJ7pkFndsjdAEdtqJ09ZiDa5Tc63vNF33uIFZXJIpGm+GSrpdM6YrDe e9auv2xyKRKhRpX8uISN5wMBTVrMWm2aaGkz4eWv18XdLW9ewrZq+do8t9cN3+Evk2g8 xoGxSPqt63JmV8HlgeE5qkqr74HU6ndCuhcucqkG5haiEuxSHI54xy2hpQUu7ezSPcfj KqrH4Je64nFxY+cRFDGkIxWDMxVSkKobzXGU21wgJT/xEysImIyuJNtP1x1A50Qt7CJr Vv1g== X-Gm-Message-State: ALoCoQm1J9oJMitG30UbpuMpksLbI2vhYr1tqPzgpUUxIJlxK00Ytlznh5rKQTuYLibjcJ/6Cjej 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 (-) 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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