From patchwork Wed Jul 27 16:37:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9250157 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4D23160B17 for ; Wed, 27 Jul 2016 16:39:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EEAE212D6 for ; Wed, 27 Jul 2016 16:39:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 337E1212D9; Wed, 27 Jul 2016 16:39:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CDCDE26907 for ; Wed, 27 Jul 2016 16:39:58 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSRpi-0001K4-Bg; Wed, 27 Jul 2016 16:37:22 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSRph-0001JE-AM for xen-devel@lists.xen.org; Wed, 27 Jul 2016 16:37:21 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 36/8A-21406-043E8975; Wed, 27 Jul 2016 16:37:20 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTdfh8Yx wg1tz+SyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oymX8oFlwUqWlZ/ZWxgnMDbxcjFISSwkVHi 0OdpLBDOaUaJjsmngRxODjYBTYk7nz8xgdgiAtIS1z5fZgSxmQUiJZ7MvMEMYgsLpEismbWNH cRmEVCVODjpDCuIzSvgLPHt3GawuISAnMTJY5PB4pwCLhI/Jv1iA7GFQGr2PWaewMi9gJFhFa N6cWpRWWqRroleUlFmekZJbmJmjq6hgZlebmpxcWJ6ak5iUrFecn7uJkagdxmAYAdj92X/Q4y SHExKoryLHGeEC/El5adUZiQWZ8QXleakFh9ilOHgUJLgTXkElBMsSk1PrUjLzAGGGUxagoNH SYQ3HiTNW1yQmFucmQ6ROsWoKCXOWwOSEABJZJTmwbXBQvsSo6yUMC8j0CFCPAWpRbmZJajyr xjFORiVhHkjQKbwZOaVwE1/BbSYCWhxcSzY4pJEhJRUA2PR3hDlrWdrmiy+sZ0t3nNCf9dORi 7r4oKu4xwKVTXPVS0PqHukRKfd8l+99tHno6cWK9yLWbyZ6dzc+1rsqeL/9SM6LgvG907R81Y 9/oX1i+U67z/fKlvX/zYUjti0VnHK9nh1SysWM9ZaoQXR7TXf+BRS2cSDFrfsUt41pz2nLKvg hvuTSCWW4oxEQy3mouJEAKTHTdNoAgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-13.tower-21.messagelabs.com!1469637439!25981998!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 60675 invoked from network); 27 Jul 2016 16:37:20 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-13.tower-21.messagelabs.com with SMTP; 27 Jul 2016 16:37:20 -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 B59F728; Wed, 27 Jul 2016 09:38:35 -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 90E6A3F25F; Wed, 27 Jul 2016 09:37:18 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 27 Jul 2016 17:37:06 +0100 Message-Id: <1469637431-1069-3-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1469637431-1069-1-git-send-email-julien.grall@arm.com> References: <1469637431-1069-1-git-send-email-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v6 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" X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Konrad Rzeszutek Wilk --- Changes in v6: - Add Konrad's reviewed-by 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