• 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
check.c 91.5 KB