Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp653250iog; Thu, 30 Jun 2022 07:44:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vQkIGS4adu0KeVorNRbWBX+3UtOOq58AWqOoV9QI2YkaTXIG/HtQxPgB1djqkm1CON6hYf X-Received: by 2002:a17:90b:4c4e:b0:1ec:bc42:47c2 with SMTP id np14-20020a17090b4c4e00b001ecbc4247c2mr12078468pjb.180.1656600277033; Thu, 30 Jun 2022 07:44:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656600277; cv=none; d=google.com; s=arc-20160816; b=Fd5SOGK2EiwNVoUnVsRMI1SR/EN3FSbc7BCvaKHBAyyEeNFpnOxZ/sz30vJzYXT9+Q HPtc40mIC7SF2esGNiEXap1gNbPu/qWfIdfLlm+mmXD+eAtJnzFgT7VTtWv5ZCTCWqZY RJo7WAiIJJJ6zmBXowwXtNTQdz0fn3ipUQ0ixnJaYmfgorYiqukj3f9X+aDyirnwfafm BBzGwvL87kfTKBYwahfQiQ8Et6nXu30hjzp8/dSAcQUQ9dJo9fzyMBBvpe1O7I6lYlS9 cj9DpT64YpMEkmYWbLVUpaSPQetvbU3UeBIf0CJBReWloAkWSCh0cC673fPnNYSuQDIQ 2e+w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3LnIqwou/Yz252yleDqcnRQO7rLUGl5I757kyLzG3F0=; b=zrLdGjrwELghsWtEvVH/wwP3D32Iqrht2J1IF5SxXzMLUxUMTHdhSnNoFw5OXQ4VYN VPLg7yeolaPcvsRy2YD1HQB469NyiqAS2Vu8yUiVIBQGfQYQ/2YXIIY/e16ZLWr7fZub 8vnOwrSlpEn3ZM+/q28oFrZJmfQ/yUv8xt+FYNpvALVGuwKE2xTYYrzsMnsxLctUFyXX XfXwHysWzR9G7Q1HZERe4UZdYVBDsafFiytkgjTnBcJ+zTonOjjgDPI2/ASGU5vfakGc M9FUdZuuE6+tRy51NIc3FZUMmNdlp4AgkG6ZVR6RyQZsSJb0slmhWfuI86/zi/fMFg+/ wKzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lpdtLjUl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c9-20020a6566c9000000b003fbb432d3c0si25695351pgw.643.2022.06.30.07.44.25; Thu, 30 Jun 2022 07:44:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lpdtLjUl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236745AbiF3OJD (ORCPT + 99 others); Thu, 30 Jun 2022 10:09:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236888AbiF3OHp (ORCPT ); Thu, 30 Jun 2022 10:07:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDCC252381; Thu, 30 Jun 2022 06:54:48 -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 BAC8B61F60; Thu, 30 Jun 2022 13:54:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA16CC34115; Thu, 30 Jun 2022 13:54:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656597276; bh=RigtA1BiIGHp2gLYVvSviVkMwmXYFkmrxHW5jWB/gIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lpdtLjUlOpcxdijuGK5j4oxwGFFOcpyDBV0py8AyywOfJIfme2NRqDKfAh5dTMgeU b7rLPVZBlm7BZ7GxMlmH9UUmUAomzJtDMalxdKhAHDtdaQlwJqtn07tvnhasDdF61K EgCQB3E9Donfwoiob2fRHBlfr3x5Tza9uSTv59c8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Naveen N. Rao" , Michael Ellerman Subject: [PATCH 5.15 12/28] powerpc/ftrace: Remove ftrace init tramp once kernel init is complete Date: Thu, 30 Jun 2022 15:47:08 +0200 Message-Id: <20220630133233.288523016@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220630133232.926711493@linuxfoundation.org> References: <20220630133232.926711493@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: Naveen N. Rao commit 84ade0a6655bee803d176525ef457175cbf4df22 upstream. Stop using the ftrace trampoline for init section once kernel init is complete. Fixes: 67361cf8071286 ("powerpc/ftrace: Handle large kernel configs") Cc: stable@vger.kernel.org # v4.20+ Signed-off-by: Naveen N. Rao Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220516071422.463738-1-naveen.n.rao@linux.vnet.ibm.com Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/include/asm/ftrace.h | 4 +++- arch/powerpc/kernel/trace/ftrace.c | 15 ++++++++++++--- arch/powerpc/mm/mem.c | 2 ++ 3 files changed, 17 insertions(+), 4 deletions(-) --- a/arch/powerpc/include/asm/ftrace.h +++ b/arch/powerpc/include/asm/ftrace.h @@ -96,7 +96,7 @@ static inline bool arch_syscall_match_sy #endif /* PPC64_ELF_ABI_v1 */ #endif /* CONFIG_FTRACE_SYSCALLS */ -#ifdef CONFIG_PPC64 +#if defined(CONFIG_PPC64) && defined(CONFIG_FUNCTION_TRACER) #include static inline void this_cpu_disable_ftrace(void) @@ -120,11 +120,13 @@ static inline u8 this_cpu_get_ftrace_ena return get_paca()->ftrace_enabled; } +void ftrace_free_init_tramp(void); #else /* CONFIG_PPC64 */ static inline void this_cpu_disable_ftrace(void) { } static inline void this_cpu_enable_ftrace(void) { } static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled) { } static inline u8 this_cpu_get_ftrace_enabled(void) { return 1; } +static inline void ftrace_free_init_tramp(void) { } #endif /* CONFIG_PPC64 */ #endif /* !__ASSEMBLY__ */ --- a/arch/powerpc/kernel/trace/ftrace.c +++ b/arch/powerpc/kernel/trace/ftrace.c @@ -336,9 +336,7 @@ static int setup_mcount_compiler_tramp(u /* Is this a known long jump tramp? */ for (i = 0; i < NUM_FTRACE_TRAMPS; i++) - if (!ftrace_tramps[i]) - break; - else if (ftrace_tramps[i] == tramp) + if (ftrace_tramps[i] == tramp) return 0; /* Is this a known plt tramp? */ @@ -881,6 +879,17 @@ void arch_ftrace_update_code(int command extern unsigned int ftrace_tramp_text[], ftrace_tramp_init[]; +void ftrace_free_init_tramp(void) +{ + int i; + + for (i = 0; i < NUM_FTRACE_TRAMPS && ftrace_tramps[i]; i++) + if (ftrace_tramps[i] == (unsigned long)ftrace_tramp_init) { + ftrace_tramps[i] = 0; + return; + } +} + int __init ftrace_dyn_arch_init(void) { int i; --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -314,6 +315,7 @@ void free_initmem(void) mark_initmem_nx(); init_mem_is_free = true; free_initmem_default(POISON_FREE_INITMEM); + ftrace_free_init_tramp(); } /*