Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751229AbdFDMDq (ORCPT ); Sun, 4 Jun 2017 08:03:46 -0400 Received: from mail-bl2nam02on0044.outbound.protection.outlook.com ([104.47.38.44]:47264 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751230AbdFDMDJ (ORCPT ); Sun, 4 Jun 2017 08:03:09 -0400 Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=caviumnetworks.com; From: Yury Norov To: Catalin Marinas , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Arnd Bergmann Cc: Yury Norov , Andrew Pinski , Andrew Pinski , Adam Borowski , Chris Metcalf , Steve Ellcey , Maxim Kuvyrkov , Ramana Radhakrishnan , Florian Weimer , Bamvor Zhangjian , Andreas Schwab , Chris Metcalf , Heiko Carstens , schwidefsky@de.ibm.com, broonie@kernel.org, Joseph Myers , christoph.muellner@theobroma-systems.com, szabolcs.nagy@arm.com, klimov.linux@gmail.com, Nathan_Lynch@mentor.com, agraf@suse.de, Prasun.Kapoor@caviumnetworks.com, geert@linux-m68k.org, philipp.tomsich@theobroma-systems.com, manuel.montezelo@gmail.com, linyongting@huawei.com, davem@davemloft.net, zhouchengming1@huawei.com, Bamvor Jian Zhang Subject: [PATCH 12/20] arm64: ilp32: introduce binfmt_ilp32.c Date: Sun, 4 Jun 2017 15:00:01 +0300 Message-Id: <20170604120009.342-13-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170604120009.342-1-ynorov@caviumnetworks.com> References: <20170604120009.342-1-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [176.59.55.28] X-ClientProxiedBy: HE1PR09CA0085.eurprd09.prod.outlook.com (10.174.50.157) To BY1PR0701MB1272.namprd07.prod.outlook.com (10.160.108.18) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY1PR0701MB1272: X-MS-Office365-Filtering-Correlation-Id: 2c915528-4c40-4716-bec0-08d4ab41978d X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:BY1PR0701MB1272; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1272;3:Jk1Ev74GdbiO2oAzRbBxdEssntpu6wVxN5NFazoq1YMRXdjXEOO8QmZ0kKPquQVeGKRz6Vpag7fctHipG2dMp5gmfsuEDXV8N3oRWx0dchRFeohCvWNdFM2KQt/Kdp4I1rFip9wQe8z67c92f6/8BGAInKhSgnDhiYooAWymsDAQw4MRcAljm9/8T94xqE49qaWc1M8tcbpyp/2tkcw89coUaVFkI3p6YLnS1M+BqXOihC0yQIp8y4mlz1DIAxz+X8lvx7zIE8y5jLm5fLNLgP6hIy2mqtXM1S6LsAYV9qMYlyUCVimHH883BWNry9kuKRrpTQpJqv4KT/cC9aSHbw==;25:fL6TVdGnANymKksiTljXxolvsXPWbUZa8UEUdUMqUuws6euhdxa3Ugr9IR5EviAveIPcx3TLGxd7iwgkJPPpqNNfV+Ls4z9q+VIqgxOOyo384g2hZyp1I0UuEnjfF6eu7WAstg7RK7BL2m7XGTG+9OSYfq5vsyFgTI5tzlxakXVZnvh8K14hiuA0Onght/bTrMoRme1q9qjIHqoshmJsXXB8IVf8bmtiha5dCgvKtG5PRhb1BDBLAW5E0dE5VwJ0sAYjtluoEWK/fBiq3C49kyiBRYNdxq/6kZqm99SW6c/9sS38caRboI/iN9pBjUL9wfiq9gKOEIrsKdbJ1rcYQgBEsHD4gISUEXRm2PB+O13mxFlrJjSDrLAlHAOSgNpHupZEY/7qeVH6wImWVgEL0pPmp/fS+BzqcCuh68onLCICSCkLkov63Cws73RcC3soZZZcFdWmQxOV/z+PCJ32W/Ciz2gGQPc1CtlcZwl8hn8= X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1272;31:nQA4M4UzT312d0XzD4Q1pf2k0W8qPIXwW9yZW3DZ35AyE6pcZJx5tlUGa+30n276+F3bF3FfhVP/EJLhi/R5/mLtBYixLZ9fSmERZvjlfi/748BJLBtNhATCw0VeN4wg+g6izDjNKNTU44liccxPagaRoPl/XDKDga32CmSjxYa5OkZktoFXHH7EJWJ3zbuku9bBV7fSotiIlhV1w4naxJ2pKbmIoTTwTUOEFM3cIVs=;20:KlUrgOg2+GaT2hEP447EAiMiKyHVSjt6XRYASOyO01mNLUTbFx7Frr9yFWNfGNDxZbO9nYR4dMDt8N4pUuglTyJ3Cb26R1MCSi71ef6nmmoeq2oawi9qzuSz3Tk8f/Q/TkPLNpACjGvyMBf9b1OOfm/bkLpU0LBqUtDQq8Q0zYwxrDOCkjbLGNxdwA5J22LVa1VCsfvkE7pqFn56dxVqQSf+IDVyIO0pebNT02DY5zAJiPmxrQ2w2shj4Qj54r36OliduYd7fTQiJ+NMnxUJjlqJ9mblBq7/nA9ZngWyEKTUocaNO+1xYLvoZJQLQHsro2gyl2F7ZEuDhHMM8ByzwyiNbAPbDkWbEZohviyfAUZV3MURQ0nUeotm4bt751VsTEGZA4REDPGfe2+QqgXXzqeuZL6YTGJ55OZ3Me6CYRrUjLYmZgz/Z4t5nYPkgs+vfa8HzpJYwXKc0xWgNqY1CE+jMbnSbKFn7zxAQ2+SThI8+gY/8C9LMbTApQGrd30/+4NhwX3lczw7OoF39Bm5LdE4ihYt07DLhYKltd6MXDWvmOJW/V5+2FYo1ctk81pSVMve5v8qVi42MKf23azRkVK9wCKk+fkeJ+Jf2M4U2iM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(10201501046)(3002001)(93006095)(6041248)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BY1PR0701MB1272;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BY1PR0701MB1272; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR0701MB1272;4:XQ5CIMfSAeXhUm2/9F8yfAxw3h0vD75dnvOmwCl7?= =?us-ascii?Q?KjJ1hX5CxD7EiGXQ2O6qkCw6UmRuSkxSuYI5npSlrPUr1y3mSYtg/h8uecR8?= =?us-ascii?Q?Avaz0GPwvM3FJ9gPhH/IqMK7XouZ93bDoR5mF5ej3Z2B/G6s6M5ubqTxyx3E?= =?us-ascii?Q?ANkHAiMh/6qEW7zNrbQyVnI6KTJHHpvespMtZlcV+J6k1BRTkOgbuTm8rMUS?= =?us-ascii?Q?+WKlmDfRjcyKEx5NQv5V501cgsV2BxlqaO0Yi0zmsLK8T8MBJ3pkF4OJAwF9?= =?us-ascii?Q?jrF8SeSJJseyTor4CQF52vVrEU0vsJ+a/z0hzaFJJ9xeW4lWYGocC4LNPAJP?= =?us-ascii?Q?9/2Jezlft3dZIUzng1aSekSbUFTycX3DpNBS362nPe2f7IARa+Yiv0POFXdW?= =?us-ascii?Q?Ws07MtyvfQttyAxvhgwemJ+GCPVDqrF9X7nj42UCfORtke9ijZ/oYw1jpmAB?= =?us-ascii?Q?Kp5dTD8dis51r6B+G+1yfiO7IBjKg7XFlAGvYoylPBfyHzQsHJv0Eb0z/Wym?= =?us-ascii?Q?U4r930VaAwBON4Ho43/+fF8Hk6+GuVFgqH2SRYchpWxfz60SgKe2TgOnRXlL?= =?us-ascii?Q?iwwfZ0w/D9L50GbN8NiF2TsK/yWDxEPLxUh3TOY09FAybp55b07PFBZd64oI?= =?us-ascii?Q?+YAjl2wAiOVB6DTXsBIiYKYY/f+6oG1T6oQnm/I15mpEsnhcioe8RkBXP0t7?= =?us-ascii?Q?1qjKNz9z6bnAhRU9rVNA+3ZV61EMO6UbEFE9MhFRX37FjTG7QnTd2h66qefZ?= =?us-ascii?Q?xXarvogdZ+kmGGGqYO44qer01UdP+qaHNVpsYmjCqEdJUmedZEVOTugUBzr6?= =?us-ascii?Q?NuKdSNvZ540vsBuZHZWJUaTbkteTkXB/PDAUlIETcaYwfy0cnEjkuLdpZbvy?= =?us-ascii?Q?MN496ZeYnb4Pno/stsAzz+jot/+f6oirRBIr3Ya3E/SuCY1C8gQUrUnxYtAZ?= =?us-ascii?Q?isbges9Vm7qeKXZMCgQmY+Xz9cvv5h2ue5kG5gsZ3X8UJ3YMRYzicXYyI0Ls?= =?us-ascii?Q?CTF9FVwqyZmZVsIs+SuSskOmlpHEEHQsEILvKZQpQbxyQDqB6Zsg/gUQK/cc?= =?us-ascii?Q?kUEUnxeg4fOmm+mQAtGvZXGzQsI90WQo/t7IOBVByYo5/kAMZg5cbYhPhNH7?= =?us-ascii?Q?Ya5Nu713G/0=3D?= X-Forefront-PRVS: 03283976A6 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(979002)(6009001)(6069001)(39450400003)(39850400002)(39400400002)(39840400002)(39410400002)(6666003)(42882006)(2950100002)(6496005)(47776003)(38730400002)(66066001)(36756003)(6486002)(54906002)(478600001)(48376002)(68736007)(72206003)(2906002)(50466002)(81166006)(76506005)(3846002)(305945005)(53936002)(33646002)(6116002)(5660300001)(42186005)(50986999)(25786009)(50226002)(76176999)(7736002)(1076002)(4326008)(189998001)(8676002)(7416002)(7406005)(5003940100001)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1272;H:localhost;FPR:;SPF:None;MLV:ovrnspm;PTR:InfoNoRecords;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR0701MB1272;23:5Jz2XF+ZesuVTfTSLbaIwoLclKpaCEus1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fYniqrwFuznIFrx76XeTAFFZonf+QRHadq/xC?= =?us-ascii?Q?MTG0KkHsT3HjPX6GvRuI6+n3NJjIYfxwB9DFtYZbF99qIgr7DK4+r/iPnnc8?= =?us-ascii?Q?NP3PGOWhxfGL4hG130Bs5xdNsP/oUkMgRW4AwnkFXZkd59xmf9WlJ3dPcFOl?= =?us-ascii?Q?8AE3tM9ItFLKFPqhrC/e/ihMVNqIhQEFztGUp75t2eTBAXYgjYQVQJZz6e1h?= =?us-ascii?Q?UydOMwcVsXiXiXodab1jVIevwLCxtK6hwzb0IPurMu9TV0mmfp+OmbTTt0e6?= =?us-ascii?Q?tmj/l7DkWUU2At5Yk39GZWuLVvwWK2Gg7F9ZqgAYTk7x0vVueWZ4/H58Giw?= =?us-ascii?Q?=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1272;6:EGiOBvYcrL8clZRug7jfqHLfxHcY+G+u2xAWkCFfJAiPQOBv3+dNWb9G+t25IP5R4TSkF1Fv+rvoVswlPR3nX8QE9RcKlj8pmJdDlMTM0fYOP2KPnoz+J235H5XPiE5bM03n81EBybuZqllWP9ZeRPvl5mZp9G0+iEOEdDLbtSZSBu3gZrieVlpwr6bwVeHftU+rof6vgstx5DxQ14LqC71DcdkyMtCveXgShzOnSSVG28d+UpRns1rAJfBUzVnIFVCZkITgAIszdvzkxCoBwzl/3q5/LoSNgxicnnFPUJO3zUZQzrxJi7RJP4H0noIw7PEcUSqLhaiagrGq/XwNnQHFZ8rCBalbhSU9hHsgGg9prKLRkHIWjNtaGhU2fHLQQy6ITIEddmNkhbZcGgRVh5SXzNsgOeJGEt7L113/28FtPrjwoGhflPJO+EoWx1cZu48XeWU2toQCUuZOHVZXaMigB3kbHzGSH/zNSV/hY8e/vFtbVAXlkVKZmMV400eat/Dq6pJX9zWdAWZYoYEw2w== X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1272;5:zaBVQK67yDv6JiBy9j7HwSeAFf9j6LzDEpAJ4GemOA0y24CQQNJYaL1EdLUA6fkF3oPm+8pP3+macbBBgtGUNBzpF4a05j6mNl/PKtKDVf9w9EFzCVYGmTgWO9aoinDDOjuTrowJexIrANuoSH72UabqDIo9aACPO8Nh61xgVzbLptoYXe9bD2wgZR5NYOtDlhujd17GIXMzJm4ECfJRvZQZW4vXq51cdPEn584LSENrGUAZ0lfJfthmgnnRDY17FDIuPVQ+LKJmPxl0MTjWLeaA9BjcbNmTNyrkh7r9Oes5pDjdycgblto7wAI2SHLzJ61uCKk1Aqb5EZCZ3Xnu3eVttxVeyGut6J7n1Q4v15e3Z6tKlH6rmMRLT5XIgi7hkA3+LrrSeRFZYanu9rNc2QMXRD7JpUuuSehIlm0iIz1+S26nBRG0tfXOo+lklApl1qvA2fMnSTABxQp326CZpUlnWJPjA8wWa2qIe5e0ehFcH9H5jG3olVr+pAnAde3C;24:yvOoVba4lx37XbvJ8me4pfAOhCSkFoxFBEaXuu44anuu25E3Clyxs94BMScCBAxzlJJIq6lJAe4/VgR2htesvEHCuRQ9/hj18UZTxCyx0GU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1272;7:gBARX+zW6lgElS8wSqoVjF0jZ2pZPzsg72r38ybpP8dv4bfYirAM5uHgTnKi2MDvZdHtJeJE80NOg5Ok+8nf7bqsPGxIvG3WYmp6QcoQRZrZL6HiX7+q8CpXLstG05rzHWH6D8vYcnku/LAugSVk/ZkzdMK3umcsPG7wjIHTMYPToFUTMaaAHDthg640KLiY3vyLpDy0YNIyptxs/+HYvUUKPslC+naOT3FGd/kzAiEM8NqQ7o2GKVt9sumq4F+7vvX5qyKh7LQA9/C5uph1fHJ/kMks5PsL/lUJWEQIun7EbsT2zp9KjcxUgn2x/TqoJSvEx4R7n5wGxwPu0tRGNg== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2017 12:02:36.0580 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1272 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3448 Lines: 115 Like binfmt_elf32.c, binfmt_ilp32.c is needed to handle ILP32 binaries Signed-off-by: Yury Norov Signed-off-by: Bamvor Jian Zhang --- arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/binfmt_ilp32.c | 85 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 arch/arm64/kernel/binfmt_ilp32.c diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 6f872741fd3d..5ba41095c466 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -29,6 +29,7 @@ $(obj)/%.stub.o: $(obj)/%.o FORCE arm64-obj-$(CONFIG_AARCH32_EL0) += sys32.o kuser32.o signal32.o \ sys_compat.o entry32.o binfmt_elf32.o +arm64-obj-$(CONFIG_ARM64_ILP32) += binfmt_ilp32.o arm64-obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o arm64-obj-$(CONFIG_MODULES) += arm64ksyms.o module.o arm64-obj-$(CONFIG_ARM64_MODULE_PLTS) += module-plts.o diff --git a/arch/arm64/kernel/binfmt_ilp32.c b/arch/arm64/kernel/binfmt_ilp32.c new file mode 100644 index 000000000000..bb31325e6f80 --- /dev/null +++ b/arch/arm64/kernel/binfmt_ilp32.c @@ -0,0 +1,85 @@ +/* + * Support for ILP32 Linux/aarch64 ELF binaries. + */ +#undef CONFIG_AARCH32_EL0 +#define compat_elf_gregset_t elf_gregset_t + +#include +#include + +#undef ELF_CLASS +#define ELF_CLASS ELFCLASS32 + +#undef elfhdr +#undef elf_phdr +#undef elf_shdr +#undef elf_note +#undef elf_addr_t +#define elfhdr elf32_hdr +#define elf_phdr elf32_phdr +#define elf_shdr elf32_shdr +#define elf_note elf32_note +#define elf_addr_t Elf32_Addr + +/* + * Some data types as stored in coredump. + */ +#define user_long_t compat_long_t +#define user_siginfo_t compat_siginfo_t +#define copy_siginfo_to_user copy_siginfo_to_user32 + +/* + * The machine-dependent core note format types are defined in elfcore-compat.h, + * which requires asm/elf.h to define compat_elf_gregset_t et al. + */ +#define elf_prstatus compat_elf_prstatus +#define elf_prpsinfo compat_elf_prpsinfo + +/* AARCH64 ILP32 EABI. */ +#undef elf_check_arch +#define elf_check_arch(x) (((x)->e_machine == EM_AARCH64) \ + && (x)->e_ident[EI_CLASS] == ELFCLASS32) + +#undef SET_PERSONALITY +#define SET_PERSONALITY(ex) \ +do { \ + set_bit(TIF_32BIT, ¤t->mm->context.flags); \ + set_thread_flag(TIF_32BIT_AARCH64); \ + clear_thread_flag(TIF_32BIT); \ +} while (0) + +#undef ARCH_DLINFO +#define ARCH_DLINFO \ +do { \ + NEW_AUX_ENT(AT_SYSINFO_EHDR, \ + (elf_addr_t)(long)current->mm->context.vdso); \ +} while (0) + +#undef ELF_PLATFORM +#ifdef __AARCH64EB__ +#define ELF_PLATFORM ("aarch64_be:ilp32") +#else +#define ELF_PLATFORM ("aarch64:ilp32") +#endif + +#undef ELF_ET_DYN_BASE +#define ELF_ET_DYN_BASE COMPAT_ELF_ET_DYN_BASE + +#undef ELF_HWCAP +#undef ELF_HWCAP2 +#define ELF_HWCAP ((u32) elf_hwcap) +#define ELF_HWCAP2 ((u32) (elf_hwcap >> 32)) + +/* + * Rename a few of the symbols that binfmt_elf.c will define. + * These are all local so the names don't really matter, but it + * might make some debugging less confusing not to duplicate them. + */ +#define elf_format compat_elf_format +#define init_elf_binfmt init_compat_elf_binfmt +#define exit_elf_binfmt exit_compat_elf_binfmt + +#undef ns_to_timeval +#define ns_to_timeval ns_to_compat_timeval + +#include "../../../fs/binfmt_elf.c" -- 2.11.0