Commit-ID:  e27c310af5c05cf876d9cad006928076c27f54d4
Gitweb:     https://git.kernel.org/tip/e27c310af5c05cf876d9cad006928076c27f54d4
Author:     Ricardo Neri <ricardo.neri-calde...@linux.intel.com>
AuthorDate: Fri, 27 Oct 2017 13:25:30 -0700
Committer:  Thomas Gleixner <t...@linutronix.de>
CommitDate: Wed, 1 Nov 2017 21:50:08 +0100

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 <b...@suse.de>
Signed-off-by: Ricardo Neri <ricardo.neri-calde...@linux.intel.com>
Signed-off-by: Thomas Gleixner <t...@linutronix.de>
Reviewed-by: Borislav Petkov <b...@suse.de>
Cc: "Michael S. Tsirkin" <m...@redhat.com>
Cc: Peter Zijlstra <pet...@infradead.org>
Cc: Dave Hansen <dave.han...@linux.intel.com>
Cc: ricardo.n...@intel.com
Cc: Adrian Hunter <adrian.hun...@intel.com>
Cc: Paul Gortmaker <paul.gortma...@windriver.com>
Cc: Huang Rui <ray.hu...@amd.com>
Cc: Qiaowei Ren <qiaowei....@intel.com>
Cc: Shuah Khan <sh...@kernel.org>
Cc: Kees Cook <keesc...@chromium.org>
Cc: Jonathan Corbet <cor...@lwn.net>
Cc: Jiri Slaby <jsl...@suse.cz>
Cc: Dmitry Vyukov <dvyu...@google.com>
Cc: "Ravi V. Shankar" <ravi.v.shan...@intel.com>
Cc: Chris Metcalf <cmetc...@mellanox.com>
Cc: Brian Gerst <brge...@gmail.com>
Cc: Arnaldo Carvalho de Melo <a...@redhat.com>
Cc: Andy Lutomirski <l...@kernel.org>
Cc: Colin Ian King <colin.k...@canonical.com>
Cc: Chen Yucong <sla...@gmail.com>
Cc: Adam Buchbinder <adam.buchbin...@gmail.com>
Cc: Vlastimil Babka <vba...@suse.cz>
Cc: Lorenzo Stoakes <lstoa...@gmail.com>
Cc: Masami Hiramatsu <mhira...@kernel.org>
Cc: Paolo Bonzini <pbonz...@redhat.com>
Cc: Andrew Morton <a...@linux-foundation.org>
Cc: Thomas Garnier <thgar...@google.com>
Link: 
https://lkml.kernel.org/r/1509135945-13762-4-git-send-email-ricardo.neri-calde...@linux.intel.com

---
 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)
 #endif
 }
 
-#ifdef CONFIG_X86_64
 static inline bool user_64bit_mode(struct pt_regs *regs)
 {
+#ifdef CONFIG_X86_64
 #ifndef CONFIG_PARAVIRT
        /*
         * 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;
 #endif
+#else /* !CONFIG_X86_64 */
+       return false;
+#endif
 }
 
+#ifdef CONFIG_X86_64
 #define current_user_stack_pointer()   current_pt_regs()->sp
 #define compat_user_stack_pointer()    current_pt_regs()->sp
 #endif

Reply via email to