From nobody Fri May 15 08:28:59 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3408DC433EF for ; Thu, 28 Apr 2022 03:35:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242250AbiD1DiN (ORCPT ); Wed, 27 Apr 2022 23:38:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229499AbiD1DiJ (ORCPT ); Wed, 27 Apr 2022 23:38:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6DF97DAA7; Wed, 27 Apr 2022 20:34:56 -0700 (PDT) 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 5B7DA618FB; 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =20 #endif --=20 2.25.1 From nobody Fri May 15 08:28:59 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A89F7C433F5 for ; Thu, 28 Apr 2022 03:35:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242353AbiD1Di0 (ORCPT ); Wed, 27 Apr 2022 23:38:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242309AbiD1DiQ (ORCPT ); Wed, 27 Apr 2022 23:38:16 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0F032AE24; Wed, 27 Apr 2022 20:35:02 -0700 (PDT) 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 17C8BB82AEB; Thu, 28 Apr 2022 03:35:01 +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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =20 #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 =3D 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[] =3D { + [REGSET_GPR] =3D { + .core_note_type =3D NT_PRSTATUS, + .n =3D ELF_NGREG, + .size =3D sizeof(u32), + .align =3D sizeof(u16), + .regset_get =3D m68k_regset_get, + }, +#ifdef CONFIG_FPU + [REGSET_FPU] =3D { + .core_note_type =3D NT_PRFPREG, + .n =3D sizeof(struct user_m68kfp_struct) / sizeof(u32), + .size =3D sizeof(u32), + .align =3D sizeof(u32), + } +#endif /* CONFIG_FPU */ +}; + +static const struct user_regset_view user_m68k_view =3D { + .name =3D "m68k", + .e_machine =3D EM_68K, + .ei_osabi =3D ELF_OSABI, + .regsets =3D m68k_user_regsets, + .n =3D ARRAY_SIZE(m68k_user_regsets) +}; + +const struct user_regset_view *task_user_regset_view(struct task_struct *t= ask) +{ + return &user_m68k_view; +} +#endif /* CONFIG_BINFMT_ELF_FDPIC && CONFIG_ELF_CORE */ --=20 2.25.1 From nobody Fri May 15 08:28:59 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 178BDC433F5 for ; Thu, 28 Apr 2022 03:35:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242327AbiD1Die (ORCPT ); Wed, 27 Apr 2022 23:38:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241736AbiD1DiR (ORCPT ); Wed, 27 Apr 2022 23:38:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 980DA267; Wed, 27 Apr 2022 20:35:03 -0700 (PDT) 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 22C6361A94; Thu, 28 Apr 2022 03:35:03 +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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D 0 =20 +#define ELF_FDPIC_PLAT_INIT(_r, _exec_map_addr, _interp_map_addr, dynamic_= addr) \ + do { \ + (_r)->d3 =3D _exec_map_addr; \ + (_r)->d4 =3D _interp_map_addr; \ + (_r)->d5 =3D 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; =20 #define ELF_PLATFORM (NULL) =20 +#define ELF_FDPIC_CORE_EFLAGS 0 + #endif diff --git a/arch/m68k/include/uapi/asm/ptrace.h b/arch/m68k/include/uapi/a= sm/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 { =20 #define PTRACE_GET_THREAD_AREA 25 =20 +#define PTRACE_GETFDPIC 31 + #define PTRACE_SINGLEBLOCK 33 /* resume execution until next branch */ =20 +#define PTRACE_GETFDPIC_EXEC 0 +#define PTRACE_GETFDPIC_INTERP 1 + #endif /* __ASSEMBLY__ */ #endif /* _UAPI_M68K_PTRACE_H */ --=20 2.25.1 From nobody Fri May 15 08:28:59 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90C9AC433EF for ; Thu, 28 Apr 2022 03:35:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241736AbiD1Dij (ORCPT ); Wed, 27 Apr 2022 23:38:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242342AbiD1DiW (ORCPT ); Wed, 27 Apr 2022 23:38:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B24C11167; Wed, 27 Apr 2022 20:35:07 -0700 (PDT) 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 915A9B82AEB; Thu, 28 Apr 2022 03:35:06 +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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --=20 2.25.1