From patchwork Wed Jun 22 11:15:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 70628 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp2492592qgy; Wed, 22 Jun 2016 04:17:41 -0700 (PDT) X-Received: by 10.31.108.17 with SMTP id h17mr10357493vkc.65.1466594259762; Wed, 22 Jun 2016 04:17:39 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id f128si30500142vkh.17.2016.06.22.04.17.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jun 2016 04:17:39 -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 1bFg8M-0002PE-1I; Wed, 22 Jun 2016 11:15:50 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFg8K-0002KT-S7 for xen-devel@lists.xen.org; Wed, 22 Jun 2016 11:15:48 +0000 Received: from [193.109.254.147] by server-5.bemta-14.messagelabs.com id 5E/22-08132-4637A675; Wed, 22 Jun 2016 11:15:48 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMLMWRWlGSWpSXmKPExsVysyfVTTe5OCv c4P8zYYslHxezODB6HN39mymAMYo1My8pvyKBNeNcz0W2ggf8FZuayhsYt/F0MXJyCAlsYpT4 Mtuni5ELyD7NKLH53VoWkASbgKbEnc+fmEBsEQFpiWufLzOC2MwCDhJvPt4DquHgEBZIk2j6a Q4SZhFQlZjQ3QFWwivgKrGo4wAziC0hICdx8thkVhCbEyh+8uhkRoi9LhK3D+xhncDIvYCRYR WjenFqUVlqka6FXlJRZnpGSW5iZo6uoaGJXm5qcXFiempOYlKxXnJ+7iZGoGcZgGAH48ZJzoc YJTmYlER55ZWzwoX4kvJTKjMSizPii0pzUosPMcpwcChJ8N7KAcoJFqWmp1akZeYAQwwmLcHB oyTCew8kzVtckJhbnJkOkTrFqCglDpEQAElklObBtcHC+hKjrJQwLyPQIUI8BalFuZklqPKvG MU5GJWEeT+CTOHJzCuBm/4KaDET0OJl/ekgi0sSEVJSDYwTlypq8KpFNJ9+U+njfv+JMPvzXX LfYjV0Tz2JXRP+KOhOyO5vyu/0LDceEZx/bmKFR9inhb+POOV9+RZ2dMqM8EfSBudrg5qaZ7l OOe24NWKX9Obd+vmnvvb3OcpOn1pceqa3pP7mT47EsorD88PFDjN4XebZ7DfzYFPn26smCw40 ZjXpVzUpsRRnJBpqMRcVJwIACGBGvWYCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-10.tower-27.messagelabs.com!1466594145!49250234!2 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 25762 invoked from network); 22 Jun 2016 11:15:46 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-10.tower-27.messagelabs.com with SMTP; 22 Jun 2016 11:15:46 -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 A11373B0; Wed, 22 Jun 2016 04:16:33 -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 152343F213; Wed, 22 Jun 2016 04:15:45 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 22 Jun 2016 12:15:25 +0100 Message-Id: <1466594130-19251-11-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 10/15] xen/arm: cpufeature: Provide an helper to check if a capability is supported 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" The CPU capabilities will be set depending on the value found in the CPU registers. This patch provides a generic to go through a set of capabilities and find which one should be enabled. The parameter "info" is used to display the kind of capability updated (e.g workaround, feature...). Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- Changes in v4: - Add Stefano's acked-by Changes in v3: - Patch added. The code was previously part of "Detect silicon...". --- xen/arch/arm/cpufeature.c | 16 ++++++++++++++++ xen/include/asm-arm/cpufeature.h | 9 +++++++++ 2 files changed, 25 insertions(+) diff --git a/xen/arch/arm/cpufeature.c b/xen/arch/arm/cpufeature.c index 7a1b56b..088625b 100644 --- a/xen/arch/arm/cpufeature.c +++ b/xen/arch/arm/cpufeature.c @@ -24,6 +24,22 @@ DECLARE_BITMAP(cpu_hwcaps, ARM_NCAPS); +void update_cpu_capabilities(const struct arm_cpu_capabilities *caps, + const char *info) +{ + int i; + + for ( i = 0; caps[i].matches; i++ ) + { + if ( !caps[i].matches(&caps[i]) ) + continue; + + if ( !cpus_have_cap(caps[i].capability) && caps[i].desc ) + printk(XENLOG_INFO "%s: %s\n", info, caps[i].desc); + cpus_set_cap(caps[i].capability); + } +} + /* * Local variables: * mode: C diff --git a/xen/include/asm-arm/cpufeature.h b/xen/include/asm-arm/cpufeature.h index 2bebad1..be2414c 100644 --- a/xen/include/asm-arm/cpufeature.h +++ b/xen/include/asm-arm/cpufeature.h @@ -62,6 +62,15 @@ static inline void cpus_set_cap(unsigned int num) __set_bit(num, cpu_hwcaps); } +struct arm_cpu_capabilities { + const char *desc; + u16 capability; + bool_t (*matches)(const struct arm_cpu_capabilities *); +}; + +void update_cpu_capabilities(const struct arm_cpu_capabilities *caps, + const char *info); + #endif /* __ASSEMBLY__ */ #endif