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

[PATCH v2] xen/arm: Using unsigned long for arm64 MPIDR mask


  • To: <wei.chen@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>, <sstabellini@xxxxxxxxxx>, <julien@xxxxxxx>
  • From: Wei Chen <wei.chen@xxxxxxx>
  • Date: Fri, 8 Jan 2021 14:29:53 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.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-SenderADCheck; bh=Q1kznTpSO0ImK3gQ075WEn8T69BRrdKA5SL5H2MCV6A=; b=I2MeU6FmqeWXllZjzzJr8hCVpqwMMum0cnKINbaQfPUr7jpxT0hQrefPKQKzA+lumXRpcYIjFl4SO+sbhtGxzHOIFQyPPf8ExS46WPpPmC/HipELLjz45Mt66vIYjKq+FEsKHpAds/e5u6V3u386Yy5LDcD/5GnQQxmejon1tM7IWxZeWAOxaXUCY+xRshCakWLJCw083EjMp4HqFoGD3wiLCDwT7WVTwjOzFcTT1tDunLb90gM4TuHJB6JuzwitLQWgBPDhIFsl9H5hdYzvCkEMKsm1uw4EYc0+mJ3tWubILTqhlrp00qnum4HsWll0FQcqLj6mxH4Qe85KAK/i+A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NiifW5Ns4j0Icyl2b66nMz/uMZgtyraDdLAaw0HK9cla+nzOSkksWNlMfj0xmC6XIkBo0Xiha2yeVtA0ooMMr7hQXRHiYnphzMcCnMT06npEp7CMqERWZj1a3j/tjZ8NMzzNpoQZJXYGsxM2m1zW7Cd6rKwTFC0x60GV3YjSrUTz2Xito0Y1U6LRVIXUSaa2E7hDSGJnswLvd/uNjqvfCVt8eTPgHT7s6SPXfoeGeFOjQ43GBA3jN7vCfgK+puMO0UOimsLwG9ZwjyJYKj1XOOO/cWFDZnPac6s00f7oJpC/FgBsbVuqmTZys97gVFqgXVuy5CS1e+7tqkInnrSWMA==
  • Cc: <Bertrand.Marquis@xxxxxxx>, <Penny.Zheng@xxxxxxx>, <Jiamei.Xie@xxxxxxx>, <nd@xxxxxxx>
  • Delivery-date: Fri, 08 Jan 2021 06:30:28 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true

Currently, Xen is using UINT32 for MPIDR mask to retrieve
affinity[0,1,2,3] values for MPIDR_EL1 register. The value
of MPIDR_EL1 is 64-bit unsigned long. The 32-bit unsinged
integer will do unsigned extend while doing some operations
with 64-bit unsigned integer. This can lead to unexpected
result in some use cases.

For example, in gicv3_send_sgi_list of GICv3 driver:
uint64_t cluster_id = cpu_logical_map(cpu) & ~MPIDR_AFF0_MASK;

When MPIDR_AFF0_MASK is 0xFFU, compiler output:
    f7c: 92785c16 and x22, x0, #0xffffff00
When MPIDR_AFF0_MASK is 0xFFUL, compiler output:
    f88: 9278dc75 and x21, x3, #0xffffffffffffff00

If cpu_logical_map(cpu) = 0x100000000UL and MPIDR_AFF0_MASK is
0xFFU, the cluster_id returns 0. But the expected value should
be 0x100000000.

So, in this patch, we force aarch64 to use unsigned long
as MPIDR mask to avoid such unexpected results.

Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
---
v1 -> v2:
1. Remove inaccurate descriptions
2. Update example description
 
---
 xen/include/asm-arm/processor.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/include/asm-arm/processor.h b/xen/include/asm-arm/processor.h
index 87c8136022..5c1768cdec 100644
--- a/xen/include/asm-arm/processor.h
+++ b/xen/include/asm-arm/processor.h
@@ -75,11 +75,11 @@

 /* MPIDR Multiprocessor Affinity Register */
 #define _MPIDR_UP           (30)
-#define MPIDR_UP            (_AC(1,U) << _MPIDR_UP)
+#define MPIDR_UP            (_AC(1,UL) << _MPIDR_UP)
 #define _MPIDR_SMP          (31)
-#define MPIDR_SMP           (_AC(1,U) << _MPIDR_SMP)
+#define MPIDR_SMP           (_AC(1,UL) << _MPIDR_SMP)
 #define MPIDR_AFF0_SHIFT    (0)
-#define MPIDR_AFF0_MASK     (_AC(0xff,U) << MPIDR_AFF0_SHIFT)
+#define MPIDR_AFF0_MASK     (_AC(0xff,UL) << MPIDR_AFF0_SHIFT)
 #ifdef CONFIG_ARM_64
 #define MPIDR_HWID_MASK     _AC(0xff00ffffff,UL)
 #else
--
2.25.1




 


Rackspace

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