From patchwork Thu Jun 23 03:16:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 70712 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp217270qgy; Wed, 22 Jun 2016 20:20:32 -0700 (PDT) X-Received: by 10.107.6.89 with SMTP id 86mr47352564iog.77.1466652026745; Wed, 22 Jun 2016 20:20:26 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id w203si3079695itc.10.2016.06.22.20.20.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jun 2016 20:20:26 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFv9R-00008U-FC; Thu, 23 Jun 2016 03:17:57 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFv9Q-00008I-1S for xen-devel@lists.xen.org; Thu, 23 Jun 2016 03:17:56 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 96/D1-09256-3E45B675; Thu, 23 Jun 2016 03:17:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsVSPpHPSfdRSHa 4wfJlJhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8arJ5NYCg7wV3S9l25gfM/dxcjFISRwilFi 7cJtLBDOHkaJn8d72boYOTnYBHQlPm6cwg5iiwjISqzumsMOUsQscJ1R4s77bawgCWGBQInOK Z/BbBYBVYmW34+ZQWxeAXeJE5OmsoDYEgIaEit7J4DZnAIeEidnPQGrEQKqmbNmLwtEvaDEyZ lPwGxmAQmJgy9eMEP0Kkq0rT/JBmFLShxccQPsUgmQs0+sugG1wFRi4d5nTBMYBWchmTULyaw FjEyrGNWLU4vKUot0jfSSijLTM0pyEzNzdA0NzPRyU4uLE9NTcxKTivWS83M3MQIDlAEIdjAu ++t0iFGSg0lJlNfKITtciC8pP6UyI7E4I76oNCe1+BCjDAeHkgTvsWCgnGBRanpqRVpmDjBWY NISHDxKIrwSIGne4oLE3OLMdIjUKUZFKXHeQyAJAZBERmkeXBssPi8xykoJ8zICHSLEU5BalJ tZgir/ilGcg1FJmHctyBSezLwSuOmvgBYzAS1e1p8OsrgkESEl1cCocaDuRqT160rD081qTXP EDn+/Mu3fXubVKdKX062O6tQcUnptXLTjBfec0+FytfEPrZQPSCrWPuaozCr0O8ChXhlU3fL/ ob3OkdXWLOdc5c1+MitfcyqdfF+y+FXGplLNirmTPz7JuNx8/7MVQ1Eic5tVyJu/h1tq2RgF1 RX2h1XH3n22fJMSS3FGoqEWc1FxIgBCtiStygIAAA== X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-15.tower-21.messagelabs.com!1466651871!20315407!1 X-Originating-IP: [119.145.14.66] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NiA9PiA4NTI3\n X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 57270 invoked from network); 23 Jun 2016 03:17:54 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-15.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 23 Jun 2016 03:17:54 -0000 Received: from 172.24.1.36 (EHLO szxeml430-hub.china.huawei.com) ([172.24.1.36]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CDT13162; Thu, 23 Jun 2016 11:17:37 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml430-hub.china.huawei.com (10.82.67.185) with Microsoft SMTP Server id 14.3.235.1; Thu, 23 Jun 2016 11:17:31 +0800 From: Shannon Zhao To: Date: Thu, 23 Jun 2016 11:16:55 +0800 Message-ID: <1466651824-6964-9-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1466651824-6964-1-git-send-email-zhaoshenglong@huawei.com> References: <1466651824-6964-1-git-send-email-zhaoshenglong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090204.576B54D2.003C, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 375187cdcd5209531febd0f329134bef Cc: sstabellini@kernel.org, wei.liu2@citrix.com, ian.jackson@eu.citrix.com, peter.huangpeng@huawei.com, julien.grall@arm.com, shannon.zhao@linaro.org, boris.ostrovsky@oracle.com Subject: [Xen-devel] [PATCH v2 08/17] libxl/arm: Factor MPIDR computing codes out as a helper X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" From: Shannon Zhao Factor MPIDR computing codes out as a helper, so it could be shared between DT and ACPI. Signed-off-by: Shannon Zhao --- tools/libxl/libxl_arm.c | 8 +------- tools/libxl/libxl_arm_acpi.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index f5db74b..a766732 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -312,13 +312,7 @@ static int make_cpus_node(libxl__gc *gc, void *fdt, int nr_cpus, for (i = 0; i < nr_cpus; i++) { const char *name; - /* - * According to ARM CPUs bindings, the reg field should match - * the MPIDR's affinity bits. We will use AFF0 and AFF1 when - * constructing the reg value of the guest at the moment, for it - * is enough for the current max vcpu number. - */ - mpidr_aff = (i & 0x0f) | (((i >> 4) & 0xff) << 8); + mpidr_aff = libxl__compute_mpdir(i); name = GCSPRINTF("cpu@%"PRIx64, mpidr_aff); res = fdt_begin_node(fdt, name); diff --git a/tools/libxl/libxl_arm_acpi.h b/tools/libxl/libxl_arm_acpi.h index 5899210..9b58de6 100644 --- a/tools/libxl/libxl_arm_acpi.h +++ b/tools/libxl/libxl_arm_acpi.h @@ -23,6 +23,18 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, libxl__domain_build_state *state, struct xc_dom_image *dom); +static inline uint64_t libxl__compute_mpdir(int index) +{ + /* + * According to ARM CPUs bindings, the reg field should match + * the MPIDR's affinity bits. We will use AFF0 and AFF1 when + * constructing the reg value of the guest at the moment, for it + * is enough for the current max vcpu number. + */ + assert(index >= 0); + return (index & 0x0f) | (((index >> 4) & 0xff) << 8); +} + /* * Local variables: * mode: C