Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp741396pxb; Fri, 22 Apr 2022 10:11:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywyygb0U5G4taS4ZpaPMK4XG6v3Qn5tZcpejumoFKBAfc9tA83bE5qc/200HfVMK/qQLcy X-Received: by 2002:a17:902:9a81:b0:158:1c91:4655 with SMTP id w1-20020a1709029a8100b001581c914655mr5723655plp.162.1650647508958; Fri, 22 Apr 2022 10:11:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650647508; cv=none; d=google.com; s=arc-20160816; b=Xpmfo4lEhY07AY9x564ZKG2jSiQ332PrNqtjyzkTmEdhIwOT41lqnMm2l8ltA2Gan3 DASAVpIXq44xZM82PxbontQ59T1XW2P4gceUzWPKFaww+qVGZOQGgJzyByyUer2Pa+Rj V+rj2wK1J+DP7rksXPATkXHc2G3gB/dV8+WUZPIKuJaKoFIpnDjAcyzOLMpahqExrc12 gFicEoUhVz0cuBZi4PB/hTyvWRkyLqoliOG/TBHhETNPzoYNtJTSENKneGaJ3KtP0jRo zNvI6RADfGUxjKtNGEXgvrTFq8yHIEjMIiKNIF8PU/4TPWlsdcZKqnlRXYebbJwCYs2S xW0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=buE3fKl9ggtbbrgGjp28kGp8TEgXxOQU8so5LDW0X/A=; b=OQ7aXfXDiCXkmleYZQgccHww+w9Xv5YAhdfj9hNCsSQqEB7WxncB1BuF6xGKlJ9R9i 9Xt7OfA/TBGvRDGfS6Rv/4+UiR6IqwtvUZ3vLYDY6N3xWHhmOpqe/jvO8kVcjun+9ZXv h8kOd+F6ewdVG14es/3tx34j6FUhE8A7qyysrKR4s1VwryFsi9tqPXaqROe4iTMADGxR MhKnSRFiqP3NAaLinquqzlpPMydTAylI8wyBaeOsJsqfO41H8RIVBG6l4G3idGEj4eIa CaVLtNNBKN/Zht44HFE+xZXXFwP1LNfKzJRafSZMDoNGVT+/50V4OjWUUXjwcgQmpyId Tvzw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x35-20020a634a23000000b003816043efcdsi8660782pga.450.2022.04.22.10.11.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 10:11:48 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CA8E397B83; Fri, 22 Apr 2022 10:11:28 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233819AbiDVKPl (ORCPT + 99 others); Fri, 22 Apr 2022 06:15:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233775AbiDVKPk (ORCPT ); Fri, 22 Apr 2022 06:15:40 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8CDC253A7E for ; Fri, 22 Apr 2022 03:12:46 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4CAD31576; Fri, 22 Apr 2022 03:12:46 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.74.110]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7D0D33F766; Fri, 22 Apr 2022 03:12:44 -0700 (PDT) Date: Fri, 22 Apr 2022 11:12:39 +0100 From: Mark Rutland To: Steven Rostedt Cc: Wang ShaoBo , cj.chengjian@huawei.com, huawei.libin@huawei.com, xiexiuqi@huawei.com, liwei391@huawei.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org, zengshun.wu@outlook.com Subject: Re: [RFC PATCH -next v2 3/4] arm64/ftrace: support dynamically allocated trampolines Message-ID: References: <20220316100132.244849-1-bobo.shaobowang@huawei.com> <20220316100132.244849-4-bobo.shaobowang@huawei.com> <20220421100639.03c0d123@gandalf.local.home> <20220421114201.21228eeb@gandalf.local.home> <20220421130648.56b21951@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220421130648.56b21951@gandalf.local.home> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no 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 On Thu, Apr 21, 2022 at 01:06:48PM -0400, Steven Rostedt wrote: > On Thu, 21 Apr 2022 17:27:40 +0100 > Mark Rutland wrote: > > > We can initialize the ops pointer to a default ops that does the whole > > __do_for_each_ftrace_ops() dance. > > OK, I think I understand now. What you are doing is instead of creating a > trampoline that has all the information in the trampoline, you add nops to > all the functions where you can place the information in the nops (before > the function), and then have the trampoline just read that information to > find the ops pointer as well as the function to call. Yup! > I guess you could have two trampolines as well. One that always calls the > list loop, and one that calls the data stored in front of the function that > was just called the trampoline. As it is always safe to call the loop > function, you could have the call call that trampoline first, set up the > specific data before the function, then call the trampoline that will read > it. And same thing for tear down. Having separate trampolines is possible, but there are some complications, and we might end up with an explosion of trampolines (and associated module PLTs) due to needing BTI/!BTI and REGs/!REGS variants, so if it's possible to have a default ops that handled the list case, that'd be my preference to keep that simple and manageable. As an aside, I'd also love to remove the REGS/!REGs distinction, and always save a minimum amount of state (like ARGS, but never saving a full pt_regs), since on arm64 the extra state stored for the REGS case isn't useful (and we can't reliably capture all of the pt_regs state anyway, so bits of it are made up or not filled in). Thanks, Mark.