linux-hexagon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hexagon: Remove unusable symbols from the ptrace.h uapi
@ 2023-10-25  7:38 Thomas Huth
  2023-10-25 13:59 ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Huth @ 2023-10-25  7:38 UTC (permalink / raw)
  To: Oleg Nesterov, Arnd Bergmann, linux-hexagon, Brian Cain
  Cc: linux-kernel, Richard Kuo

Kernel-internal prototypes, references to current_thread_info()
and code hidden behind a CONFIG_HEXAGON_ARCH_VERSION switch are
certainly not usable in userspace, so this should not reside
in a uapi header. Move the code into an internal version of
ptrace.h instead.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 I've compile tested it now with a hexagon cross-compiler and the kernel
 compiles fine with this change, so I think this should be good to go.

 arch/hexagon/include/asm/ptrace.h      | 25 +++++++++++++++++++++++++
 arch/hexagon/include/uapi/asm/ptrace.h | 13 -------------
 scripts/headers_install.sh             |  1 -
 3 files changed, 25 insertions(+), 14 deletions(-)
 create mode 100644 arch/hexagon/include/asm/ptrace.h

diff --git a/arch/hexagon/include/asm/ptrace.h b/arch/hexagon/include/asm/ptrace.h
new file mode 100644
index 000000000000..ed35da1ee685
--- /dev/null
+++ b/arch/hexagon/include/asm/ptrace.h
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Ptrace definitions for the Hexagon architecture
+ *
+ * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
+ */
+
+#ifndef _ASM_HEXAGON_PTRACE_H
+#define _ASM_HEXAGON_PTRACE_H
+
+#include <uapi/asm/ptrace.h>
+
+/* kprobe-based event tracer support */
+extern int regs_query_register_offset(const char *name);
+extern const char *regs_query_register_name(unsigned int offset);
+
+#define current_pt_regs() \
+	((struct pt_regs *) \
+	 ((unsigned long)current_thread_info() + THREAD_SIZE) - 1)
+
+#if CONFIG_HEXAGON_ARCH_VERSION >= 4
+#define arch_has_single_step()	(1)
+#endif
+
+#endif
diff --git a/arch/hexagon/include/uapi/asm/ptrace.h b/arch/hexagon/include/uapi/asm/ptrace.h
index f79de05b8689..2a3ea14ad9b9 100644
--- a/arch/hexagon/include/uapi/asm/ptrace.h
+++ b/arch/hexagon/include/uapi/asm/ptrace.h
@@ -29,17 +29,4 @@
 
 #define profile_pc(regs) instruction_pointer(regs)
 
-/* kprobe-based event tracer support */
-extern int regs_query_register_offset(const char *name);
-extern const char *regs_query_register_name(unsigned int offset);
-
-#define current_pt_regs() \
-	((struct pt_regs *) \
-	 ((unsigned long)current_thread_info() + THREAD_SIZE) - 1)
-
-#if CONFIG_HEXAGON_ARCH_VERSION >= 4
-#define arch_has_single_step()	(1)
-#endif
-
-
 #endif
diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
index 56d3c338d91d..c3064ac31003 100755
--- a/scripts/headers_install.sh
+++ b/scripts/headers_install.sh
@@ -74,7 +74,6 @@ arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_16K
 arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_4K
 arch/arc/include/uapi/asm/swab.h:CONFIG_ARC_HAS_SWAPE
 arch/arm/include/uapi/asm/ptrace.h:CONFIG_CPU_ENDIAN_BE8
-arch/hexagon/include/uapi/asm/ptrace.h:CONFIG_HEXAGON_ARCH_VERSION
 arch/hexagon/include/uapi/asm/user.h:CONFIG_HEXAGON_ARCH_VERSION
 arch/m68k/include/uapi/asm/ptrace.h:CONFIG_COLDFIRE
 arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_NO
-- 
2.41.0


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

* Re: [PATCH] hexagon: Remove unusable symbols from the ptrace.h uapi
  2023-10-25  7:38 [PATCH] hexagon: Remove unusable symbols from the ptrace.h uapi Thomas Huth
