Skip to content

Commit 838d992

Browse files
author
Marc Zyngier
committed
KVM: arm64: Convert kvm_mpidr_index() to bitmap_gather()
Linux 6.9 has introduced new bitmap manipulation helpers, with bitmap_gather() being of special interest, as it does exactly what kvm_mpidr_index() is already doing. Make the latter a wrapper around the former. Reviewed-by: Oliver Upton <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent 03b3d00 commit 838d992

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -220,20 +220,10 @@ struct kvm_mpidr_data {
220220

221221
static inline u16 kvm_mpidr_index(struct kvm_mpidr_data *data, u64 mpidr)
222222
{
223-
unsigned long mask = data->mpidr_mask;
224-
u64 aff = mpidr & MPIDR_HWID_BITMASK;
225-
int nbits, bit, bit_idx = 0;
226-
u16 index = 0;
223+
unsigned long index = 0, mask = data->mpidr_mask;
224+
unsigned long aff = mpidr & MPIDR_HWID_BITMASK;
227225

228-
/*
229-
* If this looks like RISC-V's BEXT or x86's PEXT
230-
* instructions, it isn't by accident.
231-
*/
232-
nbits = fls(mask);
233-
for_each_set_bit(bit, &mask, nbits) {
234-
index |= (aff & BIT(bit)) >> (bit - bit_idx);
235-
bit_idx++;
236-
}
226+
bitmap_gather(&index, &aff, &mask, fls(mask));
237227

238228
return index;
239229
}

0 commit comments

Comments
 (0)