[PATCH 23/25] KVM: arm64: Make AMU sysreg UNDEF if FEAT_AMU is not advertised to the guest
Joey Gouly
joey.gouly at arm.com
Thu Jan 25 05:42:39 PST 2024
On Mon, Jan 22, 2024 at 08:18:50PM +0000, Marc Zyngier wrote:
> No AMU? No AMU! IF we see an AMU-related trap, let's turn it into
> an UNDEF!
>
> Signed-off-by: Marc Zyngier <maz at kernel.org>
> ---
> arch/arm64/kvm/sys_regs.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> index bcde43b81755..afe6975fcf5c 100644
> --- a/arch/arm64/kvm/sys_regs.c
> +++ b/arch/arm64/kvm/sys_regs.c
> @@ -3994,6 +3994,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);
Reviewed-by: Joey Gouly <joey.gouly at arm.com>
Thanks,
Joey
More information about the linux-arm-kernel
mailing list