From patchwork Tue Jun 7 16:06:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9161819 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 8B20F60801 for ; Tue, 7 Jun 2016 16:08:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CF3C2723E for ; Tue, 7 Jun 2016 16:08:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FBB22823D; Tue, 7 Jun 2016 16:08:51 +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 EAB1727248 for ; Tue, 7 Jun 2016 16:08:50 +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 1bAJWa-0002FS-Q6; Tue, 07 Jun 2016 16:06:40 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAJWZ-0002EX-5w for xen-devel@lists.xen.org; Tue, 07 Jun 2016 16:06:39 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 57/0E-30266-E01F6575; Tue, 07 Jun 2016 16:06:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRWlGSWpSXmKPExsVysyfVTZf3Y1i 4wYMJphZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aJl0dYCvaJV2x59o21gXGHcBcjF4eQwAZG id/XNrJ0MXICOacZJaY08oDYbAKaEnc+f2ICsUUEpCWufb7MCGIzCzQzSiw84AdiCwuYS6w+O 5sVxGYRUJX4vasPrIZXwFli2/F57CC2hICcxMljk8FqOAVcJNoePGKD2OUssfRXA+MERu4FjA yrGNWLU4vKUot0DfWSijLTM0pyEzNzdA0NzPRyU4uLE9NTcxKTivWS83M3MQK9ywAEOxh3Pnc 6xCjJwaQkyvv5WVi4EF9SfkplRmJxRnxRaU5q8SFGGQ4OJQnewndAOcGi1PTUirTMHGCYwaQl OHiURHi3vwVK8xYXJOYWZ6ZDpE4x6nIcm3tjLZMQS15+XqqUOO8RkCIBkKKM0jy4EbCQv8QoK yXMywh0lBBPQWpRbmYJqvwrRnEORiVhXjOQS3gy80rgNr0COoIJ6Ihl14JBjihJREhJNTAyRH zucW88qlMbPXvJbrVDt9c7m926nKqkHv3oif9KlaO3cr3tb/x347v+IPpxtm52VNRUw9faYpt LmN4p9HVd+L+oc5oMu0vZhX5Vbuc3kYf/LJsR9MI1T8Kx9s3yg7+unznyJcR91+YnBc+jPDSe Nq48ed18wYyVyVmMf/9LJnWYuWif+yWixFKckWioxVxUnAgA7wN6I3QCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-14.tower-21.messagelabs.com!1465315597!17761724!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 47509 invoked from network); 7 Jun 2016 16:06:37 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-14.tower-21.messagelabs.com with SMTP; 7 Jun 2016 16:06:37 -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 92565F; Tue, 7 Jun 2016 09:07:11 -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 B7E503F21A; Tue, 7 Jun 2016 09:06:35 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 7 Jun 2016 17:06:11 +0100 Message-Id: <1465315583-1278-5-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 04/16] 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" X-Virus-Scanned: ClamAV using ClamSMTP 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 bd93013..b95d924 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: