Thread (6 messages) 6 messages, 3 authors, 2021-10-14

Re: [PATCH v3 1/2] MIPS: convert syscall to generic entry

From: WANG Xuerui <hidden>
Date: 2021-10-14 08:46:45
Also in: linux-mips

Hi Feiyang,

On 2021/10/14 16:32, Feiyang Chen wrote:
quoted hunk ↗ jump to hunk
Convert MIPS syscall to use the generic entry infrastructure from
kernel/entry/*.

There are a few special things on MIPS:

- There is one type of syscall on MIPS32 (scall32-o32) and three types
of syscalls on MIPS64 (scall64-o32, scall64-n32 and scall64-n64). Now
convert to C code to handle different types of syscalls.

- For some special syscalls (e.g. fork, clone, clone3 and sysmips),
save_static_function() wrapper is used to save static registers. Now
SAVE_STATIC is used in handle_sys before calling do_syscall(), so the
save_static_function() wrapper can be removed.

- For sigreturn/rt_sigreturn and sysmips, inline assembly is used to
jump to syscall_exit directly for skipping setting the error flag and
restoring all registers. Now use regs->regs[27] to mark whether to
handle the error flag and restore all registers in handle_sys, so these
functions can return normally as other architecture.

Signed-off-by: Feiyang Chen <redacted>
Signed-off-by: Yanteng Si <redacted>
Reviewed-by: Huacai Chen <chenhuacai@kernel.org>
---
 arch/mips/Kconfig                         |   1 +
 arch/mips/include/asm/entry-common.h      |  13 ++
 arch/mips/include/asm/ptrace.h            |   8 +-
 arch/mips/include/asm/sim.h               |  70 -------
 arch/mips/include/asm/syscall.h           |   5 +
 arch/mips/include/asm/thread_info.h       |  17 +-
 arch/mips/include/uapi/asm/ptrace.h       |   7 +-
 arch/mips/kernel/Makefile                 |  14 +-
 arch/mips/kernel/entry.S                  |  75 ++------
 arch/mips/kernel/linux32.c                |   1 -
 arch/mips/kernel/ptrace.c                 |  78 --------
 arch/mips/kernel/scall.S                  | 137 +++++++++++++
 arch/mips/kernel/scall32-o32.S            | 223 ----------------------
 arch/mips/kernel/scall64-n32.S            | 107 -----------
 arch/mips/kernel/scall64-n64.S            | 116 -----------
 arch/mips/kernel/scall64-o32.S            | 221 ---------------------
 arch/mips/kernel/signal.c                 |  37 ++--
 arch/mips/kernel/signal_n32.c             |  16 +-
 arch/mips/kernel/signal_o32.c             |  31 +--
 arch/mips/kernel/syscall.c                | 148 +++++++++++---
 arch/mips/kernel/syscalls/syscall_n32.tbl |   8 +-
 arch/mips/kernel/syscalls/syscall_n64.tbl |   8 +-
 arch/mips/kernel/syscalls/syscall_o32.tbl |   8 +-
 23 files changed, 354 insertions(+), 995 deletions(-)
 create mode 100644 arch/mips/include/asm/entry-common.h
 delete mode 100644 arch/mips/include/asm/sim.h
 create mode 100644 arch/mips/kernel/scall.S
 delete mode 100644 arch/mips/kernel/scall32-o32.S
 delete mode 100644 arch/mips/kernel/scall64-n32.S
 delete mode 100644 arch/mips/kernel/scall64-n64.S
 delete mode 100644 arch/mips/kernel/scall64-o32.S
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 1291774a2fa5..debd125100ad 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -32,6 +32,7 @@ config MIPS
 	select GENERIC_ATOMIC64 if !64BIT
 	select GENERIC_CMOS_UPDATE
 	select GENERIC_CPU_AUTOPROBE
+	select GENERIC_ENTRY
 	select GENERIC_GETTIMEOFDAY
 	select GENERIC_IOMAP
 	select GENERIC_IRQ_PROBE
diff --git a/arch/mips/include/asm/entry-common.h b/arch/mips/include/asm/entry-common.h
new file mode 100644
index 000000000000..0fe2a098ded9
--- /dev/null
+++ b/arch/mips/include/asm/entry-common.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef ARCH_LOONGARCH_ENTRY_COMMON_H
+#define ARCH_LOONGARCH_ENTRY_COMMON_H
Do you intend to say "MIPS"? ;-)
+
+#include <linux/sched.h>
+#include <linux/processor.h>
+
+static inline bool on_thread_stack(void)
+{
+	return !(((unsigned long)(current->stack) ^ current_stack_pointer) & ~(THREAD_SIZE - 1));
+}
+
+#endif
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help