Skip to content

Commit 8f8d608

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: Mark HCR.EL2.{NV*,AT} RES0 when ID_AA64MMFR4_EL1.NV_frac is 0
Enforce HCR_EL2.{NV*,AT} being RES0 when NV2 is disabled, so that we can actually rely on these bits never being flipped behind our back. This of course relies on our earlier ID reg sanitising. Signed-off-by: Marc Zyngier <maz@kernel.org> Reviewed-by: Joey Gouly <joey.gouly@arm.com> Link: https://lore.kernel.org/r/20250220134907.554085-5-maz@kernel.org Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
1 parent d9f943f commit 8f8d608

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

arch/arm64/kvm/nested.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,10 +1021,11 @@ int kvm_init_nv_sysregs(struct kvm_vcpu *vcpu)
10211021
res0 |= HCR_FIEN;
10221022
if (!kvm_has_feat(kvm, ID_AA64MMFR2_EL1, FWB, IMP))
10231023
res0 |= HCR_FWB;
1024-
if (!kvm_has_feat(kvm, ID_AA64MMFR2_EL1, NV, NV2))
1025-
res0 |= HCR_NV2;
1026-
if (!kvm_has_feat(kvm, ID_AA64MMFR2_EL1, NV, IMP))
1027-
res0 |= (HCR_AT | HCR_NV1 | HCR_NV);
1024+
/* Implementation choice: NV2 is the only supported config */
1025+
if (!kvm_has_feat(kvm, ID_AA64MMFR4_EL1, NV_frac, NV2_ONLY))
1026+
res0 |= (HCR_NV2 | HCR_NV | HCR_AT);
1027+
if (!kvm_has_feat(kvm, ID_AA64MMFR4_EL1, E2H0, NI))
1028+
res0 |= HCR_NV1;
10281029
if (!(kvm_vcpu_has_feature(kvm, KVM_ARM_VCPU_PTRAUTH_ADDRESS) &&
10291030
kvm_vcpu_has_feature(kvm, KVM_ARM_VCPU_PTRAUTH_GENERIC)))
10301031
res0 |= (HCR_API | HCR_APK);

0 commit comments

Comments
 (0)