linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC] KVM: arm64: allow ID_MMFR4_EL1 to be writable
@ 2024-05-01 17:06 Russell King (Oracle)
  2024-05-01 17:57 ` Oliver Upton
  0 siblings, 1 reply; 15+ messages in thread
From: Russell King (Oracle) @ 2024-05-01 17:06 UTC (permalink / raw)
  To: Marc Zyngier, Oliver Upton, Catalin Marinas, Will Deacon
  Cc: James Morse, Suzuki K Poulose, Zenghui Yu, linux-arm-kernel,
	kvmarm

Between 5.4 and 5.15, the guests view of HPDS, CnP, XNX and AC2
changed their value on the same Neoverse N1 r3p1 hardware which makes
migrating between these kernels on the host problematical.

We already permit changing HPDS in AA64MMFR1_EL1 and CnP in
AA64MMFR2_EL1. We also allow LSM as we allow that in AA64MMFR2_EL1,
so this patch includes support for that even though it isn't required.

Discussing with Marc Zygnier, AC2 should also be fine to be writable,
even though we don't inject an UNDEF if the guest accesses those
registers.

The only questionable one is XNX, execute-never control distinction,
which is also in AA64MMFR1_EL1 but we don't allow to be changed there.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 arch/arm64/kvm/sys_regs.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 0cc289b17665..f306b38ec341 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -2116,6 +2116,16 @@ static unsigned int hidden_user_visibility(const struct kvm_vcpu *vcpu,
 	.val = mask,				\
 }
 
+/* sys_reg_desc initialiser for writable AA32 ID registers */
+#define AA32_ID_WRITABLE(name, mask) {		\
+	ID_DESC(name),				\
+	.set_user = set_id_reg,			\
+	.visibility = aa32_id_visibility,	\
+	.reset = kvm_read_sanitised_id_reg,	\
+	.val = mask,				\
+}
+
+
 /*
  * sys_reg_desc initialiser for architecturally unallocated cpufeature ID
  * register with encoding Op0=3, Op1=0, CRn=0, CRm=crm, Op2=op2
@@ -2270,7 +2280,11 @@ static const struct sys_reg_desc sys_reg_descs[] = {
 	AA32_ID_SANITISED(ID_ISAR3_EL1),
 	AA32_ID_SANITISED(ID_ISAR4_EL1),
 	AA32_ID_SANITISED(ID_ISAR5_EL1),
-	AA32_ID_SANITISED(ID_MMFR4_EL1),
+	AA32_ID_WRITABLE(ID_MMFR4_EL1, ID_MMFR4_EL1_LSM |
+				       ID_MMFR4_EL1_HPDS |
+				       ID_MMFR4_EL1_CnP |
+				       ID_MMFR4_EL1_XNX |
+				       ID_MMFR4_EL1_AC2),
 	AA32_ID_SANITISED(ID_ISAR6_EL1),
 
 	/* CRm=3 */
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2024-05-22 10:14 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-01 17:06 [PATCH RFC] KVM: arm64: allow ID_MMFR4_EL1 to be writable Russell King (Oracle)
2024-05-01 17:57 ` Oliver Upton
2024-05-01 18:08   ` Russell King (Oracle)
2024-05-01 18:59     ` Oliver Upton
2024-05-01 19:51       ` Russell King (Oracle)
2024-05-02 10:50         ` Russell King (Oracle)
2024-05-02 15:23           ` Marc Zyngier
2024-05-07  9:27             ` Russell King (Oracle)
2024-05-02 14:40       ` Russell King (Oracle)
2024-05-02 16:45         ` Oliver Upton
2024-05-08 12:06           ` Cornelia Huck
2024-05-08 17:14             ` Oliver Upton
2024-05-10 15:11               ` Cornelia Huck
2024-05-13 21:26                 ` Oliver Upton
2024-05-22 10:14                   ` Cornelia Huck

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).