Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754177AbbKBXdb (ORCPT ); Mon, 2 Nov 2015 18:33:31 -0500 Received: from mail-bl2on0077.outbound.protection.outlook.com ([65.55.169.77]:24192 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751787AbbKBXd2 (ORCPT ); Mon, 2 Nov 2015 18:33:28 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; From: Yury Norov To: , , , CC: , , , , , , , , , , , , Andrew Pinski , Yury Norov , Andrew Pinski Subject: [PATCH v6 10/17] arm64:ilp32: support core dump generation for ILP32 Date: Tue, 3 Nov 2015 02:30:39 +0300 Message-ID: <1446507046-24604-11-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1446507046-24604-1-git-send-email-ynorov@caviumnetworks.com> References: <1446507046-24604-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [109.252.143.100] X-ClientProxiedBy: DB5PR03CA0013.eurprd03.prod.outlook.com (25.162.150.23) To BLUPR07MB612.namprd07.prod.outlook.com (10.141.207.27) X-Microsoft-Exchange-Diagnostics: 1;BLUPR07MB612;2:ALATEZR7U49NfbiaWMg7fSeg2T70wOQdzVHyPIKVImz30jPeUeyT/5Ophnv2ZCX49ajGYTagGA5qPTblr8BuR/YCWgp6BN1Ldeznt/rT2DXdaoyC1vnqK1d3R9wfx241NCieHPb6XvkpTnxhYfABrRtFdgSGIBTIEp0JeXjvk6s=;3:FuXhpq7ifgvanC3RfTuMFjvQGAvhpPMydN5p6NB9OsfkfNXp8vSZkwZ8M4z6sVGf/uIJSA7mmXG5OlA6aE7krCA9hSGcUhhgSojqJkcQILDLf1rEsG+AW3cOTGUv/6ZKpFkk17jYMl5G91QhgNwc6g==;25:BvvSU2WT1DICSHlhAR0KeUvRjo+N17Vm4cUfOoJ4EetxQAmhoSDtZqb9aAFQXwaCYXW/WL/oaZzLNMYpyN17oE/sJqOyjfp97k1SGFq4vduq+zqWZa4xev7TE1ArsisnQGzbRlqxCuPWjwalGMxl0si3wY8FGq0e7GtgM97RWJcSUEw9P5XMkD/POonhr/trPgPJxOwv0giYvjdly0uTR1Sn/hFBEKN5+ODmMZzKLRWyCMFQp/e8O5W/PJeVijxMi4iIEiqoUldkwXcocO8PYw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR07MB612; X-Microsoft-Exchange-Diagnostics: 1;BLUPR07MB612;20:Y+CjZefu0zdquawjZbyb6VV5E2rghLoNNxRXOW2VFyj3VFeoqCxkjmHHx4wqpQkzZeAHzD3NNLzt+CgFnYgZ1/psghGQ7/tjadg8qCFDfD0bZ8pRkxqsVtcUswxB0kZAwV5cebX0BbxvLdj+2bakfl6UUzYwZQI4LFwGx0zSFUtQfWt5jMpdGFI+Zhg0o5A083JTQ85aJwMtURG9ITxs+kwzWIwlFj6lmXcMHyaZhSL5PsNzrLkV8vbIeDwE5lObtlLvFNrEpkFExHUPeXZp/POvX/LzWVHysxSPbCNYTtgh5XhPal4ujooZKmRdtaOH8BYMwizTYkfUScrKIh5TcwKzLLmx4wJSHYcfTnk2Kq8oFpWLqPLYAr1e1rKDqoiJD75/uqKXFIIQ4WNsIXEi95SaHLWXfBEaQNuG1nWqF89KWn70Cg7BoapJglKMe3NyNwowJ6jHm5LfsUKZzUchKLcq8KysOV83icoTVG0ZldYv478nWR6ooHdFmotIBc9FfQ7rlp0m6c8zcty2RUg/ac3CWX9wjJkcbOOV+25ovhVUJy8b8tIG4xfJckudOa6ePIxpkePL2Mou8Vg3/LPTq+oTOMPZfnR11AYSv7QjwSk= 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)(10201501046)(3002001);SRVR:BLUPR07MB612;BCL:0;PCL:0;RULEID:;SRVR:BLUPR07MB612; X-Microsoft-Exchange-Diagnostics: 1;BLUPR07MB612;4:YPVPaZBLmU00v8a/9rXxe3AlViMkky58mFuP6Zqnzr9rt4up+LkWF1oG8M2tSBS/iHtPa2gJWs1OMe0x98AfRA3HGJISiRj9yyQQRmDjb35rbIHUC/J4aaISR7cCYB8eRa33qUPdyhAehF9j1vud9Vy/+u610zyMucmo4Qj0zGanmIS4/Y+rPPXBwDUWi03LsKoFE6m9Jp1tc52I6Xjye6yvb7Yf0jKlM9rwA0Mig+O0z3ZpJ46I/E6fXX8xs10OR0R3PI7XN7ji/NxmiItlhp2zerrRa4uOo7OTXC0kbkb8sWK67f/wMCwruGNezQ4efqbMvXCP5oHczFv7E06cKzjovP/QnM8IF0bjMl1P4oxYnD3e565fEQqwLBc711mA X-Forefront-PRVS: 0748FF9A04 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(6069001)(199003)(189002)(4001430100002)(19580395003)(106356001)(92566002)(50466002)(575784001)(19580405001)(36756003)(5003940100001)(50226001)(87976001)(47776003)(2201001)(66066001)(40100003)(189998001)(122386002)(97736004)(81156007)(101416001)(5004730100002)(77096005)(5008740100001)(33646002)(50986999)(105586002)(229853001)(48376002)(5001960100002)(107886002)(5007970100001)(2950100001)(42186005)(5001770100001)(76506005)(76176999)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:BLUPR07MB612;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR07MB612;23:o4luVWjEzw0nu9t7FqQLCpMBKnV1pzjcstYCsq1QM5?= =?us-ascii?Q?C6NEw5PQngUgzgFutZR6fR4zX6L/FdNjaazKkR31LpMHGLeGKAx4houQ8PHJ?= =?us-ascii?Q?/ktP26vZk1KzCAIDFlM698Utd7zRju86vbs2kQsAyG8DNQQ2c7Ow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ejtMZscpjHGRiN0u3T24REd4aQlha5xrrFh/wA5ngVpljdWtkYjCdI3r?= =?us-ascii?Q?ADGrwoTWUriQjIHIVZAVESAPqnbvUr4F/SKFhn+E7KbtzePJZRRmj5CnUV73?= =?us-ascii?Q?JcTg+wAa8=3D?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR07MB612;5:ilw8GlPqgPFWNrxuPCJlJHrsPwBhd/fkQjxHQke//+TbaPt0M3CSfLBkq6iZB5K2Wg6+jMLSHGG5Mbe6/oIRhvppV4qCJ/LsmRipkCDxhFMZ+nHh0eSIRK3eqltwFf41rPCEtl6UhxNIcUJzndZUIw==;24:O0WPQSFb2PkGfeNeRzz6gKmqYeqNqKaNiIe0OxjwsX33piIb3qZmMd+PDQI3C6DPGqFtv4OWb0fIDKIh62yCCMYGuZEfyHqX7ilcYg/XUxQ=;20:pejx45fvsA4+J468afAnpUp5Xsg9f7bkqxfSdFs529fs+PUlQNegt5gRuIcIIU8t+vpOLwA+SfXzl4bKNFa3tQ== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2015 23:33:24.4439 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR07MB612 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7740 Lines: 220 From: Andrew Pinski This patch supports core dumping on ILP32. We need a few extra macros (COMPAT_PR_REG_SIZE and COMPAT_PRSTATUS_SIZE) due to size differences of the register sets. Signed-off-by: Philipp Tomsich Signed-off-by: Christoph Muellner Signed-off-by: Yury Norov Signed-off-by: Andrew Pinski Reviewed-by: David Daney --- arch/arm64/include/asm/elf.h | 87 ++++++++++++++++++++++++++++++++++++++------ arch/arm64/kernel/ptrace.c | 12 +++--- arch/arm64/kernel/vdso.c | 8 ++++ 3 files changed, 89 insertions(+), 18 deletions(-) diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index 01e032c..8f13dac 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -134,7 +134,11 @@ typedef struct user_fpsimd_state elf_fpregset_t; */ #define ELF_PLAT_INIT(_r, load_addr) (_r)->regs[0] = 0 -#define SET_PERSONALITY(ex) clear_thread_flag(TIF_32BIT); +#define SET_PERSONALITY(ex) \ +do { \ + clear_thread_flag(TIF_32BIT_AARCH64); \ + clear_thread_flag(TIF_32BIT); \ +} while (0) #define ARCH_DLINFO \ do { \ @@ -166,12 +170,15 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm, #define COMPAT_ELF_ET_DYN_BASE (2 * TASK_SIZE_32 / 3) +extern int aarch32_setup_vectors_page(struct linux_binprm *bprm, + int uses_interp); + #ifdef CONFIG_AARCH32_EL0 /* AArch32 registers. */ #define COMPAT_A32_ELF_NGREG 18 -typedef unsigned int compat_elf_greg_t; -typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_A32_ELF_NGREG]; +typedef unsigned int compat_a32_elf_greg_t; +typedef compat_a32_elf_greg_t compat_a32_elf_gregset_t[COMPAT_A32_ELF_NGREG]; /* AArch32 EABI. */ #define EF_ARM_EABI_MASK 0xff000000 @@ -179,24 +186,80 @@ typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_A32_ELF_NGREG]; ((x)->e_flags & EF_ARM_EABI_MASK)) #define compat_start_thread compat_start_thread -#define COMPAT_SET_PERSONALITY(ex) set_thread_flag(TIF_32BIT); -#define COMPAT_ARCH_DLINFO -extern int aarch32_setup_vectors_page(struct linux_binprm *bprm, - int uses_interp); -#define compat_arch_setup_additional_pages \ - aarch32_setup_vectors_page +#define COMPAT_A32_SET_PERSONALITY(ex) \ +do { \ + clear_thread_flag(TIF_32BIT_AARCH64); \ + set_thread_flag(TIF_32BIT); \ +} while (0) +#define COMPAT_A32_ARCH_DLINFO do {} while (0) #else typedef elf_greg_t compat_elf_greg_t; typedef elf_gregset_t compat_elf_gregset_t; #define compat_a32_elf_check_arch(x) 0 -#define COMPAT_SET_PERSONALITY(ex) -#define COMPAT_ARCH_DLINFO +#define COMPAT_A32_SET_PERSONALITY(ex) do {} while (0) +#define COMPAT_A32_ARCH_DLINFO do {} while (0) +#endif + +/* If ILP32 is turned on, we want to define the compat_elf_greg_t to the non compat + one and define PR_REG_SIZE/PRSTATUS_SIZE/SET_PR_FPVALID so we pick up the correct + ones for AARCH32. Note also the definition of the macros have to be correct for + LP64 as this file is included in the standard binfmt_elf.c. */ +#ifdef CONFIG_ARM64_ILP32 +typedef elf_greg_t compat_elf_greg_t; +typedef elf_gregset_t compat_elf_gregset_t; +#define PR_REG_SIZE(S) (is_a32_compat_task() ? 72 : 272) +#define PRSTATUS_SIZE(S) (is_a32_compat_task() ? 124 : (is_ilp32_compat_task() ? 352 : 392)) +#define SET_PR_FPVALID(S, V) \ +do { \ + *(int *) (((void *) &((S)->pr_reg)) + PR_REG_SIZE((S)->pr_reg)) = (V); \ +} while (0) +#else +typedef compat_a32_elf_greg_t compat_elf_greg_t; +typedef compat_a32_elf_gregset_t compat_elf_gregset_t; +#endif +#ifdef CONFIG_ARM64_ILP32 +#define compat_ilp32_elf_check_arch(x) ((x)->e_machine == EM_AARCH64) +#define COMPAT_ILP32_SET_PERSONALITY(ex) \ +do { \ + set_thread_flag(TIF_32BIT_AARCH64); \ + clear_thread_flag(TIF_32BIT); \ +} while (0) +#define COMPAT_ILP32_ARCH_DLINFO \ +do { \ + NEW_AUX_ENT(AT_SYSINFO_EHDR, \ + (elf_addr_t)(long)current->mm->context.vdso); \ +} while (0) +#else +#define compat_ilp32_elf_check_arch(x) 0 +#define COMPAT_ILP32_SET_PERSONALITY(ex) do {} while (0) +#define COMPAT_ILP32_ARCH_DLINFO do {} while (0) #endif -#define compat_elf_check_arch(x) compat_a32_elf_check_arch(x) +#define compat_elf_check_arch(x) (compat_a32_elf_check_arch(x) || compat_ilp32_elf_check_arch(x)) +#define COMPAT_SET_PERSONALITY(ex) \ +do { \ + if (compat_a32_elf_check_arch(&ex)) \ + COMPAT_A32_SET_PERSONALITY(ex); \ + else \ + COMPAT_ILP32_SET_PERSONALITY(ex); \ +} while (0) + +/* ILP32 uses the "LP64-like" vdso pages */ +#define compat_arch_setup_additional_pages \ + (is_a32_compat_task() \ + ? &aarch32_setup_vectors_page \ + : &(arch_setup_additional_pages)) + +#define COMPAT_ARCH_DLINFO \ +do { \ + if (is_a32_compat_task()) \ + COMPAT_A32_ARCH_DLINFO; \ + else \ + COMPAT_ILP32_ARCH_DLINFO; \ +} while (0) #endif /* CONFIG_COMPAT */ diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index d2e428c..22d0d5e 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -854,8 +854,8 @@ static const struct user_regset aarch32_regsets[] = { [REGSET_COMPAT_GPR] = { .core_note_type = NT_PRSTATUS, .n = COMPAT_A32_ELF_NGREG, - .size = sizeof(compat_elf_greg_t), - .align = sizeof(compat_elf_greg_t), + .size = sizeof(compat_a32_elf_greg_t), + .align = sizeof(compat_a32_elf_greg_t), .get = compat_gpr_get, .set = compat_gpr_set }, @@ -946,7 +946,7 @@ static int compat_ptrace_read_user(struct task_struct *tsk, compat_ulong_t off, tmp = tsk->mm->start_data; else if (off == COMPAT_PT_TEXT_END_ADDR) tmp = tsk->mm->end_code; - else if (off < sizeof(compat_elf_gregset_t)) + else if (off < sizeof(compat_a32_elf_gregset_t)) return copy_regset_to_user(tsk, &user_aarch32_view, REGSET_COMPAT_GPR, off, sizeof(compat_ulong_t), ret); @@ -967,7 +967,7 @@ static int compat_ptrace_write_user(struct task_struct *tsk, compat_ulong_t off, if (off & 3 || off >= COMPAT_USER_SZ) return -EIO; - if (off >= sizeof(compat_elf_gregset_t)) + if (off >= sizeof(compat_a32_elf_gregset_t)) return 0; set_fs(KERNEL_DS); @@ -1130,7 +1130,7 @@ long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request, ret = copy_regset_to_user(child, &user_aarch32_view, REGSET_COMPAT_GPR, - 0, sizeof(compat_elf_gregset_t), + 0, sizeof(compat_a32_elf_gregset_t), datap); break; @@ -1138,7 +1138,7 @@ long compat_a32_arch_ptrace(struct task_struct *child, compat_long_t request, ret = copy_regset_from_user(child, &user_aarch32_view, REGSET_COMPAT_GPR, - 0, sizeof(compat_elf_gregset_t), + 0, sizeof(compat_a32_elf_gregset_t), datap); break; diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c index 26352a6..b239b9b 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -107,6 +107,14 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp) return PTR_ERR_OR_ZERO(ret); } +#else +int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp) +{ + (void) bprm; + (void) uses_interp; + + return -EINVAL; +} #endif /* CONFIG_AARCH32_EL0 */ static struct vm_special_mapping vdso_spec[2]; -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/