From patchwork Tue Sep 1 14:41:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 7105751 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E82DB9F32B for ; Tue, 1 Sep 2015 14:46:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1540C201D3 for ; Tue, 1 Sep 2015 14:46:18 +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 99B1F201F4 for ; Tue, 1 Sep 2015 14:45:59 +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 1ZWmnA-0005dr-Ij; Tue, 01 Sep 2015 14:44:08 +0000 Received: from mail-bn1on0076.outbound.protection.outlook.com ([157.56.110.76] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZWmn6-00056d-CF for linux-arm-kernel@lists.infradead.org; Tue, 01 Sep 2015 14:44:05 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (91.77.150.194) by DM2PR07MB624.namprd07.prod.outlook.com (10.141.177.154) with Microsoft SMTP Server (TLS) id 15.1.256.15; Tue, 1 Sep 2015 14:41:53 +0000 From: Yury Norov To: , Subject: [PATCH 2/2] arm64: don't load 32-bit binaries if platform has no aarch32_el0 Date: Tue, 1 Sep 2015 17:41:12 +0300 Message-ID: <1441118472-3513-3-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1441118472-3513-1-git-send-email-ynorov@caviumnetworks.com> References: <1441118472-3513-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [91.77.150.194] X-ClientProxiedBy: HE1PR06CA0066.eurprd06.prod.outlook.com (25.164.28.162) To DM2PR07MB624.namprd07.prod.outlook.com (10.141.177.154) X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB624; 2:rE5ibpF00ozOWwVIvaP5/thdfdxKUXn35BCY6oSFMXtBvwONkL5bOsZ36/BZKwZ/iZP14qffs0ligzW4GKElVlw/+EDuCKs6OpKtGKtSzRpTQqfmNpHhLYOyQ0i/tRs2odAcBg+qMFd1i0WK/JMPOdu1G2OABK/pzlrsw2Xd3p0=; 3:57NHNE+Dy8V/GFQZ5GpB9Bep4WP+1GVXb8tY1fn2MUuDFJA/VV8q2pbX2M4MAbtAfi0KQp8waAUjTK+kIDjPF4uS8hOtNa6obzrlqLxohWu5t0PYMGrh/5Dvh+4yjjnuUWOlY5FC8Kli+gVblnSwnA==; 25:OcQUClL6uQVbv8KNmc8zMGuRmvH9S2hT784twHmT4K3NHVjWctlMvr7N5GBJCUX7IB9ytPJc/v13saLqfRanjnI7CnsfPdPXUX73rHmUxPHBGuLpNFEiuheeNQ2mrgvmkaNV4UFZr02WwwCcg4nQmKUgdDAkVckzesV29YnQOves7HXoEzuhoSDxsrY9qhbU8CN0/4I+2FUSx5d6qM6V6yY7mxfmgKg9aXFCbyoagx6cdOh2K5UbgR2Y9wl9x/MtWaWLNzN743ENf7S8QmBPBQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR07MB624; X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB624; 20:Rwip4EkkCIERg0RTNrivd7TJTDmANEn/tH93GpaaZUS1FS2EpeAhDT+pHsEhN/Fbc0gZYvicIWHtbcUulmBxuHPHYSNjmTfMQQUXJnDqrx5LegDg8oPmQyjgiaK5wRe9Tek1Jro9p4QhXnDB43XMzoS+LFlLSbki1aXB/YxbWg+YOilQw1BNucngn+iCCBGEQeKDfY5VykV5MhFS/NKs2sVNR2ncuXFP/7hr2KSCh1uSyyBMztMLlJgJL3oK93vPL81cY0aKvkbtPxmksFx3BVNsOznsilASfB2CmoFOdCX/eoo/88XVDf5T49X5pNEIUX3QuN5/GSoGP8ckVujTHfBiQC7nc5bTT43l512cToxO+rvNzFd6+Z66Mxi7nlGjzGWADQrnweUt5miQxC1ry0gIlo8Lq00Njnel2Ric8WFDEnfeFqXtuHYyhsXLbAaLOyuoS3t7wnaI/wVm8Zc3qzuoXxTh14RSOufOXVBmfbZVI+hDkp23oT1kn65MfrJoA7MiyoWq/6ejKcJP6+x8CcPFEjRObUgh4EAwwPmgRD1vmgyAzjNnHG92ScJhnmwTMvUmjG/PS8WJyw+eQ7zdOjiTgBBM5wd5X6MIWN6nT6w=; 4:TpK0zD3KuDgYMwOEEs2gy9Iik9ArGYV8k27hJqLGXlBwcQ/jzXaT4/h5mNTMNZpnGoS1qTCOJgfZ57XdelDVNO/hbc9moUY3SILJlF+ViqVmNi0TWsy6cgOYNk+B43ykJhqzo6ZLkYUL8UoHIKBMop4bCTrfJ0GPiQLfzz0b2Xr3nNVuDRUDN3aJ8ppxuYeLYwoEaRXpim4EeIFbyVEX58KQGjX0AV8W6DdbfTLVa/VrrAkwFWBvDz2VgDEMC5mx2Za3VhHkrPUC1OxX4LtPglq5oX1hqnh4pyELzBwVpVpE770wvsKuwqSKENkPAFref4qP3m7nxs92W+pY6x7DxQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(8121501046)(5005006)(3002001); SRVR:DM2PR07MB624; BCL:0; PCL:0; RULEID:; SRVR:DM2PR07MB624; X-Forefront-PRVS: 06860EDC7B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(6009001)(199003)(189002)(2950100001)(42186005)(76506005)(19580405001)(40100003)(5001860100001)(5001830100001)(66066001)(36756003)(50466002)(33646002)(48376002)(122386002)(97736004)(46102003)(5001960100002)(92566002)(81156007)(105586002)(87976001)(106356001)(77156002)(4001540100001)(77096005)(5001770100001)(50226001)(19580395003)(68736005)(64706001)(229853001)(47776003)(5007970100001)(76176999)(107886002)(189998001)(62966003)(5004730100002)(50986999)(101416001)(5003940100001)(4001430100001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR07MB624; 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; DM2PR07MB624; 23:D7G5NvMFzBCxfoNb+CeXBw6Jj+J59BRWu07MNoVn5g?= =?us-ascii?Q?aeMIw14jY4j69cXO4RpHbpxiBUjwpzFHOFt16MkLlPvxKEo+/jZZ6AGllLI4?= =?us-ascii?Q?yVRWb+utvCOBqR4q7gon05mjzrAw1j9su1XChVhJ+B7xo467ZD11xZ/vrMPh?= =?us-ascii?Q?VDHTVivrb73UKif94PE925Qq6bHriP5nXgVJy9jY33UipmK/L9z6m7NZYy26?= =?us-ascii?Q?8FG+BMHoW6iLWGdXwnytiYUubY/psp26wiay28NzbJzoUCz7vjCmOR+/A9P5?= =?us-ascii?Q?ykiXbQl2OVPm+NBQ9X0LvE//4OFbjyK0vUD+dQnaCtlm/nCfyvXDhhUypswR?= =?us-ascii?Q?z/DEHUkWrUf+czyneyAGIi/kZW5KxLyq075Tkj6GeEwic+ZCqjmhKesiIXyt?= =?us-ascii?Q?/bs2anSQJXW9ciqzD+vmJx+1jfIgTBE6GKL18M+YFArAXw6abPe05VmDNHBK?= =?us-ascii?Q?dWi6B8yluei0q7fTWdJr/ZO1+nqdz48u6XO7jrZS3eFGrqi8WRc0KOXyd2rw?= =?us-ascii?Q?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+bg==; 24:YuAPpOaeGW6jSznHMjzB0Lb8hDLy7EHGY1hHVgUWOGWbu8B3y4DFKhAsUci0J75LKeJ1FHFe6u8vS7CErPX9rPM4ef6fDNUb+4Iu42czkgc=; 20:bV5nGrvw2DeIiTE+8NJv+d0YrV59FygPydfohGAmCD/cBEbNTg+FksaLdG/a+4jZaZIc6mS1BX6f9bwxM3gpGg== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2015 14:41:53.8668 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR07MB624 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150901_074404_643354_74382B66 X-CRM114-Status: UNSURE ( 9.38 ) 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: Yury Norov , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, ddaney@caviumnetworks.com 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, T_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. Signed-off-by: Yury Norov --- arch/arm64/include/asm/cpufeature.h | 1 + arch/arm64/include/asm/elf.h | 6 ++++-- arch/arm64/kernel/cpuinfo.c | 9 +++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 20cdc26..d24ea15 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -81,6 +81,7 @@ void check_local_cpu_errata(void); void check_local_cpu_features(void); bool cpu_supports_mixed_endian_el0(void); bool system_supports_mixed_endian_el0(void); +bool system_supports_aarch32_el0(void); #endif /* __ASSEMBLY__ */ diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index faad6df..461897b 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); diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c index 75d5a86..95d953f 100644 --- a/arch/arm64/kernel/cpuinfo.c +++ b/arch/arm64/kernel/cpuinfo.c @@ -79,6 +79,15 @@ bool system_supports_mixed_endian_el0(void) return mixed_endian_el0; } +#define AARCH64 1 +#define AARCH32_64 2 +bool system_supports_aarch32_el0(void) +{ + struct cpuinfo_arm64 *info = this_cpu_ptr(&cpu_data); + u64 arm64_el0 = info->reg_id_aa64pfr0 & 0xf; + return arm64_el0 == AARCH32_64; +} + static void update_mixed_endian_el0_support(struct cpuinfo_arm64 *info) { mixed_endian_el0 &= id_aa64mmfr0_mixed_endian_el0(info->reg_id_aa64mmfr0);