[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/2] xen/arm: smmuv3: Add missing U for shifted constant
- To: Michal Orzel <michal.orzel@xxxxxxx>
- From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
- Date: Mon, 4 Sep 2023 11:59:28 +0000
- Accept-language: en-GB, en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; 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=c27yNJOKjC7RlfGgXnh4UN95e54DnrHxIaarBPGZC5Y=; b=jiXO3hbQSpZ4aKKpXR0zT7lL/KhYiNb4KL1lJ3AeVuAPiAFUq4MvCMcw/F7vHaabgjz4C5f9AfV40UkpDY3RovnkADvWOzrNJatZHm+Kh9AH5FCC7GKPzpBEtx0jlxk8Weg/54Co/VmHudSo2gMCODzJZIchQJU0gj8AImxVl4gHuEUpIMJPrq2fcrKO07QTY1BIUolwYdboPF4B+jCVUevAv0iJWjwvTPo0lukjDqKWi37z6gRwRgRZJ3FCFSw4C3xZvIyuvwd8SJeH73UMGhQ0Zv0RZDvW0sqRjRx2GNpEXkTFwfuUmet9gRH4uhqCQLOR+O+uoz+wHOsxHbBi/g==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U69xA5w+o7jGAM/nkULT6sabWCjHVW3kkjElFYBiLLMpogSm6qRdd48dP4ttWHqpp5DX2qx3Kzvj800EXHde/9xsjOH/PiXC+kfZQQ379pZBKgR69J4Zy5Lal3QNiFWFg21eeSgpP9CG0p1/30BJjr8vzct+ht0ECLEb0eopuoCzFOLLV5LOTbYII/kAxwrSqqkecha3RzhNOadg7ptrOUns4v+RFwGyHQMqjGuq2QzrVlgIOQR+WPB8FLGcEGbUuRRxPLqwwkwfez9crtHgQVGw+NYFiYi21Y5VkZPEW0RDEB7VWWiV7ag1OLu3t/kRl5FGoow5Lg2B1ScA4Br2nA==
- Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
- Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
- Delivery-date: Mon, 04 Sep 2023 12:00:06 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Nodisclaimer: true
- Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
- Thread-index: AQHZ3xA6Uh0Zbf8c6kSq95XOBrrVBLAKkFYA
- Thread-topic: [PATCH 1/2] xen/arm: smmuv3: Add missing U for shifted constant
Hi Michal,
> On 4 Sep 2023, at 11:14, Michal Orzel <michal.orzel@xxxxxxx> wrote:
>
> 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>
Cheers
Bertrand
> ---
> 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
>
|