Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86: Make is_64bit_mm() widely available

The uprobes code has a nice helper, is_64bit_mm(), that consults
both the runtime and compile-time flags for 32-bit support.
Instead of reinventing the wheel, pull it in to an x86 header so
we can use it for MPX.

I prefer passing the 'mm' around to test_thread_flag(TIF_IA32)
because it makes it explicit where the context is coming from.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Dave Hansen <dave@sr71.net>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20150607183704.F0209999@viggo.jf.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Dave Hansen and committed by
Ingo Molnar
b0e9b09b cd4996dc

+14 -9
+13
arch/x86/include/asm/mmu_context.h
··· 142 142 paravirt_arch_exit_mmap(mm); 143 143 } 144 144 145 + #ifdef CONFIG_X86_64 146 + static inline bool is_64bit_mm(struct mm_struct *mm) 147 + { 148 + return !config_enabled(CONFIG_IA32_EMULATION) || 149 + !(mm->context.ia32_compat == TIF_IA32); 150 + } 151 + #else 152 + static inline bool is_64bit_mm(struct mm_struct *mm) 153 + { 154 + return false; 155 + } 156 + #endif 157 + 145 158 static inline void arch_bprm_mm_init(struct mm_struct *mm, 146 159 struct vm_area_struct *vma) 147 160 {
+1 -9
arch/x86/kernel/uprobes.c
··· 29 29 #include <linux/kdebug.h> 30 30 #include <asm/processor.h> 31 31 #include <asm/insn.h> 32 + #include <asm/mmu_context.h> 32 33 33 34 /* Post-execution fixups. */ 34 35 ··· 313 312 } 314 313 315 314 #ifdef CONFIG_X86_64 316 - static inline bool is_64bit_mm(struct mm_struct *mm) 317 - { 318 - return !config_enabled(CONFIG_IA32_EMULATION) || 319 - !(mm->context.ia32_compat == TIF_IA32); 320 - } 321 315 /* 322 316 * If arch_uprobe->insn doesn't use rip-relative addressing, return 323 317 * immediately. Otherwise, rewrite the instruction so that it accesses ··· 493 497 } 494 498 } 495 499 #else /* 32-bit: */ 496 - static inline bool is_64bit_mm(struct mm_struct *mm) 497 - { 498 - return false; 499 - } 500 500 /* 501 501 * No RIP-relative addressing on 32-bit 502 502 */