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
Unified · Split
| @@ -154,6 +154,14 @@ ifdef CONFIG_FUNCTION_GRAPH_TRACER · 153 unmodified lines | ||
| 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 |
| @@ -29,12 +29,6 @@ · 28 unmodified lines | ||
| 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) |
| @@ -989,6 +983,18 @@ void prepare_ftrace_return(unsigned long self_addr, unsigned long *parent, · 948 unmodified lines | ||
| 989 | 983 | unsigned long return_hooker = (unsigned long) |
| 990 | 984 | &return_to_handler; |
| 991 | 985 | |
| 986 | + /* | |
| 987 | + * When resuming from suspend-to-ram, this function can be indirectly | |
| 988 | + * called from early CPU startup code while the CPU is in real mode, | |
| 989 | + * which would fail miserably. Make sure the stack pointer is a | |
| 990 | + * virtual address. | |
| 991 | + * | |
| 992 | + * This check isn't as accurate as virt_addr_valid(), but it should be | |
| 993 | + * good enough for this purpose, and it's fast. | |
| 994 | + */ | |
| 995 | + if (unlikely((long)__builtin_frame_address(0) >= 0)) | |
| 996 | + return; | |
| 997 | + | |
| 992 | 998 | if (unlikely(ftrace_graph_is_dead())) |
| 993 | 999 | return; |
| 994 | 1000 | |
| @@ -93,6 +93,13 @@ static void delay_mwaitx(unsigned long __loops) · 92 unmodified lines | ||
| 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 (;;) { |