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

[PATCH 2/2] xen: Change parameter of generic_fls() to unsigned int


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Mon, 4 Sep 2023 11:14:06 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QBnCGHonNCHGh97PQEUyjKjN1aii3LsbaDXQQKkQfu8=; b=HZCpeZHRL2t81CSzWe94wdYQOJvMgeS+zQtT1tO48ak7eTRrxqbQB+95hV4hd1fuHLkyj1UJwb52/otv9HQyau4OduhbntNMWMLum/oaCHBDqLgCUvpafT3DTfE1lM/iCwu7rQYo5YB6kD9V09OObTivotwhRdk1+dPQzRvPKFriq3yeFS1Btkr1J2QfZpRFm+08P5E5Sv9xZ6FTkaWCsC3Cz+97D9pJdFhg4m8qggeNe6uS3yTNDJcsv/bEleAZszN8wN9V+W8QJeKkq7yTASKcoj6YC/HgWnKgrlkeGZiwVO2NtlmZBzdvoCVHS/vcQsR4q9hpTmgpYfVSzpZoQQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R/Bw3H1chNc6T9PUaqygjcSB9ZqRy0j1Jlby3vKAmjsx4CPIfq5BVAFsNFXmI4K8uGKgRGGV2IsQkm5x2M7GnyLHwfgwbdGNyaAp5iaMOT7RGMKIp4ITpHmVgQ+oYfAkyj+SKwo7mF22mBsVuytruKz3wBsGl8UBvXmHE2N5Yz0djwt+/XxOxZo28Alr3hqtZjimFaTtRJ3Amktpq6r6zh51sytqzT47TiQtE9YUymqKez6Rw2vF2cLBGtlBSTjA954djzu8BYGvGsnADZ7AAH8qwwpFeM8oo/D9rDH0JG0DnNx6YDgGqV8wnw4rnSiaSrL0RWS0TgBxqyE++Rlnwg==
  • Cc: Michal Orzel <michal.orzel@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, "Stefano Stabellini" <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Mon, 04 Sep 2023 09:14:46 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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 <michal.orzel@xxxxxxx>
---
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




 


Rackspace

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