From: Ben Horgan Date: Wed, 9 Jul 2025 09:38:07 +0000 (+0100) Subject: KVM: arm64: Fix enforcement of upper bound on MDCR_EL2.HPMN X-Git-Tag: v6.16-rc7~23^2~3^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2265c08ec393ef1f5ef5019add0ab1e3a7ee0b79;p=thirdparty%2Flinux.git KVM: arm64: Fix enforcement of upper bound on MDCR_EL2.HPMN Previously, u64_replace_bits() was used to no effect as the return value was ignored. Convert to u64p_replace_bits() so the value is updated in place. Reviewed-by: Zenghui Yu Signed-off-by: Ben Horgan Fixes: efff9dd2fee7 ("KVM: arm64: Handle out-of-bound write to MDCR_EL2.HPMN") Link: https://lore.kernel.org/r/20250709093808.920284-2-ben.horgan@arm.com Signed-off-by: Marc Zyngier --- diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 76c2f0da821f..c20bd6f21e60 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -2624,7 +2624,7 @@ static bool access_mdcr(struct kvm_vcpu *vcpu, */ if (hpmn > vcpu->kvm->arch.nr_pmu_counters) { hpmn = vcpu->kvm->arch.nr_pmu_counters; - u64_replace_bits(val, hpmn, MDCR_EL2_HPMN); + u64p_replace_bits(&val, hpmn, MDCR_EL2_HPMN); } __vcpu_assign_sys_reg(vcpu, MDCR_EL2, val);