[PATCH v5 2/3] arm64/cpufeature: Store elf_hwcaps as a bitmap rather than unsigned long

Mark Brown broonie at kernel.org
Thu Jul 7 04:52:37 PDT 2022


On Thu, Jul 07, 2022 at 12:37:58PM +0100, Catalin Marinas wrote:
> On Thu, Jul 07, 2022 at 11:36:31AM +0100, Mark Brown wrote:

> > -#define MAX_CPU_FEATURES	64
> > +#define MAX_CPU_FEATURES	128

> Should this be (32 + 64)? I guess it's easier as you did since we have
> 128 bits in total, only that we reserved the top 32 in ELF_HWCAP.

We need to have the full 64 bits allocated for AT_HWCAP storage even if
nothing uses the top 32 so that we can return the elements in the array,
otherwise we need logic for fishing variably sized silces of bits out of
the bitmap which seems more trouble than it's worth.

> >  unsigned long cpu_get_elf_hwcap2(void)
> >  {
> > -	return upper_32_bits(elf_hwcap);
> > +	return elf_hwcap[1];
> >  }

> This is fine on the assumption that DECLARE_BITMAP is always an array of
> longs. I couldn't see any documentation on this but at least the
> set_bit() etc. API only works on 'long *' pointers.

If someone changes DECLARE_BITMAP() they're going to have to be very,
very careful.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20220707/a09d2a1f/attachment-0001.sig>


More information about the linux-arm-kernel mailing list