From patchwork Wed Jun 22 11:15:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 70630 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp2492643qgy; Wed, 22 Jun 2016 04:17:45 -0700 (PDT) X-Received: by 10.237.54.5 with SMTP id e5mr25529060qtb.41.1466594262574; Wed, 22 Jun 2016 04:17:42 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id b71si488559qkj.116.2016.06.22.04.17.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jun 2016 04:17:42 -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 1bFg8G-0002FJ-4Y; Wed, 22 Jun 2016 11:15:44 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFg8F-0002El-A6 for xen-devel@lists.xen.org; Wed, 22 Jun 2016 11:15:43 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id AC/13-11548-E537A675; Wed, 22 Jun 2016 11:15:42 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTTeuOCv c4PIsVoslHxezODB6HN39mymAMYo1My8pvyKBNWP/ltXsBfvEK2YemsLewLhDuIuRi0NIYBOj xO9L/xghnNOMEv+nb2DpYuTkYBPQlLjz+RMTiC0iIC1x7fNlRhCbWcBB4s3He2A1wgLmEnuOr WAFsVkEVCWaDk1nBrF5BVwkZhxfDBaXEJCTOHlsMpjNKeAqcfLoZLA5QkA1tw/sYZ3AyL2AkW EVo3pxalFZapGuoV5SUWZ6RkluYmaOrqGBmV5uanFxYnpqTmJSsV5yfu4mRqB/GYBgB+PO506 HGCU5mJREeeWVs8KF+JLyUyozEosz4otKc1KLDzHKcHAoSfDaFAHlBItS01Mr0jJzgIEGk5bg 4FES4a0DSfMWFyTmFmemQ6ROMepyHJt7Yy2TEEtefl6qlDgvH0iRAEhRRmke3AhY0F9ilJUS5 mUEOkqIpyC1KDezBFX+FaM4B6OSMG8QyBSezLwSuE2vgI5gAjpiWX86yBEliQgpqQZGTof6+Z Oj5zr8DZP1aHN+F+nDK3NEcB1746KCqitLDuzt/LLrBYdhjKGTnOcVK5178YKv/HMbntTkL26 Ye90jdV/5A2O+v03sl+/FWcx9/zzmVwqT1uefCo97pCPCZ+ye4ee4cv3d/+68S8oerPDk4p7x i/HMhAW3WmZdnH/g70HfL1uMfq0/r8RSnJFoqMVcVJwIAFLG1Et1AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-2.tower-21.messagelabs.com!1466594141!6324924!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.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19301 invoked from network); 22 Jun 2016 11:15:41 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-2.tower-21.messagelabs.com with SMTP; 22 Jun 2016 11:15:41 -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 4AFCC440; Wed, 22 Jun 2016 04:16:28 -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 B05ED3F213; Wed, 22 Jun 2016 04:15:40 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 22 Jun 2016 12:15:19 +0100 Message-Id: <1466594130-19251-5-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466594130-19251-1-git-send-email-julien.grall@arm.com> References: <1466594130-19251-1-git-send-email-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v4 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 Reviewed-by: Stefano Stabellini --- Changes in v3: - Add Stefano's reviewed-by --- 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 e35cde7..b264ed4 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: