linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: guard AMU register access with ARM64_HAS_AMU_EXTN
@ 2025-10-22 13:35 Marek Vasut
  2025-10-22 14:20 ` Marc Zyngier
  0 siblings, 1 reply; 15+ messages in thread
From: Marek Vasut @ 2025-10-22 13:35 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Marek Vasut, Anshuman Khandual, Catalin Marinas,
	Geert Uytterhoeven, Marc Zyngier, Ryan Roberts, Will Deacon,
	Yicong Yang, linux-renesas-soc

The AMU configuration register access may fault and prevent successful
kernel boot. This can occur for example in case the firmware does not
allow AMU counter access from EL1. Guard the AMU configuration register
access with ARM64_HAS_AMU_EXTN to prevent this fault if ARM64_HAS_AMU_EXTN
Kconfig option is explicitly disabled. Other interaction with the AMU is
already guarded by similar ifdeffery.

Fixes: 87a1f063464a ("arm64: trap to EL1 accesses to AMU counters from EL0")
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
---
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Yicong Yang <yangyicong@hisilicon.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-renesas-soc@vger.kernel.org
---
 arch/arm64/mm/proc.S | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S
index 86818511962b6..123538ffeda6b 100644
--- a/arch/arm64/mm/proc.S
+++ b/arch/arm64/mm/proc.S
@@ -145,7 +145,9 @@ SYM_FUNC_START(cpu_do_resume)
 	ubfx	x11, x11, #1, #1
 	msr	oslar_el1, x11
 	reset_pmuserenr_el0 x0			// Disable PMU access from EL0
+alternative_if ARM64_HAS_AMU_EXTN
 	reset_amuserenr_el0 x0			// Disable AMU access from EL0
+alternative_else_nop_endif
 
 alternative_if ARM64_HAS_RAS_EXTN
 	msr_s	SYS_DISR_EL1, xzr
@@ -470,7 +472,9 @@ SYM_FUNC_START(__cpu_setup)
 	mov	x1, MDSCR_EL1_TDCC		// Reset mdscr_el1 and disable
 	msr	mdscr_el1, x1			// access to the DCC from EL0
 	reset_pmuserenr_el0 x1			// Disable PMU access from EL0
+alternative_if ARM64_HAS_AMU_EXTN
 	reset_amuserenr_el0 x1			// Disable AMU access from EL0
+alternative_else_nop_endif
 
 	/*
 	 * Default values for VMSA control registers. These will be adjusted
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2025-12-30  2:00 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-22 13:35 [PATCH] arm64: guard AMU register access with ARM64_HAS_AMU_EXTN Marek Vasut
2025-10-22 14:20 ` Marc Zyngier
2025-10-22 14:33   ` Marek Vasut
2025-10-22 15:02     ` Marc Zyngier
2025-10-22 15:19       ` Catalin Marinas
2025-10-22 15:31         ` Marek Vasut
2025-10-22 15:29       ` Marek Vasut
2025-10-23 14:19         ` Marc Zyngier
2025-10-23 15:58           ` Marek Vasut
2025-10-24  9:27             ` Marc Zyngier
2025-12-30  2:00               ` Marek Vasut
2025-10-23 12:01     ` Yicong Yang
2025-10-23 13:16       ` Marek Vasut
2025-10-23 14:21       ` Marc Zyngier
2025-10-23 14:44         ` Yicong Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).