From patchwork Wed Jun 22 13:21:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 70643 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp2547150qgy; Wed, 22 Jun 2016 06:23:34 -0700 (PDT) X-Received: by 10.107.138.6 with SMTP id m6mr38997379iod.181.1466601811301; Wed, 22 Jun 2016 06:23:31 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id e101si642171ioi.60.2016.06.22.06.23.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jun 2016 06:23:31 -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 1bFi5v-000197-Bq; Wed, 22 Jun 2016 13:21:27 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFi5u-00016i-4B for xen-devel@lists.xen.org; Wed, 22 Jun 2016 13:21:26 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id C7/B2-11548-5D09A675; Wed, 22 Jun 2016 13:21:25 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMLMWRWlGSWpSXmKPExsVysyfVTffqhKx wg3WrpSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1ozNh/wKXkpU3DvXydzAeJqvi5GLQ0hgE6PE 8R/drF2MnEDOaUaJV3/zQGw2AU2JO58/MYHYIgLSEtc+X2YEaWAWaGOUWDt7KiNIQlggQOLTh k3sXYwcHCwCqhILz8WCmLwCLhKbt6uDVEgIyEmcPDYZbDyngKvE//NNUKtcJNZ9Ps86gZF7AS PDKkb14tSistQiXWO9pKLM9IyS3MTMHF1DAzO93NTi4sT01JzEpGK95PzcTYxAzzIAwQ7Gjn9 OhxglOZiURHnllbPChfiS8lMqMxKLM+KLSnNSiw8xynBwKEnwuvYD5QSLUtNTK9Iyc4AhBpOW 4OBREuGNBEnzFhck5hZnpkOkTjEqSonz1oAkBEASGaV5cG2wsL7EKCslzMsIdIgQT0FqUW5mC ar8K0ZxDkYlYV4FkCk8mXklcNNfAS1mAlq8rD8dZHFJIkJKqoFx8Y1rz97FzsvWCkv/lTfz2M 5ZOsX5des4N3Se5xe1WOH7n+Fu7xetAsXWZHsNsxsKJ31my4T1Tv2VsGRiw1TVPaGph/6wrGO c2npYefeuTav2XIl/1/XkdicfY0DK2pNRjNJq/yqF175UniFqqr5Mc5XAHjfh7juuOp3JmxnD /a9NOMy5PElHiaU4I9FQi7moOBEAVBU2EGYCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-2.tower-21.messagelabs.com!1466601683!6353330!2 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 51587 invoked from network); 22 Jun 2016 13:21:25 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-2.tower-21.messagelabs.com with SMTP; 22 Jun 2016 13:21:25 -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 E1E2F440; Wed, 22 Jun 2016 06:22: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 CA1303F21A; Wed, 22 Jun 2016 06:21:23 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 22 Jun 2016 14:21:05 +0100 Message-Id: <1466601669-25398-6-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466601669-25398-1-git-send-email-julien.grall@arm.com> References: <1466601669-25398-1-git-send-email-julien.grall@arm.com> Cc: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org, steve.capper@arm.com, wei.chen@linaro.org Subject: [Xen-devel] [PATCH 5/9] xen/arm: Provide macros to help creating workaround helpers 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" Workarounds may require to execute a different path when the platform is affected by the associated erratum. Furthermore, this may need to be called in the common code. To avoid too much intrusion/overhead, the workaround helpers need to be a nop on architecture which will never have the workaround and have to be quick to check whether the platform requires it. The alternative framework is used to transform the check in a single instruction. When the framework is not available, the helper will have ~6 instructions including 1 instruction load. The macro will create a handler called check_workaround_xxxxx with xxxx the erratum number. For instance, the line bellow will create a workaround helper for erratum #424242 which is enabled when the capability ARM64_WORKAROUND_424242 is set and only available for ARM64: CHECK_WORKAROUND_HELPER(424242, ARM64_WORKAROUND_42424242, CONFIG_ARM64) Signed-off-by: Julien Grall --- xen/include/asm-arm/cpuerrata.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/xen/include/asm-arm/cpuerrata.h b/xen/include/asm-arm/cpuerrata.h index fe93beb..b9d8dfc 100644 --- a/xen/include/asm-arm/cpuerrata.h +++ b/xen/include/asm-arm/cpuerrata.h @@ -1,8 +1,47 @@ #ifndef __ARM_CPUERRATA_H #define __ARM_CPUERRATA_H +#include +#include +#include + void check_local_cpu_errata(void); +#ifdef CONFIG_ALTERNATIVE + +#define CHECK_WORKAROUND_HELPER(erratum, feature, arch) \ +static inline bool_t check_workaround_##erratum(void) \ +{ \ + if ( !IS_ENABLED(arch) ) \ + return 0; \ + else \ + { \ + bool_t ret; \ + \ + asm volatile (ALTERNATIVE("mov %0, #0", \ + "mov %0, #1", \ + feature) \ + : "=r" (ret)); \ + \ + return unlikely(ret); \ + } \ +} + +#else /* CONFIG_ALTERNATIVE */ + +#define CHECK_WORKAROUND_HELPER(erratum, feature, arch) \ +static inline bool_t check_workaround_##erratum(void) \ +{ \ + if ( !IS_ENABLED(arch) ) \ + return 0; \ + else \ + return unlikely(cpus_have_cap(feature)); \ +} + +#endif + +#undef CHECK_WORKAROUND_HELPER + #endif /* __ARM_CPUERRATA_H */ /* * Local variables: