Linux KVM/arm64 development list
 help / color / mirror / Atom feed
* [PATCH] arm64: Add command-line override for ID_AA64MMFR0_EL1.ECV
@ 2024-10-21 18:14 Marc Zyngier
  2024-10-23 11:05 ` Catalin Marinas
  0 siblings, 1 reply; 2+ messages in thread
From: Marc Zyngier @ 2024-10-21 18:14 UTC (permalink / raw)
  To: linux-arm-kernel, kvmarm; +Cc: Will Deacon, Catalin Marinas, Oliver Upton

It appears that relatively popular hardware out there implements
the CNTPOFF_EL2 variant of FEAT_ECV, advertises it via ID_AA64MMFR0_EL1,
but cannot be bothered to set SCR_EL3.ECVEn to 1.

You would probably think that "this is fine, EL3 will take the
trap on access to CNTPOFF_EL2 and flip the ECVEn bit", as that's
what a semi-decent firmware implementation would do.

But no. None of that. This particular implementation takes the trap,
considers its purpose in life, decides that it has none, and *RESETS*
the system.

Yes, x1e001de, I'm talking about you.

In order to allow this machine to be promoted slightly above the
level of a glorified door-stop, add a new "id_aa64mmfr0.ecv" override.
allowing the kernel to pretend this option was never there.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 arch/arm64/kernel/pi/idreg-override.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm64/kernel/pi/idreg-override.c b/arch/arm64/kernel/pi/idreg-override.c
index 29d4b6244a6f6..fbc37b2733e20 100644
--- a/arch/arm64/kernel/pi/idreg-override.c
+++ b/arch/arm64/kernel/pi/idreg-override.c
@@ -38,6 +38,15 @@ struct ftr_set_desc {
 
 #define FIELD(n, s, f)	{ .name = n, .shift = s, .width = 4, .filter = f }
 
+static const struct ftr_set_desc mmfr0 __prel64_initconst = {
+	.name		= "id_aa64mmfr0",
+	.override	= &id_aa64mmfr0_override,
+	.fields		= {
+		FIELD("ecv", ID_AA64MMFR0_EL1_ECV_SHIFT, NULL),
+		{}
+	},
+};
+
 static bool __init mmfr1_vh_filter(u64 val)
 {
 	/*
@@ -196,6 +205,7 @@ static const struct ftr_set_desc sw_features __prel64_initconst = {
 
 static const
 PREL64(const struct ftr_set_desc, reg) regs[] __prel64_initconst = {
+	{ &mmfr0	},
 	{ &mmfr1	},
 	{ &mmfr2	},
 	{ &pfr0 	},
-- 
2.39.2


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

* Re: [PATCH] arm64: Add command-line override for ID_AA64MMFR0_EL1.ECV
  2024-10-21 18:14 [PATCH] arm64: Add command-line override for ID_AA64MMFR0_EL1.ECV Marc Zyngier
@ 2024-10-23 11:05 ` Catalin Marinas
  0 siblings, 0 replies; 2+ messages in thread
From: Catalin Marinas @ 2024-10-23 11:05 UTC (permalink / raw)
  To: linux-arm-kernel, kvmarm, Marc Zyngier; +Cc: Will Deacon, Oliver Upton

On Mon, 21 Oct 2024 19:14:34 +0100, Marc Zyngier wrote:
> It appears that relatively popular hardware out there implements
> the CNTPOFF_EL2 variant of FEAT_ECV, advertises it via ID_AA64MMFR0_EL1,
> but cannot be bothered to set SCR_EL3.ECVEn to 1.
> 
> You would probably think that "this is fine, EL3 will take the
> trap on access to CNTPOFF_EL2 and flip the ECVEn bit", as that's
> what a semi-decent firmware implementation would do.
> 
> [...]

Applied to arm64 (for-next/misc), thanks!

[1/1] arm64: Add command-line override for ID_AA64MMFR0_EL1.ECV
      https://git.kernel.org/arm64/c/358dd4a9bdac

-- 
Catalin


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

end of thread, other threads:[~2024-10-23 11:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-21 18:14 [PATCH] arm64: Add command-line override for ID_AA64MMFR0_EL1.ECV Marc Zyngier
2024-10-23 11:05 ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox