mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] x86: arch_prctl cleanups
@ 2025-02-02 20:23 Brian Gerst
  2025-02-02 20:23 ` [PATCH 1/2] x86/arch_prctl: Simplify sys_arch_prctl() Brian Gerst
  2025-02-02 20:23 ` [PATCH 2/2] x86/arch_prctl/64: Clean up ARCH_MAP_VDSO_32 Brian Gerst
  0 siblings, 2 replies; 5+ messages in thread
From: Brian Gerst @ 2025-02-02 20:23 UTC (permalink / raw)
  To: linux-kernel, x86
  Cc: Ingo Molnar, H . Peter Anvin, Thomas Gleixner, Borislav Petkov,
	Brian Gerst

Here are two simple cleanups to sys_arch_prctl(), removing the compat
syscall entry and a config condition that is always false.

Brian Gerst (2):
  x86/arch_prctl: Simplify sys_arch_prctl()
  x86/arch_prctl/64: Clean up ARCH_MAP_VDSO_32

 arch/x86/entry/syscalls/syscall_32.tbl |  2 +-
 arch/x86/include/asm/proto.h           |  3 +--
 arch/x86/kernel/process.c              |  5 ++++-
 arch/x86/kernel/process_32.c           |  5 -----
 arch/x86/kernel/process_64.c           | 20 +-------------------
 5 files changed, 7 insertions(+), 28 deletions(-)


base-commit: c911589353d148ffc65cddd5c0b00ac4f80a5b9a
-- 
2.48.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] x86/arch_prctl: Simplify sys_arch_prctl()
  2025-02-02 20:23 [PATCH 0/2] x86: arch_prctl cleanups Brian Gerst
@ 2025-02-02 20:23 ` Brian Gerst
  2025-02-21 21:41   ` [tip: x86/core] " tip-bot2 for Brian Gerst
  2025-02-02 20:23 ` [PATCH 2/2] x86/arch_prctl/64: Clean up ARCH_MAP_VDSO_32 Brian Gerst
  1 sibling, 1 reply; 5+ messages in thread
From: Brian Gerst @ 2025-02-02 20:23 UTC (permalink / raw)
  To: linux-kernel, x86
  Cc: Ingo Molnar, H . Peter Anvin, Thomas Gleixner, Borislav Petkov,
	Brian Gerst

Use in_ia32_syscall() instead of a compat syscall entry.

Signed-off-by: Brian Gerst <brgerst@gmail.com>
---
 arch/x86/entry/syscalls/syscall_32.tbl |  2 +-
 arch/x86/include/asm/proto.h           |  3 +--
 arch/x86/kernel/process.c              |  5 ++++-
 arch/x86/kernel/process_32.c           |  5 -----
 arch/x86/kernel/process_64.c           | 18 ------------------
 5 files changed, 6 insertions(+), 27 deletions(-)

diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl
index 4d0fb2fba7e2..62283097a7cc 100644
--- a/arch/x86/entry/syscalls/syscall_32.tbl
+++ b/arch/x86/entry/syscalls/syscall_32.tbl
@@ -396,7 +396,7 @@
 381	i386	pkey_alloc		sys_pkey_alloc
 382	i386	pkey_free		sys_pkey_free
 383	i386	statx			sys_statx
-384	i386	arch_prctl		sys_arch_prctl			compat_sys_arch_prctl
+384	i386	arch_prctl		sys_arch_prctl
 385	i386	io_pgetevents		sys_io_pgetevents_time32	compat_sys_io_pgetevents
 386	i386	rseq			sys_rseq
 393	i386	semget			sys_semget
diff --git a/arch/x86/include/asm/proto.h b/arch/x86/include/asm/proto.h
index 484f4f0131a5..05224a695872 100644
--- a/arch/x86/include/asm/proto.h
+++ b/arch/x86/include/asm/proto.h
@@ -15,7 +15,6 @@ void entry_SYSCALL_64(void);
 void entry_SYSCALL_64_safe_stack(void);
 void entry_SYSRETQ_unsafe_stack(void);
 void entry_SYSRETQ_end(void);
-long do_arch_prctl_64(struct task_struct *task, int option, unsigned long arg2);
 #endif
 
 #ifdef CONFIG_X86_32
@@ -41,6 +40,6 @@ void x86_configure_nx(void);
 
 extern int reboot_force;
 
-long do_arch_prctl_common(int option, unsigned long arg2);
+long do_arch_prctl_64(struct task_struct *task, int option, unsigned long arg2);
 
 #endif /* _ASM_X86_PROTO_H */
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 6da6769d7254..0f398a42c1e2 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -1043,7 +1043,7 @@ unsigned long __get_wchan(struct task_struct *p)
 	return addr;
 }
 
-long do_arch_prctl_common(int option, unsigned long arg2)
+SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2)
 {
 	switch (option) {
 	case ARCH_GET_CPUID:
@@ -1058,5 +1058,8 @@ long do_arch_prctl_common(int option, unsigned long arg2)
 		return fpu_xstate_prctl(option, arg2);
 	}
 
+	if (!in_ia32_syscall())
+		return do_arch_prctl_64(current, option, arg2);
+
 	return -EINVAL;
 }
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index 0917c7f25720..2bdab416298c 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -215,8 +215,3 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
 
 	return prev_p;
 }
-
-SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2)
-{
-	return do_arch_prctl_common(option, arg2);
-}
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 226472332a70..e067c61b5fca 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -980,24 +980,6 @@ long do_arch_prctl_64(struct task_struct *task, int option, unsigned long arg2)
 	return ret;
 }
 
-SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2)
-{
-	long ret;
-
-	ret = do_arch_prctl_64(current, option, arg2);
-	if (ret == -EINVAL)
-		ret = do_arch_prctl_common(option, arg2);
-
-	return ret;
-}
-
-#ifdef CONFIG_IA32_EMULATION
-COMPAT_SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2)
-{
-	return do_arch_prctl_common(option, arg2);
-}
-#endif
-
 unsigned long KSTK_ESP(struct task_struct *task)
 {
 	return task_pt_regs(task)->sp;
-- 
2.48.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] x86/arch_prctl/64: Clean up ARCH_MAP_VDSO_32
  2025-02-02 20:23 [PATCH 0/2] x86: arch_prctl cleanups Brian Gerst
  2025-02-02 20:23 ` [PATCH 1/2] x86/arch_prctl: Simplify sys_arch_prctl() Brian Gerst
@ 2025-02-02 20:23 ` Brian Gerst
  2025-02-21 21:41   ` [tip: x86/core] " tip-bot2 for Brian Gerst
  1 sibling, 1 reply; 5+ messages in thread
From: Brian Gerst @ 2025-02-02 20:23 UTC (permalink / raw)
  To: linux-kernel, x86
  Cc: Ingo Molnar, H . Peter Anvin, Thomas Gleixner, Borislav Petkov,
	Brian Gerst

process_64.c is not built on native 32-bit, so CONFIG_X86_32 will never
be set.

Signed-off-by: Brian Gerst <brgerst@gmail.com>
---
 arch/x86/kernel/process_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index e067c61b5fca..4ca73ddfb30b 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -942,7 +942,7 @@ long do_arch_prctl_64(struct task_struct *task, int option, unsigned long arg2)
 	case ARCH_MAP_VDSO_X32:
 		return prctl_map_vdso(&vdso_image_x32, arg2);
 # endif
-# if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
+# ifdef CONFIG_IA32_EMULATION
 	case ARCH_MAP_VDSO_32:
 		return prctl_map_vdso(&vdso_image_32, arg2);
 # endif
-- 
2.48.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [tip: x86/core] x86/arch_prctl/64: Clean up ARCH_MAP_VDSO_32
  2025-02-02 20:23 ` [PATCH 2/2] x86/arch_prctl/64: Clean up ARCH_MAP_VDSO_32 Brian Gerst
@ 2025-02-21 21:41   ` tip-bot2 for Brian Gerst
  0 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Brian Gerst @ 2025-02-21 21:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Brian Gerst, Ingo Molnar, H. Peter Anvin, x86, linux-kernel

The following commit has been merged into the x86/core branch of tip:

Commit-ID:     684b12916a107157633311f07bb74307221eff92
Gitweb:        https://git.kernel.org/tip/684b12916a107157633311f07bb74307221eff92
Author:        Brian Gerst <brgerst@gmail.com>
AuthorDate:    Sun, 02 Feb 2025 15:23:23 -05:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Fri, 21 Feb 2025 22:32:25 +01:00

x86/arch_prctl/64: Clean up ARCH_MAP_VDSO_32

process_64.c is not built on native 32-bit, so CONFIG_X86_32 will never
be set.

No change in functionality intended.

Signed-off-by: Brian Gerst <brgerst@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Link: https://lore.kernel.org/r/20250202202323.422113-3-brgerst@gmail.com
---
 arch/x86/kernel/process_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index e067c61..4ca73dd 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -942,7 +942,7 @@ long do_arch_prctl_64(struct task_struct *task, int option, unsigned long arg2)
 	case ARCH_MAP_VDSO_X32:
 		return prctl_map_vdso(&vdso_image_x32, arg2);
 # endif
-# if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
+# ifdef CONFIG_IA32_EMULATION
 	case ARCH_MAP_VDSO_32:
 		return prctl_map_vdso(&vdso_image_32, arg2);
 # endif

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [tip: x86/core] x86/arch_prctl: Simplify sys_arch_prctl()
  2025-02-02 20:23 ` [PATCH 1/2] x86/arch_prctl: Simplify sys_arch_prctl() Brian Gerst
@ 2025-02-21 21:41   ` tip-bot2 for Brian Gerst
  0 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Brian Gerst @ 2025-02-21 21:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Brian Gerst, Ingo Molnar, H. Peter Anvin, x86, linux-kernel

The following commit has been merged into the x86/core branch of tip:

Commit-ID:     2df1ad0d25803399056d439425e271802cd243f6
Gitweb:        https://git.kernel.org/tip/2df1ad0d25803399056d439425e271802cd243f6
Author:        Brian Gerst <brgerst@gmail.com>
AuthorDate:    Sun, 02 Feb 2025 15:23:22 -05:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Fri, 21 Feb 2025 22:32:25 +01:00

x86/arch_prctl: Simplify sys_arch_prctl()

Use in_ia32_syscall() instead of a compat syscall entry.

No change in functionality intended.

Signed-off-by: Brian Gerst <brgerst@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Link: https://lore.kernel.org/r/20250202202323.422113-2-brgerst@gmail.com
---
 arch/x86/entry/syscalls/syscall_32.tbl |  2 +-
 arch/x86/include/asm/proto.h           |  3 +--
 arch/x86/kernel/process.c              |  5 ++++-
 arch/x86/kernel/process_32.c           |  5 -----
 arch/x86/kernel/process_64.c           | 18 ------------------
 5 files changed, 6 insertions(+), 27 deletions(-)

diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl
index 4d0fb2f..6228309 100644
--- a/arch/x86/entry/syscalls/syscall_32.tbl
+++ b/arch/x86/entry/syscalls/syscall_32.tbl
@@ -396,7 +396,7 @@
 381	i386	pkey_alloc		sys_pkey_alloc
 382	i386	pkey_free		sys_pkey_free
 383	i386	statx			sys_statx
-384	i386	arch_prctl		sys_arch_prctl			compat_sys_arch_prctl
+384	i386	arch_prctl		sys_arch_prctl
 385	i386	io_pgetevents		sys_io_pgetevents_time32	compat_sys_io_pgetevents
 386	i386	rseq			sys_rseq
 393	i386	semget			sys_semget
diff --git a/arch/x86/include/asm/proto.h b/arch/x86/include/asm/proto.h
index 484f4f0..05224a6 100644
--- a/arch/x86/include/asm/proto.h
+++ b/arch/x86/include/asm/proto.h
@@ -15,7 +15,6 @@ void entry_SYSCALL_64(void);
 void entry_SYSCALL_64_safe_stack(void);
 void entry_SYSRETQ_unsafe_stack(void);
 void entry_SYSRETQ_end(void);
-long do_arch_prctl_64(struct task_struct *task, int option, unsigned long arg2);
 #endif
 
 #ifdef CONFIG_X86_32
@@ -41,6 +40,6 @@ void x86_configure_nx(void);
 
 extern int reboot_force;
 
-long do_arch_prctl_common(int option, unsigned long arg2);
+long do_arch_prctl_64(struct task_struct *task, int option, unsigned long arg2);
 
 #endif /* _ASM_X86_PROTO_H */
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 6da6769..0f398a4 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -1043,7 +1043,7 @@ unsigned long __get_wchan(struct task_struct *p)
 	return addr;
 }
 
-long do_arch_prctl_common(int option, unsigned long arg2)
+SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2)
 {
 	switch (option) {
 	case ARCH_GET_CPUID:
@@ -1058,5 +1058,8 @@ long do_arch_prctl_common(int option, unsigned long arg2)
 		return fpu_xstate_prctl(option, arg2);
 	}
 
+	if (!in_ia32_syscall())
+		return do_arch_prctl_64(current, option, arg2);
+
 	return -EINVAL;
 }
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index 0917c7f..2bdab41 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -215,8 +215,3 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
 
 	return prev_p;
 }
-
-SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2)
-{
-	return do_arch_prctl_common(option, arg2);
-}
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 2264723..e067c61 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -980,24 +980,6 @@ long do_arch_prctl_64(struct task_struct *task, int option, unsigned long arg2)
 	return ret;
 }
 
-SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2)
-{
-	long ret;
-
-	ret = do_arch_prctl_64(current, option, arg2);
-	if (ret == -EINVAL)
-		ret = do_arch_prctl_common(option, arg2);
-
-	return ret;
-}
-
-#ifdef CONFIG_IA32_EMULATION
-COMPAT_SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2)
-{
-	return do_arch_prctl_common(option, arg2);
-}
-#endif
-
 unsigned long KSTK_ESP(struct task_struct *task)
 {
 	return task_pt_regs(task)->sp;

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-02-21 21:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-02 20:23 [PATCH 0/2] x86: arch_prctl cleanups Brian Gerst
2025-02-02 20:23 ` [PATCH 1/2] x86/arch_prctl: Simplify sys_arch_prctl() Brian Gerst
2025-02-21 21:41   ` [tip: x86/core] " tip-bot2 for Brian Gerst
2025-02-02 20:23 ` [PATCH 2/2] x86/arch_prctl/64: Clean up ARCH_MAP_VDSO_32 Brian Gerst
2025-02-21 21:41   ` [tip: x86/core] " tip-bot2 for Brian Gerst

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®