Collecting entropy from device_attach() times.
Dag-Erling Smørgrav
des at des.no
Thu Sep 20 09:58:56 UTC 2012
Pawel Jakub Dawidek <pjd at FreeBSD.org> writes:
> http://people.freebsd.org/~pjd/patches/harvest_device_attach.2.patch
You can replace highbit(x) - 9 with flsll(x) - 10. Unfortunately, we
don't have flsll() in the kernel, but here's a simple implementation:
/*
* Find last bit set in an unsigned long long. Assumes that ULL is
* always 64 bits wide while UL may be either 32 or 64 bits wide.
*/
static __inline unsigned int
flsll(unsigned long long mask)
{
#ifdef __LP64__
return (flsl(mask));
#else
return (mask >> 32 ? 32 + flsl(mask >> 32) : flsl(mask));
#endif
}
On i386 and amd64, flsl() is an inline function that expands to a single
assembler instruction. On all other platforms, it is a function in
libkern, which is stupid - gcc and clang have builtin functions for it
which are almost certainly faster than a function call.
Same goes for s/last bit/first bit/; s/fls/ffs/g.
DES
--
Dag-Erling Smørgrav - des at des.no
More information about the freebsd-security
mailing list