Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp126413iof; Sun, 5 Jun 2022 23:09:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZhRdWTgIGDNIfAbIS9itcnPqCKV+iuDm5/2A5dhBGp6yPdrlaBHBeXdwnKH4xyKQHdIZX X-Received: by 2002:a17:903:208:b0:162:284:3396 with SMTP id r8-20020a170903020800b0016202843396mr23116307plh.121.1654495759745; Sun, 05 Jun 2022 23:09:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654495759; cv=none; d=google.com; s=arc-20160816; b=wsHIGimZJkc+HrKyHUqBsRSpLKtGh/2auU1JKzej222kEzyLvahRIqUadAVU23/2WD WCbVtiim0jaTstUMLVIaZ41vGD120AUATP9ldncRLk/UlVBGwPwm8L4w8Ncbc+p+DYaF w0c9gpn906T8M/ls7SA26t4wp5AIfBvMhzMBaCCKxvbrmLXD8FwsBtba2YaKO0EOOAue 9gQgJ0y+rILogSkKDCYuN5dE9I7zhXporZ4DNrTgCLnx4kgW7rie2k5nvIinemMKhMxB Vkmmbz6kQ5WlXw8kq7y525OomZPnSI1keKFYrYyHVfmAhgCw9+x6/bn/4ekJ15ZEpj1Z UnOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=AisYuyQE1BLoKfsx8HMMMhB6h0wNydb4ICwTHQA//J8=; b=eq2aQCpN4sZao7oR06QU1DQZ/24fZlW5NC7HmVT7kUIZvgzM2ibC70F+2tOCmoXRle p9c8QdP4X8sfVshQW5mClc1WjEBgmJM0n8k6l3vFlM2H+cav7kwcKbar4nW2d10A854S iZqJyzo3sChsCAr3feyzYY5tHNjn3YvevCT9Nj9Ipv4HXJvYLP7Q9Pae0yZC3cZrTAd9 PJfkU26Jw0I3B6Gh4Ucv0zEiMqi7U6mrccjVixpCcAogxxWer8ee4fY5vPunjd7FUPmf VkOmIBuYMv4GbtcB6ZYF/K9i0ZX/RT95pjXlB6wyGWFHWT030nmnGEeam5CTffmpBRzh 0IYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iaB3A9y2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id l190-20020a6388c7000000b003db48a0c6ecsi19828168pgd.792.2022.06.05.23.09.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 23:09:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iaB3A9y2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 327A0B6400; Sun, 5 Jun 2022 22:00:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245310AbiFCPEx (ORCPT + 99 others); Fri, 3 Jun 2022 11:04:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244661AbiFCPEv (ORCPT ); Fri, 3 Jun 2022 11:04:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE27C64D8 for ; Fri, 3 Jun 2022 08:04:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8A91B616F9 for ; Fri, 3 Jun 2022 15:04:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD885C385A9; Fri, 3 Jun 2022 15:04:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654268690; bh=lwutLgb9SNOCxmpQkrrPjmYr91eeRNJxGbGYmZ6+CXI=; h=From:To:Cc:Subject:Date:From; b=iaB3A9y22XEAuVmr8z1+mkmxwgdlJPj0cehin/oAo7lAZv+VKBCFWL6miUtnf8ujs Mtdej2X1gwAEl38iXH9+AuFF+C7Sa6BJUJdvxNssnVqYekx4lsJ6eIN2b4knXyaLUS MtlOcShlpCOOc6Azq1vbrbrx0H0hM7Mxy3Qegud69oF/SEh7/9pFYj4QBJWGyCN5QV 56F7gZUJSLjWHeD0XIpYiYLH9O59TR0ysJ6lJdlLzP6ziUNsrNQXuG3anlCo7+CFqp jCpgAI9MGBTBujBasmglF4ZtdtN8dmpeX7X0vqLrZu5X6N3ETvCA8GRx+K2h6fEBbd csNNWDlVwAi8g== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Steven Rostedt , Peter Zijlstra , kernel test robot Subject: [PATCH v2] x86/ftrace: Remove OBJECT_FILES_NON_STANDARD usage Date: Fri, 3 Jun 2022 08:04:44 -0700 Message-Id: X-Mailer: git-send-email 2.34.3 MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The file-wide OBJECT_FILES_NON_STANDARD annotation is used with CONFIG_FRAME_POINTER to tell objtool to skip the entire file when frame pointers are enabled. However that annotation is now deprecated because it doesn't work with IBT, where objtool runs on vmlinux.o instead of individual translation units. Instead, use more fine-grained function-specific annotations: - The 'save_mcount_regs' macro does funny things with the frame pointer. Use STACK_FRAME_NON_STANDARD_FP to tell objtool to ignore the functions using it. - The return_to_handler() "function" isn't actually a callable function. Instead of being called, it's returned to. The real return address isn't on the stack, so unwinding is already doomed no matter which unwinder is used. So just remove the STT_FUNC annotation, telling objtool to ignore it. That also removes the implicit ANNOTATE_NOENDBR, which now needs to be made explicit. Fixes the following warning: vmlinux.o: warning: objtool: __fentry__+0x16: return with modified stack frame Fixes: ed53a0d97192 ("x86/alternative: Use .ibt_endbr_seal to seal indirect calls") Reported-by: kernel test robot Signed-off-by: Josh Poimboeuf --- v2: - fix return_to_handler() arch/x86/kernel/Makefile | 4 ---- arch/x86/kernel/ftrace_64.S | 11 ++++++++--- include/linux/objtool.h | 6 ++++++ tools/include/linux/objtool.h | 6 ++++++ 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index 03364dc40d8d..4c8b6ae802ac 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile @@ -36,10 +36,6 @@ KCSAN_SANITIZE := n OBJECT_FILES_NON_STANDARD_test_nx.o := y -ifdef CONFIG_FRAME_POINTER -OBJECT_FILES_NON_STANDARD_ftrace_$(BITS).o := y -endif - # If instrumentation of this dir is enabled, boot hangs during first second. # Probably could be more selective here, but note that files related to irqs, # boot, dumpstack/stacktrace, etc are either non-interesting or can lead to diff --git a/arch/x86/kernel/ftrace_64.S b/arch/x86/kernel/ftrace_64.S index 4ec13608d3c6..dfeb227de561 100644 --- a/arch/x86/kernel/ftrace_64.S +++ b/arch/x86/kernel/ftrace_64.S @@ -175,6 +175,7 @@ SYM_INNER_LABEL(ftrace_caller_end, SYM_L_GLOBAL) jmp ftrace_epilogue SYM_FUNC_END(ftrace_caller); +STACK_FRAME_NON_STANDARD_FP(ftrace_caller) SYM_FUNC_START(ftrace_epilogue) /* @@ -282,6 +283,7 @@ SYM_INNER_LABEL(ftrace_regs_caller_end, SYM_L_GLOBAL) jmp ftrace_epilogue SYM_FUNC_END(ftrace_regs_caller) +STACK_FRAME_NON_STANDARD_FP(ftrace_regs_caller) #else /* ! CONFIG_DYNAMIC_FTRACE */ @@ -311,10 +313,14 @@ trace: jmp ftrace_stub SYM_FUNC_END(__fentry__) EXPORT_SYMBOL(__fentry__) +STACK_FRAME_NON_STANDARD_FP(__fentry__) + #endif /* CONFIG_DYNAMIC_FTRACE */ #ifdef CONFIG_FUNCTION_GRAPH_TRACER -SYM_FUNC_START(return_to_handler) +SYM_CODE_START(return_to_handler) + UNWIND_HINT_EMPTY + ANNOTATE_NOENDBR subq $16, %rsp /* Save the return values */ @@ -339,7 +345,6 @@ SYM_FUNC_START(return_to_handler) int3 .Ldo_rop: mov %rdi, (%rsp) - UNWIND_HINT_FUNC RET -SYM_FUNC_END(return_to_handler) +SYM_CODE_END(return_to_handler) #endif diff --git a/include/linux/objtool.h b/include/linux/objtool.h index 6491fa8fba6d..15b940ec1eac 100644 --- a/include/linux/objtool.h +++ b/include/linux/objtool.h @@ -143,6 +143,12 @@ struct unwind_hint { .popsection .endm +.macro STACK_FRAME_NON_STANDARD_FP func:req +#ifdef CONFIG_FRAME_POINTER + STACK_FRAME_NON_STANDARD \func +#endif +.endm + .macro ANNOTATE_NOENDBR .Lhere_\@: .pushsection .discard.noendbr diff --git a/tools/include/linux/objtool.h b/tools/include/linux/objtool.h index 6491fa8fba6d..15b940ec1eac 100644 --- a/tools/include/linux/objtool.h +++ b/tools/include/linux/objtool.h @@ -143,6 +143,12 @@ struct unwind_hint { .popsection .endm +.macro STACK_FRAME_NON_STANDARD_FP func:req +#ifdef CONFIG_FRAME_POINTER + STACK_FRAME_NON_STANDARD \func +#endif +.endm + .macro ANNOTATE_NOENDBR .Lhere_\@: .pushsection .discard.noendbr -- 2.34.3