From patchwork Tue Jul 5 03:12:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 71383 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp91974qgy; Mon, 4 Jul 2016 20:19:48 -0700 (PDT) X-Received: by 10.36.17.131 with SMTP id 125mr11585731itf.81.1467688788392; Mon, 04 Jul 2016 20:19:48 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id e202si403453ioe.30.2016.07.04.20.19.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jul 2016 20:19:48 -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 1bKGro-0001R9-CB; Tue, 05 Jul 2016 03:17:44 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKGrn-0001Qm-Bh for xen-devel@lists.xen.org; Tue, 05 Jul 2016 03:17:43 +0000 Received: from [85.158.139.211] by server-13.bemta-5.messagelabs.com id 32/D1-16475-6D62B775; Tue, 05 Jul 2016 03:17:42 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsVSPpHPUfeaWnW 4wcT9PBZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8anz8oFE/krVn6cw9zAeJq7i5GLQ0jgFKPE j6sbGCGc3YwSOyYuY+ti5ORgE9CV+LhxCjuILSIgK7G6aw6YzSzwgVHi1GwJEFtYIFCit/0nW JxFQEViw6bJzCA2r4CnRPfUBSwgtoSAhsTK3glgNidQ/OtNCFtIwEOi/8B6Voh6QYmTM5+wQM yXkDj44gUzRK+iRNv6k2wQtqTEwRU3WEAOlQC5uuNcB9QCU4l1j9cwT2AUnIVk1iwksxYwMq1 i1ChOLSpLLdI1NNRLKspMzyjJTczM0TU0MNXLTS0uTkxPzUlMKtZLzs/dxAgMUAYg2MG4st35 EKMkB5OSKO+rf1XhQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4O1Wrw4UEi1LTUyvSMnOAsQKTl uDgURLhvQWS5i0uSMwtzkyHSJ1iVJQS550HkhAASWSU5sG1weLzEqOslDAvI9AhQjwFqUW5mS Wo8q8YxTkYlYR554JM4cnMK4Gb/gpoMRPQYtbYcpDFJYkIKakGxiWzTjpx+hjxLT1WeMPt6pX uM55WgrnyRwwqstplpudOYfSWChQslI91uXbpfLT1GpGadsuY32d5RXfFFk1NWNq1dcqqj/c2 PS3IWOzT9CrfkCWG307+aXDl0vibqi8Zlt35FnJ8/4b4upgdc/683Duj6egDXYeXL3k+C5xnc 2Zf8e72G/VZTkosxRmJhlrMRcWJAPiTXcTKAgAA X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-7.tower-206.messagelabs.com!1467688659!48270015!1 X-Originating-IP: [119.145.14.65] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NSA9PiA3NzQ2Mw==\n X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 24379 invoked from network); 5 Jul 2016 03:17:41 -0000 Received: from szxga02-in.huawei.com (HELO szxga02-in.huawei.com) (119.145.14.65) by server-7.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 5 Jul 2016 03:17:41 -0000 Received: from 172.24.1.47 (EHLO SZXEML429-HUB.china.huawei.com) ([172.24.1.47]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DJT71995; Tue, 05 Jul 2016 11:14:08 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by SZXEML429-HUB.china.huawei.com (10.82.67.184) with Microsoft SMTP Server id 14.3.235.1; Tue, 5 Jul 2016 11:14:02 +0800 From: Shannon Zhao To: Date: Tue, 5 Jul 2016 11:12:40 +0800 Message-ID: <1467688367-17320-11-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1467688367-17320-1-git-send-email-zhaoshenglong@huawei.com> References: <1467688367-17320-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.0A020203.577B2600.00CD, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 5de12a4433089a61c85396eae729c3e3 Cc: hangaohuai@huawei.com, 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 v3 10/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.h | 11 +++++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index 7c522e1..94cb773 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -309,13 +309,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.h b/tools/libxl/libxl_arm.h index 1c01177..a91ff93 100644 --- a/tools/libxl/libxl_arm.h +++ b/tools/libxl/libxl_arm.h @@ -24,6 +24,17 @@ 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(unsigned int cpuid) +{ + /* + * 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. + */ + return (cpuid & 0x0f) | (((cpuid >> 4) & 0xff) << 8); +} + /* * Local variables: * mode: C