When running with SMMUv3 and UBSAN enabled on arm64, there are a lot of
warnings printed related to shifting into sign bit in generic_fls()
as it takes parameter of type int.
Example:
(XEN) UBSAN: Undefined behaviour in ./include/xen/bitops.h:69:11
(XEN) left shift of 134217728 by 4 places cannot be represented in type 'int'
It does not make a lot of sense to ask for the last set bit of a negative
value. We don't have a direct user of this helper and all the wrappers
pass value of type unsigned {int,long}.
Linux did the same as part of commit:
3fc2579e6f16 ("fls: change parameter to unsigned int")
Signed-off-by: Michal Orzel <[email protected]>
---
It looks like generic_fls() is only used by Arm and invoked only if
the arguement passed is a compile time constant. This is true for SMMUv3
which makes use of ffs64() in FIELD_{PREP,GET} macros.
---
xen/include/xen/bitops.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h
index 654f525fb437..b2d7bbd66687 100644
--- a/xen/include/xen/bitops.h
+++ b/xen/include/xen/bitops.h
@@ -51,7 +51,7 @@ static inline int generic_ffs(int x)
* fls: find last bit set.
*/
-static __inline__ int generic_fls(int x)
+static __inline__ int generic_fls(unsigned int x)
{
int r = 32;
--
2.25.1