From patchwork Wed Jul 20 15:25:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 72428 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp43096qga; Wed, 20 Jul 2016 08:28:29 -0700 (PDT) X-Received: by 10.36.111.72 with SMTP id x69mr9609635itb.71.1469028509841; Wed, 20 Jul 2016 08:28:29 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id q69si2412163itq.87.2016.07.20.08.28.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jul 2016 08:28:29 -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 1bPtNy-0001vq-9y; Wed, 20 Jul 2016 15:26:10 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bPtNx-0001vP-KL for xen-devel@lists.xen.org; Wed, 20 Jul 2016 15:26:09 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id 69/B1-12946-0189F875; Wed, 20 Jul 2016 15:26:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTVdgRn+ 4wdQHqhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8a5notsBQ/4KzY1lTcwbuPpYuTiEBLYxChx bdtydgjnNKNEw7mrLF2MnBxsApoSdz5/YgKxRQSkJa59vswIYjMLOEi8+XgPrEZYIEXi67U77 CA2i4CqxPIJv9m6GDk4eAVcJNYc9wUJSwjISZw8NpkVxOYUcJXYtuERM4gtBFTSOn078wRG7g WMDKsYNYpTi8pSi3SNTPWSijLTM0pyEzNzdA0NTPVyU4uLE9NTcxKTivWS83M3MQK9W8/AwLi DcVe73yFGSQ4mJVFeVdHecCG+pPyUyozE4oz4otKc1OJDjDIcHEoSvBbT+8OFBItS01Mr0jJz gGEGk5bg4FES4f04DSjNW1yQmFucmQ6ROsWoKCXO+x4kIQCSyCjNg2uDhfYlRlkpYV5GBgYGI Z6C1KLczBJU+VeM4hyMSsK830Cm8GTmlcBNfwW0mAlo8RwBsMUliQgpqQbGDgHz3bH3vhwRfr +x2C5te1SN0x/+F6c/zLJjL98QPfvzWrN/DB/O/TKcGix8t73n37WNUe2GjBuEp5srnrr3k/H LQ73cT5se5kqc05Ip29Peedj6hd/rRi2fVJVds9gWGeh2v2sUPHtDxij0ovd9vhueP7f+vO5n pvT92PrJnry3rFLCzvVYKLEUZyQaajEXFScCAGutZOloAgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-2.tower-206.messagelabs.com!1469028368!34565216!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.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 21570 invoked from network); 20 Jul 2016 15:26:08 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-2.tower-206.messagelabs.com with SMTP; 20 Jul 2016 15:26:08 -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 416C2433; Wed, 20 Jul 2016 08:27:18 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.218.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 13D6A3F387; Wed, 20 Jul 2016 08:26:06 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 20 Jul 2016 16:25:55 +0100 Message-Id: <1469028360-20907-3-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1469028360-20907-1-git-send-email-julien.grall@arm.com> References: <1469028360-20907-1-git-send-email-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v5 2/7] 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