Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp667667iog; Thu, 30 Jun 2022 08:01:59 -0700 (PDT) X-Google-Smtp-Source: AGRyM1utoambpn8LurcHQA09ulBBjqdzwmBaiPOXplY6iVnNq7CerLwXLQAysAkL9aVs4vbLrDDl X-Received: by 2002:a17:902:c401:b0:16a:1873:5ca3 with SMTP id k1-20020a170902c40100b0016a18735ca3mr16039634plk.157.1656601319362; Thu, 30 Jun 2022 08:01:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656601319; cv=none; d=google.com; s=arc-20160816; b=xfGN/MFuVhd5nYkLk7SWcOZa0MBfyYQv42W8c9ycwSy28dKKOqr0qsfCY5R0zkeX9s tmXqdka5EhMbgx3jHn/jWjODTydsdYs/4oRZs7IUfgHVGs5l1AVUO1fjHhaIA4E/fRT9 cszMK7hU4Hvdef+fbfFnbjXmDLgLdCoq1vU+4ceR5hRkXPiZoZQWRLRjrPoVMklKehI2 Fiqrn4h/VwVJ/2159C47osPYFOqHS/L2nGJWQeCZdbRz7+DUp9H2rRzkN2xZO1v1N3W5 Ur3wBvLAc7WVrUTYFPjt5NWxp5PvNqIFJjI4V92dGKftUYu0zNW0ZKEDWJe/cZxdocDh C5Dg== 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=nkLG1PoATS9pc8bctGUVJSHX0tPRJbyulNiBmgX/LDI=; b=G4YF9ZSoZ325SzvonRTBwCNY8amsfBN4q7zJ/2junVgjSQ72wfy9VAjW2iU03zdJ8m 0/gLiv10c7HORTzKxLyG/qJ2GQLLms1mNOUqa3RAHxnYeyQ5AQa2i7YsUN3ZBdawEWjm lrvvVlex6EQjs2J2Ole7EY6PTKlwh3/lhsQoO2G271O5WflhvnjBCAkX0x5dZjZKr6Nm 7H7pcxPYCFyQxaH9qlt+K6aeprhCNaUW4DDxgPxXa+EdSHE47TGELLmnERMrX1efn9n4 iAYjdGYeZlLWEQvQY0YQ4QlV9dohEpghVSC4p5zXorNn0DnPXkEo+0AhQYnnFDjFqwQB QWwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uE0IFEyw; 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 a7-20020a654187000000b004051d974ce4si14407071pgq.458.2022.06.30.08.01.38; Thu, 30 Jun 2022 08:01:59 -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=uE0IFEyw; 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 S236615AbiF3OGW (ORCPT + 99 others); Thu, 30 Jun 2022 10:06:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236391AbiF3OFx (ORCPT ); Thu, 30 Jun 2022 10:05:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D06DC4D16A; Thu, 30 Jun 2022 06:54:01 -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 ams.source.kernel.org (Postfix) with ESMTPS id CD68EB82AD8; Thu, 30 Jun 2022 13:53:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32FCAC34115; Thu, 30 Jun 2022 13:53:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656597237; bh=5cYcswnD9bzIj7ja95kn+E7EGC6en3Fc8aGW1HQhA4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uE0IFEywkRw/ffiMCxGoJ5Iyy1YJprp7ZSZTYeFBA1wgO5R5vsLcOXrV6nn/gp2T6 hfMIrV3Zg/bSNd5KPFT5raAwQ8gQbBwDhwj4At9lh8Ve7ly5PoE66/MDsAXQYmQJ6G BGECJjPw2lZF5XsYXgw2/ONfYW/gHPNS5AxaqKbA= 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.10 11/12] powerpc/ftrace: Remove ftrace init tramp once kernel init is complete Date: Thu, 30 Jun 2022 15:47:16 +0200 Message-Id: <20220630133231.025237779@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220630133230.676254336@linuxfoundation.org> References: <20220630133230.676254336@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? */ @@ -882,6 +880,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 @@ -51,6 +51,7 @@ #include #include #include +#include #include @@ -347,6 +348,7 @@ void free_initmem(void) mark_initmem_nx(); init_mem_is_free = true; free_initmem_default(POISON_FREE_INITMEM); + ftrace_free_init_tramp(); } /**