[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] xen: Change parameter of generic_{fls,ffs}() to unsigned int



commit c0291d6b5c84de104b931111d1f81da323feb67f
Author:     Michal Orzel <michal.orzel@xxxxxxx>
AuthorDate: Wed Sep 6 14:54:48 2023 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Sep 6 14:54:48 2023 +0200

    xen: Change parameter of generic_{fls,ffs}() to unsigned int
    
    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")
    
    To keep consistency between the helpers, take the opportunity to:
     - replace __inline__ with inline,
     - modify generic_ffs() to take parameter of type unsigned int as well
       (currently no user and the only wrapper generic_ffsl() passes unsigned
       long).
    
    Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Henry Wang <Henry.Wang@xxxxxxx>
---
 xen/include/xen/bitops.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h
index 654f525fb4..edd6817d53 100644
--- a/xen/include/xen/bitops.h
+++ b/xen/include/xen/bitops.h
@@ -18,7 +18,7 @@
  * differs in spirit from the above ffz (man ffs).
  */
 
-static inline int generic_ffs(int x)
+static inline int generic_ffs(unsigned int x)
 {
     int r = 1;
 
@@ -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;
 
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.