From patchwork Sat May 24 07:02:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 30882 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CE6742066E for ; Sat, 24 May 2014 07:09:54 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id kq14sf23388216pab.2 for ; Sat, 24 May 2014 00:09:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:to:to:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=xw3BdthRswJblSmzhRB1DZ1BJVAs0bSZSh4Ep1+xWgA=; b=gp2YPU9lcsvgcK/YX7PwbD+L1kqQirR1NR80SufOP95D9G7rTKxTgnBEkyRQ3QHv4n 3QM9IUfzc+uUSrcSvLs3ljhL+gC2glKi267bYVoKgJbCvruInCOUozEO3h74D861/uqf W/vX4xd+CJPjoqMOyPQWTpA2FLVkO52T3rTSu9WE+/HnRZaOfA7vh2HuqmjDohq3LwiT mFDn5LTqHhpWfuZDu7sV0yajv8ZygK7oZOXPXXOzf0op0QsknQiKPvbJr4Ea+TQym3Kp avwLrFlgANQaRxZB01ZhA/786E/f1feAzgZwsaYtuVXqwdPwQeelgk6P0AkjnuAJyaJP UEZA== X-Gm-Message-State: ALoCoQn2D8Ie4lrfcVRhd21Bz/+goYikPhF0WIUW/D/Q73zjxEgjayg/IlXNlg+VJbkKrek0e7vi X-Received: by 10.66.217.170 with SMTP id oz10mr4785340pac.9.1400915394119; Sat, 24 May 2014 00:09:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.82.37 with SMTP id g34ls1997937qgd.64.gmail; Sat, 24 May 2014 00:09:54 -0700 (PDT) X-Received: by 10.58.46.231 with SMTP id y7mr8529203vem.5.1400915394003; Sat, 24 May 2014 00:09:54 -0700 (PDT) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id rs1si3078915vec.31.2014.05.24.00.09.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 24 May 2014 00:09:53 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.177 as permitted sender) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id db11so7226059veb.22 for ; Sat, 24 May 2014 00:09:53 -0700 (PDT) X-Received: by 10.58.23.6 with SMTP id i6mr8668530vef.12.1400915393916; Sat, 24 May 2014 00:09:53 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp87721vcb; Sat, 24 May 2014 00:09:53 -0700 (PDT) X-Received: by 10.68.134.101 with SMTP id pj5mr12170979pbb.62.1400915393081; Sat, 24 May 2014 00:09:53 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sl2si6783819pbc.221.2014.05.24.00.09.52 for ; Sat, 24 May 2014 00:09:52 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751543AbaEXHJc (ORCPT + 27 others); Sat, 24 May 2014 03:09:32 -0400 Received: from mail-ie0-f181.google.com ([209.85.223.181]:63856 "EHLO mail-ie0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751478AbaEXHJ3 (ORCPT ); Sat, 24 May 2014 03:09:29 -0400 Received: by mail-ie0-f181.google.com with SMTP id rp18so4414100iec.12 for ; Sat, 24 May 2014 00:09:28 -0700 (PDT) X-Received: by 10.50.61.226 with SMTP id t2mr7143044igr.44.1400915368649; Sat, 24 May 2014 00:09:28 -0700 (PDT) Received: from localhost.localdomain (64.2.3.195.ptr.us.xo.net. [64.2.3.195]) by mx.google.com with ESMTPSA id qh3sm10016919igb.17.2014.05.24.00.09.27 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 24 May 2014 00:09:28 -0700 (PDT) Received: from localhost.localdomain (apinskidesktop [127.0.0.1]) by localhost.localdomain (8.14.3/8.14.3/Debian-9.4) with ESMTP id s4O72M4Y009812 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=NO); Sat, 24 May 2014 00:02:22 -0700 Received: (from apinski@localhost) by localhost.localdomain (8.14.3/8.14.3/Submit) id s4O72M9c009811; Sat, 24 May 2014 00:02:22 -0700 From: Andrew Pinski To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Andrew Pinski Subject: [PATCH 17/24] ARM64:ILP32: Support core dump for ILP32. Date: Sat, 24 May 2014 00:02:12 -0700 Message-Id: <1400914939-9708-18-git-send-email-apinski@cavium.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1400914939-9708-1-git-send-email-apinski@cavium.com> References: <1400914939-9708-1-git-send-email-apinski@cavium.com> To: linux-arm-kernel@lists.infradead.org To: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: apinski@cavium.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch supports core dumping on ILP32. We need a few extra macros (PR_REG_SIZE and PRSTATUS_SIZE) due to size differences of the register sets. Thanks, Andrew Pinski Signed-off-by: Andrew Pinski --- arch/arm64/include/asm/elf.h | 22 ++++++++++++++++++++-- arch/arm64/kernel/ptrace.c | 12 ++++++------ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index 8180511..4106386 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -176,8 +176,8 @@ extern unsigned long arch_randomize_brk(struct mm_struct *mm); /* 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 @@ -204,6 +204,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 7fb1377..7890f95 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -771,8 +771,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 }, @@ -805,7 +805,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); @@ -825,7 +825,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; ret = copy_regset_from_user(tsk, &user_aarch32_view, @@ -985,7 +985,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; @@ -993,7 +993,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;