Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp700763iog; Fri, 17 Jun 2022 11:34:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vVVwMVnTg9jfjgnKIkvfXj8sbfz912YIQ8mfqLoqfQ4VsBLyqVRZ2NgAHL61KXe+awf+zq X-Received: by 2002:a17:906:5047:b0:710:456a:695e with SMTP id e7-20020a170906504700b00710456a695emr10374782ejk.433.1655490840243; Fri, 17 Jun 2022 11:34:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655490840; cv=none; d=google.com; s=arc-20160816; b=ZQ3mVdkLzrv8JkWeBR/3dD91aSiy6+CAM6JYarOp8sj6haGD6VzWVamXxa0fO4A59r +/NnKm7SllfHvwo2JIR6CgqGcIWrP/91qaf3JopccXqXMhu916WZILuIregLnsVzDi04 F4R606WKpFb7NacnDKfxZn/IoNo/B57DMiGCuP/pbmIOTi39j4wPfBDf1FpyW2DT2p35 xFlB3dWasIhUHoBCfoJcnLsi9WxDL9HjF83zFTFWv0Y6Ht8Ee20qWmDWuuyqdM2Lncad 855WCGKHHbwzmP2cKDMuU2bVCaR/7a0nGK8Us1SbOaP/uOg06DVlXZKYhSB6jkm7FiZd 4xkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Y76kZ0lKNy7hLuz/DelrdLdQImF/Of48EBnxr+132Ps=; b=Xfx1QygD0PX9+e/KEWBjRDyYAxqdbdIT6BkaxRe4FxffbhbfXhz+gyrt6qxuo3FRUI yKSnttqQ82tYaCBZfETKS7XnezB/E8xV/8Ni6z7E3hQwvOTuEEsFXaeRvttsJ2hRWFAm KGbXsBp4vEJNY5195B/UGVWrm9zgJ4vvHTgMesh44nfsL92XCPFYD4VlXa1xtG0NU2vo 92oNEd9QlqWqC99wZj3efvPpfVMl/DdrD9NIqNkCBbdQpDxZahdXNdr48R4fmQp8l+2i 0HnUo4kdbULd1ObnyOdMmpjQLpAOLYTspeU3aqaZYj+dQk8uCUEq5HDn0cg4eqZRhnyh Hwyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m17-20020a056402431100b0043198fec649si7275826edc.32.2022.06.17.11.33.35; Fri, 17 Jun 2022 11:34:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229737AbiFQSYp (ORCPT + 99 others); Fri, 17 Jun 2022 14:24:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbiFQSYn (ORCPT ); Fri, 17 Jun 2022 14:24:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3557E19FB9 for ; Fri, 17 Jun 2022 11:24:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D0966B82815 for ; Fri, 17 Jun 2022 18:24:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F62AC3411B; Fri, 17 Jun 2022 18:24:39 +0000 (UTC) Date: Fri, 17 Jun 2022 19:24:35 +0100 From: Catalin Marinas To: Ionela Voinescu Cc: Will Deacon , James Morse , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm64: errata: add detection for AMEVCNTR01 incrementing incorrectly Message-ID: References: <20220607125340.13635-1-ionela.voinescu@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 14, 2022 at 02:42:58PM +0100, Ionela Voinescu wrote: > On Friday 10 Jun 2022 at 17:47:12 (+0100), Catalin Marinas wrote: > > On Tue, Jun 07, 2022 at 01:53:40PM +0100, Ionela Voinescu wrote: > > > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > > > index 42ea2bd856c6..b9e4b2bd2c63 100644 > > > --- a/arch/arm64/kernel/cpufeature.c > > > +++ b/arch/arm64/kernel/cpufeature.c > > > @@ -1791,6 +1791,19 @@ int get_cpu_with_amu_feat(void) > > > return cpumask_any(&amu_cpus); > > > } > > > > > > +bool cpu_has_broken_amu_constcnt(void) > > > +{ > > > + /* List of CPUs which have broken AMEVCNTR01 (constant counter) */ > > > + static const struct midr_range cpus[] = { > > > +#ifdef CONFIG_ARM64_ERRATUM_2457168 > > > + MIDR_RANGE(MIDR_CORTEX_A510, 0, 0, 1, 1), > > > +#endif > > > + {}, > > > + }; > > > + > > > + return is_midr_in_range(read_cpuid_id(), cpus); > > > +} > > > > I'd rather not have this in cpufeature.c as it's not really a feature. > > We have some precedent with checking errata in cpufeature.c but IIRC we > > did that only to check whether to enable a feature or not in that file > > (DBM). > > If it's okay with you I can move this to cpu_errata.c:arm64_errata[], but > the type of the capability would have to be > ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE. I see there are other workarounds > like this so I hope it's not a problem. I think this should work. If you want to make a per-CPU decision, instead of checking cpus_have_const_cap(), use this_cpu_has_cap(). It would read the actual CPU regs pretty much like your cpu_has_broken_amu_constcnt() but at least is more unified with the errata framework. -- Catalin