From patchwork Thu Apr 28 03:33:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Ungerer X-Patchwork-Id: 12829943 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 20717C433F5 for ; Thu, 28 Apr 2022 03:35:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EC916B0072; Wed, 27 Apr 2022 23:34:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 99B816B0073; Wed, 27 Apr 2022 23:34:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 88B7D6B0075; Wed, 27 Apr 2022 23:34:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id 7A3DA6B0072 for ; Wed, 27 Apr 2022 23:34:59 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3D22461B5A for ; Thu, 28 Apr 2022 03:34:59 +0000 (UTC) X-FDA: 79404871518.17.76EEFA1 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf09.hostedemail.com (Postfix) with ESMTP id 3256E14004F for ; Thu, 28 Apr 2022 03:34:54 +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 ams.source.kernel.org (Postfix) with ESMTPS id C1350B828A1; Thu, 28 Apr 2022 03:34:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60DC8C385AD; Thu, 28 Apr 2022 03:34:54 +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 1/4] m68knommu: use asm-generic/mmu.h for nommu setups Date: Thu, 28 Apr 2022 13:33:16 +1000 Message-Id: <20220428033319.239341-2-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: uz9ykztb5dttk5prccc8rn3be13bz8ir X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 3256E14004F Authentication-Results: imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of "SRS0=aK2k=VG=linux-m68k.org=gerg@kernel.org" designates 145.40.68.75 as permitted sender) smtp.mailfrom="SRS0=aK2k=VG=linux-m68k.org=gerg@kernel.org"; dmarc=none X-Rspam-User: X-HE-Tag: 1651116894-147463 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: The nommu case defines its own local mm_context_t structure. There is nothing special or different about the m68knommu version of this and it can easily use the common asm-generic version. Remove the local mmu_context struct and include the asm-generic version instead. This will also make it easier to support ELF format executables in the future (since the asm-generic version has support for this already). Signed-off-by: Greg Ungerer Reviewed-by: Geert Uytterhoeven --- arch/m68k/include/asm/mmu.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/m68k/include/asm/mmu.h b/arch/m68k/include/asm/mmu.h index 5c15aacb1370..e00672425b00 100644 --- a/arch/m68k/include/asm/mmu.h +++ b/arch/m68k/include/asm/mmu.h @@ -6,9 +6,7 @@ /* Default "unsigned long" context */ typedef unsigned long mm_context_t; #else -typedef struct { - unsigned long end_brk; -} mm_context_t; +#include #endif #endif 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 */ From patchwork Thu Apr 28 03:33:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Ungerer X-Patchwork-Id: 12829946 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 9109DC433FE for ; Thu, 28 Apr 2022 03:35:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 30FDD6B0078; Wed, 27 Apr 2022 23:35:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 248BD6B007B; Wed, 27 Apr 2022 23:35:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 111DA6B007D; Wed, 27 Apr 2022 23:35:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 022FA6B0078 for ; Wed, 27 Apr 2022 23:35:09 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id DC307294F3 for ; Thu, 28 Apr 2022 03:35:08 +0000 (UTC) X-FDA: 79404871896.22.25E364A Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf13.hostedemail.com (Postfix) with ESMTP id C6E3420057 for ; Thu, 28 Apr 2022 03:35:00 +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 sin.source.kernel.org (Postfix) with ESMTPS id 07808CE290E; Thu, 28 Apr 2022 03:35:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14D2BC385AE; Thu, 28 Apr 2022 03:35:00 +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 3/4] m68knommu: add definitions to support elf_fdpic program loader Date: Thu, 28 Apr 2022 13:33:18 +1000 Message-Id: <20220428033319.239341-4-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: h4whm7jrcyopxrtjdwk1nqorop1zsxgp Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of "SRS0=aK2k=VG=linux-m68k.org=gerg@kernel.org" designates 145.40.73.55 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: C6E3420057 X-HE-Tag: 1651116900-177148 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 a few required defines to support using the binfmt_elf_fdpic loader on the m68k architecture. The values are defined to be consistent with those used on arm and sh which support this too. The most important m68k specific change is the register initialization. The pt_reg structure only contains a subset of the architecture general registers, so we are more limited than to be expected on what can be used. Signed-off-by: Greg Ungerer --- arch/m68k/include/asm/elf.h | 9 +++++++++ arch/m68k/include/uapi/asm/ptrace.h | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/arch/m68k/include/asm/elf.h b/arch/m68k/include/asm/elf.h index 3d387ceaea3f..2def06a99b08 100644 --- a/arch/m68k/include/asm/elf.h +++ b/arch/m68k/include/asm/elf.h @@ -60,6 +60,13 @@ typedef struct user_m68kfp_struct elf_fpregset_t; is actually used on ASV. */ #define ELF_PLAT_INIT(_r, load_addr) _r->a1 = 0 +#define ELF_FDPIC_PLAT_INIT(_r, _exec_map_addr, _interp_map_addr, dynamic_addr) \ + do { \ + (_r)->d3 = _exec_map_addr; \ + (_r)->d4 = _interp_map_addr; \ + (_r)->d5 = dynamic_addr; \ + } while(0) + #if defined(CONFIG_SUN3) || defined(CONFIG_COLDFIRE) #define ELF_EXEC_PAGESIZE 8192 #else @@ -114,4 +121,6 @@ typedef struct user_m68kfp_struct elf_fpregset_t; #define ELF_PLATFORM (NULL) +#define ELF_FDPIC_CORE_EFLAGS 0 + #endif diff --git a/arch/m68k/include/uapi/asm/ptrace.h b/arch/m68k/include/uapi/asm/ptrace.h index 19a1b9d0d858..5b50ea592e00 100644 --- a/arch/m68k/include/uapi/asm/ptrace.h +++ b/arch/m68k/include/uapi/asm/ptrace.h @@ -74,7 +74,12 @@ struct switch_stack { #define PTRACE_GET_THREAD_AREA 25 +#define PTRACE_GETFDPIC 31 + #define PTRACE_SINGLEBLOCK 33 /* resume execution until next branch */ +#define PTRACE_GETFDPIC_EXEC 0 +#define PTRACE_GETFDPIC_INTERP 1 + #endif /* __ASSEMBLY__ */ #endif /* _UAPI_M68K_PTRACE_H */ From patchwork Thu Apr 28 03:33:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Ungerer X-Patchwork-Id: 12829945 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 91FB8C433EF for ; Thu, 28 Apr 2022 03:35:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 272876B0075; Wed, 27 Apr 2022 23:35:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 221206B0078; Wed, 27 Apr 2022 23:35:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E9A96B007B; Wed, 27 Apr 2022 23:35:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id F3EBC6B0075 for ; Wed, 27 Apr 2022 23:35:07 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D898D218E4 for ; Thu, 28 Apr 2022 03:35:07 +0000 (UTC) X-FDA: 79404871854.08.293165E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id EE64FA0057 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 95953618FB; Thu, 28 Apr 2022 03:35:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CE6CC385A9; Thu, 28 Apr 2022 03:35:04 +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 4/4] m68knommu: allow elf_fdpic loader to be selected Date: Thu, 28 Apr 2022 13:33:19 +1000 Message-Id: <20220428033319.239341-5-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-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: EE64FA0057 X-Stat-Signature: 5yt8hjys57uypkn6975zfiwycjq4e399 X-Rspam-User: Authentication-Results: imf25.hostedemail.com; dkim=none; spf=pass (imf25.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-HE-Tag: 1651116897-33432 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: The m68k architecture code is capable of supporting the binfmt_elf_fdpic loader, so allow it to be configured. It is restricted to nommu configurations at this time due to the MMU context structures/code not supporting everything elf_fdpic needs when MMU is enabled. Signed-off-by: Greg Ungerer Reviewed-by: Geert Uytterhoeven --- fs/Kconfig.binfmt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt index 21c6332fa785..2666398120c4 100644 --- a/fs/Kconfig.binfmt +++ b/fs/Kconfig.binfmt @@ -58,7 +58,7 @@ config ARCH_USE_GNU_PROPERTY config BINFMT_ELF_FDPIC bool "Kernel support for FDPIC ELF binaries" default y if !BINFMT_ELF - depends on (ARM || (SUPERH && !MMU)) + depends on (ARM || ((M68K || SUPERH) && !MMU)) select ELFCORE help ELF FDPIC binaries are based on ELF, but allow the individual load