Skip to contentSkip to conversation

hexagon: Remove CONFIG_HEXAGON_ARCH_VERSION from uapi header

PATCH In review Thomas Huth 2 participants 3 messages Oct 26, 2023 – Dec 11, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hexagon: Remove CONFIG_HEXAGON_ARCH_VERSION from uapi header

uapi headers should not expose CONFIG switches since they are not available in userspace. Fix it in arch/hexagon/include/uapi/asm/user.h by always defining the cs0 and cs1 entries instead of pad values.

---
Based-on: <[email protected]>

Compile tested only (with CONFIG_HEXAGON_ARCH_VERSION set to 2 and with CONFIG_HEXAGON_ARCH_VERSION set to 4)

 arch/hexagon/include/uapi/asm/user.h | 7 +------
 arch/hexagon/kernel/ptrace.c         | 7 +++++--
 scripts/headers_install.sh           | 1 -
 3 files changed, 6 insertions(+), 9 deletions(-)
arch/hexagon/include/uapi/asm/user.h +1 -6
index 7327ec59b22f..abae6a4b5813 100644
@@ -56,15 +56,10 @@ struct user_regs_struct {
 	unsigned long pc;
 	unsigned long cause;
 	unsigned long badva;
-#if CONFIG_HEXAGON_ARCH_VERSION < 4
-	unsigned long pad1;  /* pad out to 48 words total */
-	unsigned long pad2;  /* pad out to 48 words total */
-	unsigned long pad3;  /* pad out to 48 words total */
-#else
+	/* cs0 and cs1 are only available with HEXAGON_ARCH_VERSION >= 4 */
 	unsigned long cs0;
 	unsigned long cs1;
 	unsigned long pad1;  /* pad out to 48 words total */
-#endif
 };
 
 #endif
arch/hexagon/kernel/ptrace.c +5 -2
index 125f19995b76..905b06790ab7 100644
@@ -74,7 +74,7 @@ static int genregs_set(struct task_struct *target,
 		   unsigned int pos, unsigned int count,
 		   const void *kbuf, const void __user *ubuf)
 {
-	int ret;
+	int ret, ignore_offset;
 	unsigned long bucket;
 	struct pt_regs *regs = task_pt_regs(target);
 
@@ -111,12 +111,15 @@ static int genregs_set(struct task_struct *target,
 #if CONFIG_HEXAGON_ARCH_VERSION >=4
 	INEXT(&regs->cs0, cs0);
 	INEXT(&regs->cs1, cs1);
+	ignore_offset = offsetof(struct user_regs_struct, pad1);
+#else
+	ignore_offset = offsetof(struct user_regs_struct, cs0);
 #endif
 
 	/* Ignore the rest, if needed */
 	if (!ret)
 		user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
-			offsetof(struct user_regs_struct, pad1), -1);
+					  ignore_offset, -1);
 	else
 		return ret;
 
scripts/headers_install.sh +0 -1
index c3064ac31003..f7d9b114de8f 100755
@@ -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/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
 arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT
Signature · 1 line
2.41.0
Acked-by on v1 1/1
#1 lore raw
Quoted 90 lines

-----Original Message-----
From: Thomas Huth <[email protected]>
Sent: Thursday, October 26, 2023 6:31 AM
To: Arnd Bergmann <[email protected]>; [email protected]; Brian Cain <[email protected]>
Cc: [email protected]; Oleg Nesterov <[email protected]>
Subject: [PATCH] hexagon: Remove CONFIG_HEXAGON_ARCH_VERSION from uapi header

WARNING: This email originated from outside of Qualcomm. Please be wary of any links or attachments, and do not enable macros.

uapi headers should not expose CONFIG switches since they are not available in userspace. Fix it in arch/hexagon/include/uapi/asm/user.h by always defining the cs0 and cs1 entries instead of pad values.

---
Based-on: <[email protected]>

Compile tested only (with CONFIG_HEXAGON_ARCH_VERSION set to 2 and with CONFIG_HEXAGON_ARCH_VERSION set to 4)

 arch/hexagon/include/uapi/asm/user.h | 7 +------
 arch/hexagon/kernel/ptrace.c         | 7 +++++--
 scripts/headers_install.sh           | 1 -
 3 files changed, 6 insertions(+), 9 deletions(-)
arch/hexagon/include/uapi/asm/user.h +1 -6
index 7327ec59b22f..abae6a4b5813 100644
@@ -56,15 +56,10 @@ struct user_regs_struct {
        unsigned long pc;
        unsigned long cause;
        unsigned long badva;
-#if CONFIG_HEXAGON_ARCH_VERSION < 4
-       unsigned long pad1;  /* pad out to 48 words total */
-       unsigned long pad2;  /* pad out to 48 words total */
-       unsigned long pad3;  /* pad out to 48 words total */
-#else
+       /* cs0 and cs1 are only available with HEXAGON_ARCH_VERSION >= 4 */
        unsigned long cs0;
        unsigned long cs1;
        unsigned long pad1;  /* pad out to 48 words total */
-#endif
 };
 
 #endif
