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

[PATCH] 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: Tue, 5 Jan 2021 18:17:51 +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=kerTqOHbzqxFsECrdTq4sDrkpoMONooxgQhy93r1HZ0=; b=bC5FF/pw91ITRJjYJ0CxK90CD515ongBq8t08X1DQESjnir2iMBgcMlF02ChmL9FXF5NMgCE6VxIgFR/uhT5EAx/KDBqaqX/3+mXenehgTAiNofpZVOAQxQl4wVy6HA28sSb1CTETE+yHj4awx1vtpNk5hWefiUa/AEMWx7OzLgi3pe0bc2WD5UWUmxg4zGG5gt89dWrQB1F+XEvjFL69y/V0QIJlDilIlIaV14UXUrFFXHeZ7g2l4lZh7xiYWgmtDW9STG0sRf/IOKDdK7O5ZXD17sJS6snz6a9PTXf2EQV2Wd423hkCnXWLLmXi0Ai47XTMu87NLcwrFbM4ZF6dA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kc79qP0wiXVERLSLS4lFVCesmrfmrn3FyQwyJQQBOBUqHj4o8AtZYpO1wjaqMfca3ruGhoaW6Lamf8yX2KhujXt8ZaeaMGPsDZd3Wjl454Wx4yESqCiJ0d/sizRJTDSer11AXaWrgysNdJ09X7MGynz49PcHh1IMSSzJPi3qaSPRCFW0vYKgwtTwJg6nU/1SnFxqbHx7/8uLU9RmQ5Zs1Pk44wpag8CZtu1KxmevEk+sGZW+vtJmQuMP7Zj0rsFYBl/b5lOFpbt48iiYRnImuEenhgtMThiRdGOjmEdqWkxJySqKeCvElE34E1x3RXFxbthUYmt6VDeeRAVAok2B6g==
  • Cc: <Bertrand.Marquis@xxxxxxx>, <Penny.Zheng@xxxxxxx>, <Jiamei.Xie@xxxxxxx>, <nd@xxxxxxx>
  • Delivery-date: Tue, 05 Jan 2021 10:18:54 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true

Curretly, 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 operation of 64-bit
and 32-bit integers are compiler related. This means the value
is unpredictable.

For example, when we are using MPIDR_AFF0_MASK to get
cluster_id from a 64-bit integer in gic-v3 driver:
uint64_t cluster_id = cpu_logical_map(cpu) & ~MPIDR_AFF0_MASK;

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

If we have a cpu_logical_map(cpu)= 0x1,00000000. We except
to get a cluster_id 1, but with UINT32 MPIDR_AFF0_MASK, we
will get 0.

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

Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
---
 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®.