Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp665693iog; Thu, 30 Jun 2022 08:00:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sibwy5HQJfpUXhEpdXDazcuisu6yHXurVxA9qECVsFqop09xESrNCvpnsz/E0WTpQVcZz3 X-Received: by 2002:a17:902:f151:b0:16a:466a:4ae4 with SMTP id d17-20020a170902f15100b0016a466a4ae4mr15521770plb.61.1656601219335; Thu, 30 Jun 2022 08:00:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656601219; cv=none; d=google.com; s=arc-20160816; b=IyUDN6TwBJQzjUx0x2UDpW7xw5ZNzcb5HWcnn9N+P/w8IzZz3z2UnFOeswKXhindmB kOieSi7fWo45Mnx3yjY3JKH2KEdUlx/uHD0YroonATwXTYdaKZsOJw0P/CRtpH99o/bI NQh4koxVw/SA5KjCHG4PpYUanlmAE6PEvMVxp1W3fTXMFqU7veR30rtXrI2xc1HFO2c2 wGXtaULVguUBo7YQ6/IFOzGOJ75P015pSemG8i6/TiWtOPjJ0rUdsJkFtN1+ORDIFuin CGpg1mA3IxFkYSoKYeWHCxoF1GKIMVClQWwnDtY325J4LXHNTX+5L3ijU91Ot/XIinFz Fu1w== 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=calzhJh3+ZUUuIsa7HiWyTVYMteC9YbN6OrRsJEQPwA=; b=ePNrrW8XJYoYgVz2upZ1rrGLksaQuLC8EhJqJOCsrDgirMT72nkYsr0onC+VwjqtTM MY7ai9Y0lyWuQfZo+nZ8mk78tzsW0YFtPJtgIN5A9VvazY4meRTA6uU9dlBwd1/Tiscx JzsvP880sySRKvasE7BN/Y1q1RW6ffhiXfA8fCRdnqxl5O9cRaBNbPeBTdmzlV8tpyGY C8V5Q7Fpo0bw7owLdsNZ+td3CIhytuDHFQO4KWphpc4Em9UtDqYyfPXLTo11MdNQ5Q29 etTLWF/YVuK5QIBzrggbCvRN0Lu38+Ob2nJx8UZ/mqd7HlEk7HOo2VIuReNFRjv3G2oz /L4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hjIFpEor; 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 m10-20020a170902f64a00b0016793c0e3dcsi26317968plg.545.2022.06.30.08.00.01; Thu, 30 Jun 2022 08:00:19 -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=hjIFpEor; 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 S236993AbiF3OMZ (ORCPT + 99 others); Thu, 30 Jun 2022 10:12:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236538AbiF3OLP (ORCPT ); Thu, 30 Jun 2022 10:11:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EB727C1B5; Thu, 30 Jun 2022 06:55:59 -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 0BD576204B; Thu, 30 Jun 2022 13:55:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1327FC34115; Thu, 30 Jun 2022 13:55:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656597358; bh=OaN9Xtb+HK3G1FPwqyeCfvjC3Ef/GbvvmjKvofkkCPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hjIFpEor6tc5upuCQ0N0KiI1ABj89DrqIzvDIzh/ce2Ra158fl7rC77gS2ZAjYse5 80BGi6aGRJlfcXTl2E3oKGFfaiLMW9Hf50I1vLSn9+SFHbojASwny/cUdNWMxaODxm XfPd2TI9cF7pXqmZ7nM6jkK8x+i4L0os+tpgw7C8= 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.18 5/6] powerpc/ftrace: Remove ftrace init tramp once kernel init is complete Date: Thu, 30 Jun 2022 15:47:31 +0200 Message-Id: <20220630133230.402616375@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220630133230.239507521@linuxfoundation.org> References: <20220630133230.239507521@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 @@ -86,7 +86,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) @@ -110,11 +110,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 @@ -306,9 +306,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? */ @@ -863,6 +861,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 @@ -312,6 +313,7 @@ void free_initmem(void) ppc_md.progress = ppc_printk_progress; mark_initmem_nx(); free_initmem_default(POISON_FREE_INITMEM); + ftrace_free_init_tramp(); } /*