From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A04A93B19E for ; Mon, 12 Feb 2024 14:00:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707746452; cv=none; b=PU4rjpc5PDNXVnYaEUZ/cAl1fG7ncd/7OBDhx5J4IIKz3WFX4gCzmVRVTUQ2Qz4tPf5T+ir953zsGRo9hxI4DUYli7KcuD+S6kihDg3Uw3U8weQpKp1bHNqhYJuMskGp7m57j1Y02RMEWhpb7K06FMWpdU+/bXW9XPjV0Q7p3ts= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707746452; c=relaxed/simple; bh=/vkyCHmFM0WZYlkkthFUxg483NtsGf9YsNQH0br01aA=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=Jsy4KUru/YjoMb/Z+fAqkp3JtycG5TRPDQJlXTXAxH/RkeFTW8l8cXzWLFXbYTDszbN31nn5ike8RMAGt+yrTHEoO7DxLoKZ+JTM9Lo+eX6EsxkwXOzjbzwzOYBkhGZV1V4kZz4/968bRFcQvkoqj4ZVKHB8ai9Emk5XEbXDKvo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Sj4SU7DO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Sj4SU7DO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34B1AC433C7; Mon, 12 Feb 2024 14:00:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707746452; bh=/vkyCHmFM0WZYlkkthFUxg483NtsGf9YsNQH0br01aA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Sj4SU7DObFZmYwwKk3X4LKdSX9HkkBRBgNhhL+8TAgg6C+MMaNM52IKTha9aG1sLL NRccIu4D/RZF1g1EgQzRpuF4OQ7cXFquctUNUKUjrWO9nzt/XMwiDd/LeWWIw3WNgZ xogIlTEQsZWHUpG4eCWZUlXTBXe1b0CW6Opm+1NkctAxe+IHi5nQOJKgaxjgaUHwQ3 GkMfpJVOk/LYoUSuqlLUwIRbq8Ts8/jGg9+bFq/zo4Su7/Q3jK6kNdfugXRkmRdGvW agpy34uf1bNdSbsEqTsVJx0kCs0Y7oDZsYLN57j3wccdXGIV2ioSYZx5R63Jl39I1L aidMCGgKwTPlQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rZWrZ-002RP8-5U; Mon, 12 Feb 2024 14:00:49 +0000 Date: Mon, 12 Feb 2024 14:00:47 +0000 Message-ID: <86eddh6auo.wl-maz@kernel.org> From: Marc Zyngier To: Marek Szyprowski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, Catalin Marinas , Will Deacon , Mark Rutland , Suzuki K Poulose , Ard Biesheuvel , James Morse , Oliver Upton , Zenghui Yu Subject: Re: [PATCH v4 06/10] arm64: cpufeature: Detect HCR_EL2.NV1 being RES0 In-Reply-To: References: <20240122181344.258974-1-maz@kernel.org> <20240122181344.258974-7-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: m.szyprowski@samsung.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, suzuki.poulose@arm.com, ardb@kernel.org, james.morse@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Mon, 12 Feb 2024 12:48:35 +0000, Marek Szyprowski wrote: >=20 > Dead All, >=20 > On 22.01.2024 19:13, Marc Zyngier wrote: > > A variant of FEAT_E2H0 not being implemented exists in the form of > > HCR_EL2.E2H being RES1 *and* HCR_EL2.NV1 being RES0 (indicating that > > only VHE is supported on the host and nested guests). > > > > Add the necessary infrastructure for this new CPU capability. > > > > Reviewed-by: Suzuki K Poulose > > Signed-off-by: Marc Zyngier > > --- >=20 > This patch landed recently in linux-next as commit da9af5071b25 ("arm64: = > cpufeature: Detect HCR_EL2.NV1 being RES0"). I found that it causes a=20 > following regression in the CPU hot-plug operation: >=20 > # for i in /sys/devices/system/cpu/cpu[1-9]; do echo 1 >$i/online; done > ------------[ cut here ]------------ > kernel BUG at arch/arm64/kernel/cpufeature.c:1468! > Internal error: Oops - BUG: 00000000f2000800 [#1] PREEMPT SMP > Modules linked in: dw_hdmi_cec dw_hdmi_i2s_audio crct10dif_ce=20 > snd_soc_simple_card rockchip_saradc industrialio_triggered_buffer=20 > hantro_vpu kfifo_buf snd_soc_simple_card_utils rockchip_thermal=20 > phy_rockchip_naneng_combphy display_connector gpio_ir_recv v4l2_vp9=20 > v4l2_h264 v4l2_mem2mem dwmac_rk videobuf2_dma_contig stmmac_platform=20 > videobuf2_memops videobuf2_v4l2 stmmac rockchipdrm videodev=20 > snd_soc_rockchip_i2s_tdm snd_soc_rk817 pcs_xpcs panfrost rtc_rk808=20 > rk805_pwrkey analogix_dp rk817_charger spi_rockchip_sfc dw_mipi_dsi=20 > videobuf2_common dw_hdmi drm_shmem_helper mc gpu_sched=20 > drm_display_helper ahci_dwc ip_tables x_tables ipv6 > CPU: 1 PID: 0 Comm: swapper/1 Not tainted 6.8.0-rc1+ #14563 > Hardware name: Hardkernel ODROID-M1 (DT) > pstate: 800001c9 (Nzcv dAIF -PAN -UAO -TCO -DIT -SSBS BTYPE=3D--) > pc : __read_sysreg_by_encoding+0x38c/0x390 > lr : read_scoped_sysreg+0x4c/0x70 > ... > Call trace: > =C2=A0__read_sysreg_by_encoding+0x38c/0x390 > =C2=A0read_scoped_sysreg+0x4c/0x70 > =C2=A0has_nv1+0x18/0x48 > =C2=A0verify_local_cpu_caps+0x54/0x124 > =C2=A0check_local_cpu_capabilities+0x28/0x208 > =C2=A0secondary_start_kernel+0xb0/0x154 > =C2=A0__secondary_switched+0xb8/0xbc > Code: d53802f3 17ffff3b d5380253 17ffff39 (d4210000) > ---[ end trace 0000000000000000 ]--- > Kernel panic - not syncing: Attempted to kill the idle task! > SMP: stopping secondary CPUs > Kernel Offset: disabled > CPU features: 0x1,80000000,80050295,2100721b > Memory Limit: none > ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]--- >=20 > It looks that some additional checks are needed for the CPU hot-plug case. Nah, that's much simpler. I simply missed a spot where ID_AA64MMFR4_EL1 must be handled (it is getting annoying that we have more than a single place where these "read all the ID registers" are handled). Can you please give the following a go? If that works for you (it does for me here), I'll post an actual fix (plus another fix for another buglet I just noticed). Thanks, M. diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 0f29ac43c7a2..2f8958f27e9e 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1456,6 +1456,7 @@ u64 __read_sysreg_by_encoding(u32 sys_id) read_sysreg_case(SYS_ID_AA64MMFR1_EL1); read_sysreg_case(SYS_ID_AA64MMFR2_EL1); read_sysreg_case(SYS_ID_AA64MMFR3_EL1); + read_sysreg_case(SYS_ID_AA64MMFR4_EL1); read_sysreg_case(SYS_ID_AA64ISAR0_EL1); read_sysreg_case(SYS_ID_AA64ISAR1_EL1); read_sysreg_case(SYS_ID_AA64ISAR2_EL1); --=20 Without deviation from the norm, progress is not possible.