From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57519C433EF for ; Wed, 27 Oct 2021 18:56:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 204C8600EF for ; Wed, 27 Oct 2021 18:56:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 204C8600EF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kPE8E4WxUY6RCsaCGAUGs3EFc88LczqErXO352bSmmM=; b=V5PzVNPoK/5FAK I57KXw8dKFu9JTU1TZJkdfNt64ewMlRhnDhljWAYIdoZorA0EQTeoHiC4unevAYI3fwwyFpEUjRfI bUi8OBFR/wToaeFYmtivrDxNf0cXLasBI1SmGM4N0qglpoNeMsdcKJ8ruZ7s5/luNPtxf/YbCo4h9 ms1Iiz/XcJ2w8wAzDr4vkksX4l8if7XHKw4jikhzqVNnBlh4+T6rxvLH1DNicF5kYzkUAfwqd7exe t167k3wVi0zzTxmzOwj9xaZS3uDGn26+GiuTn4YcdKgNFdLTtEKh0DX9Svz6DIiNZCpWmq8KgWNBB DEIcrxBPEfWKTUBPe5xg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfo49-005iYR-CK; Wed, 27 Oct 2021 18:54:26 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfo19-005gWU-CY for linux-arm-kernel@lists.infradead.org; Wed, 27 Oct 2021 18:51:20 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 88E06610CA; Wed, 27 Oct 2021 18:51:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635360679; bh=Xsn3FkGjlA3xQ8mCSRT/zKEYgsuq8aDGFT9y2Y/GifQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=baxq2/3XIOh4bNIlLhcUTVhEPti4+YuTJDj9ldl4Yy92EWwryfm5lXx95XyCGk7EM 1r9t4QREWBx2cTxkongkv5NyjMTKjxGa+vxWdTX/7bp+jRbHwEzdlWTXglQTOvlVx8 1/4GB4+OnmbhWJhuZztjqnxRB+383xwOZj0/KDFOONV2g5pXYupcEYp/CyVc4pZRID YfKIQaUdNpQ+WNNtpnnmroXcmzjj6XhAYIHa/usWCe4v+9XPkaOmFFqdx44SHlA015 ePb7CM56Q/s6mH6O151fZdtyyepZlVe1IZ2J4OZT8wCSTU4eW11giJCeyleLA/rjQO RsWpwMxdvgpWw== From: Mark Brown To: Catalin Marinas , Will Deacon , Shuah Khan , Shuah Khan Cc: Alan Hayward , Luis Machado , Salil Akerkar , Basant Kumar Dwivedi , Szabolcs Nagy , linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown , Suzuki K Poulose Subject: [PATCH v5 09/38] arm64: cpufeature: Add has_feature_flag() match function Date: Wed, 27 Oct 2021 19:43:55 +0100 Message-Id: <20211027184424.166237-10-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211027184424.166237-1-broonie@kernel.org> References: <20211027184424.166237-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2131; h=from:subject; bh=Xsn3FkGjlA3xQ8mCSRT/zKEYgsuq8aDGFT9y2Y/GifQ=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBheZ3t7bCYwYvYMxRVjhGdYvloVJNrbyOgDrOBJPd8 JBu0hEmJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYXmd7QAKCRAk1otyXVSH0NnyB/ 9cyNL1b57NXD1GyShIQhqMgJvFi47XzCwfyD1Qf7WkpEg2TeTPmIjKX7Bi4GNkQanrlM0FWQsv6DsB 9Fja8jploP+X8xiOmPevcs8zxR4NEIsgLS9RvLj6Vtn840Iys5Sfq3Fnxpb/pGBh4jpSk4TCmKWe8s m44OBJsjWfP5WKIM5fCREdDWD9ucleqdWg1PjjhvXxaI0rT8E+6ni9arO4WrtBUaJtBq8b09z8jlan h0sPP+IHeFWZ1KGOy7dXcQkocCn1DlBP1Eleu2hF7C3jSD9m8YxYSsGgxqbf3gwYF9A9qyaxaET9xY Pio0lNjp3K8RjjQMWPwDltx3WT4uLU X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211027_115119_501799_1C5F1405 X-CRM114-Status: GOOD ( 12.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The default has_cpuid_feature() match function operates on the standard 4 bit fields used in the main ID registers which can't be used with some of the ID registers used for SME extensions which have features identified by single bits and need to be exposed both as hwcaps and for kernel internal use. Support matching such simple flag based matches by providing an alternative match function which simply checks if the bit at the specified field_pos is set and provide helper macros for defining hwcaps using this match function rather than has_cpuid_feature(). Signed-off-by: Mark Brown Cc: Suzuki K Poulose --- arch/arm64/kernel/cpufeature.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 405a65d7e618..5fd56c6b294f 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1311,6 +1311,20 @@ has_cpuid_feature(const struct arm64_cpu_capabilities *entry, int scope) return feature_matches(val, entry); } +static bool +has_feature_flag(const struct arm64_cpu_capabilities *entry, int scope) +{ + u64 val; + + WARN_ON(scope == SCOPE_LOCAL_CPU && preemptible()); + if (scope == SCOPE_SYSTEM) + val = read_sanitised_ftr_reg(entry->sys_reg); + else + val = __read_sysreg_by_encoding(entry->sys_reg); + + return val & ((u64)1 << entry->field_pos); +} + const struct cpumask *system_32bit_el0_cpumask(void) { if (!system_supports_32bit_el0()) @@ -2367,6 +2381,18 @@ static const struct arm64_cpu_capabilities arm64_features[] = { .matches = match, \ } + +#define HWCAP_CPUID_FLAG_MATCH(reg, field) \ + .matches = has_feature_flag, \ + .sys_reg = reg, \ + .field_pos = field, + +#define HWCAP_CAP_FLAG(reg, field, cap_type, cap) \ + { \ + __HWCAP_CAP(#cap, cap_type, cap) \ + HWCAP_CPUID_FLAG_MATCH(reg, field) \ + } + #ifdef CONFIG_ARM64_PTR_AUTH static const struct arm64_cpu_capabilities ptr_auth_hwcap_addr_matches[] = { { -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel