From patchwork Thu Apr 28 03:33:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Ungerer X-Patchwork-Id: 12829944 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3252C433F5 for ; Thu, 28 Apr 2022 03:35:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 09D366B0073; Wed, 27 Apr 2022 23:35:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 04D296B0075; Wed, 27 Apr 2022 23:35:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E092A6B0078; Wed, 27 Apr 2022 23:35:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id D145A6B0073 for ; Wed, 27 Apr 2022 23:35:01 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id A12241216CA for ; Thu, 28 Apr 2022 03:35:01 +0000 (UTC) X-FDA: 79404871602.25.D644DFE Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id C70D61C0059 for ; Thu, 28 Apr 2022 03:34:57 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8C77061A94; Thu, 28 Apr 2022 03:35:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98E55C385A9; Thu, 28 Apr 2022 03:34:58 +0000 (UTC) From: Greg Ungerer To: linux-m68k@vger.kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, dalias@libc.org, Greg Ungerer Subject: [PATCH 2/4] m68knommu: implement minimal regset support Date: Thu, 28 Apr 2022 13:33:17 +1000 Message-Id: <20220428033319.239341-3-gerg@linux-m68k.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220428033319.239341-1-gerg@linux-m68k.org> References: <20220428033319.239341-1-gerg@linux-m68k.org> MIME-Version: 1.0 X-Stat-Signature: dku3jrmk5kq7kstxt4fdorzyafznkwnm Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of "SRS0=aK2k=VG=linux-m68k.org=gerg@kernel.org" designates 139.178.84.217 as permitted sender) smtp.mailfrom="SRS0=aK2k=VG=linux-m68k.org=gerg@kernel.org"; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: C70D61C0059 X-HE-Tag: 1651116897-372348 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Add code support to the m68k architecture for regsets. Currently the only thing that will need to use regsets for m68k will be coredump support of the elf_fdpic loader. So the changes are conditional on that. The added support is the minimum definitions required to support just that. Signed-off-by: Greg Ungerer --- arch/m68k/kernel/ptrace.c | 58 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/arch/m68k/kernel/ptrace.c b/arch/m68k/kernel/ptrace.c index 6342ff4d2073..4349b9c4dd68 100644 --- a/arch/m68k/kernel/ptrace.c +++ b/arch/m68k/kernel/ptrace.c @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include #include @@ -291,3 +293,59 @@ asmlinkage void syscall_trace_leave(void) ptrace_report_syscall_exit(task_pt_regs(current), 0); } #endif /* CONFIG_COLDFIRE */ + +#if defined(CONFIG_BINFMT_ELF_FDPIC) && defined(CONFIG_ELF_CORE) +/* + * Currently the only thing that needs to use regsets for m68k is the + * coredump support of the elf_fdpic loader. Implement the minimum + * definitions required for that. + */ +static int m68k_regset_get(struct task_struct *target, + const struct user_regset *regset, + struct membuf to) +{ + struct pt_regs *ptregs = task_pt_regs(target); + u32 uregs[ELF_NGREG]; + + ELF_CORE_COPY_REGS(uregs, ptregs); + return membuf_write(&to, uregs, sizeof(uregs)); +} + +enum m68k_regset { + REGSET_GPR, +#ifdef CONFIG_FPU + REGSET_FPU, +#endif +}; + +static const struct user_regset m68k_user_regsets[] = { + [REGSET_GPR] = { + .core_note_type = NT_PRSTATUS, + .n = ELF_NGREG, + .size = sizeof(u32), + .align = sizeof(u16), + .regset_get = m68k_regset_get, + }, +#ifdef CONFIG_FPU + [REGSET_FPU] = { + .core_note_type = NT_PRFPREG, + .n = sizeof(struct user_m68kfp_struct) / sizeof(u32), + .size = sizeof(u32), + .align = sizeof(u32), + } +#endif /* CONFIG_FPU */ +}; + +static const struct user_regset_view user_m68k_view = { + .name = "m68k", + .e_machine = EM_68K, + .ei_osabi = ELF_OSABI, + .regsets = m68k_user_regsets, + .n = ARRAY_SIZE(m68k_user_regsets) +}; + +const struct user_regset_view *task_user_regset_view(struct task_struct *task) +{ + return &user_m68k_view; +} +#endif /* CONFIG_BINFMT_ELF_FDPIC && CONFIG_ELF_CORE */