From patchwork Mon May 23 14:17:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9131909 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 ECEC3607D3 for ; Mon, 23 May 2016 14:19:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3FA72822F for ; Mon, 23 May 2016 14:19:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8D682823B; Mon, 23 May 2016 14:19:56 +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 7FB862822F for ; Mon, 23 May 2016 14:19:56 +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 1b4qg2-0003UN-TZ; Mon, 23 May 2016 14:17:50 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b4qg1-0003TI-QJ for xen-devel@lists.xen.org; Mon, 23 May 2016 14:17:49 +0000 Received: from [85.158.139.211] by server-12.bemta-5.messagelabs.com id C6/94-02669-D0113475; Mon, 23 May 2016 14:17:49 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRWlGSWpSXmKPExsVysyfVTZdH0Dn coOG1qsWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmrF++za2gpNiFTNmbGVrYLwj1MXIxSEksJFR YvWDJSwQzmlGiVlX/jJ2MXJysAloStz5/IkJxBYRkJa49vkyI0gRs8AcRok1D/4ygySEBcwlb pxoZgOxWQRUJabOfAXWzCvgInHv4GwwW0JATuLkscmsIDangKvE9i/nwOJCQDUdt3ayT2DkXs DIsIpRozi1qCy1SNfQVC+pKDM9oyQ3MTNH19DAVC83tbg4MT01JzGpWC85P3cTI9DHDECwg7F hu+chRkkOJiVR3pM7nMKF+JLyUyozEosz4otKc1KLDzHKcHAoSfBu5ncOFxIsSk1PrUjLzAEG G0xagoNHSYT3EB9Qmre4IDG3ODMdInWKUZfj2Nwba5mEWPLy81KlxHmngcwQACnKKM2DGwEL/ EuMslLCvIxARwnxFKQW5WaWoMq/YhTnYFQS5t0CMoUnM68EbtMroCOYgI54KO0AckRJIkJKqo HRdGl4o9GfvcLHOdMYr/O1cSVePRX4MSB0nXW74ae8M4qXHipt3tnzpuXpk6fNN8tfLeNzVj/ 2+XjkmU+nCu5EfzaT2/XYr/3tpzO7DiZ5cKrVzU0Je/Ws1fbaRMX1AmcWnYxedWLmCtZH177P 8Hi4/HfpjpOtP49+kkvoSC1NjpXtD/rPKPFitRJLcUaioRZzUXEiAK+bEQ93AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-3.tower-206.messagelabs.com!1464013068!37465424!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.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33986 invoked from network); 23 May 2016 14:17:48 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-3.tower-206.messagelabs.com with SMTP; 23 May 2016 14:17:48 -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 DDA7659; Mon, 23 May 2016 07:18:09 -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 9A1A93F21A; Mon, 23 May 2016 07:17:46 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 23 May 2016 15:17:21 +0100 Message-Id: <1464013052-32587-5-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464013052-32587-1-git-send-email-julien.grall@arm.com> References: <1464013052-32587-1-git-send-email-julien.grall@arm.com> Cc: sstabellini@kernel.org, wei.liu2@citrix.com, steve.capper@arm.com, andre.przywara@arm.com, Julien Grall , wei.chen@linaro.org Subject: [Xen-devel] [PATCH v2 04/15] 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 --- 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 8e0d2f6..9122f78 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: