From nobody Fri Apr 19 10:52:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1610495125; cv=none; d=zohomail.com; s=zohoarc; b=gG56Hiu4z2j4n5iG1RuaCSF6h6eAXAjNJdOLqUWhu6UAd2rh3llmS/5J34gkuu0dI/o/1LqV9FmAN90GHE1D9Pqwavb/dwOLlSDmERyIAjZ2Fr2DCIBk+6IQQN1UV719CAeVRBfZyJifkFA6olIUADH7T3JHWm7d+gwRyf9niXY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610495125; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=CpZq9+ggQV+xzZr1X4BGprdNRVBNTmXAuccPiwh+A1o=; b=VdYh1qPdEuYR0JNRdY3XuJH+33TBr6yhnPDIf3bRabebXWcFxsNl5J1erGJoNOydQKcCmPbPx3FmIvoODS+yxBfu4e475U4Gkh5SfIyKbwYhdduch6hsDJeDZ0XG1DyGnWUFbhmmzgFzNzfB1cqmwN8cxDqI9SzeAdUCrf6SJMo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1610495125832297.02079077443943; Tue, 12 Jan 2021 15:45:25 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.66204.117504 (Exim 4.92) (envelope-from ) id 1kzTLR-0007fL-W3; Tue, 12 Jan 2021 23:45:01 +0000 Received: by outflank-mailman (output) from mailman id 66204.117504; Tue, 12 Jan 2021 23:45:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kzTLR-0007fE-So; Tue, 12 Jan 2021 23:45:01 +0000 Received: by outflank-mailman (input) for mailman id 66204; Tue, 12 Jan 2021 23:45:01 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kzTLR-0007f9-0P for xen-devel@lists.xenproject.org; Tue, 12 Jan 2021 23:45:01 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id cc73fda0-7527-4609-a25c-ec594981ea6b; Tue, 12 Jan 2021 23:44:59 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id D692823120; Tue, 12 Jan 2021 23:44:58 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: cc73fda0-7527-4609-a25c-ec594981ea6b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610495099; bh=S/YjHVdaoHbilb3FppMkLOATNmhVGF368nEsdpllR6o=; h=From:To:Cc:Subject:Date:From; b=rynrGXdchN4GoUiYqLRZkq3JMJjysVdvLt7Z8Z8KV44XjibckfjPv88bnXdyfsdcg jSWYpor5cRP/TW+q480DIKJYskhxOXBZO/WMJ04kDYNsreiQHtyxWNWUB1bFNFsZ6G w4rUF6ABJCNh72/BpLVNAYFTpYLN+q1qJkZRye0xGXZOlRfYIo+fZOFzr7RH99Ttju aAijNLHHRc5mkerH9oT1oFiLbZydozkujNSB2THPlcSGIpto2Dgsr7p+KZrsuklN/h PVW40oODZdjeQ5Z8KGVYzHaJDOPyM59i5/2E7iPNjJxA3r1CwMDnke+iFW7f/0LI1d HytNSKpgzDMfQ== From: Stefano Stabellini To: xen-devel@lists.xenproject.org Cc: sstabellini@kernel.org, bertrand.marquis@arm.com, Volodymyr_Babchuk@epam.com, julien@xen.org, Stefano Stabellini Subject: [PATCH v2] xen/arm: don't read aarch32 regs when aarch32 isn't available Date: Tue, 12 Jan 2021 15:44:50 -0800 Message-Id: <20210112234450.31584-1-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 X-ZohoMail-DKIM: pass (identity @kernel.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Don't read aarch32 system registers at boot time when the aarch32 state is not available at EL0. They are UNKNOWN, so it is not useful to read them. Moreover, on Cavium ThunderX reading ID_PFR2_EL1 causes a Xen crash. Instead, only read them when aarch32 is available. Leave the corresponding fields in struct cpuinfo_arm so that they are read-as-zero from a guest. Since we are editing identify_cpu, also fix the indentation: 4 spaces instead of 8. Fixes: 9cfdb489af81 ("xen/arm: Add ID registers and complete cpuinfo") Link: https://lore.kernel.org/xen-devel/f90e40ee-b042-6cc5-a08d-aef41a27952= 7@suse.com/ Suggested-by: Julien Grall Signed-off-by: Stefano Stabellini Acked-by: Julien Grall Reviewed-by: Bertrand Marquis --- Changes in v2: - check el0 instead of el1 for aarch32 support - clarify EL0 in commit message - remove temporary link in commit message - use lore.kernel.org in commit message - introduce cpu_feature64_has_el0_32 - rename aarch32 to aarch32_el0 --- xen/arch/arm/cpufeature.c | 35 +++++++++++++++++++------------- xen/include/asm-arm/cpufeature.h | 2 ++ 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/xen/arch/arm/cpufeature.c b/xen/arch/arm/cpufeature.c index 698bfa0201..99fe4db280 100644 --- a/xen/arch/arm/cpufeature.c +++ b/xen/arch/arm/cpufeature.c @@ -101,29 +101,35 @@ int enable_nonboot_cpu_caps(const struct arm_cpu_capa= bilities *caps) =20 void identify_cpu(struct cpuinfo_arm *c) { - c->midr.bits =3D READ_SYSREG(MIDR_EL1); - c->mpidr.bits =3D READ_SYSREG(MPIDR_EL1); + bool aarch32_el0 =3D true; + + c->midr.bits =3D READ_SYSREG(MIDR_EL1); + c->mpidr.bits =3D READ_SYSREG(MPIDR_EL1); =20 #ifdef CONFIG_ARM_64 - c->pfr64.bits[0] =3D READ_SYSREG(ID_AA64PFR0_EL1); - c->pfr64.bits[1] =3D READ_SYSREG(ID_AA64PFR1_EL1); + c->pfr64.bits[0] =3D READ_SYSREG(ID_AA64PFR0_EL1); + c->pfr64.bits[1] =3D READ_SYSREG(ID_AA64PFR1_EL1); + + c->dbg64.bits[0] =3D READ_SYSREG(ID_AA64DFR0_EL1); + c->dbg64.bits[1] =3D READ_SYSREG(ID_AA64DFR1_EL1); =20 - c->dbg64.bits[0] =3D READ_SYSREG(ID_AA64DFR0_EL1); - c->dbg64.bits[1] =3D READ_SYSREG(ID_AA64DFR1_EL1); + c->aux64.bits[0] =3D READ_SYSREG(ID_AA64AFR0_EL1); + c->aux64.bits[1] =3D READ_SYSREG(ID_AA64AFR1_EL1); =20 - c->aux64.bits[0] =3D READ_SYSREG(ID_AA64AFR0_EL1); - c->aux64.bits[1] =3D READ_SYSREG(ID_AA64AFR1_EL1); + c->mm64.bits[0] =3D READ_SYSREG(ID_AA64MMFR0_EL1); + c->mm64.bits[1] =3D READ_SYSREG(ID_AA64MMFR1_EL1); + c->mm64.bits[2] =3D READ_SYSREG(ID_AA64MMFR2_EL1); =20 - c->mm64.bits[0] =3D READ_SYSREG(ID_AA64MMFR0_EL1); - c->mm64.bits[1] =3D READ_SYSREG(ID_AA64MMFR1_EL1); - c->mm64.bits[2] =3D READ_SYSREG(ID_AA64MMFR2_EL1); + c->isa64.bits[0] =3D READ_SYSREG(ID_AA64ISAR0_EL1); + c->isa64.bits[1] =3D READ_SYSREG(ID_AA64ISAR1_EL1); =20 - c->isa64.bits[0] =3D READ_SYSREG(ID_AA64ISAR0_EL1); - c->isa64.bits[1] =3D READ_SYSREG(ID_AA64ISAR1_EL1); + c->zfr64.bits[0] =3D READ_SYSREG(ID_AA64ZFR0_EL1); =20 - c->zfr64.bits[0] =3D READ_SYSREG(ID_AA64ZFR0_EL1); + aarch32_el0 =3D cpu_feature64_has_el0_32(c); #endif =20 + if ( aarch32_el0 ) + { c->pfr32.bits[0] =3D READ_SYSREG(ID_PFR0_EL1); c->pfr32.bits[1] =3D READ_SYSREG(ID_PFR1_EL1); c->pfr32.bits[2] =3D READ_SYSREG(ID_PFR2_EL1); @@ -153,6 +159,7 @@ void identify_cpu(struct cpuinfo_arm *c) #ifndef MVFR2_MAYBE_UNDEFINED c->mvfr.bits[2] =3D READ_SYSREG(MVFR2_EL1); #endif + } } =20 /* diff --git a/xen/include/asm-arm/cpufeature.h b/xen/include/asm-arm/cpufeat= ure.h index 6058744c18..13a2739a69 100644 --- a/xen/include/asm-arm/cpufeature.h +++ b/xen/include/asm-arm/cpufeature.h @@ -5,6 +5,8 @@ #define cpu_feature64(c, feat) ((c)->pfr64.feat) #define boot_cpu_feature64(feat) (boot_cpu_data.pfr64.feat) =20 +#define cpu_feature64_has_el0_32(c) (cpu_feature64(c, el0) =3D=3D 2) + #define cpu_has_el0_32 (boot_cpu_feature64(el0) =3D=3D 2) #define cpu_has_el0_64 (boot_cpu_feature64(el0) >=3D 1) #define cpu_has_el1_32 (boot_cpu_feature64(el1) =3D=3D 2) --=20 2.17.1