Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753295AbdCATZD (ORCPT ); Wed, 1 Mar 2017 14:25:03 -0500 Received: from mail-co1nam03on0068.outbound.protection.outlook.com ([104.47.40.68]:55242 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753267AbdCATY5 (ORCPT ); Wed, 1 Mar 2017 14:24:57 -0500 Authentication-Results: lists.infradead.org; dkim=none (message not signed) header.d=none;lists.infradead.org; dmarc=none action=none header.from=caviumnetworks.com; From: Yury Norov To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Arnd Bergmann , Catalin Marinas 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: Thu, 2 Mar 2017 00:49:20 +0530 Message-Id: <1488395968-14313-13-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488395968-14313-1-git-send-email-ynorov@caviumnetworks.com> References: <1488395968-14313-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [27.97.135.110] X-ClientProxiedBy: HE1PR02CA0072.eurprd02.prod.outlook.com (10.163.170.40) To DM3PR07MB2249.namprd07.prod.outlook.com (10.164.33.147) X-MS-Office365-Filtering-Correlation-Id: bb731659-6225-4c88-060f-08d460d83d45 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DM3PR07MB2249; X-Microsoft-Exchange-Diagnostics: 1;DM3PR07MB2249;3:Un0BvK2YQojwcYSUrRZMQH702TRFmeZUzn3d2sdeqYAiyoDGNJ5sUSVmcfIHSSy39R53LcjYbuQeTgbbVJ6iHyhSI1O6NiYeE9nquiFDpHVN+L5U5KBzMaL1jN8MZ7djcK63YvbD+mcEmzsDHekER1NkEwcr+FOH0aPvfB9jcxM8OxiEORwvP+jOHwrH8yD+TZMBZVrl33ceNglSq4EfLKqvtJf/XVnRM8Sh7rMpW0iQlhNEpalsKxTGT31ZLGyVkwyhI/NFNZ2d0pnlVoWLYA==;25:7mDUmDOQC/+NBtq9Xgr/ufKXIjG1v9bneyNTDFBOp4Evc5AN4yerxYWIQvJQnpB8MYIkzDxhsHvWcZEKpikTaOS0KGUKNlahCUDdp/0NaEdWmbi/MyAgR3Umcd2egMpTVXsBnOqN0CR5cszLzhZG4x2aTwqDQB7QgKeoqPZ3EAtE8yzDGMxEwlbDCzbyI95/pXu3XiLsm86ig/rk4MmHbM8ouc0uBa9TPK7kTR0aYeU6f/UfVKcj2oyVc52FUtS21ofTAAHy+ORJ/yhr3kSKTsgcLnl1qG7FVufKdJz+U0lrlIG2h4fNHcnUxGnWNkHGR7QiTdsMlm5BGH1P7E9fDsRzhhHf+OJrdyv0nLAO7vgEgQkxiGBl+cZ6P4XAUkycvf372HMAlc+pp3g4fu/AIE8Ayt+P0XmH6y+Ammmfdf0ILlmBqaOtC5zwMSXQoz8iqoh4vF1F3h8vZausC53QSQ== X-Microsoft-Exchange-Diagnostics: 1;DM3PR07MB2249;31:UGblbdMxwo0SJ0Lq9aSYo6Wm4sH7RzY/l4xa3YDCjuR/Mtd6t82mq6PpDldcT8heXGXnglmZEIMHPQM6DT+ysL8z73HzUH24FzSoUZAScOtpCRJtf0vvItj/nSUNJ8xv1P0P4Il1IAHYIvkyA9gL7SEttQC8CsP9PcZ1xINDYp7NhPRP900BG12iWUtaEZPKj1nrU8rwSbYvVrTnmvjbmuIwiuxzNvfQNnYc9dPj3vI=;20:X7bxu/zwJO/ZKERmEViDouhHY7lCe2kSKZfVwarleEjEtNtX/S01AfSfALOPxgbDYuqrrri26OQR7DHSfn0sUmAjeKuZ6Ia0gFWymrGXVCUv4PvLUU1wi/BugE9SVQWXS4QMnlXE7iWeqSbftIZMQ7SFIEwdVaACJpVbhz2iTj+Fc2OLUmkv3OQw2itB0UW1Jgo/ePZc4JPbWHWq72NxuDC9Nn3zJrDeYnp9H4eMDaZwyPeqy/+s0+zjKUCP7sd17NQn33DhPalck/1XxU2UsBz3wj7kFuy8quKMiq5erZHtbQ79ZyuzcVnMknNNtGDaze6xHs0Xlr12gn9UZYKME3jJ1ynJakrKlDloSul9m9BF+nbURvRBwByLjEy6Vy+6qQKa3Tcx56DOI49N2nDtyl1IL7RycDIswUywc0YlQCpCN1Ukx4vPbR/fnKaH5Qfg4z23B3lXDyKiZ5j3VCdqQNjXi0t71bv3EV74jJgFSpTDWAKUDPmFx7ppO0qOZxXQWdkDe2LkJ5sL4GqqAwTTCzEVUJzvkcBeE9Iv7NYasad1k0tCR7FuDkCR/9p5C8pznL2/gwKfsSQ3X+c5SKJ3EXiONmrsgOuU4EpIv8EyxWM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123555025)(20161123564025)(20161123558025)(20161123562025)(20161123560025)(6072148);SRVR:DM3PR07MB2249;BCL:0;PCL:0;RULEID:;SRVR:DM3PR07MB2249; X-Microsoft-Exchange-Diagnostics: 1;DM3PR07MB2249;4:wHBB4SCVrdp/Oq0dVO8xVk/s/tCEjtgQfyyxUuQEwUecuaMxyIG/nuVd40VozYkf6REosZBZQqUiBF5zcmLmoYUnna850ZcfGxMXyQuWBIJmQqGNCbpncw8EfXEISpVmqvZTdWljwRWyUR2BxgdDJDdh+7anWuhOwzT9i44DOHwTt7p2Y0+O3WSRhEByhPHVEEw5qEu5ZYQD5qcH4NzoPtn+97h9zbqxhuM8TUTDF00NoGrXGYf+oMpVTI6h6ucEpxaErSGA+j6W6tn6O8Cdw56bOmzdnZU+Fl4zgt/6X+aX7mAJFCbj2kez8L3YE1FeJC1KR8fCHDGNp993rxEv8Uw1UjVEbwwF7p1NcsSqJ+cAVsdpegKaw/FFkhuPDNcv2/GGC29StfuhllbNoLtIu6DpKcyCKl4n1pOWWRcEUX3MldmQvPcnigjmW88tnE0eSkZ+tVyGGSxSQdzBZMlbDwVav9+StVbIsTn4Qa0XIyw7tj89vcw8sy50Rzc4jHdm5PlhVMWbUkgQAZyLll+DEBh4VHBxWXhZ6ohHLjGBvEJUTmQdGmr9/njlwqkaf2kMRaEK3FYOUYDBmVS0GbGOYRFFRpj/43j8Cr+u8qdOj+U= X-Forefront-PRVS: 0233768B38 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(39450400003)(76506005)(92566002)(50226002)(6496005)(7416002)(54906002)(5660300001)(8676002)(5009440100003)(7736002)(4326008)(81166006)(305945005)(6486002)(66066001)(189998001)(76176999)(48376002)(5003940100001)(42186005)(2906002)(6666003)(2950100002)(6116002)(50466002)(50986999)(36756003)(47776003)(3846002)(33646002)(53936002)(25786008)(38730400002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM3PR07MB2249;H:localhost;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM3PR07MB2249;23:H6xf8TCKFOD6IHJLV5+YuKNkKs463Vnu4r64d4klb?= =?us-ascii?Q?OMMQ1Ti2DjhLyww3G2ZffzwPgcOiXPQeCfq42n/Qeqadrmu+g81sTUj1q8XZ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hJGQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;DM3PR07MB2249;6:fIezW3kb2P+xOXC3oiFReTWWY9WH3DR4cfnXAxAHBE9YUygDuxFU23J+WYP2ywjTRAg8ztO1imDvN7ent4+YckLvPM+jjeIrKSZx/Y/m3B4q7ktraMPlA1sEDtryi4TFZ6XkrWmBwzCe0sB9+xSrNa2nWjAj+QeaTDzkNx4EcCfjWfu05mhdNSRsLQUPdswuW1A6e36bfS+VnV5zuNqQt0rvIj3O+EGnjjlt847/sA+qH5Z37wNJuRHFowQReFi3H2v7hHpk1egN6zypbWRbpNBOUIFckYoiI5cZqn1lIabK5cxKlQ/MjSLteojCligHLqel9C4egbVdJ4u82YGjzq8tPcHcbYPa3/kdv0pY3czkpw74P9VPnYCfuBZ1gnpn5wGV23D6HciVI1vHzGS8yg==;5:zyWLFbNRcE15pY/BuATWVzd36UQMjPRuDnHmBjJfgYu0QmrkxGdGuxSbzHZHIK5h0dy3v3m0kyqISEAapXg4BvT/sUf1+hMZtpJE408t+Js389NgK7rDfzcIQuiZSSVMIWs+nNHYYVN5+m8BH3eD7Rxi8/RNvy7hZJK07QKB8Hk=;24:AQLKUUt3ADHg9D1rsIG30wWydlZ4Pztwl4oMPOgWDGOA6AMavL58OXXLbVwcQbBpU7p6BHjwbGs7Rzb3Uj9/dVrcXwrKHyE8g47o9TuqoKY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM3PR07MB2249;7:a5laB2jnK9xZYxCogZ6wg111Lv5UcntG28qd61k6PsniN2TmmAVUwvcVCgX1JHvKU3a8pruk9n4tTJBD4lD+rURMwJmt/kLoB/+n+B3eRuFVvaUf6jgLE/6TjIK/bCejgV90TOhjRA5oHzU1rcTf1zyYIIsKNiMyqr/cZ5+oIEJsoMl9wBGgXDSePxBPsP2cILBcYwPfG3TFV9K28rfJ8GK66wdaERrBN1HYJ/GgojQbldIoqNZnOIvyRDc0b5+mfb5sImX64LrHyuoq5LZMcvSHinQRypT2QD60zFzIjGMCqjPIsHsLEnZublGm23t4wynUrwgZNBrpGD9zVEV55w== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2017 19:22:01.3891 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR07MB2249 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3427 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 aeaf474..b6f14a8 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 0000000..bb31325 --- /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.7.4