From patchwork Wed Sep 2 15:50:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 7112981 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 9E5D89F1CD for ; Wed, 2 Sep 2015 15:55:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9119D20650 for ; Wed, 2 Sep 2015 15:55:00 +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 981A3204EC for ; Wed, 2 Sep 2015 15:54: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 1ZXAKi-00027Y-Dz; Wed, 02 Sep 2015 15:52:20 +0000 Received: from mail-by2on0092.outbound.protection.outlook.com ([207.46.100.92] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZXAKf-0001ll-DO for linux-arm-kernel@lists.infradead.org; Wed, 02 Sep 2015 15:52:18 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (91.77.150.194) by DM2PR07MB622.namprd07.prod.outlook.com (10.141.177.146) with Microsoft SMTP Server (TLS) id 15.1.256.15; Wed, 2 Sep 2015 15:50:45 +0000 From: Yury Norov To: , , Subject: [PATCH v3 2/2] arm64: don't load 32-bit binaries if platform has no aarch32_el0 Date: Wed, 2 Sep 2015 18:50:00 +0300 Message-ID: <1441209000-26746-3-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1441209000-26746-1-git-send-email-ynorov@caviumnetworks.com> References: <1441209000-26746-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [91.77.150.194] X-ClientProxiedBy: HE1PR03CA0031.eurprd03.prod.outlook.com (25.163.170.169) To DM2PR07MB622.namprd07.prod.outlook.com (10.141.177.146) X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB622; 2:zm/9/mrUUev3lb70UzIFDELYSff8Isu2fL4tcAyF0BIyNiWp2juEWTwTY3m5l9jpf+MD9JcGri0NbqkFXrLIYAxXqrI12WJsSZ5R7qQKIex1PXRvS0FJMeYzAtwUCFbz0PKEZMU8ALhTkhTEbdwK580c/biPDlpUSmPi5xSoWg4=; 3:B+odUvhBxBC//LxlmMK8WBRoPgs+72POhegTIilnPrcuBxHKtmJwUSQjplKTpRKNG0PD/3PoeuOy9LShw6ZiZ8/pR6supACPmQXDaSV0VwrJohEGhNepLrPkQFHGFDu4wxGxH3t63rh1o2MtUrY5Bw==; 25:1k7/B8peghk9LEGiyXWIcYN6f/mt6vFSdeqmPccjrp4RJZbxqVvz+77PO0NMpNkegNRI/alAwP23NvXoH8Bxu3yR+Mc6FywEBjD/YsMP0+sU7ei9RBw0VPE+tk8bjLO9P7AfdHpyd/pk+uvpGtlwJmnrfWA5sY1dnEfIvD4SHtFUqhhdDSG4ZjcJJqwFrIi/dsYmtruJ7F7TUoa591aoVWFGnb/XBnzVPZnGZgSOHPKkvKrmS1F4bTkuH3pJWYxQURyMehujcAiMLukr1qEpyg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR07MB622; X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB622; 20:1eU3aGOc0kHisFrGUeYSpk2NlBYZT6Ex2tFhlM2Tedgqayk/G1ET7rvwuErufmZAarXQ9ltLkc2j4+XoXae6EBsmLTzUgo3np6iHcu1pH516/rU5EChmH45sG0oXgeVJ/9/a5N23aSBoqDJ8R2KKNO69D/9wggq0xBePBDTwhHZfEge7ev2Vic4yelYg+5q2xGP/nGQSkIOqlM80A/zDuWN+mAr+/eQI3YIGqd5g37zefRinXiu8VkehZSUDQ0L9mTgUyqo+AAGusviGHDkFGOXKKDRpYrZACZX5ZgS+knXuv3Vyg6jqm+6VNGwbig/sNpqOg5ffhV0AgVcy4dOCHVtvrE/Fi3cg3943dkKdOgBmlq1b0oemvI/p1qk83FzcVHex/vfkPBMeqj9NCBQ1QOzsrKE/dzyg1OhUH605HMhk/Y9xUkz09uDsv2bTMdXyJVaiomM19e8VZPqDYMallnkERh0jPJK6QNnwNhlZiAxkCxRZmpAgoyE0EqaAEcseCDrSCCusmiraG6z6ewxbB9H9XtrWoP4Nj8EIVyeCtvJ6fw/jojBhRn/LrT5xH0frhZdixEHwzbDBScJjmmE+25VR/RLQP5VTD5VeSraXIsY=; 4:pNRV1DE1k5KSDO21o5vhfk1efRCDK+oS4oLaUpHwUR1Z814MZaQSG5NaTljOMtnZem2rTPDc7BeUZSPGN6hWwWaObjn1pEsCgwSIIs05fXpM32OjyLqhInwg3ifFLTaaiBAL/2Zu03j/ypqyVKeBZYxp+xVbRqbF0rBGojoOeE9Tlt8eVPPUoKoDtk43dos+DOa7x9fOFXLkxqOOT6ckg6/2nlNUHuoC3uCq3hYlXnV0AlINGKX2oZU4/nm9aTOU+QsC02zxv0+VRlEzMox1dqVdKsmBPbjAfUMnTmCyjEG7GyatWBlMw3sdVCVZAMEf X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(8121501046)(3002001); SRVR:DM2PR07MB622; BCL:0; PCL:0; RULEID:; SRVR:DM2PR07MB622; X-Forefront-PRVS: 0687389FB0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(6009001)(199003)(189002)(107886002)(2201001)(76176999)(48376002)(5001960100002)(229853001)(5001830100001)(64706001)(101416001)(5007970100001)(68736005)(36756003)(66066001)(105586002)(77156002)(5004730100002)(122386002)(50466002)(62966003)(5001860100001)(19580395003)(19580405001)(77096005)(2950100001)(81156007)(106356001)(575784001)(50986999)(76506005)(33646002)(189998001)(40100003)(50226001)(47776003)(46102003)(42186005)(5003940100001)(97736004)(4001540100001)(87976001)(92566002)(5001770100001)(4001430100001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR07MB622; 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; DM2PR07MB622; 23:v+JwY5i7uxxVP6ciEAqKYUlvzykak7vaE8+N9/0+8s?= =?us-ascii?Q?brS4imPvIrUgrnQtY/WsfEtYsvCY8w8wQm11sswT1fmzVhsxj7ZgNqVvdfbj?= =?us-ascii?Q?9AMx0BN9+TK57IsbkE5FIVHmH5LSmYUbK36wR2EiCDY90vuR+YbGJokw3gEN?= =?us-ascii?Q?Uo3A5DtWGkaJij3Dok0xhOEh6g10ScV3oPHvT2j0eJULZotNZsDCRF20iaQ7?= =?us-ascii?Q?FQlDt4ZMwawC87/D7z9V8l5tJcOTzuD9AqkZbcwo/xCr8LJXP3X/i5RPtnZi?= =?us-ascii?Q?xvo7Ur+9FSS9M2HeOp6oFNqyyhWRjohKglosouqfDin7YJAnFeWQLSWc1Wia?= =?us-ascii?Q?c782uYqJrjpv8wJfPUz2a01z636OBHsVRx/vsikBaB+6zIGz5iiBAOmnshZG?= =?us-ascii?Q?fcjIs0tgy5piRMWpP+j9VmDhDThQDkKYAG5tOV2PtbW5nymnPbGtHwDsnXwo?= =?us-ascii?Q?ABppyGq+aPYuV8wX4Wln+bosFCMtCHIjaZQVGEUNuO1yqn8RqZgXGwVf8huP?= =?us-ascii?Q?slv0rZRBM8YhI3lSKE3gcufA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AnANizM91iTUc16ahtw==; 24:Tq8TsyE1M3G+LFpgRznic9vmiIJnztKknPhfCWyPAUhMtDQasMWpnFJr0W2Zg7I0i4hC43e0tfys/jNwHbbxN6FtYvGb9JGfDXKMSGyodu8=; 20:UJO2cB1hcK/h1Xrg4SEYywgIxK1qPprpSxmH/0J0BKUW9BAeVbDuh0gZ9q6ib4HOb0WGgJkGPlLAsrNO0AvzDw== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2015 15:50:45.2943 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR07MB622 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150902_085217_514854_5F717CA5 X-CRM114-Status: GOOD ( 10.82 ) 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@gmail.com, 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, 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/cputype.h | 9 +++++++++ arch/arm64/include/asm/elf.h | 6 ++++-- arch/arm64/kernel/cpuinfo.c | 12 ++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index f0e4017..35f2654 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -83,6 +83,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/cputype.h b/arch/arm64/include/asm/cputype.h index a84ec60..5fb5585 100644 --- a/arch/arm64/include/asm/cputype.h +++ b/arch/arm64/include/asm/cputype.h @@ -81,6 +81,10 @@ #define ID_AA64MMFR0_BIGEND(mmfr0) \ (((mmfr0) & ID_AA64MMFR0_BIGEND_MASK) >> ID_AA64MMFR0_BIGEND_SHIFT) +#define ID_AA64PFR0_EL0_64 1 +#define ID_AA64PFR0_EL0_6432 2 +#define ID_AA64PFR0_EL0_MASK 0xf + #define SCTLR_EL1_CP15BEN (0x1 << 5) #define SCTLR_EL1_SED (0x1 << 8) @@ -116,6 +120,11 @@ static inline u32 __attribute_const__ read_cpuid_cachetype(void) return read_cpuid(CTR_EL0); } +static inline bool id_aa64pfr0_aarch32_el0(u64 pfr0) +{ + return (pfr0 & ID_AA64PFR0_EL0_MASK) == ID_AA64PFR0_EL0_6432; +} + static inline bool id_aa64mmfr0_mixed_endian_el0(u64 mmfr0) { return (ID_AA64MMFR0_BIGEND(mmfr0) == 0x1) || 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..4a6ae31 100644 --- a/arch/arm64/kernel/cpuinfo.c +++ b/arch/arm64/kernel/cpuinfo.c @@ -36,6 +36,7 @@ DEFINE_PER_CPU(struct cpuinfo_arm64, cpu_data); static struct cpuinfo_arm64 boot_cpu_data; static bool mixed_endian_el0 = true; +static bool aarch32_el0 = true; static char *icache_policy_str[] = { [ICACHE_POLICY_RESERVED] = "RESERVED/UNKNOWN", @@ -79,13 +80,24 @@ bool system_supports_mixed_endian_el0(void) return mixed_endian_el0; } +bool system_supports_aarch32_el0(void) +{ + return aarch32_el0; +} + static void update_mixed_endian_el0_support(struct cpuinfo_arm64 *info) { mixed_endian_el0 &= id_aa64mmfr0_mixed_endian_el0(info->reg_id_aa64mmfr0); } +static void update_aarch32_el0_support(struct cpuinfo_arm64 *info) +{ + aarch32_el0 &= id_aa64pfr0_aarch32_el0(info->reg_id_aa64pfr0); +} + static void update_cpu_features(struct cpuinfo_arm64 *info) { + update_aarch32_el0_support(info); update_mixed_endian_el0_support(info); }