From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AD19C4332F for ; Fri, 18 Nov 2022 13:58:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241927AbiKRN62 (ORCPT ); Fri, 18 Nov 2022 08:58:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242072AbiKRN6I (ORCPT ); Fri, 18 Nov 2022 08:58:08 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 112A813CF1 for ; Fri, 18 Nov 2022 05:57:59 -0800 (PST) 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 3486023A; Fri, 18 Nov 2022 05:58:05 -0800 (PST) Received: from FVFF77S0Q05N.cambridge.arm.com (FVFF77S0Q05N.cambridge.arm.com [10.1.35.13]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BB4893F587; Fri, 18 Nov 2022 05:57:57 -0800 (PST) Date: Fri, 18 Nov 2022 13:57:52 +0000 From: Mark Rutland To: Will Deacon Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org, mhiramat@kernel.org, revest@chromium.org, rostedt@goodmis.org Subject: Re: [PATCH v2 4/4] ftrace: arm64: move from REGS to ARGS Message-ID: References: <20221103170520.931305-1-mark.rutland@arm.com> <20221103170520.931305-5-mark.rutland@arm.com> <20221115112701.GB32523@willie-the-truck> <20221118123149.GB3697@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221118123149.GB3697@willie-the-truck> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 18, 2022 at 12:31:50PM +0000, Will Deacon wrote: > On Thu, Nov 17, 2022 at 10:52:15AM +0000, Mark Rutland wrote: > > On Tue, Nov 15, 2022 at 11:27:03AM +0000, Will Deacon wrote: > > > On Thu, Nov 03, 2022 at 05:05:20PM +0000, Mark Rutland wrote: > > > > This commit replaces arm64's support for FTRACE_WITH_REGS with support > > > > for FTRACE_WITH_ARGS. This removes some overhead and complexity, and > > > > removes some latent issues with inconsistent presentation of struct > > > > pt_regs (which can only be reliably saved/restored at exception > > > > boundaries). > > > > > > [...] > > > > > > > @@ -78,10 +77,71 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr) > > > > return addr; > > > > } > > > > > > > > -#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS > > > > +#ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS > > > > struct dyn_ftrace; > > > > struct ftrace_ops; > > > > -struct ftrace_regs; > > > > + > > > > +#define arch_ftrace_get_regs(regs) NULL > > > > + > > > > +struct ftrace_regs { > > > > + /* x0 - x8 */ > > > > + unsigned long regs[9]; > > > > + unsigned long __unused; > > > > + > > > > + unsigned long fp; > > > > + unsigned long lr; > > > > + > > > > + unsigned long sp; > > > > + unsigned long pc; > > > > +}; > > > > + > > > > +static __always_inline unsigned long > > > > +ftrace_regs_get_instruction_pointer(const struct ftrace_regs *fregs) > > > > +{ > > > > + return fregs->pc; > > > > +} > > > > + > > > > +static __always_inline void > > > > +ftrace_regs_set_instruction_pointer(struct ftrace_regs *fregs, > > > > + unsigned long pc) > > > > +{ > > > > + fregs->pc = pc; > > > > +} > > > > + > > > > +static __always_inline unsigned long > > > > +ftrace_regs_get_stack_pointer(const struct ftrace_regs *fregs) > > > > +{ > > > > + return fregs->sp; > > > > +} > > > > + > > > > +static __always_inline unsigned long > > > > +ftrace_regs_get_argument(struct ftrace_regs *fregs, unsigned int n) > > > > +{ > > > > + if (n < 8) > > > > + return fregs->regs[n]; > > > > > > Where does this '8' come from? > > > > Because in AAPCS64 the arguments are in x0 to x7, as mentioned in the commit > > message: > > > > | Per AAPCS64, all function call argument and return values are held in > > | the following GPRs: > > | > > | * X0 - X7 : parameter / result registers > > | * X8 : indirect result location register > > | * SP : stack pointer (AKA SP) > > > > The 'indirect result location register' would be used when returning large > > structures, and isn't a function argument as such. > > Ah gotcha, I was mainly wondering about the role of x8 in 'struct > ftrace_regs', but now I see that the FETCH_OP_REG might want to get at that. Ah, I see. Should I just add the bits above from the commit message into a comment block above the definition of struct ftrace_regs ? Thanks, Mark. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C1C17C433FE for ; Fri, 18 Nov 2022 13:59:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tWz2A260ExWpD47CPw1NPzPGF/b0J4/qhvy7ZGyv9jY=; b=bxLp24QPKFGDsY Tcq9ZjeEXU2BSMbmsXSjjkFeZE0ec++xz6wa7sWcI8DNsI6FzDImpPPUzOb2x6fpQ2F2hm/sZ+XBL q+DlkKX7D0tppRjw41ui58usKlSqiIAye6or0USGkLQiLkjEQkPVA/H+C5CEScdJScFTjIg87rAXq DJ9hZVuzxSXs+jSaLc/WyjXGZQyljwHT0Fbey5avWzyNnoGutoogMjVfXYegXmCiEdoUvtt6Ttbb3 ilVSYoDrfyzc8PxRXgoOrM+hg++4mFgtADq/xQQvhcIZTQSy5zBLBzinqPcaHQwq8FDUjz+hHCNmc bz/0of3IGWnsygfH2a4g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ow1sb-004FsY-A8; Fri, 18 Nov 2022 13:58:05 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ow1sY-004FqV-2H for linux-arm-kernel@lists.infradead.org; Fri, 18 Nov 2022 13:58:03 +0000 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 3486023A; Fri, 18 Nov 2022 05:58:05 -0800 (PST) Received: from FVFF77S0Q05N.cambridge.arm.com (FVFF77S0Q05N.cambridge.arm.com [10.1.35.13]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BB4893F587; Fri, 18 Nov 2022 05:57:57 -0800 (PST) Date: Fri, 18 Nov 2022 13:57:52 +0000 From: Mark Rutland To: Will Deacon Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org, mhiramat@kernel.org, revest@chromium.org, rostedt@goodmis.org Subject: Re: [PATCH v2 4/4] ftrace: arm64: move from REGS to ARGS Message-ID: References: <20221103170520.931305-1-mark.rutland@arm.com> <20221103170520.931305-5-mark.rutland@arm.com> <20221115112701.GB32523@willie-the-truck> <20221118123149.GB3697@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221118123149.GB3697@willie-the-truck> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221118_055802_223173_AE85CD8F X-CRM114-Status: GOOD ( 25.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Nov 18, 2022 at 12:31:50PM +0000, Will Deacon wrote: > On Thu, Nov 17, 2022 at 10:52:15AM +0000, Mark Rutland wrote: > > On Tue, Nov 15, 2022 at 11:27:03AM +0000, Will Deacon wrote: > > > On Thu, Nov 03, 2022 at 05:05:20PM +0000, Mark Rutland wrote: > > > > This commit replaces arm64's support for FTRACE_WITH_REGS with support > > > > for FTRACE_WITH_ARGS. This removes some overhead and complexity, and > > > > removes some latent issues with inconsistent presentation of struct > > > > pt_regs (which can only be reliably saved/restored at exception > > > > boundaries). > > > > > > [...] > > > > > > > @@ -78,10 +77,71 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr) > > > > return addr; > > > > } > > > > > > > > -#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS > > > > +#ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS > > > > struct dyn_ftrace; > > > > struct ftrace_ops; > > > > -struct ftrace_regs; > > > > + > > > > +#define arch_ftrace_get_regs(regs) NULL > > > > + > > > > +struct ftrace_regs { > > > > + /* x0 - x8 */ > > > > + unsigned long regs[9]; > > > > + unsigned long __unused; > > > > + > > > > + unsigned long fp; > > > > + unsigned long lr; > > > > + > > > > + unsigned long sp; > > > > + unsigned long pc; > > > > +}; > > > > + > > > > +static __always_inline unsigned long > > > > +ftrace_regs_get_instruction_pointer(const struct ftrace_regs *fregs) > > > > +{ > > > > + return fregs->pc; > > > > +} > > > > + > > > > +static __always_inline void > > > > +ftrace_regs_set_instruction_pointer(struct ftrace_regs *fregs, > > > > + unsigned long pc) > > > > +{ > > > > + fregs->pc = pc; > > > > +} > > > > + > > > > +static __always_inline unsigned long > > > > +ftrace_regs_get_stack_pointer(const struct ftrace_regs *fregs) > > > > +{ > > > > + return fregs->sp; > > > > +} > > > > + > > > > +static __always_inline unsigned long > > > > +ftrace_regs_get_argument(struct ftrace_regs *fregs, unsigned int n) > > > > +{ > > > > + if (n < 8) > > > > + return fregs->regs[n]; > > > > > > Where does this '8' come from? > > > > Because in AAPCS64 the arguments are in x0 to x7, as mentioned in the commit > > message: > > > > | Per AAPCS64, all function call argument and return values are held in > > | the following GPRs: > > | > > | * X0 - X7 : parameter / result registers > > | * X8 : indirect result location register > > | * SP : stack pointer (AKA SP) > > > > The 'indirect result location register' would be used when returning large > > structures, and isn't a function argument as such. > > Ah gotcha, I was mainly wondering about the role of x8 in 'struct > ftrace_regs', but now I see that the FETCH_OP_REG might want to get at that. Ah, I see. Should I just add the bits above from the commit message into a comment block above the definition of struct ftrace_regs ? Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel