From: Yury Norov <ynorov@caviumnetworks.com>
To: <mark.rutland@arm.com>, <Suzuki.Poulose@arm.com>,
<Catalin.Marinas@arm.com>
Cc: <klimov.linux@gmail.com>, <ddaney.cavm@gmail.com>,
<ard.biesheuvel@linaro.org>, <will.deacon@arm.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>,
Yury Norov <ynorov@caviumnetworks.com>
Subject: [PATCH v4] arm64: run-time detection for aarch32 support
Date: Fri, 18 Dec 2015 19:00:29 +0300 [thread overview]
Message-ID: <1450454429-22976-1-git-send-email-ynorov@caviumnetworks.com> (raw)
Kernel option COMPAT defines the ability of executing aarch32 binaries.
Some platforms does not support aarch32 mode, and so cannot execute that
binaries. But we cannot just disable COMPAT for them because the same
kernel binary may be used by multiple platforms.
In this patch, system_supports_aarch32_el0() is introduced to detect
aarch32 support at run-time.
v4: use new CPU Feature API.
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
---
arch/arm64/include/asm/cpufeature.h | 7 +++++++
arch/arm64/include/asm/elf.h | 6 ++++--
arch/arm64/include/asm/sysreg.h | 1 +
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index 8f271b8..781a2f7 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -184,6 +184,13 @@ static inline bool system_supports_mixed_endian_el0(void)
return id_aa64mmfr0_mixed_endian_el0(read_system_reg(SYS_ID_AA64MMFR0_EL1));
}
+static inline bool system_supports_aarch32_el0(void)
+{
+ u64 pfr0 = read_system_reg(SYS_ID_AA64PFR0_EL1);
+ return ((pfr0 >> ID_AA64PFR0_EL0_SHIFT) & ID_AA64PFR0_ELx_MASK)
+ != ID_AA64PFR0_EL0_64BIT_ONLY;
+}
+
#endif /* __ASSEMBLY__ */
#endif
diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index faad6df..1053cd7 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -23,6 +23,7 @@
*/
#include <asm/ptrace.h>
#include <asm/user.h>
+#include <asm/cpufeature.h>
typedef unsigned long elf_greg_t;
@@ -173,8 +174,9 @@ typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
/* AArch32 EABI. */
#define EF_ARM_EABI_MASK 0xff000000
-#define compat_elf_check_arch(x) (((x)->e_machine == EM_ARM) && \
- ((x)->e_flags & EF_ARM_EABI_MASK))
+#define compat_elf_check_arch(x) (system_supports_aarch32_el0() \
+ && ((x)->e_machine == EM_ARM) \
+ && ((x)->e_flags & EF_ARM_EABI_MASK))
#define compat_start_thread compat_start_thread
#define COMPAT_SET_PERSONALITY(ex) set_thread_flag(TIF_32BIT);
diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h
index d48ab5b..a67b203 100644
--- a/arch/arm64/include/asm/sysreg.h
+++ b/arch/arm64/include/asm/sysreg.h
@@ -102,6 +102,7 @@
#define ID_AA64PFR0_EL2_SHIFT 8
#define ID_AA64PFR0_EL1_SHIFT 4
#define ID_AA64PFR0_EL0_SHIFT 0
+#define ID_AA64PFR0_ELx_MASK 0xf
#define ID_AA64PFR0_FP_NI 0xf
#define ID_AA64PFR0_FP_SUPPORTED 0x0
--
2.5.0
next reply other threads:[~2015-12-18 16:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-18 16:00 Yury Norov [this message]
2015-12-18 17:03 ` Suzuki K. Poulose
2015-12-18 17:46 ` Mark Rutland
2015-12-18 22:09 ` Suzuki K. Poulose
2015-12-18 17:42 ` Mark Rutland
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=1450454429-22976-1-git-send-email-ynorov@caviumnetworks.com \
--to=ynorov@caviumnetworks.com \
--cc=Catalin.Marinas@arm.com \
--cc=Suzuki.Poulose@arm.com \
--cc=ard.biesheuvel@linaro.org \
--cc=ddaney.cavm@gmail.com \
--cc=klimov.linux@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=will.deacon@arm.com \
/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
all inboxes | Powered by JetHome®