[PATCH 1/3] KVM: arm64: nv: Forward PIR_EL2, PIRE0_EL2 and POR_EL2 traps

Dan Carpenter dan at pereq.eu
Wed Nov 18 07:29:51 PST 2026


These registers were added to KVM, but not to the encoding_to_cgt[]
table which decides when a trap is forwarded to a nested hypervisor.

The result is that if an L1 hypervisor runs its L2 with HCR_EL2.NV set
(meaning the L2 is itself a hypervisor), and the L2 accesses these
registers, KVM handles the access itself and it goes to the L1's own
registers instead of being emulated on L1.  This is quite a serious bug
because it lets the L2 change the permissions of the L1's own stage 1
translations.  It could mark everything as no-access and cause a crash
in L1 or mark everything as read-write-execute which weakens the
protections in L1.

Add the three registers with CGT_HCR_NV, MAIR_EL2 and AMAIR_EL2.

Fixes: 874ae1d48e60 ("KVM: arm64: Handle PIR{,E0}_EL2 traps")
Fixes: 5970e9903f03 ("KVM: arm64: Add basic support for POR_EL2")
Cc: stable at vger.kernel.org
Signed-off-by: Dan Carpenter <dan at pereq.eu>
---
 arch/arm64/kvm/emulate-nested.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/kvm/emulate-nested.c b/arch/arm64/kvm/emulate-nested.c
index 2bec81668361..bf4b8a44b9c4 100644
--- a/arch/arm64/kvm/emulate-nested.c
+++ b/arch/arm64/kvm/emulate-nested.c
@@ -889,6 +889,9 @@ static const struct encoding_to_trap_config encoding_to_cgt[] __initconst = {
 	SR_TRAP(SYS_PMSCR_EL2,		CGT_HCR_NV),
 	SR_TRAP(SYS_MAIR_EL2,		CGT_HCR_NV),
 	SR_TRAP(SYS_AMAIR_EL2,		CGT_HCR_NV),
+	SR_TRAP(SYS_PIR_EL2,		CGT_HCR_NV),
+	SR_TRAP(SYS_PIRE0_EL2,		CGT_HCR_NV),
+	SR_TRAP(SYS_POR_EL2,		CGT_HCR_NV),
 	SR_TRAP(SYS_MPAMHCR_EL2,	CGT_HCR_NV),
 	SR_TRAP(SYS_MPAMVPMV_EL2,	CGT_HCR_NV),
 	SR_TRAP(SYS_MPAM2_EL2,		CGT_HCR_NV),
-- 
2.53.0




More information about the linux-arm-kernel mailing list