From patchwork Mon Dec 21 04:44:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 7893031 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DF9CFBEEE5 for ; Mon, 21 Dec 2015 04:47:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1A2C2203AB for ; Mon, 21 Dec 2015 04:47:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3A13F20396 for ; Mon, 21 Dec 2015 04:47:40 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aAsMK-0007IK-BI; Mon, 21 Dec 2015 04:46:08 +0000 Received: from mail-bl2on0058.outbound.protection.outlook.com ([65.55.169.58] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aAsMH-0007Gt-67 for linux-arm-kernel@lists.infradead.org; Mon, 21 Dec 2015 04:46:05 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (95.143.213.121) by CO2PR07MB617.namprd07.prod.outlook.com (10.141.228.143) with Microsoft SMTP Server (TLS) id 15.1.361.13; Mon, 21 Dec 2015 04:45:40 +0000 From: Yury Norov To: , , Subject: [PATCH v5] arm64: run-time detection for aarch32 support Date: Mon, 21 Dec 2015 07:44:10 +0300 Message-ID: <1450673050-12101-1-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.5.0 MIME-Version: 1.0 X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: AM2PR09CA0036.eurprd09.prod.outlook.com (25.161.22.174) To CO2PR07MB617.namprd07.prod.outlook.com (10.141.228.143) X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB617; 2:vsVmYpqXjk+pyj8lGYjExyzpuBZz8EhOqYIlBvx9BftBfdepcfDlyarCv4snUivYZkMY0K/9f9YuGI/dJqDSka6m3uiZNn14sGkxTrNy5QUTdtG6B/BFi7ya/WinWl0eTkvRkCwSkPCfc/DauiU9gQ==; 3:oCqlwNJsNZOUcMtnmyHCdOv6basyf6dzvSAiCh8h0pet1gseQ95moff7eToQ0/3D7RP3/m6oJFIvNTFOOpAeNYTjmL6sq0f8o3yIHMb2nr81wGyHaFUcR8xa0ObqUFOd; 25:UlSD/ZmYSQ9FlbPX50pcBuCX6mE0SU7/PDuPKcgFKroq6/TmdY25g21vDbYhycvKu3xO1WLfp4ZD0CvPRiRZxNteePIccMUDAU91/FymriIdA1g/i8Ig4FrF2cTAUxmpV6Cp8iefYwwSw2hcIBIJ1FcxgTdBS+bs0QakCdUfdU4Gha4sz1uaMcUhQOECytWbfgub9Aec8JL2/ekFVw0sBgh6JmV/bTlQ8IS4zNJkKsbyem2xtFJ3Hic3VNgn+abYdoJmHPMLumNBJlqpf7q8Zw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CO2PR07MB617; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB617; 20:WO+qg2+NPVJv/oVhkSv7Ksdb/seLwdw8rAOPiZOigWmWOidCesuK2QtNG65t0+tgDfgi4BiOczWUJC7abNP3MraDRLeMg552YGMMQ5M6Au6VmVqTdrH3wpDbtSjnkesxaKzDZtsfXUwhB7ik8k6LJIba4L8MSrJxVC2f7B3u8LkNUyJiFsU0MXHmp+x6QLMG7lsb+nSZaT8IVrMG4HXrRs+7iU6pBTj+l3WCj88dNdiX7G7qA6H7UY/Rzg34igfT6bnLUinNFt9h1TA/JCdaz0WkLd6XrQ5Xsao0KUQhHSsVBv0bIJzjYriDcSs2TA0kSUwbnlUf3pmz3mdPLXZgP/xV0CP7rAH7wNKEvIcUJG76fjMU+GjxflBhSvJ+tt/jY04Pff4VLvB9U9ulWUz9SVfx1TmcdsTNRscEE3ANHDKXH7H3WrDjYwC3cDus5Fkmbr08SO+KG6/D/O34/wwAtZHxlO/dVTbkkQ3Ic/esJtju3pQGublP/8f0UD76+151UtPdr4rVbYNb/wow0lgjQCF9v9/oMD0Kzq+7TTABFoRc2a3RSOEyvX7Vqj4M4if6/03DOgBsW6Ma1Xi2w1KqRTKUNwrIH1TEjnewk95uSLE= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(3002001)(10201501046); SRVR:CO2PR07MB617; BCL:0; PCL:0; RULEID:; SRVR:CO2PR07MB617; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB617; 4:xLaTgGEB4uH8fYv6A9ur8M3FVme9z1dwMMSFls/js6LP2rzl2LoPw0q1jzQMz4cliH8KZM5LAnZ8aJokU81fjdbDxKaNSTNV3O901CHZy1gHmku2Dzo1aBPt2Q0uWOotlxo096mTJ0A2GDHNMVskWM+uFa3xQGLQLL3UykIF0ev/ieRUzko6arVxmzGK223pAd46BuE/8ME6QfaBbIKIFYFHz5XSg2cfmaWInrafyBshb8T4gDFHRkv7ceMO/QmyjiMpS8bBWOzkldFCC9FVHOPyo6hOIj2Ke1mlTEsICOuHki0RTjIQrPy9g+bevK78mcsfm/udsTHu/zqj+f0p8vzfiC+fgwzBps/hGEY1VZBM7jS1U7QG/0unUmawBbGXC3pdZQmUk7KevWeCBV7merxQciehdlodGzBvLITyVFC9YslM8lWgGwTzEL6MH95x X-Forefront-PRVS: 079756C6B9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(6009001)(199003)(189002)(50986999)(19580405001)(19580395003)(77096005)(66066001)(3846002)(6116002)(42186005)(5008740100001)(36756003)(87976001)(575784001)(40100003)(92566002)(47776003)(122386002)(5003940100001)(50466002)(48376002)(81156007)(4001430100002)(229853001)(5001960100002)(107886002)(76506005)(189998001)(33646002)(50226001)(5001770100001)(586003)(101416001)(97736004)(2201001)(1096002)(5004730100002)(106356001)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR07MB617; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR07MB617; 23:WTUasAZw5mPcTCskmXqeFwJh0WY8v9ghyjdXGmlALR?= =?us-ascii?Q?XDADuRwIugbS2+2kOJ5PwHAPFqZI8P9CfBf0LrkBvbpDEQpIlJnzXFI6asrd?= =?us-ascii?Q?LakXIHoE96PgPv68fJSb3HojdqoHO5wi483z5/9kthW6x/f29MthMvA1ieRF?= =?us-ascii?Q?DOs+Sg6iGCgFIUoLdrjz2NaSRPBiDXqhwpFgwY7DFZ3quAAsUNgK8PpqK3SG?= =?us-ascii?Q?d7EdEaFMTFHesDZilVjjnUInwzGAi0Zsj+XIG7FXseEQqXLIwiuIIIphdczg?= =?us-ascii?Q?IG18KmDj5Disskb2GuC9StuR7nGTTZF/y1MTCpBSF1uxb98zHoz8SF/BbV6I?= =?us-ascii?Q?u1V8Uk7kazIDAvuA6G7m5FQvz79B2ZC3SfC49/J8W3FKciGuhrsrT/Q8xchh?= =?us-ascii?Q?gdqAIB2L81hWOxQEPgdoNcOOXtR+r8dQOwEGC0PMRly8nA15ywxcXIhyEh1B?= =?us-ascii?Q?KGK51E5pzXBy7HMpscOlFNNAEfzIc+Ygdne7CM1mKmoZKn3yxLxj0W2JCpZc?= =?us-ascii?Q?4gaW6kmNQOvAHGQIe/MxA/Z0zo+FWn9qWOjVFh2msbTCpkeJ50GmiOUpLthX?= =?us-ascii?Q?1K7EBx3UJ47e2hk12Axw8m70vIOzR122JDE9zLebHji2cVw3nmhmDgrPBMqb?= =?us-ascii?Q?CV4tNBBvMCVK5sHmQIsilz9E1coZOutn73VFT1+hpKAQBl75rRNWTjufNaWg?= =?us-ascii?Q?1ZhVk1RxfEGOV+ByJS9tnS6W6T50VRs+DLeoDCyUhQ91OCm0SsehTS7rRojF?= =?us-ascii?Q?pIMjg2WDWWgs8sBLd8mIKx9sp1b4Dx9q9htK3RqbZSZIXrLm1JM9NOByIfPI?= =?us-ascii?Q?fl+zVVWq0OPArp8rrD/gjIbAmoDxMjkDzHRPCrFF+gRhueoGld7F7AXnHIAd?= =?us-ascii?Q?ry1Vc8VfeJJUUr5KIt7L5ARze07nXJFvLMD7V4hux/Wl+qNLIuOVzxb0rhQj?= =?us-ascii?Q?ulWHNVMudkcMs2U001asGS3rl9gHLCG9rXlG9wKCjw9ou3bcv4DtVF3OtlHK?= =?us-ascii?Q?O73mRCcvQab2ccRqx6lKXFNdM550VTEWOJVusU5tyqHKZWUNKCLwL4vsiXTK?= =?us-ascii?Q?S14s5i3LnF/xE/nGnL6YemP5K035Km1iy4JbmNO5ZUvPjOFA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB617; 5:/OwAoxS9buUegiVRvF2v/0ZzSmeqfYD4XGikX/WAb1Yni2YnKo2j6iCuhFHMDKSe5s61TENEQAdvHti+m5MXxs6QAwPNAumAd/QRT8AQvuyckoB6kxSAPMyJsLrNn+UYLM8EHTNqhtDoQX20OLzzag==; 24:So/iwLl1uvYF1qe3aDjM4bmDN/wdtV7NE9RCOQJr40SHhF/OssaLl3t85BFgI/VAPEwprz7jDqEDtNlDj0Upq4hPPCVVDUfNlUiYkvSCIqk= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2015 04:45:40.2164 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR07MB617 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151220_204605_463755_C14478FC X-CRM114-Status: UNSURE ( 7.65 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ard.biesheuvel@linaro.org, will.deacon@arm.com, linux-kernel@vger.kernel.org, klimov.linux@gmail.com, Yury Norov , ddaney.cavm@gmail.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. v5: use cpuid_feature_extract_field. Signed-off-by: Yury Norov --- arch/arm64/include/asm/cpufeature.h | 7 +++++++ arch/arm64/include/asm/elf.h | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 8f271b8..bcb0dbe 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 cpuid_feature_extract_field(pfr0, ID_AA64PFR0_EL0_SHIFT) + != 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..99ec9ac 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -21,6 +21,7 @@ /* * ELF register definitions.. */ +#include #include #include @@ -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);