From patchwork Tue Jun 7 16:06:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 69523 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2056489qgf; Tue, 7 Jun 2016 09:08:16 -0700 (PDT) X-Received: by 10.55.143.129 with SMTP id r123mr217944qkd.170.1465315687904; Tue, 07 Jun 2016 09:08:07 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id s190si14410014qkc.198.2016.06.07.09.08.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jun 2016 09:08:07 -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 1bAJWi-0002Pu-Mk; Tue, 07 Jun 2016 16:06:48 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAJWh-0002NE-2J for xen-devel@lists.xen.org; Tue, 07 Jun 2016 16:06:47 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id AF/BB-31933-611F6575; Tue, 07 Jun 2016 16:06:46 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTVf0Y1i 4QcdHQ4slHxezODB6HN39mymAMYo1My8pvyKBNWPl4s1MBV/5Knp2X2BrYHzM3cXIxSEksIlR 4s+FN0wQzmlGifu7J7J3MXJysAloStz5/IkJxBYRkJa49vkyI4jNLNDMKLHwgB+ILSyQJnHo8 A9WEJtFQFViRfsNFhCbV8BF4vGh62C9EgJyEiePTQar4QSKtz14xAZiCwk4Syz91cA4gZF7AS PDKkb14tSistQiXXO9pKLM9IyS3MTMHF1DA2O93NTi4sT01JzEpGK95PzcTYxA/zIAwQ7Gxu9 OhxglOZiURHk/PwsLF+JLyk+pzEgszogvKs1JLT7EKMPBoSTBK/0OKCdYlJqeWpGWmQMMNJi0 BAePkghvFkiat7ggMbc4Mx0idYpRUUqcVwckIQCSyCjNg2uDBfclRlkpYV5GoEOEeApSi3IzS 1DlXzGKczAqCfOagUzhycwrgZv+CmgxE9DiZdeCQRaXJCKkpBoYWcw/n8iLc+47cIs34X54WW 98bGGSDIdof8XyyjffjTat3JW4Len8nkTDK3PzS/+Jyuq6SF92/SD79WfU+hDO5h1ibO5SF8z 1dy7fIvFxhsmZwuIJbaoHcznr0pg000vbaxWWP2PcGmL2av3ywBmPDE4aeF9hK/pgsfso90Vr n7AzX9ZKXT6hxFKckWioxVxUnAgAEmvunmkCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-4.tower-31.messagelabs.com!1465315605!34523219!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 1923 invoked from network); 7 Jun 2016 16:06:45 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-31.messagelabs.com with SMTP; 7 Jun 2016 16:06:45 -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 98C90434; Tue, 7 Jun 2016 09:07:19 -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 17FFC3F21A; Tue, 7 Jun 2016 09:06:43 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 7 Jun 2016 17:06:17 +0100 Message-Id: <1465315583-1278-11-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465315583-1278-1-git-send-email-julien.grall@arm.com> References: <1465315583-1278-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] [PATCH v3 10/16] 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 --- 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