Skip to contentSkip to conversation

powerpc/ptrace: Add prototype for function pt_regs_check

PATCH Applied Mathieu Malaterre 3 participants 5 messages Dec 8, 2018 – Nov 7, 2019

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

PATCH 1/1 powerpc/ptrace: Add prototype for function pt_regs_check

pt_regs_check is a dummy function, its purpose is to break the build if struct pt_regs and struct user_pt_regs don't match.

This function has no functionnal purpose, and will get eliminated at link time or after init depending on CONFIG_LD_DEAD_CODE_DATA_ELIMINATION

This commit adds a prototype to fix warning at W=1:

arch/powerpc/kernel/ptrace.c:3339:13: error: no previous prototype for ‘pt_regs_check’ [-Werror=missing-prototypes]

---
 arch/powerpc/kernel/ptrace.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/powerpc/kernel/ptrace.c +4 -0
index a398999d0770..341c0060b4c8 100644
@@ -3338,6 +3338,10 @@ void do_syscall_trace_leave(struct pt_regs *regs)
 	user_enter();
 }
 
+void __init pt_regs_check(void);
+/* dummy function, its purpose is to break the build if struct pt_regs and
+ * struct user_pt_regs don't match.
+ */
 void __init pt_regs_check(void)
 {
 	BUILD_BUG_ON(offsetof(struct pt_regs, gpr) !=
Signature · 1 line
2.19.2
#1 lore raw
Quoted 22 lines · Mathieu Malaterre

pt_regs_check is a dummy function, its purpose is to break the build if struct pt_regs and struct user_pt_regs don't match.

This function has no functionnal purpose, and will get eliminated at link time or after init depending on CONFIG_LD_DEAD_CODE_DATA_ELIMINATION

This commit adds a prototype to fix warning at W=1:

arch/powerpc/kernel/ptrace.c:3339:13: error: no previous prototype for ‘pt_regs_check’ [-Werror=missing-prototypes]

---
 arch/powerpc/kernel/ptrace.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/powerpc/kernel/ptrace.c +0 -0
index a398999d0770..341c0060b4c8 100644

arch/powerpc/kernel/ptrace.c void do_syscall_trace_leave(struct pt_regs *regs) · line 3344

Quoted 7 lines
arch/powerpc/kernel/ptrace.c +4 -0
@@ -3338,6 +3338,10 @@ void do_syscall_trace_leave(struct pt_regs *regs)
        user_enter();
 }
 
+void __init pt_regs_check(void);
+/* dummy function, its purpose is to break the build if struct pt_regs and
+ * struct user_pt_regs don't match.
+ */

Another trick which seems to work with GCC is:

-void __init pt_regs_check(void)
+static inline void __init pt_regs_check(void)

Quoted 6 lines
arch/powerpc/kernel/ptrace.c +0 -1
 void __init pt_regs_check(void)
 {
        BUILD_BUG_ON(offsetof(struct pt_regs, gpr) !=
--

2.19.2

#2 lore raw

Le 15/02/2019 à 09:11, Mathieu Malaterre a écrit :

Quoted 33 lines · Mathieu Malaterre
Quoted 22 lines

pt_regs_check is a dummy function, its purpose is to break the build if struct pt_regs and struct user_pt_regs don't match.

This function has no functionnal purpose, and will get eliminated at link time or after init depending on CONFIG_LD_DEAD_CODE_DATA_ELIMINATION

This commit adds a prototype to fix warning at W=1:

arch/powerpc/kernel/ptrace.c:3339:13: error: no previous prototype for ‘pt_regs_check’ [-Werror=missing-prototypes]

---
  arch/powerpc/kernel/ptrace.c | 4 ++++
  1 file changed, 4 insertions(+)
arch/powerpc/kernel/ptrace.c +0 -0
index a398999d0770..341c0060b4c8 100644

arch/powerpc/kernel/ptrace.c void do_syscall_trace_leave(struct pt_regs *regs) · line 3344

Quoted 7 lines
arch/powerpc/kernel/ptrace.c +4 -0
@@ -3338,6 +3338,10 @@ void do_syscall_trace_leave(struct pt_regs *regs)
         user_enter();
  }
 
+void __init pt_regs_check(void);
+/* dummy function, its purpose is to break the build if struct pt_regs and
+ * struct user_pt_regs don't match.
+ */

Another trick which seems to work with GCC is:

Review

Quoted 2 lines
(quoted diff) +1 -1
-void __init pt_regs_check(void)
+static inline void __init pt_regs_check(void)

Does this really work ? Did you test to ensure that the BUILD_BUG_ON still detect mismatch between struct pt_regs and struct user_pt_regs ?

Christophe

Quoted 7 lines
Quoted 7 lines
arch/powerpc/kernel/ptrace.c +0 -1
  void __init pt_regs_check(void)
  {
         BUILD_BUG_ON(offsetof(struct pt_regs, gpr) !=
--

2.19.2

#3 lore raw
Quoted 37 lines · Christophe Leroy
Quoted 33 lines · Mathieu Malaterre
Quoted 22 lines · Mathieu Malaterre

pt_regs_check is a dummy function, its purpose is to break the build if struct pt_regs and struct user_pt_regs don't match.

This function has no functionnal purpose, and will get eliminated at link time or after init depending on CONFIG_LD_DEAD_CODE_DATA_ELIMINATION

This commit adds a prototype to fix warning at W=1:

arch/powerpc/kernel/ptrace.c:3339:13: error: no previous prototype for ‘pt_regs_check’ [-Werror=missing-prototypes]

---
  arch/powerpc/kernel/ptrace.c | 4 ++++
  1 file changed, 4 insertions(+)
arch/powerpc/kernel/ptrace.c +0 -0
index a398999d0770..341c0060b4c8 100644

arch/powerpc/kernel/ptrace.c void do_syscall_trace_leave(struct pt_regs *regs) · line 3344

Quoted 7 lines
arch/powerpc/kernel/ptrace.c +4 -0
@@ -3338,6 +3338,10 @@ void do_syscall_trace_leave(struct pt_regs *regs)
         user_enter();
  }
 
+void __init pt_regs_check(void);
+/* dummy function, its purpose is to break the build if struct pt_regs and
+ * struct user_pt_regs don't match.
+ */

Another trick which seems to work with GCC is:

Quoted 6 lines

Review

Quoted 2 lines
(quoted diff) +1 -1
-void __init pt_regs_check(void)
+static inline void __init pt_regs_check(void)

Does this really work ? Did you test to ensure that the BUILD_BUG_ON still detect mismatch between struct pt_regs and struct user_pt_regs ?

My bad, I was unaware of GCC behavior for static inline in this case. Sorry for the noise.
Original ugly patch does work though.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
arch/powerpc/kernel/ptrace.c +0 -1
  void __init pt_regs_check(void)
  {
         BUILD_BUG_ON(offsetof(struct pt_regs, gpr) !=
--

2.19.2

#4 lore raw
In reply to Mathieu Malaterre
Quoted 6 lines · Mathieu Malaterre

pt_regs_check is a dummy function, its purpose is to break the build if struct pt_regs and struct user_pt_regs don't match.

This function has no functionnal purpose, and will get eliminated at link time or after init depending on CONFIG_LD_DEAD_CODE_DATA_ELIMINATION

Quoted 6 lines

This commit adds a prototype to fix warning at W=1:

arch/powerpc/kernel/ptrace.c:3339:13: error: no previous prototype for ‘pt_regs_check’ [-Werror=missing-prototypes]

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/5c74f79958682fccd82a6029c53859d1dab3b239

cheers