Skip to content

Commit 7af7cfb

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: Prevent userspace from disabling AArch64 support at any virtualisable EL
A sorry excuse for a selftest is trying to disable AArch64 support. And yes, this goes as well as you can imagine. Let's forbid this sort of things. Normal userspace shouldn't get caught doing that. Signed-off-by: Marc Zyngier <maz@kernel.org> Reviewed-by: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com> Link: https://lore.kernel.org/r/20250429114117.3618800-2-maz@kernel.org Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
1 parent 859c602 commit 7af7cfb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

arch/arm64/kvm/sys_regs.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,6 +1945,12 @@ static int set_id_aa64pfr0_el1(struct kvm_vcpu *vcpu,
19451945
if ((hw_val & mpam_mask) == (user_val & mpam_mask))
19461946
user_val &= ~ID_AA64PFR0_EL1_MPAM_MASK;
19471947

1948+
/* Fail the guest's request to disable the AA64 ISA at EL{0,1,2} */
1949+
if (!FIELD_GET(ID_AA64PFR0_EL1_EL0, user_val) ||
1950+
!FIELD_GET(ID_AA64PFR0_EL1_EL1, user_val) ||
1951+
(vcpu_has_nv(vcpu) && !FIELD_GET(ID_AA64PFR0_EL1_EL2, user_val)))
1952+
return -EINVAL;
1953+
19481954
return set_id_reg(vcpu, rd, user_val);
19491955
}
19501956

0 commit comments

Comments
 (0)