From patchwork Tue Sep 29 22:14:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 7291051 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A3785BEEA4 for ; Tue, 29 Sep 2015 22:31:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A7E87204A7 for ; Tue, 29 Sep 2015 22:31:05 +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 AB9D52042C for ; Tue, 29 Sep 2015 22:31:04 +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 1Zh3Oy-0006V1-7L; Tue, 29 Sep 2015 22:29:36 +0000 Received: from mail-bl2on0065.outbound.protection.outlook.com ([65.55.169.65] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zh3Dr-0003hb-C6 for linux-arm-kernel@lists.infradead.org; Tue, 29 Sep 2015 22:18:08 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (91.78.158.8) by DM2PR07MB624.namprd07.prod.outlook.com (10.141.177.154) with Microsoft SMTP Server (TLS) id 15.1.280.20; Tue, 29 Sep 2015 22:17:45 +0000 From: Yury Norov To: , , , , , Subject: [PATCH v5 15/23] arm64:ilp32: support core dump generation for ILP32 Date: Wed, 30 Sep 2015 01:14:12 +0300 Message-ID: <1443564860-31208-16-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1443564860-31208-1-git-send-email-ynorov@caviumnetworks.com> References: <1443564860-31208-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [91.78.158.8] X-ClientProxiedBy: DB5PR02CA0014.eurprd02.prod.outlook.com (25.161.237.24) To DM2PR07MB624.namprd07.prod.outlook.com (10.141.177.154) X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB624; 2:AOlN7tSam1JQrU+OEHuGiRlHjGN7ym2kTCfRAF/FCRrKU40YnxaP15/AvW2lGE4c3/GyUMo1UFDjIwtJPFA9wtDuimhGMV1rs3rr5TokjeJDgOBLZBLoy3847TFanbA72Em9ddE1VqpfPgTj5tSSLN82npBbftXOx50Qxv3kNK0=; 3:cVpMbzvbNeYhELvoCHb67U/Mw0J33rXD76Pe5i17KQEm6lOG0ijnG8FQJp2oP0IVG0/9nNkyklBkZ+97JxbtZ+6gR4xXHCjKCDfS6Blu+Zb8S3oYzKmIhC8WAb47eg+BjBUOs77W/KsmcX8NujuLew==; 25:V2kNwMP2OF5g6Kcpb6vbbLcAQTmdCsI03DGmo+wLMSuwBu7GiRc00v+ZC4czRQuxcwts0+YLCgUF5ylq7Dc79NDipoTw8/gsr5tXc6MFA9NEqDLUqDkKQkF8d69Y4xqkqayj1epaaqs1TPw+oB0MAjlPu6NPzkg+q1OrItoRtodT3yIbuRE3E+ahHr3J+bGhe2iC8ifFHNoqNuuMvzlFE3W0Jbrbl3EPrWlAuRf8ApezcGTCympsFTQjLZ4pBxuph955Yr6YOKUBArgMaz4msQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR07MB624; X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB624; 20:UH2Z5QvnOpBX+11Rxjl9KkLJaGTUcpM3y4Lr/UWrcb6g3sINwnc8FEQ4EEZ4MBxvjqoynhz0YIWomcGVLIclQJX6u7SoMP3blW/AMzdBrXomSkrI1cgp+tsrH7iP2HYeqwKhAjnzFr5YQvC8TKWAhs0xvxf43NQdn+LAV0h+8+/+FlFJ9OeE+TjJPwT+SEqsOzh4dYZSngpqAUuPBYz21Y+Cj3qRdj+Vowrp6opLBSoP0uBxlTGNy3FJgG4fbpEBcHgLccAdMVM0QBhh0OtqWs3uzfnFdvR3Nhu9UTUVx1//dvdWb9wrp0jgeGX96Ca3/E3OZ6jW8JqH5zdTrVMsRCeKDmmbMrFt3QPWej0im9TYTrdYAAhPgryHqhGnyXXC/FTZFQ2Dnz4bvJKDHeyZZ3MmjZU+VgjhcocVsx9MvROEeXhcd3jmRKT431qjb2HWLF9Ty4YHufHaEuC+Z1XuHVgtW8rysUUYsmXrhLSLg3hamDYAi6MJlMdtQXje4jPGlnzi/Aotq1LX0pcipaRqGc5UQ0YTyqkWATHwoe02+omzd80C0Zf4SVJzBXi/mT1Q4nblDTttKx3OmjNjIC0HQTYcRWl0p7E44j+SlKG8Ass= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(3002001); SRVR:DM2PR07MB624; BCL:0; PCL:0; RULEID:; SRVR:DM2PR07MB624; X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB624; 4:AjP3TuFDSJKa8TcgMhsuQRAP8AvXRhsiYWUEbvij3IhMDbrudaahz769gdOYOvmmksD70p6ibCkUfV554oqQvWwnrNnv25neHPejVd30GvPH2Ugg6lECi0jjVqRmVRVHMnWjCY4L1bNVWJzATFxDZ4GNYuYvf/CR2lMgqaGXfV4KFZd7FfXEztr8QBIKpuYAFkpYDVobbsMOjsPc4gYwxVYL25J9S3ARdlFIwX8bMhiIa+cL9sDY6vDuxc6l8wrrRvhAaCe1TA8js0kq2xVUUojmGsSe+p9pJqpXw6eXWVWQ6kso+18uOkJCtKCklN/XIzvWnMyl9jF59+FX1senZT1GIikbZ40Np+JcRaMGFFg= X-Forefront-PRVS: 0714841678 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(6009001)(199003)(189002)(42186005)(19580405001)(189998001)(50226001)(107886002)(87976001)(92566002)(46102003)(5004730100002)(5001960100002)(5007970100001)(97736004)(122386002)(19580395003)(101416001)(2201001)(50986999)(5001860100001)(47776003)(50466002)(76176999)(4001540100001)(48376002)(68736005)(81156007)(40100003)(5001830100001)(76506005)(5001770100001)(229853001)(36756003)(77156002)(2950100001)(77096005)(66066001)(64706001)(33646002)(105586002)(106356001)(5003940100001)(5008740100001)(62966003)(2101003)(4001430100001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR07MB624; 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; DM2PR07MB624; 23:/IrUkc3Gyblo/hXxUni3yrQ86RaVEqPRxjSXH6zkWs?= =?us-ascii?Q?9w044Havx06eVq0OHWoDL6X3xsljoi9t4bgSe/CbFRwANernCU04eHgQRDev?= =?us-ascii?Q?Nf2O/NXUcY7T75A7LCrkjhxYfWHzo/0pflOCr5e+p5BepzXxSN7sGin2PoJM?= =?us-ascii?Q?7qEc8QcOsC1KSG2KWhZEbwtChFvrs42r4/O5CdlIp01MHV93vijTku/zG8GA?= =?us-ascii?Q?wZ5+STjda+W2v5ShnfPFfsvaBEeF7pVf1DotnsLDW581wwLT1yIoMfZfnO16?= =?us-ascii?Q?JMulKZkll8Xa1vsRG8L1rw1PTDTAJfoAqRZO2fc+yjDJu2gkl6RnT84vnaKf?= =?us-ascii?Q?xg35aGFs0GX4A8b8CABA3UeJPv0o4GQ8JeivX+1r2T2a5S00W+VP80g+tTTT?= =?us-ascii?Q?8BFTa88S0iF1cjK5xL+TfFxXQ7pjP9N/IQHwfkYYfV+iKEZrbh8MfBzL8p0P?= =?us-ascii?Q?ujcYOAsTiKG0B4Hh9irZ7v9RuucY18tYu4V0gMKxcPwwcQYRaVONXlZtMV9H?= =?us-ascii?Q?JnobugYBbbrNfOUOegKe3npw8F7fiiqLjNrvUuevajPuRt9x9F8+CNOt65Ob?= =?us-ascii?Q?bHogygf1ReWviybWLAg5KI3jqYcUDY/T+5ur2f7FpF0/we356U3pNFOc/x3T?= =?us-ascii?Q?o/M9T3BEmu9iKyyKrGHHR3np6RE4pwySwmhYcKe6LmynqqxsW8YqzxTDgpLS?= =?us-ascii?Q?mPENHMqv5HoMu8XJy1YbOTgRiLsGzMbBpDR4mRkTBzpVP47Dk7Sc5kjzldNb?= =?us-ascii?Q?7x3yuFVubsgoMNLi2dt2+ECpEPMVae7UAbasaWQiD8yhtuBKnK2w3xQconpi?= =?us-ascii?Q?zJaVKnSg76uLO4177Bt9nglk0Yu+iw6DZumLyGpq9VYTXRppc2fXbG3WOV5R?= =?us-ascii?Q?7zVHnGqILVbO+Fp6KCDD714u6cgrS2cIqSInzls0aigBIfWR3+Dt8caJpfNq?= =?us-ascii?Q?PaDc4RLgxCmp+3zfUGm8MX/eGla5mIvRkQxdItiomxk+YCi3xic+oWz5vYdI?= =?us-ascii?Q?/WvipDsQSzu5l178lPcvkXZlD0VIX4u+0b6YpjecJvdTxYB6BrOj9GzIXkVl?= =?us-ascii?Q?O25DuRZtU2FkqTK00Ga2t45oWsRuoLRj29vRE0G2rs/TtLsiL9YGGKfXKB4Z?= =?us-ascii?Q?IchRpURgs4xaJEV8KElIiwvtYVcm4kBlsxppuXmIwhtZoiYCv2bFgbSoqPXi?= =?us-ascii?Q?p3IAuze2ZpmNJVGLByY6lP6YpGde9u78pdaODmsoe1SSlvaGl6k1RYxIj0mv?= =?us-ascii?Q?hwM6bZZG4K2N90Iom5C6hxW0BQMcpRdQsugOuiHJoLms+DuD0fSn05PW8CYr?= =?us-ascii?Q?+g9XCvbYfJgrVnGDTQdeo=3D?= X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB624; 5:FaJ1DmoyNIkiBceKIAnKyggGvK4g/M6znj3i2UncLpr1FBD+5aq60xK8eS4Z9znfcIIM/UnK/sTdWFh79GlSD9K7CaVT4X6qm1Oo+gnZ+uLfHe510F2K/d8Di4ZfgnAmTxUPaTBccU2ICS/BRx/SRg==; 24:jf8tKJgsunqxTzH4nQ0MUsR0BcDZbjKbthj7bWu1gZw4CgZq1wfxn14nKeOGFc3QFk99+Yk3IjZV6yQ9zAWmv01tCo5FMU1rvAaarViN2+g=; 20:+GHTnTx73e7bmHWPDydCmnC6RlxjTthag574jhogw44EdepssIqKRof+9Is145E8FUPWi9BZlizbejRVfqYYhg== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2015 22:17:45.5918 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR07MB624 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150929_151807_690099_7872ED40 X-CRM114-Status: UNSURE ( 8.87 ) X-CRM114-Notice: Please train this message. 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, klimov.linux@gmail.com, Yury Norov , apinski@cavium.com, philipp.tomsich@theobroma-systems.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-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 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 diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index 9ecbaf2..d4d53c91a 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -171,8 +171,8 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm, /* 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 @@ -199,6 +199,24 @@ typedef elf_gregset_t compat_elf_gregset_t; #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 + #define compat_elf_check_arch(x) compat_a32_elf_check_arch(x) #endif /* CONFIG_COMPAT */ diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 8cd1eb7..1f5c38c 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;