From patchwork Mon May 23 14:17:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 68376 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp112094qge; Mon, 23 May 2016 07:19:00 -0700 (PDT) X-Received: by 10.31.189.81 with SMTP id n78mr8864743vkf.36.1464013140252; Mon, 23 May 2016 07:19:00 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id w188si20072627vkg.139.2016.05.23.07.19.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 May 2016 07:19:00 -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 1b4qg2-0003UN-TZ; Mon, 23 May 2016 14:17:50 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b4qg1-0003TI-QJ for xen-devel@lists.xen.org; Mon, 23 May 2016 14:17:49 +0000 Received: from [85.158.139.211] by server-12.bemta-5.messagelabs.com id C6/94-02669-D0113475; Mon, 23 May 2016 14:17:49 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRWlGSWpSXmKPExsVysyfVTZdH0Dn coOG1qsWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmrF++za2gpNiFTNmbGVrYLwj1MXIxSEksJFR YvWDJSwQzmlGiVlX/jJ2MXJysAloStz5/IkJxBYRkJa49vkyI0gRs8AcRok1D/4ygySEBcwlb pxoZgOxWQRUJabOfAXWzCvgInHv4GwwW0JATuLkscmsIDangKvE9i/nwOJCQDUdt3ayT2DkXs DIsIpRozi1qCy1SNfQVC+pKDM9oyQ3MTNH19DAVC83tbg4MT01JzGpWC85P3cTI9DHDECwg7F hu+chRkkOJiVR3pM7nMKF+JLyUyozEosz4otKc1KLDzHKcHAoSfBu5ncOFxIsSk1PrUjLzAEG G0xagoNHSYT3EB9Qmre4IDG3ODMdInWKUZfj2Nwba5mEWPLy81KlxHmngcwQACnKKM2DGwEL/ EuMslLCvIxARwnxFKQW5WaWoMq/YhTnYFQS5t0CMoUnM68EbtMroCOYgI54KO0AckRJIkJKqo HRdGl4o9GfvcLHOdMYr/O1cSVePRX4MSB0nXW74ae8M4qXHipt3tnzpuXpk6fNN8tfLeNzVj/ 2+XjkmU+nCu5EfzaT2/XYr/3tpzO7DiZ5cKrVzU0Je/Ws1fbaRMX1AmcWnYxedWLmCtZH177P 8Hi4/HfpjpOtP49+kkvoSC1NjpXtD/rPKPFitRJLcUaioRZzUXEiAK+bEQ93AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-3.tower-206.messagelabs.com!1464013068!37465424!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33986 invoked from network); 23 May 2016 14:17:48 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-3.tower-206.messagelabs.com with SMTP; 23 May 2016 14:17:48 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DDA7659; Mon, 23 May 2016 07:18:09 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.215.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9A1A93F21A; Mon, 23 May 2016 07:17:46 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 23 May 2016 15:17:21 +0100 Message-Id: <1464013052-32587-5-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464013052-32587-1-git-send-email-julien.grall@arm.com> References: <1464013052-32587-1-git-send-email-julien.grall@arm.com> Cc: sstabellini@kernel.org, wei.liu2@citrix.com, steve.capper@arm.com, andre.przywara@arm.com, Julien Grall , wei.chen@linaro.org Subject: [Xen-devel] [PATCH v2 04/15] xen/arm: Add cpu_hwcap bitmap 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" This will be used to know if a feature, which Xen cares, is available accross all the CPUs. This code is a light version of arch/arm64/kernel/cpufeature.c from Linux v4.6-rc3. Signed-off-by: Julien Grall --- xen/arch/arm/Makefile | 1 + xen/arch/arm/cpufeature.c | 34 ++++++++++++++++++++++++++++++++++ xen/include/asm-arm/cpufeature.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 xen/arch/arm/cpufeature.c diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 8e0d2f6..9122f78 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -6,6 +6,7 @@ subdir-$(CONFIG_ACPI) += acpi obj-y += bootfdt.o obj-y += cpu.o +obj-y += cpufeature.o obj-y += decode.o obj-y += device.o obj-y += domain.o diff --git a/xen/arch/arm/cpufeature.c b/xen/arch/arm/cpufeature.c new file mode 100644 index 0000000..7a1b56b --- /dev/null +++ b/xen/arch/arm/cpufeature.c @@ -0,0 +1,34 @@ +/* + * Contains CPU feature definitions + * + * Copyright (C) 2015 ARM Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include + +DECLARE_BITMAP(cpu_hwcaps, ARM_NCAPS); + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/asm-arm/cpufeature.h b/xen/include/asm-arm/cpufeature.h index 7b519cd..2bebad1 100644 --- a/xen/include/asm-arm/cpufeature.h +++ b/xen/include/asm-arm/cpufeature.h @@ -35,6 +35,35 @@ #endif #define cpu_has_security (boot_cpu_feature32(security) > 0) +#define ARM_NCAPS 0 + +#ifndef __ASSEMBLY__ + +#include +#include +#include + +extern DECLARE_BITMAP(cpu_hwcaps, ARM_NCAPS); + +static inline bool_t cpus_have_cap(unsigned int num) +{ + if ( num >= ARM_NCAPS ) + return 0; + + return test_bit(num, cpu_hwcaps); +} + +static inline void cpus_set_cap(unsigned int num) +{ + if (num >= ARM_NCAPS) + printk(XENLOG_WARNING "Attempt to set an illegal CPU capability (%d >= %d)\n", + num, ARM_NCAPS); + else + __set_bit(num, cpu_hwcaps); +} + +#endif /* __ASSEMBLY__ */ + #endif /* * Local variables: