Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3877171pxb; Mon, 8 Feb 2021 02:20:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJyU2EhOVG6paGRMFyegD9K9iqpyCs/k1fHFM2lb1PdyX30byeDUzKFhZmIbQg2N1OuDMXdp X-Received: by 2002:a17:907:aa9:: with SMTP id bz9mr15606510ejc.528.1612779639355; Mon, 08 Feb 2021 02:20:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612779639; cv=none; d=google.com; s=arc-20160816; b=alPdCmdtubKSrr2NW1n7CP/gQBfxIn3FiJ/C9KO+4ed2uVrs9D7nx8fjIpc9rhd5/1 3bwJDTF6EEgM9rrU9olJkxsO6QXrAUNlISUYyBhEeLnBfeIHZ7HpLjBKEjtdxSmR5nrI blTO11xVQIq6TwPlkESbbeMMNvSMxpnBGL3F0JuHNawKLaPKDmaDSh98hg68sLQa3xDn pmhICNHLdbYLOCRKLKa/K2/9O0UkR9bjQlrwuSjKE658av881dECW3AsFPtwj9anpxPi mdNm9q3cXZQUdVQ4vIDyXsXqLJnQ9NG0xHhzBNPwfu9mYS5mTwj9/hfB9vzKEhi9D6UM Ky8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=z+wQ0yDjYVK64ksL1bgsInRDVx4FjS4Y0Jh5kxKbEKU=; b=WkrUEtl14g8oOoDuvBLcysxsukQWDBOmFaCXJJb+gWMVP7Povey4K+KsKi+TI5oZfq Ytsua0SqRXwFeqnGf9Vp8h30aY80QgEZEiECehVu6W8XwVwYKFUsZCk3kYeNOpP5ISgg Mh0SIlis6uhL861njv2f7IohhOStiVtZIzEJ9zRjBdOq5XwViNPuBv1+YA4DQ8S5IlBn fSUt/2c8W51ulnkYgbgTklgpXg7OBtB28mJ6717uaaSqkR5GkTTolFGba18cZZAwmWNg ZqX4wYNr9XWOzuiJCxQIPkXyee6Qwy2ovmZpFqgM7Oh4Mg+pjhIXnrW5Zk4bTWad/sdY kGnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h22si11581345edj.344.2021.02.08.02.20.15; Mon, 08 Feb 2021 02:20:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232069AbhBHKSL (ORCPT + 99 others); Mon, 8 Feb 2021 05:18:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:59712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231797AbhBHKFE (ORCPT ); Mon, 8 Feb 2021 05:05:04 -0500 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 570C564E88; Mon, 8 Feb 2021 10:04:23 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1l93Is-00Ck14-W6; Mon, 08 Feb 2021 09:57:59 +0000 From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Mark Rutland , David Brazdil , Alexandru Elisei , Ard Biesheuvel , Jing Zhang , Ajay Patil , Prasad Sodagudi , Srinivas Ramana , Hector Martin , James Morse , Julien Thierry , Suzuki K Poulose , kernel-team@android.com Subject: [PATCH v7 11/23] arm64: cpufeature: Use IDreg override in __read_sysreg_by_encoding() Date: Mon, 8 Feb 2021 09:57:20 +0000 Message-Id: <20210208095732.3267263-12-maz@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210208095732.3267263-1-maz@kernel.org> References: <20210208095732.3267263-1-maz@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, dbrazdil@google.com, alexandru.elisei@arm.com, ardb@kernel.org, jingzhangos@google.com, pajay@qti.qualcomm.com, psodagud@codeaurora.org, sramana@codeaurora.org, marcan@marcan.st, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org __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 Reviewed-by: Suzuki K Poulose Acked-by: David Brazdil Reviewed-by: Catalin Marinas --- arch/arm64/include/asm/cpufeature.h | 1 + arch/arm64/kernel/cpufeature.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index b1f53147e2b2..b5bf7af68691 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -606,6 +606,7 @@ void __init setup_cpu_features(void); void check_local_cpu_capabilities(void); u64 read_sanitised_ftr_reg(u32 id); +u64 __read_sysreg_by_encoding(u32 sys_id); static inline bool cpu_supports_mixed_endian_el0(void) { diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index a4e5c619a516..97da9ed4b79d 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1148,14 +1148,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); @@ -1198,6 +1201,14 @@ static u64 __read_sysreg_by_encoding(u32 sys_id) BUG(); return 0; } + + regp = get_arm64_ftr_reg(sys_id); + if (regp) { + val &= ~regp->override->mask; + val |= (regp->override->val & regp->override->mask); + } + + return val; } #include -- 2.29.2