1. 05 Apr, 2022 2 commits
    • Peter Zijlstra's avatar
      objtool: Fix IBT tail-call detection · d139bca4
      Peter Zijlstra authored
      Objtool reports:
      
        arch/x86/crypto/poly1305-x86_64.o: warning: objtool: poly1305_blocks_avx() falls through to next function poly1305_blocks_x86_64()
        arch/x86/crypto/poly1305-x86_64.o: warning: objtool: poly1305_emit_avx() falls through to next function poly1305_emit_x86_64()
        arch/x86/crypto/poly1305-x86_64.o: warning: objtool: poly1305_blocks_avx2() falls through to next function poly1305_blocks_x86_64()
      
      Which reads like:
      
      0000000000000040 <poly1305_blocks_x86_64>:
      	 40:       f3 0f 1e fa             endbr64
      	...
      
      0000000000000400 <poly1305_blocks_avx>:
      	400:       f3 0f 1e fa             endbr64
      	404:       44 8b 47 14             mov    0x14(%rdi),%r8d
      	408:       48 81 fa 80 00 00 00    cmp    $0x80,%rdx
      	40f:       73 09                   jae    41a <poly1305_blocks_avx+0x1a>
      	411:       45 85 c0                test   %r8d,%r8d
      	414:       0f 84 2a fc ff ff       je     44 <poly1305_blocks_x86_64+0x4>
      	...
      
      These are simple conditional tail-calls and *should* be recognised as
      such by objtool, however due to a mistake in commit 08f87a93
      ("objtool: Validate IBT assumptions") this is failing.
      
      Specifically, the jump_dest is +4, this means the instruction pointed
      at will not be ENDBR and as such it will fail the second clause of
      is_first_func_insn() that was supposed to capture this exact case.
      
      Instead, have is_first_func_insn() look at the previous instruction.
      
      Fixes: 08f87a93 ("objtool: Validate IBT assumptions")
      Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20220322115125.811582125@infradead.org
      d139bca4
    • Vincent Mailhol's avatar
      x86/bug: Prevent shadowing in __WARN_FLAGS · 9ce02f0f
      Vincent Mailhol authored
      The macro __WARN_FLAGS() uses a local variable named "f". This being a
      common name, there is a risk of shadowing other variables.
      
      For example, GCC would yield:
      
      | In file included from ./include/linux/bug.h:5,
      |                  from ./include/linux/cpumask.h:14,
      |                  from ./arch/x86/include/asm/cpumask.h:5,
      |                  from ./arch/x86/include/asm/msr.h:11,
      |                  from ./arch/x86/include/asm/processor.h:22,
      |                  from ./arch/x86/include/asm/timex.h:5,
      |                  from ./include/linux/timex.h:65,
      |                  from ./include/linux/time32.h:13,
      |                  from ./include/linux/time.h:60,
      |                  from ./include/linux/stat.h:19,
      |                  from ./include/linux/module.h:13,
      |                  from virt/lib/irqbypass.mod.c:1:
      | ./include/linux/rcupdate.h: In function 'rcu_head_after_call_rcu':
      | ./arch/x86/include/asm/bug.h:80:21: warning: declaration of 'f' shadows a parameter [-Wshadow]
      |    80 |         __auto_type f = BUGFLAG_WARNING|(flags);                \
      |       |                     ^
      | ./include/asm-generic/bug.h:106:17: note: in expansion of macro '__WARN_FLAGS'
      |   106 |                 __WARN_FLAGS(BUGFLAG_ONCE |                     \
      |       |                 ^~~~~~~~~~~~
      | ./include/linux/rcupdate.h:1007:9: note: in expansion of macro 'WARN_ON_ONCE'
      |  1007 |         WARN_ON_ONCE(func != (rcu_callback_t)~0L);
      |       |         ^~~~~~~~~~~~
      | In file included from ./include/linux/rbtree.h:24,
      |                  from ./include/linux/mm_types.h:11,
      |                  from ./include/linux/buildid.h:5,
      |                  from ./include/linux/module.h:14,
      |                  from virt/lib/irqbypass.mod.c:1:
      | ./include/linux/rcupdate.h:1001:62: note: shadowed declaration is here
      |  1001 | rcu_head_after_call_rcu(struct rcu_head *rhp, rcu_callback_t f)
      |       |                                               ~~~~~~~~~~~~~~~^
      
      For reference, sparse also warns about it, c.f. [1].
      
      This patch renames the variable from f to __flags (with two underscore
      prefixes as suggested in the Linux kernel coding style [2]) in order
      to prevent collisions.
      
      [1] https://lore.kernel.org/all/CAFGhKbyifH1a+nAMCvWM88TK6fpNPdzFtUXPmRGnnQeePV+1sw@mail.gmail.com/
      
      [2] Linux kernel coding style, section 12) Macros, Enums and RTL,
      paragraph 5) namespace collisions when defining local variables in
      macros resembling functions
      https://www.kernel.org/doc/html/latest/process/coding-style.html#macros-enums-and-rtl
      
      Fixes: bfb1a7c9 ("x86/bug: Merge annotate_reachable() into_BUG_FLAGS() asm")
      Signed-off-by: default avatarVincent Mailhol <mailhol.vincent@wanadoo.fr>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Link: https://lkml.kernel.org/r/20220324023742.106546-1-mailhol.vincent@wanadoo.fr
      9ce02f0f
  2. 04 Apr, 2022 1 commit
  3. 03 Apr, 2022 8 commits
  4. 02 Apr, 2022 29 commits