From patchwork Wed Jun 15 00:40:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 9177177 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9B4B160772 for ; Wed, 15 Jun 2016 00:42:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89F66200E7 for ; Wed, 15 Jun 2016 00:42:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DFD42833B; Wed, 15 Jun 2016 00:42:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id E2524200E7 for ; Wed, 15 Jun 2016 00:42:31 +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 1bCyt0-0007Uc-Q5; Wed, 15 Jun 2016 00:40:50 +0000 Received: from mail-bn1bon0096.outbound.protection.outlook.com ([157.56.111.96] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bCysx-0007TX-2O for linux-arm-kernel@lists.infradead.org; Wed, 15 Jun 2016 00:40:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-caviumnetworks-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=u+rTis5piI/y+wbfR3x6K3Anf2+3rWgDsOpkW3nGbKc=; b=Hxt0Fz+Ru8y/vi9l1o4MenzJYacb1aUiyRiBkaHAe7GVfm8ibsnHATM76J+3TADDnVhDnh6a7OsZCn4BNXKSvv1IUR+Y2XxaffiU4FPeJ81BQaZnOHGUqHRKmsojy3Ym0Ru9ak7pY4iHIQ1Buf5EMVrahSBKbe940EAKL2OAChs= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (50.233.148.158) by BN4PR07MB2241.namprd07.prod.outlook.com (10.164.63.147) with Microsoft SMTP Server (TLS) id 15.1.523.12; Wed, 15 Jun 2016 00:40:23 +0000 Date: Wed, 15 Jun 2016 03:40:19 +0300 From: Yury Norov To: "Zhangjian (Bamvor)" Subject: Re: [PATCH 16/23] arm64: ilp32: introduce binfmt_ilp32.c Message-ID: <20160615004019.GA20783@yury-N73SV> References: <5746FEF6.9070405@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5746FEF6.9070405@huawei.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [50.233.148.158] X-ClientProxiedBy: BN3PR16CA0025.namprd16.prod.outlook.com (10.165.112.163) To BN4PR07MB2241.namprd07.prod.outlook.com (10.164.63.147) X-MS-Office365-Filtering-Correlation-Id: 914ef925-58ba-4e47-fb9a-08d394b5a33c X-Microsoft-Exchange-Diagnostics: 1; BN4PR07MB2241; 2:AwZiResl0HttXlRDxrHzAcUWyBmaiLhIom3e1WELT8Egwn+BoaBgAXsX3ebCWZi55aafNufttwazvYMfQT7UO9Sv/3GbxliLMUdAJUL//Z1M5OWAmTizJbkNIf0iuXkcAhlzT6vlsRZe/+MTHyZRHkUqSJNe7C8/0jGoySmTBwNw4jKUdqfj4am8504qzHdi; 3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KScWLwkOZsEILv1bwKy9547ra6aaDky050yYb5sQjsCFwZYdLrqI4WjGsbfvGM3ugqV+rjWBo/pXdXYqMsVmoKaBsz8rFb70S7bSkLUKw5/ZUltDgYdRFkag+db7pxBq+btN9K92IdHJTyaYZgRPN5b5q/2vOJATTYOBCk6++Q4LPKrfhGKpnXU8DE/23UOmvkrcK6a25kp9g0CJt+Us6XG2oMiYnv9FqIaJpFSmiPalfmca8AHR8+xoZkm+mCmXe9IXLKszbyNzVOUtbj6tNjEokNgMrE6+bp4tO+21Jy9aJk8UQAojr8zK2e6QSjL/AjFPL2G2cF2s1n9S7EqB6ojr16Bj53l5oHlkT2WoBb6TDY55a2xE2MeyAd0uIjEyQejWYzQgRQG7fWPN/TII23UrFSJG2dMVm+RcVXYV0i2qwuafDrzU7JH0Iqg0CbYTDyqBSXRkYdPus+G9vBuSbiO36TLDQyb7GSG4jp0MOZfDLe3u7qW+2Mab8BZ7ZdMXME8kdCOTByEJiU+NKG+TRgkPV+lXRNxIY4KH5L194NAlngnVx012Q7eYV3HgXPXNHXEMFA3IVREUBpg9wJyPlrg= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(50582790962513); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001); SRVR:BN4PR07MB2241; BCL:0; PCL:0; RULEID:; SRVR:BN4PR07MB2241; X-Microsoft-Exchange-Diagnostics: 1; BN4PR07MB2241; 4:Ej3MoXeK6Tb5J5K8ckrnh1T42PJibZEeee5A1kQDA0ft6HE3VCCWyLLzDAJQOVpm8p/ZFal8glKVwOzVu4qNkM3M1u7MB7W3DCuKEbLg+rAHP3BEz43mKYIbLJwKJwawCKbTdACXOQ48sIUrJK1wEn7PWzowLMloiqZWIthW+SF+NeG0h35YvfuoHTQZDFK2VfDlTKkwQdm22mGz6coNPBOaJB0HUnJg4Im5AwaMA4Gk3DIvA01OvgVNlRLi8PtpaYbUuaKp6Y/E6liY9DlVCdjPrHUhAnGkklaC4zcx+5fQv3j4YBMSh9z1XhWfRHBDauLJGgCxcmVnXk0bcNaaEN11tbNRbB6aD8CmXK/mhnnVPArOHPo4sdGwnLEQHs2FalNTr17p3YnyV1p6LsH6XcsjqPYnMz+0ADr2JO9A8R8= X-Forefront-PRVS: 09749A275C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6069001)(7916002)(24454002)(189002)(199003)(97736004)(54356999)(19580395003)(46406003)(4001350100001)(81166006)(81156014)(2906002)(106356001)(5890100001)(83506001)(33656002)(105586002)(101416001)(8676002)(19580405001)(4326007)(3846002)(66066001)(2950100001)(6116002)(97756001)(586003)(23726003)(1076002)(5004730100002)(9686002)(68736007)(50466002)(76176999)(42186005)(33716001)(189998001)(76506005)(50986999)(92566002)(5008740100001)(110136002)(77096005)(47776003)(21314002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN4PR07MB2241; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; CAT:NONE; LANG:en; CAT:NONE; Received-SPF: None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN4PR07MB2241; 23:Q5N8Og68HN2sTZsP0//cs6nSBRtENe/WO52gmF+lL?= =?us-ascii?Q?1X3aY5H35H8+dFevZuxfYtP1I6oGBe9zM/Vv2f5+DAWBoWD7v+wccgT227fM?= =?us-ascii?Q?wgMxTAQmzpue6JqJ4c7DBItxmYTPe3FfoUV58f0AXitHxwkAnZZD+9Mt+D1u?= =?us-ascii?Q?psCtJp5dv+GkhK14fgidCMisOQ2iAeYBKDQw8e8MULyIqn6ez0o5q+jSFvH0?= =?us-ascii?Q?N3pCqxY63jZcXuHn0WrsWc71oHguodM1FPfOK2c7h8YUeU9yXg1PqzCfjdKf?= =?us-ascii?Q?6fkaBwH3wlaayHOy5czpGLCCm5VeIlxQcZt1UvEuv98oEdes1Xkxcmy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OarhqcxlRFh1cyH0waO+QsE6dP1lwywpg=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN4PR07MB2241; 6:n2PUtLQtQPgqTjsA9NHptFFuWZ0ra91elbp7sO2IcWNc9TMJto8Fkvo7DzVGt0YHte+VmdRzbRFRAxImaWqwiZ2F+fuis9NfM9hsbt8mvNUpwcvOAihs48Rpix+i7adk568zDKmlUnvcKr4KwGI13lqNQh8EYoO9NYiXPz0B6YpARPfIsvvjfl1eFy0BR4F5qxmjFvatJmK167xhzgGCUV1Ux4ojCxfL6+x1Q+CdUuaIT0Rh3rieFTle4bjc4J963JYZtGADS+dOHojrMdISsg==; 5:r0Z5oiSNpDfX24vopq2hHq8KWYQUes3RLtAUsGT+hE8MnzmqaBTOmUS2rYuHz4I+GUXr1AgX0I18oWqxyCcLTbrppua3Ckltgi5tgyKLSAcQyiCvIwIKZTx7N+MS/Iffbjb27iuW9RMrBEkFii1yYw==; 24:InFj5rW8MY/rSQpoUUylGpH1RyU93Seqm/ka1U4+lYoeSFd4QT8KxiPsjVrUb5RvVpQwSz8nE0zzqivkS7ST9jAf1GnOp4KDHA2nZVb1CYc=; 7:4T/1WLzTUUlt6SqgzjBfiKN0l9wITCoZHPDSApyO3UxLSsVO1WVC0RF9C73VFOdiXE2UgXQyhEkfA/shf38//5EWo5EB4sncxOTUD2MNAH6SUmlHaHr1v1c1rqxZeuEvAhHmND+6Y4rH2WkNWoU/Q0c1mjb2Tz3/eaIsnmawM7QsYxZoJFm01P40Oh2scYpFiicmyursgMmlK4Du0OMLgQ== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2016 00:40:23.6224 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN4PR07MB2241 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160614_174047_389113_809F94A0 X-CRM114-Status: GOOD ( 22.09 ) 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: linux-doc@vger.kernel.org, szabolcs.nagy@arm.com, catalin.marinas@arm.com, heiko.carstens@de.ibm.com, Hanjun Guo , philipp.tomsich@theobroma-systems.com, joseph@codesourcery.com, linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Prasun.Kapoor@caviumnetworks.com, agraf@suse.de, geert@linux-m68k.org, kilobyte@angband.pl, arnd@arndb.de, pinskia@gmail.com, klimov.linux@gmail.com, broonie@kernel.org, linux-arm-kernel@lists.infradead.org, libc-alpha@sourceware.org, Nathan_Lynch@mentor.com, linux-kernel@vger.kernel.org, schwidefsky@de.ibm.com, christoph.muellner@theobroma-systems.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, May 26, 2016 at 09:49:42PM +0800, Zhangjian (Bamvor) wrote: > Hi, yury > > The coredump is usable in our platform. It miss the following definition: > +#define compat_elf_greg_t elf_greg_t > +#define compat_elf_gregset_t elf_gregset_t > > And it leads to the wrong register save in core dump. After apply this patch, > gdb could debug core dump files. > > Here is the full patch: > From 102624840aa5dacdd1bbfe3b390290f52f530ea2 Mon Sep 17 00:00:00 2001 > From: Bamvor Jian Zhang > Date: Thu, 26 May 2016 21:00:16 +0800 > Subject: [PATCH hulk-4.1-next] arm64: ilp32: fix coredump issue > > ILP32 use aarch64 register and 32bit signal struct which means it > could not make use of the existing compat_elf_prstatus/elf_prstatus > and compat_elf_prpsinfo/elf_prpsinfo. > > This patch fix this issue by introducing the different > compat_elf_greg_t, compat_elf_gregset_t for aarch64 ilp32 and aarch32 > el0. > > Tested pass on huawei's hardware in bigendian. > > Signed-off-by: Bamvor Jian Zhang > --- > arch/arm64/include/asm/elf.h | 14 +++++++------- > arch/arm64/kernel/binfmt_elf32.c | 3 +++ > arch/arm64/kernel/binfmt_ilp32.c | 8 +++++++- > arch/arm64/kernel/ptrace.c | 20 ++++++++++---------- > 4 files changed, 27 insertions(+), 18 deletions(-) > > diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h > index 0106d18..9019441 100644 > --- a/arch/arm64/include/asm/elf.h > +++ b/arch/arm64/include/asm/elf.h > @@ -154,18 +154,18 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm, > int uses_interp); > > /* 1GB of VA */ > -#define STACK_RND_MASK (is_compat_task() ? \ > - 0x7ff >> (PAGE_SHIFT - 12) : \ > - 0x3ffff >> (PAGE_SHIFT - 12)) > +#define STACK_RND_MASK (is_compat_task() ? \ > + 0x7ff >> (PAGE_SHIFT - 12) : \ > + 0x3ffff >> (PAGE_SHIFT - 12)) > > #ifdef CONFIG_COMPAT > > -#define COMPAT_ELF_ET_DYN_BASE (2 * TASK_SIZE_32 / 3) > +#define COMPAT_ELF_ET_DYN_BASE (2 * TASK_SIZE_32 / 3) > > /* AArch32 registers. */ > -#define COMPAT_ELF_NGREG 18 > -typedef unsigned int compat_elf_greg_t; > -typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG]; > +#define COMPAT_ELF_NGREG 18 > +typedef unsigned int compat_a32_elf_greg_t; > +typedef compat_a32_elf_greg_t compat_a32_elf_gregset_t[COMPAT_ELF_NGREG]; > > #endif /* CONFIG_COMPAT */ > > diff --git a/arch/arm64/kernel/binfmt_elf32.c b/arch/arm64/kernel/binfmt_elf32.c > index 7b9b445..f75253c 100644 > --- a/arch/arm64/kernel/binfmt_elf32.c > +++ b/arch/arm64/kernel/binfmt_elf32.c > @@ -31,4 +31,7 @@ struct linux_binprm; > extern int aarch32_setup_vectors_page(struct linux_binprm *bprm, > int uses_interp); > > +#define compat_elf_greg_t compat_a32_elf_greg_t > +#define compat_elf_gregset_t compat_a32_elf_gregset_t > + > #include "../../../fs/compat_binfmt_elf.c" > diff --git a/arch/arm64/kernel/binfmt_ilp32.c b/arch/arm64/kernel/binfmt_ilp32.c > index b827a9a..01baf83 100644 > --- a/arch/arm64/kernel/binfmt_ilp32.c > +++ b/arch/arm64/kernel/binfmt_ilp32.c > @@ -2,7 +2,9 @@ > * Support for ILP32 Linux/aarch64 ELF binaries. > */ > > -#include > +#include > +#include > +#include > #include > > #undef ELF_CLASS > @@ -30,9 +32,13 @@ > * 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 compat_elf_greg_t elf_greg_t > +#define compat_elf_gregset_t elf_gregset_t > #define elf_prstatus compat_elf_prstatus > #define elf_prpsinfo compat_elf_prpsinfo > > +#include > + > /* > * Compat version of cputime_to_compat_timeval, perhaps this > * should be an inline in . > diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c > index 5c86135..9784c77 100644 > --- a/arch/arm64/kernel/ptrace.c > +++ b/arch/arm64/kernel/ptrace.c > @@ -913,8 +913,8 @@ static const struct user_regset aarch32_regsets[] = { > [REGSET_COMPAT_GPR] = { > .core_note_type = NT_PRSTATUS, > .n = COMPAT_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 > }, > @@ -947,7 +947,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); > @@ -968,7 +968,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); > @@ -1116,9 +1116,11 @@ static long compat_a32_ptrace(struct task_struct *child, compat_long_t request, > unsigned long addr = caddr; > unsigned long data = cdata; > void __user *datap = compat_ptr(data); > + unsigned int pr_reg_size = sizeof(compat_a32_elf_gregset_t); > int ret; > > switch (request) { > + > case PTRACE_PEEKUSR: > ret = compat_ptrace_read_user(child, addr, datap); > break; > @@ -1130,17 +1132,15 @@ static long compat_a32_ptrace(struct task_struct *child, compat_long_t request, > case COMPAT_PTRACE_GETREGS: > ret = copy_regset_to_user(child, > &user_aarch32_view, > - REGSET_COMPAT_GPR, > - 0, sizeof(compat_elf_gregset_t), > - datap); > + REGSET_COMPAT_GPR, 0, > + pr_reg_size, datap); > break; > > case COMPAT_PTRACE_SETREGS: > ret = copy_regset_from_user(child, > &user_aarch32_view, > - REGSET_COMPAT_GPR, > - 0, sizeof(compat_elf_gregset_t), > - datap); > + REGSET_COMPAT_GPR, 0, > + pr_reg_size, datap); > break; > > case COMPAT_PTRACE_GET_THREAD_AREA: Hi Bamvor, I didn't work much with ilp32 debugging and coredumps yet, but what I see in your patch is an attempt to use elf_gregset_t in compat_elf_prstatus for ilp32 instead of compat_elf_gregset_t. I think we can do it simpler. That's what pahole shows for binfmt_ilp32.o after applying the attached patch: struct compat_elf_prstatus { struct compat_elf_siginfo pr_info; /* 0 12 */ short int pr_cursig; /* 12 2 */ /* XXX 2 bytes hole, try to pack */ compat_ulong_t pr_sigpend; /* 16 4 */ compat_ulong_t pr_sighold; /* 20 4 */ compat_pid_t pr_pid; /* 24 4 */ compat_pid_t pr_ppid; /* 28 4 */ compat_pid_t pr_pgrp; /* 32 4 */ compat_pid_t pr_sid; /* 36 4 */ struct compat_timeval pr_utime; /* 40 8 */ struct compat_timeval pr_stime; /* 48 8 */ struct compat_timeval pr_cutime; /* 56 8 */ /* --- cacheline 1 boundary (64 bytes) --- */ struct compat_timeval pr_cstime; /* 64 8 */ elf_gregset_t pr_reg; /* 72 272 */ /* --- cacheline 5 boundary (320 bytes) was 24 bytes ago --- */ compat_int_t pr_fpvalid; /* 344 4 */ /* size: 352, cachelines: 6, members: 14 */ /* sum members: 346, holes: 1, sum holes: 2 */ /* padding: 4 */ /* last cacheline: 32 bytes */ }; Did I miss something? --- arch/arm64/include/asm/elf.h | 6 ++++++ arch/arm64/kernel/binfmt_ilp32.c | 1 + 2 files changed, 7 insertions(+) diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index a967726..4dcbcec 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -174,10 +174,16 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm, #define COMPAT_ELF_ET_DYN_BASE (2 * TASK_SIZE_32 / 3) +#ifndef USE_AARCH64_GREG /* AArch32 registers. */ #define COMPAT_ELF_NGREG 18 typedef unsigned int compat_elf_greg_t; typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG]; +#else /* AArch64 registers for AARCH64/ILP32 */ +#define COMPAT_ELF_NGREG ELF_NGREG +#define compat_elf_greg_t elf_greg_t +#define compat_elf_gregset_t elf_gregset_t +#endif /* AArch32 EABI. */ #define EF_ARM_EABI_MASK 0xff000000 diff --git a/arch/arm64/kernel/binfmt_ilp32.c b/arch/arm64/kernel/binfmt_ilp32.c index b2bd590..416b3f5 100644 --- a/arch/arm64/kernel/binfmt_ilp32.c +++ b/arch/arm64/kernel/binfmt_ilp32.c @@ -1,6 +1,7 @@ /* * Support for ILP32 Linux/aarch64 ELF binaries. */ +#define USE_AARCH64_GREG #include #include