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=-15.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,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 490AEC433DB for ; Sat, 23 Jan 2021 16:06:09 +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 0F08122A84 for ; Sat, 23 Jan 2021 16:06:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F08122A84 Authentication-Results: mail.kernel.org; dmarc=fail (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-Type: Content-Transfer-Encoding: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=uflDqZk2LBIjIG9qM+o1tS+aXEEvR8UMBGH+38svxPg=; b=TwSBa64D1g5iOlgS8fXUwDYNc 3UMqNjDRYJ4OyuJdDnmH/qyJAWuvMll0ccFcRHz85ddLPCvcNK+zP63mtR+oUnZyCG8AxAm6xTJxp bNjZX3bkN9ofFPPnlrBwEqokGtsiqH2CXkn/igoVFAdYDa/Vv+QvdV3wRBaewzDzdY/HfsDcWilQH qLiByLCcuanSj9ApX6bumqWFXQq9IgzDL5VtgrBdksagF4loffMIAMdg/t0ftXdmNE+P0hJ55hQb1 9K6u6cf3gLuLTkIzQsFUmerepCDY8e8M7jfOU4h0Otxrs9aUMnzN9I636f0cmaXdXzfAlfGF0VKkH vAoTpAtqQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l3LP2-0002mt-AR; Sat, 23 Jan 2021 16:04:44 +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 1l3LOz-0002mT-N8 for linux-arm-kernel@lists.infradead.org; Sat, 23 Jan 2021 16:04:42 +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 9EA4B11D4; Sat, 23 Jan 2021 08:04:40 -0800 (PST) Received: from [10.57.40.145] (unknown [10.57.40.145]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 60D263F68F; Sat, 23 Jan 2021 08:04:34 -0800 (PST) Subject: Re: [PATCH v4 10/21] arm64: cpufeature: Use IDreg override in __read_sysreg_by_encoding() To: Catalin Marinas , Marc Zyngier References: <20210118094533.2874082-1-maz@kernel.org> <20210118094533.2874082-11-maz@kernel.org> <20210122185344.GH8567@gaia> From: Suzuki K Poulose Message-ID: <95659e7f-090e-0ff7-3e89-1ed17df68e6d@arm.com> Date: Sat, 23 Jan 2021 16:04:26 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <20210122185344.GH8567@gaia> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210123_110441_859538_9B3384CB X-CRM114-Status: GOOD ( 21.21 ) 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 , Jing Zhang , Prasad Sodagudi , Srinivas Ramana , kernel-team@android.com, Alexandru Elisei , linux-kernel@vger.kernel.org, Ard Biesheuvel , James Morse , Julien Thierry , Ajay Patil , David Brazdil , Will Deacon , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 1/22/21 6:53 PM, Catalin Marinas wrote: > On Mon, Jan 18, 2021 at 09:45:22AM +0000, Marc Zyngier wrote: >> __read_sysreg_by_encoding() is used by a bunch of cpufeature helpers, >> which should take the feature override into account. Let's do that. >> >> For a good measure (and because we are likely to need to further >> down the line), make this helper available to the rest of the >> non-modular kernel. >> >> Code that needs to know the *real* features of a CPU can still >> use read_sysreg_s(), and find the bare, ugly truth. >> >> Signed-off-by: Marc Zyngier >> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c >> index aaa075c6f029..48a011935d8c 100644 >> --- a/arch/arm64/kernel/cpufeature.c >> +++ b/arch/arm64/kernel/cpufeature.c >> @@ -1149,14 +1149,17 @@ u64 read_sanitised_ftr_reg(u32 id) >> EXPORT_SYMBOL_GPL(read_sanitised_ftr_reg); >> >> #define read_sysreg_case(r) \ >> - case r: return read_sysreg_s(r) >> + case r: val = read_sysreg_s(r); break; >> >> /* >> * __read_sysreg_by_encoding() - Used by a STARTING cpu before cpuinfo is populated. >> * Read the system register on the current CPU >> */ >> -static u64 __read_sysreg_by_encoding(u32 sys_id) >> +u64 __read_sysreg_by_encoding(u32 sys_id) >> { >> + struct arm64_ftr_reg *regp; >> + u64 val; >> + >> switch (sys_id) { >> read_sysreg_case(SYS_ID_PFR0_EL1); >> read_sysreg_case(SYS_ID_PFR1_EL1); >> @@ -1199,6 +1202,14 @@ static u64 __read_sysreg_by_encoding(u32 sys_id) >> BUG(); >> return 0; >> } >> + >> + regp = get_arm64_ftr_reg(sys_id); >> + if (regp && regp->override_mask && regp->override_val) { >> + val &= ~*regp->override_mask; >> + val |= (*regp->override_val & *regp->override_mask); >> + } >> + >> + return val; > > Ah, now the previous patch makes more sense. I don't particularly like > this but I can't tell how to work around it. I was hoping that the > overriding feature behaves more like a secondary CPU that limits all the > overridden features. However, this approach would fail for FTR_EXACT > cases (like PAC, though I wonder whether it fails already with your > previous patch since the boot CPU value won't match the override, hence > dropping to the safe one). > Correct !For FTR_EXACT, we dont want to override a value that is not safe, e.g PAC. This is handled correctly in the previous patch and thus we are covered. Reviewed-by: Suzuki K Poulose _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel