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

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


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Mon, 4 Sep 2023 11:14:05 +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=gIq+cqKXin8yRNnzT94HulgKn5L0z4PTEoU760E1PXI=; b=n8SlCcoQgZr9ZiS72VofVj9FkYXFdIbPdAIANWH18P7pS9rE+w9qAPIlvHpjrCM4rirytiPpHwAQYd0REj3SmxL4PZqzy3yh06xlOHdqcV62Xo+tt2ugyFKUjFeLjR78QNmpIZ7/q6BPt2bUoasiqbDFKZ2Jv6ZXF6021GPnBmQ9cM39iwAy+9pA0Z7IhNKiAAqOz8WiPEh9cX6TG+HMemeFl/mPLfc/7bveuo5qZWMM5Lbs7HEf3kv/1OyMBc5NeC/t6hY+8KQeHkPy0VumtWDNE/qjagBoO4xT02CgSemDSmV+Ti6H5mI7EDOpH35DQ4+CLWDMUJy/lW5bjmpp0Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oPYrM7nLWJ17divS8FFP1TjkppFVMIcdIofyM3fqfd5XKiSyYbQJETNRMIqpeZSp4s5Jkfd0slYFyP+tm5MvEtDHpXI0uDbUqgu0hf3l2sg+y1FqX6noby01NmY3YXJ2gjqTiuNbYJ4ajUA7bOKg57wOEpX78PrpzrbXW9DODN4EKNIpq2vANOl6C+fAEF9829kE38TcBOPx7KvFKt6oj6XiLuFzHiIF9caFJlX1ZEfRbFGHvxQlUUCZEUAZ91MuoFt2EvwHSQEEKP1ARdwnUSn8Pyy+igYby+y+haDFg+3MmGKVGrAm/gAfVOtLHyHzkjgYF0v/uFlM6ikLSH1L4w==
  • Cc: Michal Orzel <michal.orzel@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • 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, 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>
---
 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®.