summaryrefslogtreecommitdiffstats
path: root/arch/arm64/kvm/sys_regs.c
diff options
context:
space:
mode:
authorMarc Zyngier <maz@kernel.org>2024-02-14 14:18:24 +0100
committerOliver Upton <oliver.upton@linux.dev>2024-02-19 18:13:01 +0100
commitb03e8bb5a906ab0b67fe90e636c3ebff8eb0e91c (patch)
tree4d45f0d42d18c5b2c59f976dbd1a705200ce4ff1 /arch/arm64/kvm/sys_regs.c
parentKVM: arm64: Make PIR{,E0}_EL1 UNDEF if S1PIE is not advertised to the guest (diff)
downloadlinux-b03e8bb5a906ab0b67fe90e636c3ebff8eb0e91c.tar.xz
linux-b03e8bb5a906ab0b67fe90e636c3ebff8eb0e91c.zip
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 <joey.gouly@arm.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20240214131827.2856277-24-maz@kernel.org Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Diffstat (limited to 'arch/arm64/kvm/sys_regs.c')
-rw-r--r--arch/arm64/kvm/sys_regs.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index da9db99c77e7..38ed47bd29db 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -3998,6 +3998,10 @@ void kvm_init_sysreg(struct kvm_vcpu *vcpu)
kvm->arch.fgu[HFGxTR_GROUP] |= (HFGxTR_EL2_nPIRE0_EL1 |
HFGxTR_EL2_nPIR_EL1);
+ if (!kvm_has_feat(kvm, ID_AA64PFR0_EL1, AMU, IMP))
+ kvm->arch.fgu[HAFGRTR_GROUP] |= ~(HAFGRTR_EL2_RES0 |
+ HAFGRTR_EL2_RES1);
+
set_bit(KVM_ARCH_FLAG_FGU_INITIALIZED, &kvm->arch.flags);
out:
mutex_unlock(&kvm->arch.config_lock);