From patchwork Thu May 5 16:34:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 67217 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp844669qge; Thu, 5 May 2016 09:35:46 -0700 (PDT) X-Received: by 10.176.1.103 with SMTP id 94mr9998241uak.41.1462466146938; Thu, 05 May 2016 09:35:46 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 99si5151324uad.166.2016.05.05.09.35.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 May 2016 09:35:46 -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 1ayMEa-0001k0-NB; Thu, 05 May 2016 16:34:40 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ayMEa-0001gF-97 for xen-devel@lists.xen.org; Thu, 05 May 2016 16:34:40 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id 58/9C-21979-0267B275; Thu, 05 May 2016 16:34:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTVe+TDv cYMVZeYslHxezODB6HN39mymAMYo1My8pvyKBNWP99m1sBSfFKmbM2MrWwHhHqIuRi0NIYCOj xLZ7D1kgnNOMEmcX3WXtYuTkYBPQlLjz+RMTiC0iIC1x7fNlRpAiZoFmRonpi16zgSSEBYwkL jy7yQJiswioSty8s4odxOYVcJGYcnoJI4gtISAncfLYZLChnAKuEkvPrwSrFwKqObljEtsERu 4FjAyrGNWLU4vKUot0TfWSijLTM0pyEzNzdA0NTPVyU4uLE9NTcxKTivWS83M3MQI9zAAEOxi /9DsfYpTkYFIS5d2upB0uxJeUn1KZkVicEV9UmpNafIhRhoNDSYJXrhQoJ1iUmp5akZaZAww1 mLQEB4+SCK8ESJq3uCAxtzgzHSJ1ilGX49jcG2uZhFjy8vNSpcR5FUCKBECKMkrz4EbAwv4So 6yUMC8j0FFCPAWpRbmZJajyrxjFORiVhHmZQKbwZOaVwG16BXQEE9AR7+dqghxRkoiQkmpgnP rDfr68pdfx/azat15sz+d49KXgSGuClHdh8ZtZ57eutSq95iteXGDh/mbpI51qrQXqZf/vzWd etGx19brpzrqBkc99JE2vWu7ZcnzugbshXGd2ToldIXL9Z6qELPcZy6nW9ZzsuYpL3D4IHYud pC+4YcPdR5fVHFun5G0pv/Q7edn9qaZhS5RYijMSDbWYi4oTAXiQ7JV2AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-206.messagelabs.com!1462466078!1741560!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 29033 invoked from network); 5 May 2016 16:34:39 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-206.messagelabs.com with SMTP; 5 May 2016 16:34:39 -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 1386C49; Thu, 5 May 2016 09:34:46 -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 55C933F252; Thu, 5 May 2016 09:34:37 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 5 May 2016 17:34:14 +0100 Message-Id: <1462466065-30212-6-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1462466065-30212-1-git-send-email-julien.grall@arm.com> References: <1462466065-30212-1-git-send-email-julien.grall@arm.com> Cc: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org, wei.chen@arm.com, steve.capper@arm.com Subject: [Xen-devel] [RFC 05/16] 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: