18c2ecf20Sopenharmony_ciCompile-time stack metadata validation
28c2ecf20Sopenharmony_ci======================================
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ciOverview
68c2ecf20Sopenharmony_ci--------
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ciThe kernel CONFIG_STACK_VALIDATION option enables a host tool named
98c2ecf20Sopenharmony_ciobjtool which runs at compile time.  It has a "check" subcommand which
108c2ecf20Sopenharmony_cianalyzes every .o file and ensures the validity of its stack metadata.
118c2ecf20Sopenharmony_ciIt enforces a set of rules on asm code and C inline assembly code so
128c2ecf20Sopenharmony_cithat stack traces can be reliable.
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ciFor each function, it recursively follows all possible code paths and
158c2ecf20Sopenharmony_civalidates the correct frame pointer state at each instruction.
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ciIt also follows code paths involving special sections, like
188c2ecf20Sopenharmony_ci.altinstructions, __jump_table, and __ex_table, which can add
198c2ecf20Sopenharmony_cialternative execution paths to a given instruction (or set of
208c2ecf20Sopenharmony_ciinstructions).  Similarly, it knows how to follow switch statements, for
218c2ecf20Sopenharmony_ciwhich gcc sometimes uses jump tables.
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci(Objtool also has an 'orc generate' subcommand which generates debuginfo
248c2ecf20Sopenharmony_cifor the ORC unwinder.  See Documentation/x86/orc-unwinder.rst in the
258c2ecf20Sopenharmony_cikernel tree for more details.)
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ciWhy do we need stack metadata validation?
298c2ecf20Sopenharmony_ci-----------------------------------------
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ciHere are some of the benefits of validating stack metadata:
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_cia) More reliable stack traces for frame pointer enabled kernels
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci   Frame pointers are used for debugging purposes.  They allow runtime
368c2ecf20Sopenharmony_ci   code and debug tools to be able to walk the stack to determine the
378c2ecf20Sopenharmony_ci   chain of function call sites that led to the currently executing
388c2ecf20Sopenharmony_ci   code.
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci   For some architectures, frame pointers are enabled by
418c2ecf20Sopenharmony_ci   CONFIG_FRAME_POINTER.  For some other architectures they may be
428c2ecf20Sopenharmony_ci   required by the ABI (sometimes referred to as "backchain pointers").
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci   For C code, gcc automatically generates instructions for setting up
458c2ecf20Sopenharmony_ci   frame pointers when the -fno-omit-frame-pointer option is used.
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci   But for asm code, the frame setup instructions have to be written by
488c2ecf20Sopenharmony_ci   hand, which most people don't do.  So the end result is that
498c2ecf20Sopenharmony_ci   CONFIG_FRAME_POINTER is honored for C code but not for most asm code.
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci   For stack traces based on frame pointers to be reliable, all
528c2ecf20Sopenharmony_ci   functions which call other functions must first create a stack frame
538c2ecf20Sopenharmony_ci   and update the frame pointer.  If a first function doesn't properly
548c2ecf20Sopenharmony_ci   create a stack frame before calling a second function, the *caller*
558c2ecf20Sopenharmony_ci   of the first function will be skipped on the stack trace.
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci   For example, consider the following example backtrace with frame
588c2ecf20Sopenharmony_ci   pointers enabled:
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci     [<ffffffff81812584>] dump_stack+0x4b/0x63
618c2ecf20Sopenharmony_ci     [<ffffffff812d6dc2>] cmdline_proc_show+0x12/0x30
628c2ecf20Sopenharmony_ci     [<ffffffff8127f568>] seq_read+0x108/0x3e0
638c2ecf20Sopenharmony_ci     [<ffffffff812cce62>] proc_reg_read+0x42/0x70
648c2ecf20Sopenharmony_ci     [<ffffffff81256197>] __vfs_read+0x37/0x100
658c2ecf20Sopenharmony_ci     [<ffffffff81256b16>] vfs_read+0x86/0x130
668c2ecf20Sopenharmony_ci     [<ffffffff81257898>] SyS_read+0x58/0xd0
678c2ecf20Sopenharmony_ci     [<ffffffff8181c1f2>] entry_SYSCALL_64_fastpath+0x12/0x76
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci   It correctly shows that the caller of cmdline_proc_show() is
708c2ecf20Sopenharmony_ci   seq_read().
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci   If we remove the frame pointer logic from cmdline_proc_show() by
738c2ecf20Sopenharmony_ci   replacing the frame pointer related instructions with nops, here's
748c2ecf20Sopenharmony_ci   what it looks like instead:
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci     [<ffffffff81812584>] dump_stack+0x4b/0x63
778c2ecf20Sopenharmony_ci     [<ffffffff812d6dc2>] cmdline_proc_show+0x12/0x30
788c2ecf20Sopenharmony_ci     [<ffffffff812cce62>] proc_reg_read+0x42/0x70
798c2ecf20Sopenharmony_ci     [<ffffffff81256197>] __vfs_read+0x37/0x100
808c2ecf20Sopenharmony_ci     [<ffffffff81256b16>] vfs_read+0x86/0x130
818c2ecf20Sopenharmony_ci     [<ffffffff81257898>] SyS_read+0x58/0xd0
828c2ecf20Sopenharmony_ci     [<ffffffff8181c1f2>] entry_SYSCALL_64_fastpath+0x12/0x76
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci   Notice that cmdline_proc_show()'s caller, seq_read(), has been
858c2ecf20Sopenharmony_ci   skipped.  Instead the stack trace seems to show that
868c2ecf20Sopenharmony_ci   cmdline_proc_show() was called by proc_reg_read().
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci   The benefit of objtool here is that because it ensures that *all*
898c2ecf20Sopenharmony_ci   functions honor CONFIG_FRAME_POINTER, no functions will ever[*] be
908c2ecf20Sopenharmony_ci   skipped on a stack trace.
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci   [*] unless an interrupt or exception has occurred at the very
938c2ecf20Sopenharmony_ci       beginning of a function before the stack frame has been created,
948c2ecf20Sopenharmony_ci       or at the very end of the function after the stack frame has been
958c2ecf20Sopenharmony_ci       destroyed.  This is an inherent limitation of frame pointers.
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_cib) ORC (Oops Rewind Capability) unwind table generation
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci   An alternative to frame pointers and DWARF, ORC unwind data can be
1008c2ecf20Sopenharmony_ci   used to walk the stack.  Unlike frame pointers, ORC data is out of
1018c2ecf20Sopenharmony_ci   band.  So it doesn't affect runtime performance and it can be
1028c2ecf20Sopenharmony_ci   reliable even when interrupts or exceptions are involved.
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci   For more details, see Documentation/x86/orc-unwinder.rst.
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_cic) Higher live patching compatibility rate
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci   Livepatch has an optional "consistency model", which is needed for
1098c2ecf20Sopenharmony_ci   more complex patches.  In order for the consistency model to work,
1108c2ecf20Sopenharmony_ci   stack traces need to be reliable (or an unreliable condition needs to
1118c2ecf20Sopenharmony_ci   be detectable).  Objtool makes that possible.
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci   For more details, see the livepatch documentation in the Linux kernel
1148c2ecf20Sopenharmony_ci   source tree at Documentation/livepatch/livepatch.rst.
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ciRules
1178c2ecf20Sopenharmony_ci-----
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ciTo achieve the validation, objtool enforces the following rules:
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci1. Each callable function must be annotated as such with the ELF
1228c2ecf20Sopenharmony_ci   function type.  In asm code, this is typically done using the
1238c2ecf20Sopenharmony_ci   ENTRY/ENDPROC macros.  If objtool finds a return instruction
1248c2ecf20Sopenharmony_ci   outside of a function, it flags an error since that usually indicates
1258c2ecf20Sopenharmony_ci   callable code which should be annotated accordingly.
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci   This rule is needed so that objtool can properly identify each
1288c2ecf20Sopenharmony_ci   callable function in order to analyze its stack metadata.
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci2. Conversely, each section of code which is *not* callable should *not*
1318c2ecf20Sopenharmony_ci   be annotated as an ELF function.  The ENDPROC macro shouldn't be used
1328c2ecf20Sopenharmony_ci   in this case.
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci   This rule is needed so that objtool can ignore non-callable code.
1358c2ecf20Sopenharmony_ci   Such code doesn't have to follow any of the other rules.
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci3. Each callable function which calls another function must have the
1388c2ecf20Sopenharmony_ci   correct frame pointer logic, if required by CONFIG_FRAME_POINTER or
1398c2ecf20Sopenharmony_ci   the architecture's back chain rules.  This can by done in asm code
1408c2ecf20Sopenharmony_ci   with the FRAME_BEGIN/FRAME_END macros.
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci   This rule ensures that frame pointer based stack traces will work as
1438c2ecf20Sopenharmony_ci   designed.  If function A doesn't create a stack frame before calling
1448c2ecf20Sopenharmony_ci   function B, the _caller_ of function A will be skipped on the stack
1458c2ecf20Sopenharmony_ci   trace.
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci4. Dynamic jumps and jumps to undefined symbols are only allowed if:
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ci   a) the jump is part of a switch statement; or
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci   b) the jump matches sibling call semantics and the frame pointer has
1528c2ecf20Sopenharmony_ci      the same value it had on function entry.
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci   This rule is needed so that objtool can reliably analyze all of a
1558c2ecf20Sopenharmony_ci   function's code paths.  If a function jumps to code in another file,
1568c2ecf20Sopenharmony_ci   and it's not a sibling call, objtool has no way to follow the jump
1578c2ecf20Sopenharmony_ci   because it only analyzes a single file at a time.
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci5. A callable function may not execute kernel entry/exit instructions.
1608c2ecf20Sopenharmony_ci   The only code which needs such instructions is kernel entry code,
1618c2ecf20Sopenharmony_ci   which shouldn't be be in callable functions anyway.
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci   This rule is just a sanity check to ensure that callable functions
1648c2ecf20Sopenharmony_ci   return normally.
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ciObjtool warnings
1688c2ecf20Sopenharmony_ci----------------
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ciFor asm files, if you're getting an error which doesn't make sense,
1718c2ecf20Sopenharmony_cifirst make sure that the affected code follows the above rules.
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ciFor C files, the common culprits are inline asm statements and calls to
1748c2ecf20Sopenharmony_ci"noreturn" functions.  See below for more details.
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ciAnother possible cause for errors in C code is if the Makefile removes
1778c2ecf20Sopenharmony_ci-fno-omit-frame-pointer or adds -fomit-frame-pointer to the gcc options.
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ciHere are some examples of common warnings reported by objtool, what
1808c2ecf20Sopenharmony_cithey mean, and suggestions for how to fix them.
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_ci1. file.o: warning: objtool: func()+0x128: call without frame pointer save/setup
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci   The func() function made a function call without first saving and/or
1868c2ecf20Sopenharmony_ci   updating the frame pointer, and CONFIG_FRAME_POINTER is enabled.
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ci   If the error is for an asm file, and func() is indeed a callable
1898c2ecf20Sopenharmony_ci   function, add proper frame pointer logic using the FRAME_BEGIN and
1908c2ecf20Sopenharmony_ci   FRAME_END macros.  Otherwise, if it's not a callable function, remove
1918c2ecf20Sopenharmony_ci   its ELF function annotation by changing ENDPROC to END, and instead
1928c2ecf20Sopenharmony_ci   use the manual unwind hint macros in asm/unwind_hints.h.
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci   If it's a GCC-compiled .c file, the error may be because the function
1958c2ecf20Sopenharmony_ci   uses an inline asm() statement which has a "call" instruction.  An
1968c2ecf20Sopenharmony_ci   asm() statement with a call instruction must declare the use of the
1978c2ecf20Sopenharmony_ci   stack pointer in its output operand.  On x86_64, this means adding
1988c2ecf20Sopenharmony_ci   the ASM_CALL_CONSTRAINT as an output constraint:
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci     asm volatile("call func" : ASM_CALL_CONSTRAINT);
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ci   Otherwise the stack frame may not get created before the call.
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_ci2. file.o: warning: objtool: .text+0x53: unreachable instruction
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_ci   Objtool couldn't find a code path to reach the instruction.
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci   If the error is for an asm file, and the instruction is inside (or
2108c2ecf20Sopenharmony_ci   reachable from) a callable function, the function should be annotated
2118c2ecf20Sopenharmony_ci   with the ENTRY/ENDPROC macros (ENDPROC is the important one).
2128c2ecf20Sopenharmony_ci   Otherwise, the code should probably be annotated with the unwind hint
2138c2ecf20Sopenharmony_ci   macros in asm/unwind_hints.h so objtool and the unwinder can know the
2148c2ecf20Sopenharmony_ci   stack state associated with the code.
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_ci   If you're 100% sure the code won't affect stack traces, or if you're
2178c2ecf20Sopenharmony_ci   a just a bad person, you can tell objtool to ignore it.  See the
2188c2ecf20Sopenharmony_ci   "Adding exceptions" section below.
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_ci   If it's not actually in a callable function (e.g. kernel entry code),
2218c2ecf20Sopenharmony_ci   change ENDPROC to END.
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci4. file.o: warning: objtool: func(): can't find starting instruction
2258c2ecf20Sopenharmony_ci   or
2268c2ecf20Sopenharmony_ci   file.o: warning: objtool: func()+0x11dd: can't decode instruction
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_ci   Does the file have data in a text section?  If so, that can confuse
2298c2ecf20Sopenharmony_ci   objtool's instruction decoder.  Move the data to a more appropriate
2308c2ecf20Sopenharmony_ci   section like .data or .rodata.
2318c2ecf20Sopenharmony_ci
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci5. file.o: warning: objtool: func()+0x6: unsupported instruction in callable function
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ci   This is a kernel entry/exit instruction like sysenter or iret.  Such
2368c2ecf20Sopenharmony_ci   instructions aren't allowed in a callable function, and are most
2378c2ecf20Sopenharmony_ci   likely part of the kernel entry code.  They should usually not have
2388c2ecf20Sopenharmony_ci   the callable function annotation (ENDPROC) and should always be
2398c2ecf20Sopenharmony_ci   annotated with the unwind hint macros in asm/unwind_hints.h.
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_ci6. file.o: warning: objtool: func()+0x26: sibling call from callable instruction with modified stack frame
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci   This is a dynamic jump or a jump to an undefined symbol.  Objtool
2458c2ecf20Sopenharmony_ci   assumed it's a sibling call and detected that the frame pointer
2468c2ecf20Sopenharmony_ci   wasn't first restored to its original state.
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_ci   If it's not really a sibling call, you may need to move the
2498c2ecf20Sopenharmony_ci   destination code to the local file.
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_ci   If the instruction is not actually in a callable function (e.g.
2528c2ecf20Sopenharmony_ci   kernel entry code), change ENDPROC to END and annotate manually with
2538c2ecf20Sopenharmony_ci   the unwind hint macros in asm/unwind_hints.h.
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_ci7. file: warning: objtool: func()+0x5c: stack state mismatch
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_ci   The instruction's frame pointer state is inconsistent, depending on
2598c2ecf20Sopenharmony_ci   which execution path was taken to reach the instruction.
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ci   Make sure that, when CONFIG_FRAME_POINTER is enabled, the function
2628c2ecf20Sopenharmony_ci   pushes and sets up the frame pointer (for x86_64, this means rbp) at
2638c2ecf20Sopenharmony_ci   the beginning of the function and pops it at the end of the function.
2648c2ecf20Sopenharmony_ci   Also make sure that no other code in the function touches the frame
2658c2ecf20Sopenharmony_ci   pointer.
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_ci   Another possibility is that the code has some asm or inline asm which
2688c2ecf20Sopenharmony_ci   does some unusual things to the stack or the frame pointer.  In such
2698c2ecf20Sopenharmony_ci   cases it's probably appropriate to use the unwind hint macros in
2708c2ecf20Sopenharmony_ci   asm/unwind_hints.h.
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ci8. file.o: warning: objtool: funcA() falls through to next function funcB()
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_ci   This means that funcA() doesn't end with a return instruction or an
2768c2ecf20Sopenharmony_ci   unconditional jump, and that objtool has determined that the function
2778c2ecf20Sopenharmony_ci   can fall through into the next function.  There could be different
2788c2ecf20Sopenharmony_ci   reasons for this:
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci   1) funcA()'s last instruction is a call to a "noreturn" function like
2818c2ecf20Sopenharmony_ci      panic().  In this case the noreturn function needs to be added to
2828c2ecf20Sopenharmony_ci      objtool's hard-coded global_noreturns array.  Feel free to bug the
2838c2ecf20Sopenharmony_ci      objtool maintainer, or you can submit a patch.
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci   2) funcA() uses the unreachable() annotation in a section of code
2868c2ecf20Sopenharmony_ci      that is actually reachable.
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_ci   3) If funcA() calls an inline function, the object code for funcA()
2898c2ecf20Sopenharmony_ci      might be corrupt due to a gcc bug.  For more details, see:
2908c2ecf20Sopenharmony_ci      https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70646
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci9. file.o: warning: objtool: funcA() call to funcB() with UACCESS enabled
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_ci   This means that an unexpected call to a non-whitelisted function exists
2958c2ecf20Sopenharmony_ci   outside of arch-specific guards.
2968c2ecf20Sopenharmony_ci   X86: SMAP (stac/clac): __uaccess_begin()/__uaccess_end()
2978c2ecf20Sopenharmony_ci   ARM: PAN: uaccess_enable()/uaccess_disable()
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ci   These functions should be called to denote a minimal critical section around
3008c2ecf20Sopenharmony_ci   access to __user variables. See also: https://lwn.net/Articles/517475/
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_ci   The intention of the warning is to prevent calls to funcB() from eventually
3038c2ecf20Sopenharmony_ci   calling schedule(), potentially leaking the AC flags state, and not
3048c2ecf20Sopenharmony_ci   restoring them correctly.
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_ci   It also helps verify that there are no unexpected calls to funcB() which may
3078c2ecf20Sopenharmony_ci   access user space pages with protections against doing so disabled.
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci   To fix, either:
3108c2ecf20Sopenharmony_ci   1) remove explicit calls to funcB() from funcA().
3118c2ecf20Sopenharmony_ci   2) add the correct guards before and after calls to low level functions like
3128c2ecf20Sopenharmony_ci      __get_user_size()/__put_user_size().
3138c2ecf20Sopenharmony_ci   3) add funcB to uaccess_safe_builtin whitelist in tools/objtool/check.c, if
3148c2ecf20Sopenharmony_ci      funcB obviously does not call schedule(), and is marked notrace (since
3158c2ecf20Sopenharmony_ci      function tracing inserts additional calls, which is not obvious from the
3168c2ecf20Sopenharmony_ci      sources).
3178c2ecf20Sopenharmony_ci
3188c2ecf20Sopenharmony_ci10. file.o: warning: func()+0x5c: stack layout conflict in alternatives
3198c2ecf20Sopenharmony_ci
3208c2ecf20Sopenharmony_ci    This means that in the use of the alternative() or ALTERNATIVE()
3218c2ecf20Sopenharmony_ci    macro, the code paths have conflicting modifications to the stack.
3228c2ecf20Sopenharmony_ci    The problem is that there is only one ORC unwind table, which means
3238c2ecf20Sopenharmony_ci    that the ORC unwind entries must be consistent for all possible
3248c2ecf20Sopenharmony_ci    instruction boundaries regardless of which code has been patched.
3258c2ecf20Sopenharmony_ci    This limitation can be overcome by massaging the alternatives with
3268c2ecf20Sopenharmony_ci    NOPs to shift the stack changes around so they no longer conflict.
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ci11. file.o: warning: unannotated intra-function call
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_ci   This warning means that a direct call is done to a destination which
3318c2ecf20Sopenharmony_ci   is not at the beginning of a function. If this is a legit call, you
3328c2ecf20Sopenharmony_ci   can remove this warning by putting the ANNOTATE_INTRA_FUNCTION_CALL
3338c2ecf20Sopenharmony_ci   directive right before the call.
3348c2ecf20Sopenharmony_ci
3358c2ecf20Sopenharmony_ci
3368c2ecf20Sopenharmony_ciIf the error doesn't seem to make sense, it could be a bug in objtool.
3378c2ecf20Sopenharmony_ciFeel free to ask the objtool maintainer for help.
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_ciAdding exceptions
3418c2ecf20Sopenharmony_ci-----------------
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ciIf you _really_ need objtool to ignore something, and are 100% sure
3448c2ecf20Sopenharmony_cithat it won't affect kernel stack traces, you can tell objtool to
3458c2ecf20Sopenharmony_ciignore it:
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_ci- To skip validation of a function, use the STACK_FRAME_NON_STANDARD
3488c2ecf20Sopenharmony_ci  macro.
3498c2ecf20Sopenharmony_ci
3508c2ecf20Sopenharmony_ci- To skip validation of a file, add
3518c2ecf20Sopenharmony_ci
3528c2ecf20Sopenharmony_ci    OBJECT_FILES_NON_STANDARD_filename.o := y
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_ci  to the Makefile.
3558c2ecf20Sopenharmony_ci
3568c2ecf20Sopenharmony_ci- To skip validation of a directory, add
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_ci    OBJECT_FILES_NON_STANDARD := y
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_ci  to the Makefile.
361