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 X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6329AC433E2 for ; Tue, 8 Sep 2020 08:13:51 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 F03DF21D20 for ; Tue, 8 Sep 2020 08:13:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="FxblpU7/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F03DF21D20 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2g6+xAD57GXC9oTyt6KolsCk7G1tnHbZjQRA5oXHi48=; b=FxblpU7/EFl97u9pcABhNadtE T2BJHUmLamlsIZEu4beRrRhvuyvAGua+EmoWY5Q2iId7/34oQOWn7YdlSqxs5r3LZYQ1xmUt8K32q uxdWIsnqoI0fba2kKlhu/L6KDjfjaCUJMLCs6AYmGdCc4WNl2LkP7hk2GiON3CCDZKzI5NE752gzX 5wgMt6Boqqb5xdb/GcNHxbUM+pAzSGPfDHKGHbaixZ8dvkdxg3+rFqvwbRSWHcNVCi46v+nI9ZxLe xsgCjiZ7u6Dvq798VnNiN/wHXSB+XEoU5N09dnBlwD3MjjmnD/4vDjb8EwdSA3xeHCy/UOazCT9Se 5kjYt/Pzw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFYjr-000203-LK; Tue, 08 Sep 2020 08:12:27 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFYjo-0001zb-Ua for linux-arm-kernel@lists.infradead.org; Tue, 08 Sep 2020 08:12:26 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A0ED41045; Tue, 8 Sep 2020 01:12:21 -0700 (PDT) Received: from [10.163.71.211] (unknown [10.163.71.211]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C8B523F66E; Tue, 8 Sep 2020 01:12:18 -0700 (PDT) Subject: Re: [PATCH V3] arm64/cpuinfo: Define HWCAP name arrays per their actual bit definitions To: Will Deacon References: <1597665863-564-1-git-send-email-anshuman.khandual@arm.com> <20200907121611.GA12237@willie-the-truck> <20200908074059.GA14790@willie-the-truck> From: Anshuman Khandual Message-ID: <2daa3ea9-b9f0-3549-6458-158410576dff@arm.com> Date: Tue, 8 Sep 2020 13:41:46 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200908074059.GA14790@willie-the-truck> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200908_041225_099198_DF892689 X-CRM114-Status: GOOD ( 23.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Suzuki K Poulose , catalin.marinas@arm.com, linux-kernel@vger.kernel.org, Ard Biesheuvel , Mark Brown , Dave Martin , linux-arm-kernel@lists.infradead.org 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 On 09/08/2020 01:11 PM, Will Deacon wrote: > On Tue, Sep 08, 2020 at 10:43:12AM +0530, Anshuman Khandual wrote: >> >> >> On 09/07/2020 05:46 PM, Will Deacon wrote: >>> On Mon, Aug 17, 2020 at 05:34:23PM +0530, Anshuman Khandual wrote: >>>> HWCAP name arrays (hwcap_str, compat_hwcap_str, compat_hwcap2_str) that are >>>> scanned for /proc/cpuinfo are detached from their bit definitions making it >>>> vulnerable and difficult to correlate. It is also bit problematic because >>>> during /proc/cpuinfo dump these arrays get traversed sequentially assuming >>>> they reflect and match actual HWCAP bit sequence, to test various features >>>> for a given CPU. This redefines name arrays per their HWCAP bit definitions >>>> . It also warns after detecting any feature which is not expected on arm64. >>>> >>>> Cc: Catalin Marinas >>>> Cc: Will Deacon >>>> Cc: Mark Brown >>>> Cc: Dave Martin >>>> Cc: Ard Biesheuvel >>>> Cc: Mark Rutland >>>> Cc: Suzuki K Poulose >>>> Cc: linux-arm-kernel@lists.infradead.org >>>> Cc: linux-kernel@vger.kernel.org >>>> Signed-off-by: Anshuman Khandual >>>> --- >>>> This applies on 5.9-rc1 >>>> >>>> Mark, since the patch has changed I have dropped your Acked-by: tag. Are you >>>> happy to give a new one ? >>>> >>>> Changes in V3: >>>> >>>> - Moved name arrays to (arch/arm64/kernel/cpuinfo.c) to prevent a build warning >>>> - Replaced string values with NULL for all compat features not possible on arm64 >>>> - Changed compat_hwcap_str[] iteration on size as some NULL values are expected >>>> - Warn once after detecting any feature on arm64 that is not expected >>>> >>>> Changes in V2: (https://patchwork.kernel.org/patch/11533755/) >>>> >>>> - Defined COMPAT_KERNEL_HWCAP[2] and updated the name arrays per Mark >>>> - Updated the commit message as required >>>> >>>> Changes in V1: (https://patchwork.kernel.org/patch/11532945/) >>>> >>>> arch/arm64/include/asm/hwcap.h | 9 +++ >>>> arch/arm64/kernel/cpuinfo.c | 172 ++++++++++++++++++++++------------------- >>>> 2 files changed, 100 insertions(+), 81 deletions(-) >>> >>> [...] >>> >>>> + [KERNEL_HWCAP_FP] = "fp", >>>> + [KERNEL_HWCAP_ASIMD] = "asimd", >>>> + [KERNEL_HWCAP_EVTSTRM] = "evtstrm", >>>> + [KERNEL_HWCAP_AES] = "aes", >>> >>> It would be nice if the cap and the string were generated by the same >>> macro, along the lines of: >>> >>> #define KERNEL_HWCAP(c) [KERNEL_HWCAP_##c] = #c, >>> >>> Does making the constants mixed case break anything, or is it just really >>> churny to do? >> >> Currently all existing HWCAP feature strings are lower case, above change >> will make them into upper case instead. I could not find a method to force >> convert #c into lower case constant strings in the macro definition. Would >> not changing the HWCAP string case here, break user interface ? > > Yes, we can't change the user-visible strings, but what's wrong with > having e.g. KERNEL_HWCAP_fp instead of KERNEL_HWCAP_FP? Unlike the new compat macros i.e COMPAT_KERNEL_HWCAP[2] in this patch, KERNEL_HWCAP_XXX macros are already defined and are getting used else where (arch/arm64/kernel/cpufeature.c) as well. [KERNEL_HWCAP_##c] can only be used here, if the input string is in upper case. Otherwise all these existing macros need to be changed first, which will result in too much code churn. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel