From: Julien Grall <julien.grall@arm.com>
To: xen-devel@lists.xen.org
Cc: sstabellini@kernel.org, steve.capper@arm.com,
andre.przywara@arm.com, Julien Grall <julien.grall@arm.com>,
wei.chen@linaro.org
Subject: [PATCH v2 2/6] xen/arm: Provide macros to help creating workaround helpers
Date: Wed, 27 Jul 2016 18:09:34 +0100 [thread overview]
Message-ID: <1469639378-9244-3-git-send-email-julien.grall@arm.com> (raw)
In-Reply-To: <1469639378-9244-1-git-send-email-julien.grall@arm.com>
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 <julien.grall@arm.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
Changes in v2:
- Add Konrad's reviewed-by
---
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 c495ee5..2982a92 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 <xen/config.h>
+#include <asm/cpufeature.h>
+#include <asm/alternative.h>
+
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:
--
1.9.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-07-27 17:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-27 17:09 [PATCH v2 0/6] xen/arm: Simplify do_trap_*_abort_guest Julien Grall
2016-07-27 17:09 ` [PATCH v2 1/6] xen/arm: traps: Simplify the switch in do_trap_*_abort_guest Julien Grall
2016-07-28 19:41 ` Stefano Stabellini
2016-07-27 17:09 ` Julien Grall [this message]
2016-07-28 19:42 ` [PATCH v2 2/6] xen/arm: Provide macros to help creating workaround helpers Stefano Stabellini
2016-07-27 17:09 ` [PATCH v2 3/6] xen/arm: Use check_workaround to handle the erratum 766422 Julien Grall
2016-07-28 19:43 ` Stefano Stabellini
2016-07-27 17:09 ` [PATCH v2 4/6] xen/arm: traps: MMIO should only be emulated for fault translation Julien Grall
2016-07-27 17:09 ` [PATCH v2 5/6] xen/arm: traps: Avoid unnecessary VA -> IPA translation in abort handlers Julien Grall
2016-07-27 17:28 ` Sergej Proskurin
2016-07-27 17:40 ` Julien Grall
2016-08-17 2:19 ` Shanker Donthineni
2016-08-17 11:11 ` Julien Grall
2016-08-17 20:08 ` Shanker Donthineni
2016-08-18 12:02 ` Julien Grall
2016-07-27 17:09 ` [PATCH v2 6/6] xen/arm: arm64: Add Cortex-A57 erratum 834220 workaround Julien Grall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1469639378-9244-3-git-send-email-julien.grall@arm.com \
--to=julien.grall@arm.com \
--cc=andre.przywara@arm.com \
--cc=sstabellini@kernel.org \
--cc=steve.capper@arm.com \
--cc=wei.chen@linaro.org \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).