Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1294996 > unrolled thread
| Started by | Yury Norov <ynorov@caviumnetworks.com> |
|---|---|
| First post | 2015-12-18 17:10 +0100 |
| Last post | 2015-12-18 18:50 +0100 |
| Articles | 5 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH v4] arm64: run-time detection for aarch32 support Yury Norov <ynorov@caviumnetworks.com> - 2015-12-18 17:10 +0100
Re: [PATCH v4] arm64: run-time detection for aarch32 support "Suzuki K. Poulose" <Suzuki.Poulose@arm.com> - 2015-12-18 18:10 +0100
Re: [PATCH v4] arm64: run-time detection for aarch32 support Mark Rutland <mark.rutland@arm.com> - 2015-12-18 18:50 +0100
Re: [PATCH v4] arm64: run-time detection for aarch32 support "Suzuki K. Poulose" <Suzuki.Poulose@arm.com> - 2015-12-18 23:20 +0100
Re: [PATCH v4] arm64: run-time detection for aarch32 support Mark Rutland <mark.rutland@arm.com> - 2015-12-18 18:50 +0100
| From | Yury Norov <ynorov@caviumnetworks.com> |
|---|---|
| Date | 2015-12-18 17:10 +0100 |
| Subject | [PATCH v4] arm64: run-time detection for aarch32 support |
| Message-ID | <qH5Ls-7Ro-3@gated-at.bofh.it> |
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | "Suzuki K. Poulose" <Suzuki.Poulose@arm.com> |
|---|---|
| Date | 2015-12-18 18:10 +0100 |
| Message-ID | <qH6Hx-8tp-33@gated-at.bofh.it> |
| In reply to | #1294996 |
On 18/12/15 16:00, Yury Norov wrote:
> 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.
> 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;
Could you please use
cpuid_feature_extract_field(pfr0, ID_AA64PFR0_EL0_SHIFT) != ID_AA64PFR0_EL0_64BIT_ONLY
instead and
> --- 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
get rid of ^ ?
As per ARM ARM, AArch32 only ID register values are unknown if AArch32 is
not implemented. So I think we need to skip accessing the AArch32 ID registers
everywhere (feature tracking), if the CPU doesn't supports it, to avoid
unnecessary SANITY failures and TAINTing the kernel.
Cheers
Suzuki
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Mark Rutland <mark.rutland@arm.com> |
|---|---|
| Date | 2015-12-18 18:50 +0100 |
| Message-ID | <qH7ke-ff-11@gated-at.bofh.it> |
| In reply to | #1295047 |
On Fri, Dec 18, 2015 at 05:03:11PM +0000, Suzuki K. Poulose wrote:
> On 18/12/15 16:00, Yury Norov wrote:
> >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.
>
>
> >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;
>
> Could you please use
>
> cpuid_feature_extract_field(pfr0, ID_AA64PFR0_EL0_SHIFT) != ID_AA64PFR0_EL0_64BIT_ONLY
>
> instead and
>
> >--- 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
>
> get rid of ^ ?
>
> As per ARM ARM, AArch32 only ID register values are unknown if AArch32 is
> not implemented. So I think we need to skip accessing the AArch32 ID registers
> everywhere (feature tracking), if the CPU doesn't supports it, to avoid
> unnecessary SANITY failures and TAINTing the kernel.
That all sounds good to me.
After boot-time we should also fail hotplug of a CPU that doesn't
support AArch32, if we decided at boot-time that AArch32 was supported
accross the system. That should probably be added to your early cpu
feature verification [1].
Thanks,
Mark.
[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-December/392237.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Suzuki K. Poulose" <Suzuki.Poulose@arm.com> |
|---|---|
| Date | 2015-12-18 23:20 +0100 |
| Message-ID | <qHbxv-36h-5@gated-at.bofh.it> |
| In reply to | #1295068 |
On 18/12/15 17:46, Mark Rutland wrote: > On Fri, Dec 18, 2015 at 05:03:11PM +0000, Suzuki K. Poulose wrote: >> On 18/12/15 16:00, Yury Norov wrote: >>> Kernel option COMPAT defines the ability of executing aarch32 binaries. >> As per ARM ARM, AArch32 only ID register values are unknown if AArch32 is >> not implemented. So I think we need to skip accessing the AArch32 ID registers >> everywhere (feature tracking), if the CPU doesn't supports it, to avoid >> unnecessary SANITY failures and TAINTing the kernel. > > That all sounds good to me. > > After boot-time we should also fail hotplug of a CPU that doesn't > support AArch32, if we decided at boot-time that AArch32 was supported > accross the system. That should probably be added to your early cpu > feature verification [1]. You are right. I think we could add this as system capability to arm64_feautres which would make the check automatic. Also, the compat_elf_arch() check won't have to always to read_system_reg(), something like ARM64_HAS_32BIT_EL0. Thanks Suzuki -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Mark Rutland <mark.rutland@arm.com> |
|---|---|
| Date | 2015-12-18 18:50 +0100 |
| Message-ID | <qH7ke-ff-7@gated-at.bofh.it> |
| In reply to | #1294996 |
> 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> Nit: please keep these ordered alphabetically. Mark. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web