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

Re: [PATCH] xen/arm: vgic: Add missing 'U' in VGIC_ICFG_MASK for shifted constant


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Hongda Deng <hongda.deng@xxxxxxx>
  • Date: Fri, 30 Jun 2023 15:16:23 +0800
  • 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=YoXiutiUDdcwntf5OsT+/rRYVryZWxjgehEe7Z76IBg=; b=YStMCWu3PP1B9goegtHF3q3EUC0ygaFCsCFqX+hzw0JEocigcDI+72qIqWkKaMjaGfaex2QonPMU9TPW+VN2jQw++asiWX7XHHIUt3VsAkeDVk6D3U7Vi274ABcZq5gOFAHsMbdlMxCLFFtPg7VoUE524sLAgnVoDKpl2YVBQKZV8U7xmHScAUAcSF7iTnXuc1uLtWM5rOkl3cNVlF/R7OMC1/FricZrzJTz2SNzzra6wqDk6gqz9+fPqM3msubWHq1rZcSeFivrcHKSrXRSCp1y1ZDEVMhLD4oBaQKB3cKsLC8P0GxanabLGYbYzg7XXxXp8Jt1/rwHCtEGjaSM9Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ft+ONMk3Wq0xM/fVkS7o3gwA4xoBv3VXk3YZkYfBLXxNBpRWN+71kAcw/izXkhJA/1VYObdixzZ5ce8bhZQvv3pITOLVkEj9/ltN60v7ZsEzc1+yJqE3mbNCzDn0TQuDIzyBHOa5PsJqkJjB3YI+DLoJu1mJlUHSPL2f9P4FHeLqOsiniBZEuQDYW/2d/GDhvumjMHfIrhx0npqzr1beq5CkqL40yBKU8MXoXKIWwIN6cFbCXz0KG+cSUS1rxcMU27hfGftQ9iUsZu23AICeFnI7v9vNK4itGx8m5EUreYxFPCAq2yvEB+DSLYVqpc4YTl2DsDv8su4EjFEL56CLzA==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Delivery-date: Fri, 30 Jun 2023 07:16:51 +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;


On 2023/6/30 07:03, Stefano Stabellini wrote:
On Fri, 30 Jun 2023, Henry Wang wrote:
With UBSAN on some arm64 platforms, e.g. FVP_Base_RevC-2xAEMvA, the
following splat will be printed while Dom0 is booting:
```
(XEN) ==================================================================
(XEN) UBSAN: Undefined behaviour in arch/arm/vgic.c:372:15
(XEN) left shift of 1 by 31 places cannot be represented in type 'int'
(XEN) Xen WARN at common/ubsan/ubsan.c:172
(XEN) ----[ Xen-4.18-unstable  arm64  debug=y ubsan=y  Not tainted ]----
```

This is because there is a device node in the device tree with 0xf
as the interrupts property. Example of the device tree node is shown
below:
```
ethernet@202000000 {
     compatible = "smsc,lan91c111";
     reg = <0x2 0x2000000 0x10000>;
     interrupts = <0xf>;
};
```
and this value is passed to vgic_get_virq_type() as "index" then "intr"
in VGIC_ICFG_MASK.

Add the missing 'U' in VGIC_ICFG_MASK as a fix, and this should also
addressing 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: Henry Wang <Henry.Wang@xxxxxxx>
Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>


---
This patch should be based on top of Julien's series
"xen/arm: Enable UBSAN support" to test.
---
  xen/arch/arm/vgic.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
index c61c68870c..97d6f61066 100644
--- a/xen/arch/arm/vgic.c
+++ b/xen/arch/arm/vgic.c
@@ -358,7 +358,7 @@ void vgic_disable_irqs(struct vcpu *v, uint32_t r, int n)
      }
  }
-#define VGIC_ICFG_MASK(intr) (1 << ((2 * ((intr) % 16)) + 1))
+#define VGIC_ICFG_MASK(intr) (1U << ((2 * ((intr) % 16)) + 1))
/* The function should be called with the rank lock taken */
  static inline unsigned int vgic_get_virq_type(struct vcpu *v, int n, int 
index)
--
2.25.1

Reviewed-by: Hongda Deng <hongda.deng@xxxxxxx>




 


Rackspace

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