On 25/11/2020 07:07, Jan Kiszka wrote:
> On 23.11.20 21:46, Andrea Bastoni wrote:
>> Signed-off-by: Andrea Bastoni <[email protected]>
>> ---
>> hypervisor/arch/arm-common/include/asm/bitops.h | 10 ++++++++++
>> 1 file changed, 10 insertions(+)
>>
>> diff --git a/hypervisor/arch/arm-common/include/asm/bitops.h
>> b/hypervisor/arch/arm-common/include/asm/bitops.h
>> index 808c9a0f..a726862f 100644
>> --- a/hypervisor/arch/arm-common/include/asm/bitops.h
>> +++ b/hypervisor/arch/arm-common/include/asm/bitops.h
>> @@ -31,6 +31,7 @@ static inline unsigned long clz(unsigned long word)
>> /* Returns the position of the least significant 1, MSB=31, LSB=0*/
>> static inline unsigned long ffsl(unsigned long word)
>> {
>> + // FIXME: the ffsl on x86 isn't robust.
>
> Can you elaborate?
There's an imbalance between the ffsl on arm and the ffsl on x86. The one on x86
doesn't check whether word is 0, this one does.
I haven't yet had time to check the callers and make sure that they will never
use 0.
I put the FIXME there before I implemented the assert(). Actually it could be
now possibile to do
unsigned long ffsl(unsigned long word)
{
assert(word != 0);
...
}
And remove the check on arm.
Furthermore it is maybe possible to get rid of the __bultin_ffsl() and use
jailhouse own ffsl() implementation.
Best,
Andrea
>
>> if (!word)
>> return 0;
>> asm volatile ("rbit %0, %0" : "+r" (word));
>> @@ -41,3 +42,12 @@ static inline unsigned long ffzl(unsigned long word)
>> {
>> return ffsl(~word);
>> }
>> +
>> +static inline unsigned long msbl(unsigned long word)
>> +{
>> +#if BITS_PER_LONG == 64
>> + return 63 - clz(word);
>> +#else
>> + return 32 - clz(word);
>> +#endif
>> +}
>>
>
> Jan
>
--
Thanks,
Andrea Bastoni
--
You received this message because you are subscribed to the Google Groups
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jailhouse-dev/bc91d85f-321e-596d-feeb-bbac5549fa18%40tum.de.