arch/hexagon/kernel/ptrace.c +5 -2
index 125f19995b76..905b06790ab7 100644
@@ -74,7 +74,7 @@ static int genregs_set(struct task_struct *target,
                   unsigned int pos, unsigned int count,
                   const void *kbuf, const void __user *ubuf)
 {
-       int ret;
+       int ret, ignore_offset;
        unsigned long bucket;
        struct pt_regs *regs = task_pt_regs(target);
 
@@ -111,12 +111,15 @@ static int genregs_set(struct task_struct *target,
 #if CONFIG_HEXAGON_ARCH_VERSION >=4
        INEXT(&regs->cs0, cs0);
        INEXT(&regs->cs1, cs1);
+       ignore_offset = offsetof(struct user_regs_struct, pad1);
+#else
+       ignore_offset = offsetof(struct user_regs_struct, cs0);
 #endif
 
        /* Ignore the rest, if needed */
        if (!ret)
                user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
-                       offsetof(struct user_regs_struct, pad1), -1);
+                                         ignore_offset, -1);
        else
                return ret;
 
scripts/headers_install.sh +0 -0
index c3064ac31003..f7d9b114de8f 100755
@@ -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

Quoted 8 lines

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/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 arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT
--
2.41.0

#2 lore raw
Quoted 92 lines · Brian Cain
Quoted 92 lines

-----Original Message-----
From: Thomas Huth <[email protected]>
Sent: Thursday, October 26, 2023 6:31 AM
To: Arnd Bergmann <[email protected]>; [email protected]; Brian Cain <[email protected]>
Cc: [email protected]; Oleg Nesterov <[email protected]>
Subject: [PATCH] hexagon: Remove CONFIG_HEXAGON_ARCH_VERSION from uapi header

WARNING: This email originated from outside of Qualcomm. Please be wary of any links or attachments, and do not enable macros.

uapi headers should not expose CONFIG switches since they are not available in userspace. Fix it in arch/hexagon/include/uapi/asm/user.h by always defining the cs0 and cs1 entries instead of pad values.

---
Based-on: <[email protected]>

Compile tested only (with CONFIG_HEXAGON_ARCH_VERSION set to 2 and with CONFIG_HEXAGON_ARCH_VERSION set to 4)

  arch/hexagon/include/uapi/asm/user.h | 7 +------
  arch/hexagon/kernel/ptrace.c         | 7 +++++--
  scripts/headers_install.sh           | 1 -
  3 files changed, 6 insertions(+), 9 deletions(-)
arch/hexagon/include/uapi/asm/user.h +1 -6
index 7327ec59b22f..abae6a4b5813 100644
@@ -56,15 +56,10 @@ struct user_regs_struct {
         unsigned long pc;
         unsigned long cause;
         unsigned long badva;
-#if CONFIG_HEXAGON_ARCH_VERSION < 4
-       unsigned long pad1;  /* pad out to 48 words total */
-       unsigned long pad2;  /* pad out to 48 words total */
-       unsigned long pad3;  /* pad out to 48 words total */
-#else
+       /* cs0 and cs1 are only available with HEXAGON_ARCH_VERSION >= 4 */
         unsigned long cs0;
         unsigned long cs1;
         unsigned long pad1;  /* pad out to 48 words total */
-#endif
  };
 
  #endif
arch/hexagon/kernel/ptrace.c +5 -2
index 125f19995b76..905b06790ab7 100644
@@ -74,7 +74,7 @@ static int genregs_set(struct task_struct *target,
                    unsigned int pos, unsigned int count,
                    const void *kbuf, const void __user *ubuf)
  {
-       int ret;
+       int ret, ignore_offset;
         unsigned long bucket;
         struct pt_regs *regs = task_pt_regs(target);
 
@@ -111,12 +111,15 @@ static int genregs_set(struct task_struct *target,
  #if CONFIG_HEXAGON_ARCH_VERSION >=4
         INEXT(&regs->cs0, cs0);
         INEXT(&regs->cs1, cs1);
+       ignore_offset = offsetof(struct user_regs_struct, pad1);
+#else
+       ignore_offset = offsetof(struct user_regs_struct, cs0);
  #endif
 
         /* Ignore the rest, if needed */
         if (!ret)
                 user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
-                       offsetof(struct user_regs_struct, pad1), -1);
+                                         ignore_offset, -1);
         else
                 return ret;
 
scripts/headers_install.sh +0 -0
index c3064ac31003..f7d9b114de8f 100755
@@ -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

Quoted 8 lines
Quoted 6 lines

-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 arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT
--
2.41.0

Thanks!

Arnd, could you maybe take this patch through your "generic include/asm header files" tree?

Thomas