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

[PATCH v2 1/2] xen/arm: smmuv3: Add missing U for shifted constant


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Tue, 5 Sep 2023 09:31:34 +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=QwVDrVREkEGynMq9B3iITCmc/U6BSq/jOOAsWVt3pQA=; b=FQCoGKWgILuLd+lZezBrnQ6KqV0lBPjl1HODhjYrWmJohHN3t6vzCrbHL4f3+LX0FzzSIg557k1swbgX3xa4xW4mLIouSx43WryvZrvBnm76vyTRFW0syhV+77p0g/XxdETPEL6uFxqJ8R3pILqhWyAvZy7cdEt7pDh+h11u7I0LCB7WxwGpCyTs9qV9Y5UJd1YxGwkfPC76F2CUODG+c2IpcvZd6txsDJtbjeIcwD60rBj+Tuaj2dkk3s77Wf+nBvmfegJhqwP3LgF1+aKA3K4wAstfM5T1F58cmC+dknw8bWsQhc6D3d52b3MeDgmsiLZeWuVujaE264O66NSSig==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bd4sco1KaaGMICWmgX7PUZnVBiVqU4E9pbMEGHezIH980GaD3lIYIpv6lGYRWsEa0avOfTsuLRD3ZN32iPyCH0igDowOrBT3RZJUh17g0mJ51KgwvOXOaUA/Jf0pRCq6lFtPV5nkhMpb7e6NV6od7Qgn9wMn1OIuLR48LtJfSmaA90oHydqGKOUuQS/bjWXjnq68X4MwctDcDHNIVcSruuBUNxlzU2MsS5e3UcLb/BxmNzRTg/c6k30jNLUKS2A1hK0eDIAFo+jFjlbbtCx1jSd5HJLlfHXhjvT2NRzMMXLu/4vzTsAJ3lUkQXJC0UB8E2cxkJ+h4RHpiRihLkI+3g==
  • Cc: Michal Orzel <michal.orzel@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, <Henry.Wang@xxxxxxx>
  • Delivery-date: Tue, 05 Sep 2023 07:32:04 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

When running with SMMUv3 and UBSAN enabled, the following is printed:

(XEN) UBSAN: Undefined behaviour in drivers/passthrough/arm/smmu-v3.c:297:12
(XEN) left shift of 1 by 31 places cannot be represented in type 'int'

This refers to shift in Q_OVERFLOW_FLAG that is missing 'U' suffix.
While there, also fix the same in GBPA_UPDATE.

This should address MISRA Rule 7.2:
    A "u" or "U" suffix shall be applied to all integer constants that
    are represented in an unsigned type

Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
---
Changes in v2:
 - add Bertrand's Rb
---
 xen/drivers/passthrough/arm/smmu-v3.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/drivers/passthrough/arm/smmu-v3.h 
b/xen/drivers/passthrough/arm/smmu-v3.h
index b381ad373845..05f6b1fb7e33 100644
--- a/xen/drivers/passthrough/arm/smmu-v3.h
+++ b/xen/drivers/passthrough/arm/smmu-v3.h
@@ -87,7 +87,7 @@
 #define CR2_E2H                                (1 << 0)
 
 #define ARM_SMMU_GBPA                  0x44
-#define GBPA_UPDATE                    (1 << 31)
+#define GBPA_UPDATE                    (1U << 31)
 #define GBPA_ABORT                     (1 << 20)
 
 #define ARM_SMMU_IRQ_CTRL              0x50
@@ -159,7 +159,7 @@
 
 #define Q_IDX(llq, p)                  ((p) & ((1 << (llq)->max_n_shift) - 1))
 #define Q_WRP(llq, p)                  ((p) & (1 << (llq)->max_n_shift))
-#define Q_OVERFLOW_FLAG                        (1 << 31)
+#define Q_OVERFLOW_FLAG                        (1U << 31)
 #define Q_OVF(p)                       ((p) & Q_OVERFLOW_FLAG)
 #define Q_ENT(q, p)                    ((q)->base +                    \
                                         Q_IDX(&((q)->llq), p) *        \
-- 
2.25.1




 


Rackspace

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