[PATCH] KVM: arm64: fix u64_replace_bits() usage

Arnd Bergmann arnd at arndb.de
Fri Jul 11 01:44:23 PDT 2025


On Fri, Jul 11, 2025, at 10:36, Marc Zyngier wrote:
> On Fri, 11 Jul 2025 08:27:47 +0100, Arnd Bergmann <arnd at kernel.org> wrote:
>>  	if (hpmn > vcpu->kvm->arch.nr_pmu_counters) {
>>  		hpmn = vcpu->kvm->arch.nr_pmu_counters;
>> -		u64_replace_bits(val, hpmn, MDCR_EL2_HPMN);
>> +		val = u64_replace_bits(val, hpmn, MDCR_EL2_HPMN);
>>  	}
>>  
>>  	__vcpu_assign_sys_reg(vcpu, MDCR_EL2, val);
>
> This is only in -next, right? Because I have a fix for this already
> queued for 6.16, as per [1].

Yes, as far as I can tell, the warning only showed up in linux-next
after f66f9c3d09c1 ("bitfield: Ensure the return values of helper
functions are checked").

As far as I can tell, Ben added the check in linux/bitfield.h
when he sent you his version of the fix, they just ended up
in linux-next in the wrong order, so I ended up recreating his
original fix slightly differently.

      Arnd



More information about the linux-arm-kernel mailing list