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.
        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
+}
-- 
2.29.2

-- 
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/20210125120044.56794-2-andrea.bastoni%40tum.de.

Reply via email to