Skip to content

Commit b03e8bb

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: Make AMU sysreg UNDEF if FEAT_AMU is not advertised to the guest
No AMU? No AMU! IF we see an AMU-related trap, let's turn it into an UNDEF! Reviewed-by: Joey Gouly <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 58627b7 commit b03e8bb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/arm64/kvm/sys_regs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3998,6 +3998,10 @@ void kvm_init_sysreg(struct kvm_vcpu *vcpu)
39983998
kvm->arch.fgu[HFGxTR_GROUP] |= (HFGxTR_EL2_nPIRE0_EL1 |
39993999
HFGxTR_EL2_nPIR_EL1);
40004000

4001+
if (!kvm_has_feat(kvm, ID_AA64PFR0_EL1, AMU, IMP))
4002+
kvm->arch.fgu[HAFGRTR_GROUP] |= ~(HAFGRTR_EL2_RES0 |
4003+
HAFGRTR_EL2_RES1);
4004+
40014005
set_bit(KVM_ARCH_FLAG_FGU_INITIALIZED, &kvm->arch.flags);
40024006
out:
40034007
mutex_unlock(&kvm->arch.config_lock);

0 commit comments

Comments
 (0)