From patchwork Thu Sep 22 12:52:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 76781 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp14827qgf; Thu, 22 Sep 2016 05:55:32 -0700 (PDT) X-Received: by 10.36.124.141 with SMTP id a135mr2465729itd.25.1474548932637; Thu, 22 Sep 2016 05:55:32 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id w5si45981558itf.18.2016.09.22.05.55.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Sep 2016 05:55:32 -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 1bn3Vi-0004KW-Gu; Thu, 22 Sep 2016 12:53:54 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bn3Vh-0004Jg-N9 for xen-devel@lists.xen.org; Thu, 22 Sep 2016 12:53:53 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id AA/06-12614-064D3E75; Thu, 22 Sep 2016 12:53:52 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBIsWRWlGSWpSXmKPExsVSPpHPSTfhyuN wgzMPJS2WfFzM4sDocXT3b6YAxijWzLyk/IoE1oy/s3+xFuznr3j//zZTA+NX7i5GTg4hgTOM EhtP83QxcgHZexgllrxdwwKSYBPQkjg//Qc7iC0iICuxumsOO0gRs8B1Rok777exgiSEBQIlj q16A2azCKhKtHffZgKxeQU8JK7cXAlmSwhoSKzsnQA2lFPAU2LCkfWsEJs9JFZeWcgKUS8ocX LmE7AaZgEJiYMvXjBD9CpKtK0/yQZhS0ocXHGDBeQICYFTjBLz7m1lhEiYSnyZsIdxAqPgLCS zZiGZtYCRaRWjRnFqUVlqka6hsV5SUWZ6RkluYmaOrqGBqV5uanFxYnpqTmJSsV5yfu4mRmCI MgDBDsZ/2zwPMUpyMCmJ8l7ofxwuxJeUn1KZkVicEV9UmpNafIhRhoNDSYL38SWgnGBRanpqR VpmDjBaYNISHDxKIrzFl4HSvMUFibnFmekQqVOMilLivL9B+gRAEhmleXBtsAi9xCgrJczLCH SIEE9BalFuZgmq/CtGcQ5GJWHeIJDxPJl5JXDTXwEtZgJavOXnA5DFJYkIKakGxpzp4s91bJd dmlwSwtCV8Hhq1p/3GnJXeBSq57G7mX1bu+VsFF961tqNu/86Pdl30+7Rbz6TzTPmqOiwtTW8 vrcz67XiS6b2zO97i3n5f2vtejdhwnp7q682mzz1080yeDy/CirYK5/VUmeQSxVVFg4rNHVUP 7P5oo/e7cS151Ktpu7LsFQVV2Ipzkg01GIuKk4EAFehPeHLAgAA X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-9.tower-206.messagelabs.com!1474548828!61046854!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.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 59132 invoked from network); 22 Sep 2016 12:53:52 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-9.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 22 Sep 2016 12:53:52 -0000 Received: from 172.24.1.137 (EHLO szxeml431-hub.china.huawei.com) ([172.24.1.137]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CIG48128; Thu, 22 Sep 2016 20:53:04 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml431-hub.china.huawei.com (10.82.67.208) with Microsoft SMTP Server id 14.3.235.1; Thu, 22 Sep 2016 20:52:55 +0800 From: z00226004 To: Date: Thu, 22 Sep 2016 20:52:25 +0800 Message-ID: <1474548753-12596-9-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1474548753-12596-1-git-send-email-zhaoshenglong@huawei.com> References: <1474548753-12596-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.0A020204.57E3D430.023F, 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: 1f4f0d6ff436001ffffc8746902a5d08 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 v6 08/16] 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 Acked-by: Julien Grall --- 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 333c9a1..2a4577c 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