Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 fixes from Thomas Gleixner:
"The final fixes for 4.11:

- prevent a triple fault with function graph tracing triggered via
suspend to ram

- prevent optimizing for size when function graph tracing is enabled
and the compiler does not support -mfentry

- prevent mwaitx() being called with a zero timeout as mwaitx() might
never return. Observed on the new Ryzen CPUs"

* 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
Prevent timer value 0 for MWAITX
x86/build: convert function graph '-Os' error to warning
ftrace/x86: Fix triple fault with graph tracing and suspend-to-ram

Changed files
+27 -6
arch
x86
+8
arch/x86/Makefile
··· 154 154 else 155 155 ifeq ($(call cc-option-yn, -mfentry), n) 156 156 ACCUMULATE_OUTGOING_ARGS := 1 157 + 158 + # GCC ignores '-maccumulate-outgoing-args' when used with '-Os'. 159 + # If '-Os' is enabled, disable it and print a warning. 160 + ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE 161 + undefine CONFIG_CC_OPTIMIZE_FOR_SIZE 162 + $(warning Disabling CONFIG_CC_OPTIMIZE_FOR_SIZE. Your compiler does not have -mfentry so you cannot optimize for size with CONFIG_FUNCTION_GRAPH_TRACER.) 163 + endif 164 + 157 165 endif 158 166 endif 159 167 endif
+12 -6
arch/x86/kernel/ftrace.c
··· 29 29 #include <asm/ftrace.h> 30 30 #include <asm/nops.h> 31 31 32 - #if defined(CONFIG_FUNCTION_GRAPH_TRACER) && \ 33 - !defined(CC_USING_FENTRY) && \ 34 - !defined(CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE) 35 - # error The following combination is not supported: ((compiler missing -mfentry) || (CONFIG_X86_32 and !CONFIG_DYNAMIC_FTRACE)) && CONFIG_FUNCTION_GRAPH_TRACER && CONFIG_CC_OPTIMIZE_FOR_SIZE 36 - #endif 37 - 38 32 #ifdef CONFIG_DYNAMIC_FTRACE 39 33 40 34 int ftrace_arch_code_modify_prepare(void) ··· 982 988 struct ftrace_graph_ent trace; 983 989 unsigned long return_hooker = (unsigned long) 984 990 &return_to_handler; 991 + 992 + /* 993 + * When resuming from suspend-to-ram, this function can be indirectly 994 + * called from early CPU startup code while the CPU is in real mode, 995 + * which would fail miserably. Make sure the stack pointer is a 996 + * virtual address. 997 + * 998 + * This check isn't as accurate as virt_addr_valid(), but it should be 999 + * good enough for this purpose, and it's fast. 1000 + */ 1001 + if (unlikely((long)__builtin_frame_address(0) >= 0)) 1002 + return; 985 1003 986 1004 if (unlikely(ftrace_graph_is_dead())) 987 1005 return;
+7
arch/x86/lib/delay.c
··· 93 93 { 94 94 u64 start, end, delay, loops = __loops; 95 95 96 + /* 97 + * Timer value of 0 causes MWAITX to wait indefinitely, unless there 98 + * is a store on the memory monitored by MONITORX. 99 + */ 100 + if (loops == 0) 101 + return; 102 + 96 103 start = rdtsc_ordered(); 97 104 98 105 for (;;) {