From: Andrew Jones <drjones@redhat.com>
To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu
Cc: marc.zyngier@arm.com, pbonzini@redhat.com, shannon.zhao@linaro.org
Subject: [kvm-unit-tests PATCH] arm/arm64: introduce is_aarch32
Date: Wed, 16 Nov 2016 15:38:36 +0100 [thread overview]
Message-ID: <1479307116-6355-1-git-send-email-drjones@redhat.com> (raw)
ARMv7-A isn't exactly the same as ARMv8-A32 (AArch32). This
function allows unit tests to make the distinction.
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
I'm actually unsure if there's a feature bit or not that I could
probe instead. It'd be nice if somebody can confirm. Thanks, drew
lib/arm/asm/processor.h | 20 ++++++++++++++++++++
lib/arm64/asm/processor.h | 5 +++++
2 files changed, 25 insertions(+)
diff --git a/lib/arm/asm/processor.h b/lib/arm/asm/processor.h
index f25e7eee3666..223e54beb72a 100644
--- a/lib/arm/asm/processor.h
+++ b/lib/arm/asm/processor.h
@@ -5,6 +5,7 @@
*
* This work is licensed under the terms of the GNU LGPL, version 2.
*/
+#include <bitops.h>
#include <asm/ptrace.h>
enum vector {
@@ -46,4 +47,23 @@ static inline unsigned int get_mpidr(void)
extern void start_usr(void (*func)(void *arg), void *arg, unsigned long sp_usr);
extern bool is_user(void);
+/*
+ * ARMv7-A isn't exactly the same as ARMv8-A32 (AArch32). This
+ * function allows unit tests to make the distinction.
+ */
+static inline bool is_aarch32(void)
+{
+ /*
+ * XXX: Unfortunately there's no feature bit we can probe for
+ * this, so we do a hacky check for the processor type not being
+ * a Cortex-A15, which is the only v7 type we currently use.
+ */
+ unsigned long midr;
+
+ asm volatile("MRC p15, 0, %0, c0, c0, 0" : "=r" (midr));
+ midr &= GENMASK(31, 24) | GENMASK(15, 4);
+
+ return midr != ((0x41 << 24) | (0xc0f << 4));
+}
+
#endif /* _ASMARM_PROCESSOR_H_ */
diff --git a/lib/arm64/asm/processor.h b/lib/arm64/asm/processor.h
index 84d5c7ce752b..b602e1fbbc2d 100644
--- a/lib/arm64/asm/processor.h
+++ b/lib/arm64/asm/processor.h
@@ -81,5 +81,10 @@ DEFINE_GET_SYSREG32(mpidr)
extern void start_usr(void (*func)(void *arg), void *arg, unsigned long sp_usr);
extern bool is_user(void);
+static inline bool is_aarch32(void)
+{
+ return false;
+}
+
#endif /* !__ASSEMBLY__ */
#endif /* _ASMARM64_PROCESSOR_H_ */
--
2.7.4
next reply other threads:[~2016-11-16 14:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-16 14:38 Andrew Jones [this message]
2016-11-16 17:42 ` [kvm-unit-tests PATCH] arm/arm64: introduce is_aarch32 Andre Przywara
2016-11-17 16:33 ` Andrew Jones
2016-11-16 17:45 ` Mark Rutland
2016-11-17 16:45 ` Andrew Jones
2016-11-17 17:47 ` Mark Rutland
2016-11-18 10:57 ` Andrew Jones
2016-11-16 17:46 ` Marc Zyngier
2016-11-16 22:02 ` Christopher Covington
2016-11-17 6:45 ` Wei Huang
2016-11-17 16:59 ` Andrew Jones
2016-11-18 15:06 ` Christopher Covington
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=1479307116-6355-1-git-send-email-drjones@redhat.com \
--to=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=marc.zyngier@arm.com \
--cc=pbonzini@redhat.com \
--cc=shannon.zhao@linaro.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).