Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754168AbbLRQB2 (ORCPT ); Fri, 18 Dec 2015 11:01:28 -0500 Received: from mail-by2on0082.outbound.protection.outlook.com ([207.46.100.82]:2910 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752087AbbLRQB0 (ORCPT ); Fri, 18 Dec 2015 11:01:26 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; From: Yury Norov To: , , CC: , , , , , , Yury Norov Subject: [PATCH v4] arm64: run-time detection for aarch32 support Date: Fri, 18 Dec 2015 19:00:29 +0300 Message-ID: <1450454429-22976-1-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.5.0 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: VI1PR06CA0016.eurprd06.prod.outlook.com (25.162.116.154) To CO2PR07MB620.namprd07.prod.outlook.com (10.141.228.156) X-Microsoft-Exchange-Diagnostics: 1;CO2PR07MB620;2:ERyvP3Rs0yZQWNP87+joiTZ2dptxT3R7DI0DEBHae0tjVEBf7o01b0ufZUu2+VJT/LwufI4IcH9tpBDD2dV2wAzu+oKVCFFBaD2a7WYjTZM6VjOgW68Cw5AvJjNPYOot/W/bSsWQJ2q4ITJodiJGfQ==;3:qqEBXlo9YBzR9nCvdUV1rSVJwMDIu51o4bxuE1u4mbA4sx4opOrjWskDcNY0s9Ccs/rkxCTer3Y4KvXAuUSCjWH8HIQV/XCaaL8A2VEQJ5QiiqOSp8FeBivvh/gYx8IM;25:gLFw2K6g5HpOEBlbA/mVjjvuqzaKxVVaexIjUVayl9rQUof6nxwG4H8X0kNEWyzzXfxil08p6i1G4UsaRZN8D4VTWdfdMLA3hq8bbgYrmzcaEyxZGadMV0AWR1AqxvuWiorm+SjqBNBf1CDUnfeqRiVg0YygKPKeBnByN2E+ebmVuBQVu1B7QfBsF5uR1lLoJAZWUKzc2+WGhOnZHur5LSJQ7Phx+yMaIz6il/GGzcsY8nOQhh+sfIBBL2hZU2Anp/i31/RCb4b5oIY7VmMSnQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CO2PR07MB620; X-Microsoft-Exchange-Diagnostics: 1;CO2PR07MB620;20:MUv6g0jaIq4bWvNEYjhIhaBMvT1qJjwlqjbN1V9OL5Ka89cTsHbFbWA6GccgIe/gRkgZU+RDqP33AjJ1AZnqHiTaoZSI8GlwlaYTTg9AHtxglnBa0sQPyTS0F2qUgIzsyv/Iqd/SaXpdnWQW+06G25ppQyOw4mL5v6R6H+5L127KA0ig7ecM1GTQs52hQJAJjFYqssR0BQaBPhOqy4iBcZhZ1GSpEvPv2eM/dlNRvzV/oLCZdoG+9oUFOeZHevdHVL8PCdq6EaM5oTrjBmKqX3SuDrYcxhlZUdjWN7NwNvOxE17zsxV713UFVHZB+VvHEVJICgLu6Od3QISCvetgTQ36woTmT3oDcon/j9vjlIQiNbMBwGTBuAEaUuHxb0UHGz5NlVgoPEtPOQ09PY5QJFs/7Qr7qZ51RY2UjprUy9yVZkANqiqAKMfTCR8V4t7vPf0eIVN0X1lWYggkogO42+FjGnfWAOjhvjHqZhHf9NYvm4MpbPGAXmhrFj1K1pWpk6ldWpAHnBMOl7FDDumVKUnJhpoQ6lWSHCliHdDevsNSF+gJNlWY5AOd8c+tE0YVuaRw7Y+hCtttVJtQQzFx/f0Nn7v/Lqk6uM04bUOzojs= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(3002001)(10201501046);SRVR:CO2PR07MB620;BCL:0;PCL:0;RULEID:;SRVR:CO2PR07MB620; X-Microsoft-Exchange-Diagnostics: 1;CO2PR07MB620;4:+MUgWi1VJRfxMhudU4KxbiZle074i9zMmcNUDZwaVDbWFbUogbbcUxLCGjvDolH9PrOsXc2nBeok/MZSHP0VXNVOzcBzCu7BK2C4lktSyRKMjylygx4JWTdi+aKZi+yoEaphmPUACO++6SGo2A5XpPoTz0V69JxfEfczjrbIKmkVcwGcdWNfZDVwbqSjSqPRqsLYtcQVor7ynX1Z+ZR4LWNSLGyLCL8xV8JxIDez4syt4asbQKlJN6QR7gmFnox8qW6qISnlkMIBDJdde2KmjGihd2sEFGlMihmy2ivV4o7y83i0cwJ1w2XsahCm5pIMYgLBl2Yv/rIW3nZ7A7pZrGSg3+w9GjhLhkujVFwQUyb+raqsfj5W6aQJmHZVhaCSyzvghiyhNVpfaRYMqVjfgtQ+5v969QZud54CS3dnmgRd2W1MnzmB5AsomZSDoltc X-Forefront-PRVS: 07943272E1 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(6009001)(189002)(199003)(101416001)(106356001)(107886002)(5001960100002)(33646002)(3846002)(1096002)(4001430100002)(5008740100001)(586003)(6116002)(5004730100002)(2201001)(47776003)(105586002)(189998001)(48376002)(92566002)(50226001)(50466002)(229853001)(77096005)(19580405001)(5003940100001)(19580395003)(50986999)(66066001)(122386002)(81156007)(97736004)(76506005)(87976001)(40100003)(5001770100001)(36756003)(42186005);DIR:OUT;SFP:1101;SCL:1;SRVR:CO2PR07MB620;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CO2PR07MB620;23:mjQIYdZ2jGRqxa1JOebPfKYi/sF1XMu/ogVquLMMzx?= =?us-ascii?Q?PUFmOHr9rmLI3H+cKE6ygs9dGaQq7LAm1tsY4DkJQl1kE5ZOURcH5xTO3nh+?= =?us-ascii?Q?f3CboXt1M1KrGmcX2x+J2g2zmlFBlK2RVGPiQRZtc2OJ3F2/QYvlaYjIx01g?= =?us-ascii?Q?b/1UlTZwgaczROm5qdqvO1BVrqxF6PEACa4eKYOKxrC1LZWJKICJ/difm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B25K3+ichI?= X-Microsoft-Exchange-Diagnostics: 1;CO2PR07MB620;5:8WAKaTvILILAFBw8JwAuukKmjiqoKE1iP3M5rjf3qkgU6Vs3bnjoS3I/NG1FGCs2U1K2MrPAgdbKdFyTa4y245dgvZbh4lqruPuurj6kwwEPICd6NmOrIxaaigrl7dhBmWXMgs/nZVpQH9v0djVDIA==;24:rdhiMRLoqOeA9tBq4CZxmACeyuWRLXrcSFJ6QSjO2EJrCsL4HMoTm65002StZeE1ILXQyZPvHjCgMIwgSxjq07OmS5MdVeBVFNh6TKJE6N0= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2015 16:01:23.4428 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR07MB620 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2768 Lines: 79 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 --- 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 #include +#include 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/