@ 2023-10-25 13:59 ` Arnd Bergmann
  2023-10-25 14:15   ` Thomas Huth
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2023-10-25 13:59 UTC (permalink / raw)
  To: Thomas Huth, Oleg Nesterov, linux-hexagon, Brian Cain
  Cc: linux-kernel, Richard Kuo

On Wed, Oct 25, 2023, at 09:38, Thomas Huth wrote:
> Kernel-internal prototypes, references to current_thread_info()
> and code hidden behind a CONFIG_HEXAGON_ARCH_VERSION switch are
> certainly not usable in userspace, so this should not reside
> in a uapi header. Move the code into an internal version of
> ptrace.h instead.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  I've compile tested it now with a hexagon cross-compiler and the kernel
>  compiles fine with this change, so I think this should be good to go.

I've applied this to the asm-generic tree, thanks for the
patch.

> +++ b/scripts/headers_install.sh
> @@ -74,7 +74,6 @@ arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_16K
>  arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_4K
>  arch/arc/include/uapi/asm/swab.h:CONFIG_ARC_HAS_SWAPE
>  arch/arm/include/uapi/asm/ptrace.h:CONFIG_CPU_ENDIAN_BE8
> -arch/hexagon/include/uapi/asm/ptrace.h:CONFIG_HEXAGON_ARCH_VERSION
>  arch/hexagon/include/uapi/asm/user.h:CONFIG_HEXAGON_ARCH_VERSION
>  arch/m68k/include/uapi/asm/ptrace.h:CONFIG_COLDFIRE
>  arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_NO

Would you like to send another patch for the other hexagon
file? It looks trivial enough as we can just drop the #if
portion there and keep the #else side.

      Arnd

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

* Re: [PATCH] hexagon: Remove unusable symbols from the ptrace.h uapi
  2023-10-25 13:59 ` Arnd Bergmann
@ 2023-10-25 14:15   ` Thomas Huth
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Huth @ 2023-10-25 14:15 UTC (permalink / raw)
  To: Arnd Bergmann, Oleg Nesterov, linux-hexagon, Brian Cain
  Cc: linux-kernel, Richard Kuo

On 25/10/2023 15.59, Arnd Bergmann wrote:
> On Wed, Oct 25, 2023, at 09:38, Thomas Huth wrote:
>> Kernel-internal prototypes, references to current_thread_info()
>> and code hidden behind a CONFIG_HEXAGON_ARCH_VERSION switch are
>> certainly not usable in userspace, so this should not reside
>> in a uapi header. Move the code into an internal version of
>> ptrace.h instead.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
>>   I've compile tested it now with a hexagon cross-compiler and the kernel
>>   compiles fine with this change, so I think this should be good to go.
> 
> I've applied this to the asm-generic tree, thanks for the
> patch.

Thanks!

>> +++ b/scripts/headers_install.sh
>> @@ -74,7 +74,6 @@ arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_16K
>>   arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_4K
>>   arch/arc/include/uapi/asm/swab.h:CONFIG_ARC_HAS_SWAPE
>>   arch/arm/include/uapi/asm/ptrace.h:CONFIG_CPU_ENDIAN_BE8
>> -arch/hexagon/include/uapi/asm/ptrace.h:CONFIG_HEXAGON_ARCH_VERSION
>>   arch/hexagon/include/uapi/asm/user.h:CONFIG_HEXAGON_ARCH_VERSION
>>   arch/m68k/include/uapi/asm/ptrace.h:CONFIG_COLDFIRE
>>   arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_NO
> 
> Would you like to send another patch for the other hexagon
> file? It looks trivial enough as we can just drop the #if
> portion there and keep the #else side.

Looks like we have at least to look carefully at 
arch/hexagon/kernel/ptrace.c first ... pad1 is still used there and the of 
offsetof(struct user_regs_struct, pad1) results in different values 
depending on the CONFIG switch ... but sure, I can have a try to come up 
with a patch.

  Thomas



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

end of thread, other threads:[~2023-10-25 14:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-25  7:38 [PATCH] hexagon: Remove unusable symbols from the ptrace.h uapi Thomas Huth
2023-10-25 13:59 ` Arnd Bergmann
2023-10-25 14:15   ` Thomas Huth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).