Skip to contentSkip to conversation

x86/asm changes for v4.12

GIT PULL Ingo Molnar 1 participant 1 message May 1, 2017

Subsystems (14)
Arm (32-bit) x86 PowerPC Library code +10 more subsystems
lore
Share & tools
lore
#0 lore raw

Linus,

Please pull the latest x86-asm-for-linus git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-asm-for-linus

# HEAD: 262fa734a0023a43391f9bd4a4099487b8393f35 x86/unwind: Dump all stacks in unwind_dump()

The main changes in this cycle were:

- unwinder fixes and enhancements

- improve ftrace interaction with the unwinder

- optimize the code footprint of WARN() and related debugging constructs

- ... plus misc updates, cleanups and fixes.

out-of-topic modifications in x86-asm-for-linus:
--------------------------------------------------

  arch/arm/kernel/vmlinux-xip.lds.S  # b5effd3815cc: debug: Fix __bug_table[] in 
  arch/arm/kernel/vmlinux.lds.S      # b5effd3815cc: debug: Fix __bug_table[] in 
  arch/arm64/include/asm/bug.h       # 19d436268dde: debug: Add _ONCE() logic to 
  arch/avr32/kernel/vmlinux.lds.S    # b5effd3815cc: debug: Fix __bug_table[] in 
  arch/blackfin/kernel/vmlinux.lds.S # b5effd3815cc: debug: Fix __bug_table[] in 
  arch/c6x/kernel/vmlinux.lds.S      # b5effd3815cc: debug: Fix __bug_table[] in 
  arch/cris/kernel/vmlinux.lds.S     # b5effd3815cc: debug: Fix __bug_table[] in 
  arch/frv/kernel/vmlinux.lds.S      # b5effd3815cc: debug: Fix __bug_table[] in 
  arch/ia64/kernel/vmlinux.lds.S     # b5effd3815cc: debug: Fix __bug_table[] in 
  arch/mips/kernel/vmlinux.lds.S     # b5effd3815cc: debug: Fix __bug_table[] in 
  arch/parisc/include/asm/bug.h      # 19d436268dde: debug: Add _ONCE() logic to 
  arch/powerpc/include/asm/bug.h     # 19d436268dde: debug: Add _ONCE() logic to 
  arch/powerpc/kernel/vmlinux.lds.S  # b5effd3815cc: debug: Fix __bug_table[] in 
  arch/s390/include/asm/bug.h        # 19d436268dde: debug: Add _ONCE() logic to 
  arch/sh/include/asm/bug.h          # 19d436268dde: debug: Add _ONCE() logic to 
  arch/um/Kconfig.common             # 9a93848fe787: x86/debug: Implement __WARN(
  include/asm-generic/bug.h          # f26dee15103f: debug: Avoid setting BUGFLAG
                                   # 19d436268dde: debug: Add _ONCE() logic to 
  include/asm-generic/vmlinux.lds.h  # 19d436268dde: debug: Add _ONCE() logic to 
  include/linux/bug.h                # 19d436268dde: debug: Add _ONCE() logic to 
  lib/bug.c                          # 19d436268dde: debug: Add _ONCE() logic to 

Thanks,

Ingo

------------------>
Arnd Bergmann (1):
x86/debug: Define BUG() again for !CONFIG_BUG

Borislav Petkov (1):
x86/asm: Optimize clear_page()

Jan Beulich (2):
x86/entry/32: Relax a pvops stub clobber specification x86/entry/64: Relax pvops stub clobber specifications

Josh Poimboeuf (9):
x86/unwind: Move common code into update_stack_state() x86/unwind: Read stack return address in update_stack_state() x86/unwind: Silence entry-related warnings x86/unwind: Ensure stack pointer is aligned x86/unwind: Properly zero-pad 32-bit values in unwind_dump() x86/unwind: Prepend hex mask value with '0x' in unwind_dump() x86/unwind: Remove unused 'sp' parameter in unwind_dump() x86/unwind: Silence more entry-code related warnings x86/unwind: Dump all stacks in unwind_dump()

Peter Zijlstra (4):
x86/debug: Implement __WARN() using UD0
debug: Add _ONCE() logic to report_bug()
debug: Fix __bug_table[] in arch linker scripts
debug: Avoid setting BUGFLAG_WARNING twice

Steven Rostedt (VMware) (7):
x86/ftrace: Rename mcount_64.S to ftrace_64.S
x86/ftrace: Move the ftrace specific code out of entry_32.S x86/ftrace: Add stack frame pointer to ftrace_caller x86/ftrace: Clean up ftrace_regs_caller
x86/ftrace: Add -mfentry support to x86_32 with DYNAMIC_FTRACE set x86/ftrace: Use Makefile logic instead of #ifdef for compiling ftrace_*.o x86/ftrace: Fix ebp in ftrace_regs_caller that screws up unwinder

 arch/arm/kernel/vmlinux-xip.lds.S            |   2 +
 arch/arm/kernel/vmlinux.lds.S                |   2 +
 arch/arm64/include/asm/bug.h                 |   2 +-
 arch/avr32/kernel/vmlinux.lds.S              |   1 +
 arch/blackfin/kernel/vmlinux.lds.S           |   2 +
 arch/c6x/kernel/vmlinux.lds.S                |   2 +
 arch/cris/kernel/vmlinux.lds.S               |   2 +
 arch/frv/kernel/vmlinux.lds.S                |   2 +
 arch/ia64/kernel/vmlinux.lds.S               |   2 +
 arch/mips/kernel/vmlinux.lds.S               |   1 +
 arch/parisc/include/asm/bug.h                |   8 +-
 arch/powerpc/include/asm/bug.h               |   4 +-
 arch/powerpc/kernel/vmlinux.lds.S            |   2 +
 arch/s390/include/asm/bug.h                  |   4 +-
 arch/sh/include/asm/bug.h                    |   4 +-
 arch/um/Kconfig.common                       |   5 -
 arch/x86/Kconfig                             |   2 +-
 arch/x86/entry/entry_32.S                    | 171 +------------------
 arch/x86/entry/entry_64.S                    |  15 +-
 arch/x86/include/asm/bug.h                   |  80 +++++++--
 arch/x86/include/asm/page_64.h               |  16 +-
 arch/x86/include/asm/unwind.h                |   2 +
 arch/x86/kernel/Makefile                     |   5 +-
 arch/x86/kernel/dumpstack.c                  |   5 +-
 arch/x86/kernel/dumpstack_32.c               |  12 --
 arch/x86/kernel/dumpstack_64.c               |  10 --
 arch/x86/kernel/ftrace_32.S                  | 244 +++++++++++++++++++++++++++
 arch/x86/kernel/{mcount_64.S => ftrace_64.S} |   6 -
 arch/x86/kernel/traps.c                      |  46 ++++-
 arch/x86/kernel/unwind_frame.c               | 234 ++++++++++++++-----------
 arch/x86/kernel/unwind_guess.c               |   4 +-
 arch/x86/kernel/vmlinux.lds.S                |   1 +
 arch/x86/lib/clear_page_64.S                 |  17 +-
 arch/x86/um/Makefile                         |   2 +-
 arch/x86/um/bug.c                            |  21 ---
 include/asm-generic/bug.h                    |  20 ++-
 include/asm-generic/vmlinux.lds.h            |   5 +-
 include/linux/bug.h                          |   2 +-
 lib/bug.c                                    |  28 ++-
 39 files changed, 592 insertions(+), 401 deletions(-)
 create mode 100644 arch/x86/kernel/ftrace_32.S
 rename arch/x86/kernel/{mcount_64.S => ftrace_64.S} (98%)
 delete mode 100644 arch/x86/um/bug.c
arch/arm/kernel/vmlinux-xip.lds.S +2 -0
index 37b2a11af345..8265b116218d 100644
@@ -242,6 +242,8 @@ SECTIONS
 	}
 	_edata_loc = __data_loc + SIZEOF(.data);
 
+	BUG_TABLE
+
 #ifdef CONFIG_HAVE_TCM
         /*
 	 * We align everything to a page boundary so we can
arch/arm/kernel/vmlinux.lds.S +2 -0
index ce18007f9e4e..c83a7ba737d6 100644
@@ -262,6 +262,8 @@ SECTIONS
 	}
 	_edata_loc = __data_loc + SIZEOF(.data);
 
+	BUG_TABLE
+
 #ifdef CONFIG_HAVE_TCM
         /*
 	 * We align everything to a page boundary so we can
arch/arm64/include/asm/bug.h +1 -1
index 561190d15881..a9be1072933c 100644
@@ -55,7 +55,7 @@ _BUGVERBOSE_LOCATION(__FILE__, __LINE__)		\
 	unreachable();				\
 } while (0)
 
-#define __WARN_TAINT(taint) _BUG_FLAGS(BUGFLAG_TAINT(taint))
+#define __WARN_FLAGS(flags) _BUG_FLAGS(BUGFLAG_WARNING|(flags))
 
 #endif /* ! CONFIG_GENERIC_BUG */
 
arch/avr32/kernel/vmlinux.lds.S +1 -0
index 17f2730eb497..623d18db0466 100644
@@ -75,6 +75,7 @@ SECTIONS
 
 		_edata = .;
 	}
+	BUG_TABLE
 
 	BSS_SECTION(0, 8, 8)
 	_end = .;
arch/blackfin/kernel/vmlinux.lds.S +2 -0
index 68069a120055..334ef8139b35 100644
@@ -115,6 +115,8 @@ SECTIONS
 	__data_lma = LOADADDR(.data);
 	__data_len = SIZEOF(.data);
 
+	BUG_TABLE
+
 	/* The init section should be last, so when we free it, it goes into
 	 * the general memory pool, and (hopefully) will decrease fragmentation
 	 * a tiny bit. The init section has a _requirement_ that it be
arch/c6x/kernel/vmlinux.lds.S +2 -0
index a1a5c166bc9b..29ebea49ddd5 100644
@@ -128,6 +128,8 @@ SECTIONS
 		. = ALIGN(8);
 	}
 
+	BUG_TABLE
+
 	_edata = .;
 
 	__bss_start = .;
arch/cris/kernel/vmlinux.lds.S +2 -0
index 979586261520..867f237d7c5c 100644
@@ -68,6 +68,8 @@ SECTIONS
 	__edata = . ;			/* End of data section. */
 	_edata = . ;
 
+	BUG_TABLE
+
 	INIT_TASK_DATA_SECTION(PAGE_SIZE)
 
 	. = ALIGN(PAGE_SIZE);		/* Init code and data. */
arch/frv/kernel/vmlinux.lds.S +2 -0
index aa6e573d57da..3f44dcbbad4d 100644
@@ -102,6 +102,8 @@ SECTIONS
 
   _edata = .;			/* End of data section */
 
+  BUG_TABLE
+
   /* GP section */
   . = ALIGN(L1_CACHE_BYTES);
   _gp = . + 2048;
arch/ia64/kernel/vmlinux.lds.S +2 -0
index f89d20c97412..798026dde52e 100644
@@ -192,6 +192,8 @@ SECTIONS {
 		CONSTRUCTORS
 	}
 
+	BUG_TABLE
+
 	. = ALIGN(16);	/* gp must be 16-byte aligned for exc. table */
 	.got : AT(ADDR(.got) - LOAD_OFFSET) {
 		*(.got.plt)
arch/mips/kernel/vmlinux.lds.S +1 -0
index f0a0e6d62be3..8ca2371aa684 100644
@@ -97,6 +97,7 @@ SECTIONS
 		DATA_DATA
 		CONSTRUCTORS
 	}
+	BUG_TABLE
 	_gp = . + 0x8000;
 	.lit8 : {
 		*(.lit8)
arch/parisc/include/asm/bug.h +4 -4
index 62a33338549c..d2742273a685 100644
@@ -46,7 +46,7 @@
 #endif
 
 #ifdef CONFIG_DEBUG_BUGVERBOSE
-#define __WARN_TAINT(taint)						\
+#define __WARN_FLAGS(flags)						\
 	do {								\
 		asm volatile("\n"					\
 			     "1:\t" PARISC_BUG_BREAK_ASM "\n"		\
@@ -56,11 +56,11 @@
 			     "\t.org 2b+%c3\n"				\
 			     "\t.popsection"				\
 			     : : "i" (__FILE__), "i" (__LINE__),	\
-			     "i" (BUGFLAG_TAINT(taint)), 		\
+			     "i" (BUGFLAG_WARNING|(flags)),		\
 			     "i" (sizeof(struct bug_entry)) );		\
 	} while(0)
 #else
-#define __WARN_TAINT(taint)						\
+#define __WARN_FLAGS(flags)						\
 	do {								\
 		asm volatile("\n"					\
 			     "1:\t" PARISC_BUG_BREAK_ASM "\n"		\
@@ -69,7 +69,7 @@
 			     "\t.short %c0\n"				\
 			     "\t.org 2b+%c1\n"				\
 			     "\t.popsection"				\
-			     : : "i" (BUGFLAG_TAINT(taint)),		\
+			     : : "i" (BUGFLAG_WARNING|(flags)),		\
 			     "i" (sizeof(struct bug_entry)) );		\
 	} while(0)
 #endif
arch/powerpc/include/asm/bug.h +2 -2
index 3a39283333c3..f2c562a0a427 100644
@@ -85,12 +85,12 @@
 	}							\
 } while (0)
 
-#define __WARN_TAINT(taint) do {				\
+#define __WARN_FLAGS(flags) do {				\
 	__asm__ __volatile__(					\
 		"1:	twi 31,0,0\n"				\
 		_EMIT_BUG_ENTRY					\
 		: : "i" (__FILE__), "i" (__LINE__),		\
-		  "i" (BUGFLAG_TAINT(taint)),			\
+		  "i" (BUGFLAG_WARNING|(flags)),		\
 		  "i" (sizeof(struct bug_entry)));		\
 } while (0)
 
arch/powerpc/kernel/vmlinux.lds.S +2 -0
index 7394b770ae1f..1c24c894c908 100644
@@ -312,6 +312,8 @@ SECTIONS
 		NOSAVE_DATA
 	}
 
+	BUG_TABLE
+
 	. = ALIGN(PAGE_SIZE);
 	_edata  =  .;
 	PROVIDE32 (edata = .);
arch/s390/include/asm/bug.h +2 -2
index bf90d1fd97a5..1bbd9dbfe4e0 100644
@@ -46,8 +46,8 @@
 	unreachable();					\
 } while (0)
 
-#define __WARN_TAINT(taint) do {			\
-	__EMIT_BUG(BUGFLAG_TAINT(taint));		\
+#define __WARN_FLAGS(flags) do {			\
+	__EMIT_BUG(BUGFLAG_WARNING|(flags));		\
 } while (0)
 
 #define WARN_ON(x) ({					\
arch/sh/include/asm/bug.h +2 -2
index dcf278075429..1b77f068be2b 100644
@@ -50,7 +50,7 @@ do {							\
 		   "i" (sizeof(struct bug_entry)));	\
 } while (0)
 
-#define __WARN_TAINT(taint)				\
+#define __WARN_FLAGS(flags)				\
 do {							\
 	__asm__ __volatile__ (				\
 		"1:\t.short %O0\n"			\
@@ -59,7 +59,7 @@ do {							\
 		 : "n" (TRAPA_BUG_OPCODE),		\
 		   "i" (__FILE__),			\
 		   "i" (__LINE__),			\
-		   "i" (BUGFLAG_TAINT(taint)),		\
+		   "i" (BUGFLAG_WARNING|(flags)),	\
 		   "i" (sizeof(struct bug_entry)));	\
 } while (0)
 
arch/um/Kconfig.common +0 -5
index fd443852103c..ed9c5b5ff028 100644
@@ -50,11 +50,6 @@ config GENERIC_CALIBRATE_DELAY
 	bool
 	default y
 
-config GENERIC_BUG
-	bool
-	default y
-	depends on BUG
-
 config HZ
 	int
 	default 100
arch/x86/Kconfig +1 -1
index cc98d5a294ee..8c17146427ca 100644
@@ -127,7 +127,7 @@ config X86
 	select HAVE_EBPF_JIT			if X86_64
 	select HAVE_EFFICIENT_UNALIGNED_ACCESS
 	select HAVE_EXIT_THREAD
-	select HAVE_FENTRY			if X86_64
+	select HAVE_FENTRY			if X86_64 || DYNAMIC_FTRACE
 	select HAVE_FTRACE_MCOUNT_RECORD
 	select HAVE_FUNCTION_GRAPH_TRACER
 	select HAVE_FUNCTION_TRACER
arch/x86/entry/entry_32.S +1 -170

196 lines not on this page · raw message

arch/x86/entry/entry_64.S +7 -8
index 044d18ebc43c..d2b2a2948ffe 100644
@@ -212,7 +212,7 @@ GLOBAL(entry_SYSCALL_64_after_swapgs)
 	 * If we see that no exit work is required (which we are required
 	 * to check with IRQs off), then we can go straight to SYSRET64.
 	 */
-	DISABLE_INTERRUPTS(CLBR_NONE)
+	DISABLE_INTERRUPTS(CLBR_ANY)
 	TRACE_IRQS_OFF
 	movq	PER_CPU_VAR(current_task), %r11
 	testl	$_TIF_ALLWORK_MASK, TASK_TI_flags(%r11)
@@ -233,7 +233,7 @@ GLOBAL(entry_SYSCALL_64_after_swapgs)
 	 * raise(3) will trigger this, for example.  IRQs are off.
 	 */
 	TRACE_IRQS_ON
-	ENABLE_INTERRUPTS(CLBR_NONE)
+	ENABLE_INTERRUPTS(CLBR_ANY)
 	SAVE_EXTRA_REGS
 	movq	%rsp, %rdi
 	call	syscall_return_slowpath	/* returns with IRQs disabled */
@@ -343,7 +343,7 @@ ENTRY(stub_ptregs_64)
 	 * Called from fast path -- disable IRQs again, pop return address
 	 * and jump to slow path
 	 */
-	DISABLE_INTERRUPTS(CLBR_NONE)
+	DISABLE_INTERRUPTS(CLBR_ANY)
 	TRACE_IRQS_OFF
 	popq	%rax
 	jmp	entry_SYSCALL64_slow_path
@@ -518,7 +518,7 @@ END(irq_entries_start)
 	interrupt do_IRQ
 	/* 0(%rsp): old RSP */
 ret_from_intr:
-	DISABLE_INTERRUPTS(CLBR_NONE)
+	DISABLE_INTERRUPTS(CLBR_ANY)
 	TRACE_IRQS_OFF
 	decl	PER_CPU_VAR(irq_count)
 
@@ -1051,7 +1051,7 @@ END(paranoid_entry)
  * On entry, ebx is "no swapgs" flag (1: don't need swapgs, 0: need it)
  */
 ENTRY(paranoid_exit)
-	DISABLE_INTERRUPTS(CLBR_NONE)
+	DISABLE_INTERRUPTS(CLBR_ANY)
 	TRACE_IRQS_OFF_DEBUG
 	testl	%ebx, %ebx			/* swapgs needed? */
 	jnz	paranoid_exit_no_swapgs
@@ -1156,10 +1156,9 @@ END(error_entry)
  *   0: user gsbase is loaded, we need SWAPGS and standard preparation for return to usermode
  */
 ENTRY(error_exit)
-	movl	%ebx, %eax
-	DISABLE_INTERRUPTS(CLBR_NONE)
+	DISABLE_INTERRUPTS(CLBR_ANY)
 	TRACE_IRQS_OFF
-	testl	%eax, %eax
+	testl	%ebx, %ebx
 	jnz	retint_kernel
 	jmp	retint_user
 END(error_exit)
arch/x86/include/asm/bug.h +63 -17

99 lines not on this page · raw message

arch/x86/include/asm/page_64.h +15 -1
index b3bebf9e5746..b4a0d43248cf 100644
@@ -4,6 +4,7 @@
 #include <asm/page_64_types.h>
 
 #ifndef __ASSEMBLY__
+#include <asm/alternative.h>
 
 /* duplicated to the one in bootmem.h */
 extern unsigned long max_pfn;
@@ -34,7 +35,20 @@ extern unsigned long __phys_addr_symbol(unsigned long);
 #define pfn_valid(pfn)          ((pfn) < max_pfn)
 #endif
 
-void clear_page(void *page);
+void clear_page_orig(void *page);
+void clear_page_rep(void *page);
+void clear_page_erms(void *page);
+
+static inline void clear_page(void *page)
+{
+	alternative_call_2(clear_page_orig,
+			   clear_page_rep, X86_FEATURE_REP_GOOD,
+			   clear_page_erms, X86_FEATURE_ERMS,
+			   "=D" (page),
+			   "0" (page)
+			   : "memory", "rax", "rcx");
+}
+
 void copy_page(void *to, void *from);
 
 #endif	/* !__ASSEMBLY__ */
arch/x86/include/asm/unwind.h +2 -0
index 6fa75b17aec3..9b10dcd51716 100644
@@ -12,8 +12,10 @@ struct unwind_state {
 	struct task_struct *task;
 	int graph_idx;
 #ifdef CONFIG_FRAME_POINTER
+	bool got_irq;
 	unsigned long *bp, *orig_sp;
 	struct pt_regs *regs;
+	unsigned long ip;
 #else
 	unsigned long *sp;
 #endif
arch/x86/kernel/Makefile +3 -2
index 84c00592d359..4b994232cb57 100644
@@ -27,7 +27,7 @@ KASAN_SANITIZE_stacktrace.o := n
 
 OBJECT_FILES_NON_STANDARD_head_$(BITS).o		:= y
 OBJECT_FILES_NON_STANDARD_relocate_kernel_$(BITS).o	:= y
-OBJECT_FILES_NON_STANDARD_mcount_$(BITS).o		:= y
+OBJECT_FILES_NON_STANDARD_ftrace_$(BITS).o		:= y
 OBJECT_FILES_NON_STANDARD_test_nx.o			:= y
 
 # If instrumentation of this dir is enabled, boot hangs during first second.
@@ -46,7 +46,7 @@ obj-$(CONFIG_MODIFY_LDT_SYSCALL)	+= ldt.o
 obj-y			+= setup.o x86_init.o i8259.o irqinit.o jump_label.o
 obj-$(CONFIG_IRQ_WORK)  += irq_work.o
 obj-y			+= probe_roms.o
-obj-$(CONFIG_X86_64)	+= sys_x86_64.o mcount_64.o
+obj-$(CONFIG_X86_64)	+= sys_x86_64.o
 obj-$(CONFIG_X86_ESPFIX64)	+= espfix_64.o
 obj-$(CONFIG_SYSFS)	+= ksysfs.o
 obj-y			+= bootflag.o e820.o
@@ -82,6 +82,7 @@ obj-y				+= apic/
 obj-$(CONFIG_X86_REBOOTFIXUPS)	+= reboot_fixups_32.o
 obj-$(CONFIG_DYNAMIC_FTRACE)	+= ftrace.o
 obj-$(CONFIG_LIVEPATCH)	+= livepatch.o
+obj-$(CONFIG_FUNCTION_TRACER)	+= ftrace_$(BITS).o
 obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o
 obj-$(CONFIG_FTRACE_SYSCALLS)	+= ftrace.o
 obj-$(CONFIG_X86_TSC)		+= trace_clock.o
arch/x86/kernel/dumpstack.c +1 -4
index 09d4ac0d2661..dbce3cca94cb 100644
@@ -77,7 +77,7 @@ void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
 	 * - softirq stack
 	 * - hardirq stack
 	 */
-	for (regs = NULL; stack; stack = stack_info.next_sp) {
+	for (regs = NULL; stack; stack = PTR_ALIGN(stack_info.next_sp, sizeof(long))) {
 		const char *stack_name;
 
 		/*
@@ -289,9 +289,6 @@ void die(const char *str, struct pt_regs *regs, long err)
 	unsigned long flags = oops_begin();
 	int sig = SIGSEGV;
 
-	if (!user_mode(regs))
-		report_bug(regs->ip, regs);
-
 	if (__die(str, regs, err))
 		sig = 0;
 	oops_end(flags, regs, sig);
arch/x86/kernel/dumpstack_32.c +0 -12
index b0b3a3df7c20..e5f0b40e66d2 100644
@@ -162,15 +162,3 @@ void show_regs(struct pt_regs *regs)
 	}
 	pr_cont("\n");
 }
-
-int is_valid_bugaddr(unsigned long ip)
-{
-	unsigned short ud2;
-
-	if (ip < PAGE_OFFSET)
-		return 0;
-	if (probe_kernel_address((unsigned short *)ip, ud2))
-		return 0;
-
-	return ud2 == 0x0b0f;
-}
arch/x86/kernel/dumpstack_64.c +0 -10
index a8b117e93b46..3e1471d57487 100644
@@ -178,13 +178,3 @@ void show_regs(struct pt_regs *regs)
 	}
 	pr_cont("\n");
 }
-
-int is_valid_bugaddr(unsigned long ip)
-{
-	unsigned short ud2;
-
-	if (__copy_from_user(&ud2, (const void __user *) ip, sizeof(ud2)))
-		return 0;
-
-	return ud2 == 0x0b0f;
-}
arch/x86/kernel/ftrace_32.S new file +244 -0

244 lines not on this page · raw message

arch/x86/kernel/ftrace_64.S renamed from arch/x86/kernel/mcount_64.S +0 -6
similarity index 98%
rename from arch/x86/kernel/mcount_64.S
rename to arch/x86/kernel/ftrace_64.S
index 7b0d3da52fb4..1dfac634bbf7 100644
@@ -1,6 +1,4 @@
 /*
- *  linux/arch/x86_64/mcount_64.S
- *
  *  Copyright (C) 2014  Steven Rostedt, Red Hat Inc
  */
 
@@ -13,9 +11,6 @@
 	.code64
 	.section .entry.text, "ax"
 
-
-#ifdef CONFIG_FUNCTION_TRACER
-
 #ifdef CC_USING_FENTRY
 # define function_hook	__fentry__
 EXPORT_SYMBOL(__fentry__)
@@ -297,7 +292,6 @@ GLOBAL(ftrace_stub)
 	jmp fgraph_trace
 END(function_hook)
 #endif /* CONFIG_DYNAMIC_FTRACE */
-#endif /* CONFIG_FUNCTION_TRACER */
 
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 ENTRY(ftrace_graph_caller)
arch/x86/kernel/traps.c +40 -6

58 lines not on this page · raw message

arch/x86/kernel/unwind_frame.c +134 -100

356 lines not on this page · raw message

arch/x86/kernel/unwind_guess.c +2 -2
index 22881ddcbb9f..039f36738e49 100644
@@ -34,7 +34,7 @@ bool unwind_next_frame(struct unwind_state *state)
 				return true;
 		}
 
-		state->sp = info->next_sp;
+		state->sp = PTR_ALIGN(info->next_sp, sizeof(long));
 
 	} while (!get_stack_info(state->sp, state->task, info,
 				 &state->stack_mask));
@@ -49,7 +49,7 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task,
 	memset(state, 0, sizeof(*state));
 
 	state->task = task;
-	state->sp   = first_frame;
+	state->sp   = PTR_ALIGN(first_frame, sizeof(long));
 
 	get_stack_info(first_frame, state->task, &state->stack_info,
 		       &state->stack_mask);
arch/x86/kernel/vmlinux.lds.S +1 -0
index c74ae9ce8dc4..c8a3b61be0aa 100644
@@ -146,6 +146,7 @@ SECTIONS
 		_edata = .;
 	} :data
 
+	BUG_TABLE
 
 	. = ALIGN(PAGE_SIZE);
 	__vvar_page = .;
arch/x86/lib/clear_page_64.S +7 -10
index 5e2af3a88cf5..81b1635d67de 100644
@@ -14,20 +14,15 @@
  * Zero a page.
  * %rdi	- page
  */
-ENTRY(clear_page)
-
-	ALTERNATIVE_2 "jmp clear_page_orig", "", X86_FEATURE_REP_GOOD, \
-		      "jmp clear_page_c_e", X86_FEATURE_ERMS
-
+ENTRY(clear_page_rep)
 	movl $4096/8,%ecx
 	xorl %eax,%eax
 	rep stosq
 	ret
-ENDPROC(clear_page)
-EXPORT_SYMBOL(clear_page)
+ENDPROC(clear_page_rep)
+EXPORT_SYMBOL_GPL(clear_page_rep)
 
 ENTRY(clear_page_orig)
-
 	xorl   %eax,%eax
 	movl   $4096/64,%ecx
 	.p2align 4
@@ -47,10 +42,12 @@ ENTRY(clear_page_orig)
 	nop
 	ret
 ENDPROC(clear_page_orig)
+EXPORT_SYMBOL_GPL(clear_page_orig)
 
-ENTRY(clear_page_c_e)
+ENTRY(clear_page_erms)
 	movl $4096,%ecx
 	xorl %eax,%eax
 	rep stosb
 	ret
-ENDPROC(clear_page_c_e)
+ENDPROC(clear_page_erms)
+EXPORT_SYMBOL_GPL(clear_page_erms)
arch/x86/um/Makefile +1 -1
index e7e7055a8658..76f17f05446f 100644
@@ -8,7 +8,7 @@ else
 	BITS := 64
 endif
 
-obj-y = bug.o bugs_$(BITS).o delay.o fault.o ldt.o \
+obj-y = bugs_$(BITS).o delay.o fault.o ldt.o \
 	ptrace_$(BITS).o ptrace_user.o setjmp_$(BITS).o signal.o \
 	stub_$(BITS).o stub_segv.o \
 	sys_call_table_$(BITS).o sysrq_$(BITS).o tls_$(BITS).o \
arch/x86/um/bug.c deleted +0 -21
deleted file mode 100644
index e8034e363d83..000000000000
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2006 Jeff Dike ([email protected])
- * Licensed under the GPL V2
- */
-
-#include <linux/uaccess.h>
-
-/*
- * Mostly copied from i386/x86_86 - eliminated the eip < PAGE_OFFSET because
- * that's not relevant in skas mode.
- */
-
-int is_valid_bugaddr(unsigned long eip)
-{
-	unsigned short ud2;
-
-	if (probe_kernel_address((unsigned short __user *)eip, ud2))
-		return 0;
-
-	return ud2 == 0x0b0f;
-}
include/asm-generic/bug.h +18 -2
index 6f96247226a4..d6f4aed479a1 100644
@@ -5,7 +5,9 @@
 
 #ifdef CONFIG_GENERIC_BUG
 #define BUGFLAG_WARNING		(1 << 0)
-#define BUGFLAG_TAINT(taint)	(BUGFLAG_WARNING | ((taint) << 8))
+#define BUGFLAG_ONCE		(1 << 1)
+#define BUGFLAG_DONE		(1 << 2)
+#define BUGFLAG_TAINT(taint)	((taint) << 8)
 #define BUG_GET_TAINT(bug)	((bug)->flags >> 8)
 #endif
 
@@ -55,6 +57,18 @@ struct bug_entry {
 #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
 #endif
 
+#ifdef __WARN_FLAGS
+#define __WARN_TAINT(taint)		__WARN_FLAGS(BUGFLAG_TAINT(taint))
+#define __WARN_ONCE_TAINT(taint)	__WARN_FLAGS(BUGFLAG_ONCE|BUGFLAG_TAINT(taint))
+
+#define WARN_ON_ONCE(condition) ({				\
+	int __ret_warn_on = !!(condition);			\
+	if (unlikely(__ret_warn_on))				\
+		__WARN_ONCE_TAINT(TAINT_WARN);			\
+	unlikely(__ret_warn_on);				\
+})
+#endif
+
 /*
  * WARN(), WARN_ON(), WARN_ON_ONCE, and so on can be used to report
  * significant issues that need prompt attention if they should ever
@@ -97,7 +111,7 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
 #endif
 
 #ifndef WARN
-#define WARN(condition, format...) ({						\
+#define WARN(condition, format...) ({					\
 	int __ret_warn_on = !!(condition);				\
 	if (unlikely(__ret_warn_on))					\
 		__WARN_printf(format);					\
@@ -112,6 +126,7 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
 	unlikely(__ret_warn_on);					\
 })
 
+#ifndef WARN_ON_ONCE
 #define WARN_ON_ONCE(condition)	({				\
 	static bool __section(.data.unlikely) __warned;		\
 	int __ret_warn_once = !!(condition);			\
@@ -122,6 +137,7 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
 	}							\
 	unlikely(__ret_warn_once);				\
 })
+#endif
 
 #define WARN_ONCE(condition, format...)	({			\
 	static bool __section(.data.unlikely) __warned;		\
include/asm-generic/vmlinux.lds.h +2 -3
index 0968d13b3885..51c8dbe8e8d9 100644
@@ -286,8 +286,6 @@
 		*(.rodata1)						\
 	}								\
 									\
-	BUG_TABLE							\
-									\
 	/* PCI quirks */						\
 	.pci_fixup        : AT(ADDR(.pci_fixup) - LOAD_OFFSET) {	\
 		VMLINUX_SYMBOL(__start_pci_fixups_early) = .;		\
@@ -855,7 +853,8 @@
 		READ_MOSTLY_DATA(cacheline)				\
 		DATA_DATA						\
 		CONSTRUCTORS						\
-	}
+	}								\
+	BUG_TABLE
 
 #define INIT_TEXT_SECTION(inittext_align)				\
 	. = ALIGN(inittext_align);					\
include/linux/bug.h +1 -1
index 5828489309bb..687b557fc5eb 100644
@@ -105,7 +105,7 @@ static inline int is_warning_bug(const struct bug_entry *bug)
 	return bug->flags & BUGFLAG_WARNING;
 }
 
-const struct bug_entry *find_bug(unsigned long bugaddr);
+struct bug_entry *find_bug(unsigned long bugaddr);
 
 enum bug_trap_type report_bug(unsigned long bug_addr, struct pt_regs *regs);
 
lib/bug.c +20 -8
index 06edbbef0623..a6a1137d06db 100644
@@ -47,7 +47,7 @@
 #include <linux/sched.h>
 #include <linux/rculist.h>
 
-extern const struct bug_entry __start___bug_table[], __stop___bug_table[];
+extern struct bug_entry __start___bug_table[], __stop___bug_table[];
 
 static inline unsigned long bug_addr(const struct bug_entry *bug)
 {
@@ -62,10 +62,10 @@ static inline unsigned long bug_addr(const struct bug_entry *bug)
 /* Updates are protected by module mutex */
 static LIST_HEAD(module_bug_list);
 
-static const struct bug_entry *module_find_bug(unsigned long bugaddr)
+static struct bug_entry *module_find_bug(unsigned long bugaddr)
 {
 	struct module *mod;
-	const struct bug_entry *bug = NULL;
+	struct bug_entry *bug = NULL;
 
 	rcu_read_lock_sched();
 	list_for_each_entry_rcu(mod, &module_bug_list, bug_list) {
@@ -122,15 +122,15 @@ void module_bug_cleanup(struct module *mod)
 
 #else
 
-static inline const struct bug_entry *module_find_bug(unsigned long bugaddr)
+static inline struct bug_entry *module_find_bug(unsigned long bugaddr)
 {
 	return NULL;
 }
 #endif
 
-const struct bug_entry *find_bug(unsigned long bugaddr)
+struct bug_entry *find_bug(unsigned long bugaddr)
 {
-	const struct bug_entry *bug;
+	struct bug_entry *bug;
 
 	for (bug = __start___bug_table; bug < __stop___bug_table; ++bug)
 		if (bugaddr == bug_addr(bug))
@@ -141,9 +141,9 @@ const struct bug_entry *find_bug(unsigned long bugaddr)
 
 enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
 {
-	const struct bug_entry *bug;
+	struct bug_entry *bug;
 	const char *file;
-	unsigned line, warning;
+	unsigned line, warning, once, done;
 
 	if (!is_valid_bugaddr(bugaddr))
 		return BUG_TRAP_TYPE_NONE;
@@ -164,6 +164,18 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
 		line = bug->line;
 #endif
 		warning = (bug->flags & BUGFLAG_WARNING) != 0;
+		once = (bug->flags & BUGFLAG_ONCE) != 0;
+		done = (bug->flags & BUGFLAG_DONE) != 0;
+
+		if (warning && once) {
+			if (done)
+				return BUG_TRAP_TYPE_WARN;
+
+			/*
+			 * Since this is the only store, concurrency is not an issue.
+			 */
+			bug->flags |= BUGFLAG_DONE;
+		}
 	}
 
 	if (warning) {