[lkml]   [2017]   [Oct]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH v9 03/29] ptrace,x86: Make user_64bit_mode() available to 32-bit builds
In its current form, user_64bit_mode() can only be used when CONFIG_X86_64
is selected. This implies that code built with CONFIG_X86_64=n cannot use
it. If a piece of code needs to be built for both CONFIG_X86_64=y and
CONFIG_X86_64=n and wants to use this function, it needs to wrap it in
an #ifdef/#endif; potentially, in multiple places.

This can be easily avoided with a single #ifdef/#endif pair within
user_64bit_mode() itself.

Suggested-by: Borislav Petkov <>
Cc: Dave Hansen <>
Cc: Adam Buchbinder <>
Cc: Colin Ian King <>
Cc: Lorenzo Stoakes <>
Cc: Qiaowei Ren <>
Cc: Arnaldo Carvalho de Melo <>
Cc: Masami Hiramatsu <>
Cc: Adrian Hunter <>
Cc: Kees Cook <>
Cc: Thomas Garnier <>
Cc: Peter Zijlstra <>
Cc: Borislav Petkov <>
Cc: Dmitry Vyukov <>
Cc: Ravi V. Shankar <>
Reviewed-by: Borislav Petkov <>
Signed-off-by: Ricardo Neri <>
arch/x86/include/asm/ptrace.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
index 91c04c8..e2afbf6 100644
--- a/arch/x86/include/asm/ptrace.h
+++ b/arch/x86/include/asm/ptrace.h
@@ -135,9 +135,9 @@ static inline int v8086_mode(struct pt_regs *regs)

-#ifdef CONFIG_X86_64
static inline bool user_64bit_mode(struct pt_regs *regs)
+#ifdef CONFIG_X86_64
* On non-paravirt systems, this is the only long mode CPL 3
@@ -148,8 +148,12 @@ static inline bool user_64bit_mode(struct pt_regs *regs)
/* Headers are too twisted for this to go in paravirt.h. */
return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
+#else /* !CONFIG_X86_64 */
+ return false;

+#ifdef CONFIG_X86_64
#define current_user_stack_pointer() current_pt_regs()->sp
#define compat_user_stack_pointer() current_pt_regs()->sp
 \ /
  Last update: 2017-10-04 05:56    [W:0.341 / U:5.328 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site