From patchwork Thu Sep 29 01:18:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 9355507 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B75E8608A0 for ; Thu, 29 Sep 2016 01:22:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A15A828E6B for ; Thu, 29 Sep 2016 01:22:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FFB029716; Thu, 29 Sep 2016 01:22:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B732328E6B for ; Thu, 29 Sep 2016 01:22:31 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpQ0o-0001Qv-9j; Thu, 29 Sep 2016 01:19:46 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpQ0n-0001Ok-Du for xen-devel@lists.xen.org; Thu, 29 Sep 2016 01:19:45 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id 1D/45-30284-03C6CE75; Thu, 29 Sep 2016 01:19:44 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsVyMfTAel2DnDf hBn8XcFss+biYxYHR4+ju30wBjFGsmXlJ+RUJrBlfZ1xhKZjIX7H/8gfGBsZH3F2MXBxCAhMZ JWZsf8YM4rAIzGOWuDTtNksXIyeHhEA/q8T/i9kQdozEvdXrmboYOYDsKom+O6YgYSEBNYllh xcyQwxqYpK48PsXK0iCTUBH4sWknWwgtoiAtMS1z5cZQYqYBY4wStyaf5IZJCEsECgxdfoWdh CbRUBV4uvMQ2A2r4C1xNffFxkhFmtKTJ/1GqyeU8BG4kPLL2aIzdYSy75tZpnAKLCAkWEVo3p xalFZapGuoV5SUWZ6RkluYmaOrqGBqV5uanFxYnpqTmJSsV5yfu4mRmBg1TMwMO5gbOp1PsQo ycGkJMrL6fMmXIgvKT+lMiOxOCO+qDQntfgQowwHh5IEr1c2UE6wKDU9tSItMwcY4jBpCQ4eJ RHeV1lAad7igsTc4sx0iNQpRmOOLb+vrWXi2Db13lomIZa8/LxUKXHeqyClAiClGaV5cINgsX eJUVZKmJeRgYFBiKcgtSg3swRV/hWjOAejkjCvMsg9PJl5JXD7XgGdwgR0ytITL0BOKUlESEk 1MPKucL2esaaBrTTgZaWA9u0LH6RXFl82P7N/Ak8wy4Q1XBLVv99N2H3MZpv7v0WSYvdLS/Y9 iAt5nLRm7YbqW3oTbxU3LFcKvRX8I0LkwcJgGVeRfw2Wx6xWfQqK/ctbtzjGWOn/C0eWr9vmL lXZeOfvkaJ3Hb9dP32I0nlkFKv5VJdPbFN+ZKcSS3FGoqEWc1FxIgCZ4oiauAIAAA== X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-10.tower-206.messagelabs.com!1475111982!44938026!1 X-Originating-IP: [209.85.192.175] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 3911 invoked from network); 29 Sep 2016 01:19:44 -0000 Received: from mail-pf0-f175.google.com (HELO mail-pf0-f175.google.com) (209.85.192.175) by server-10.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 29 Sep 2016 01:19:44 -0000 Received: by mail-pf0-f175.google.com with SMTP id q2so22843227pfj.3 for ; Wed, 28 Sep 2016 18:19:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=f2fjUUdAa3OsWpipqzqF2IhpQYS4kbkM+0QimD4Qt84=; b=ZGca4TYQebukIqbdf4bUadPGQIAoXE2X43cEGZB9p2zCNIfzZN39bI7yU1iQJ7E2L8 qgmNmTLdWjiGSrGFHnLKDseSmQsYesiof1bno4fnquGUG2+K9SRTvTnQzkn2I5EO3/It uFd4BOFgEcOcT4d+XmB0sMngI1KYHScShHsAQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=f2fjUUdAa3OsWpipqzqF2IhpQYS4kbkM+0QimD4Qt84=; b=NCaTDYkuVswpfJEkyLzQMR3w++O6RC1Krw95/J9xldLkMHMlRRBMOR1ih41toIqXyf CoNjkUqEFWVWK/Xkg6OhGoOwx/EnkoFwGhV2rjzSkfy8IvBLxPnMQM6wBOSpAFNypaxV dsuJsg1VnLXEJBuNWWChADdBE3BiFqlCp3CT6MEDcEdKm3TI2sS5Lkga+nFLTpr+69FV bAghLgfBMuAUaLEfeZQBoPsph5kNpP0urtuwjOuXxaDf+vW6xgzokGuxFlx6EtRAB1TU 8RU0kUI+kOqeGbMPcTIeBS0Ml8l5nRPYUQVBbAVUOrN1djQMu5unFzqFMDyUf1LVGDB5 XX8Q== X-Gm-Message-State: AE9vXwOVVXJEwf2QnxvGj9MINF+kENR+mD2fpyxeWmMxTrjd0+/cBY1A8zEp6UjvUxLAPhSk X-Received: by 10.98.158.90 with SMTP id s87mr61181744pfd.117.1475111982585; Wed, 28 Sep 2016 18:19:42 -0700 (PDT) Received: from HZA160860128-A.china.huawei.com ([67.238.99.186]) by smtp.gmail.com with ESMTPSA id wd7sm15228744pab.2.2016.09.28.18.19.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Sep 2016 18:19:41 -0700 (PDT) From: Shannon Zhao To: xen-devel@lists.xen.org Date: Wed, 28 Sep 2016 18:18:54 -0700 Message-Id: <20160929011902.7784-9-shannon.zhao@linaro.org> X-Mailer: git-send-email 2.10.0.windows.1 In-Reply-To: <20160929011902.7784-1-shannon.zhao@linaro.org> References: <20160929011902.7784-1-shannon.zhao@linaro.org> Cc: sstabellini@kernel.org, wei.liu2@citrix.com, ian.jackson@eu.citrix.com, julien.grall@arm.com, Shannon Zhao , zhaoshenglong@huawei.com, boris.ostrovsky@oracle.com Subject: [Xen-devel] [PATCH v8 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Wei Liu --- 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 ec76c32..a21dc56 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 fcce405..7097def 100644 --- a/tools/libxl/libxl_arm.h +++ b/tools/libxl/libxl_arm.h @@ -23,6 +23,17 @@ _hidden int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, 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