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 X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2DB6C10F0E for ; Fri, 12 Apr 2019 13:49:29 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 84E1720850 for ; Fri, 12 Apr 2019 13:49:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="sEtjEhLq"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="dPC6hmU5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 84E1720850 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Mime-Version:References:In-Reply-To: Message-Id:Subject: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=iGYsfTH6vgIjEBKuwlcD05cuUd86LeerDh6hBwO7Tk8=; b=sEtjEhLqtuXJwb /KoVJl5caG5xgUPTfkCi3zqtxSUyQFO0smzOdAPjxkjW4GMWbGrprT8YKOI+irD3GS0knYQMAqXfg 1nFJL8kPX9crLjJMV+PQOpk7lXgNMFGXldwRRmVjHtiqho2ZlcwO2vJ6RNuXryWTRbPO+lww3gK29 WZiHZ1F369hYZAb152HE0AYgM4biVwdmw4Wyi+RGvtCrkyZRDtH9I653SSNw8AcA9hYcMNOmB3ndW te7h9xVNoghkwH4DO+rwGfcMMRWwd7i4tgU276p9BzjZntnOlaJJxnOmh5fK5BG6GppE1u4yipoXX X0ucAgm2fmVbsecez58w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEwYW-0003ri-CO; Fri, 12 Apr 2019 13:49:24 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEwYT-0003rL-UK for linux-arm-kernel@lists.infradead.org; Fri, 12 Apr 2019 13:49:23 +0000 Received: from devnote2 (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8E3E92084D; Fri, 12 Apr 2019 13:49:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555076961; bh=/6YSBsCEYlkSXwaJHg4fmlnapDa79xojOFgqTwN7IDo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=dPC6hmU5VVHipggOy2xRcgC3X8cQ2Wsq1r6AcGlI4j4LITlc0pxkj0Gig6KTgYU1B kqNdmju8A3gEPuzNUavfSMHGlSMOcE2nntS1ZGFdyTvssr081bN1cEgT2EEZ+S2GT2 Jrxd6Ugkfv+xFrePTn68GonfQWdLhaCTm4zVF0pY= Date: Fri, 12 Apr 2019 22:49:16 +0900 From: Masami Hiramatsu To: Will Deacon Subject: Re: [PATCH] arm64: ptrace: Add function argument access API Message-Id: <20190412224916.fea6405337457c1242d8960a@kernel.org> In-Reply-To: <20190411172253.GH29081@fuggles.cambridge.arm.com> References: <155289594227.10570.1879705446198840331.stgit@devnote2> <20190403120649.GB29409@fuggles.cambridge.arm.com> <20190408093320.35f4050788937c995ca56a6b@kernel.org> <20190411172253.GH29081@fuggles.cambridge.arm.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190412_064922_011058_2074DDA6 X-CRM114-Status: GOOD ( 26.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Catalin Marinas , Oleg Nesterov , Steven Rostedt , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 11 Apr 2019 18:22:53 +0100 Will Deacon wrote: > On Mon, Apr 08, 2019 at 09:33:20AM +0900, Masami Hiramatsu wrote: > > On Wed, 3 Apr 2019 13:06:49 +0100 > > Will Deacon wrote: > > > On Mon, Mar 18, 2019 at 04:59:02PM +0900, Masami Hiramatsu wrote: > > > > Add regs_get_argument() which returns N th argument of the function > > > > call. On arm64, it supports up to 8th argument. > > > > Note that this chooses most probably assignment, in some case > > > > it can be incorrect (e.g. passing data structure or floating > > > > point etc.) > > > > > > > > This enables ftrace kprobe events to access kernel function > > > > arguments via $argN syntax. > > > > > > > > Signed-off-by: Masami Hiramatsu > > > > --- > > > > arch/arm64/Kconfig | 1 + > > > > arch/arm64/include/asm/ptrace.h | 18 ++++++++++++++++++ > > > > 2 files changed, 19 insertions(+) > > > > > > > > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > > > > index 117b2541ef3d..6ba0da4be73c 100644 > > > > --- a/arch/arm64/Kconfig > > > > +++ b/arch/arm64/Kconfig > > > > @@ -148,6 +148,7 @@ config ARM64 > > > > select HAVE_PERF_REGS > > > > select HAVE_PERF_USER_STACK_DUMP > > > > select HAVE_REGS_AND_STACK_ACCESS_API > > > > + select HAVE_FUNCTION_ARG_ACCESS_API > > > > select HAVE_RCU_TABLE_FREE > > > > select HAVE_RCU_TABLE_INVALIDATE > > > > select HAVE_RSEQ > > > > diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h > > > > index ec60174c8c18..cfa1bc9b8b70 100644 > > > > --- a/arch/arm64/include/asm/ptrace.h > > > > +++ b/arch/arm64/include/asm/ptrace.h > > > > @@ -305,6 +305,24 @@ static inline unsigned long regs_return_value(struct pt_regs *regs) > > > > return regs->regs[0]; > > > > } > > > > > > > > +/** > > > > + * regs_get_kernel_argument() - get Nth function argument in kernel > > > > + * @regs: pt_regs of that context > > > > + * @n: function argument number (start from 0) > > > > + * > > > > + * regs_get_argument() returns @n th argument of the function call. > > > > + * Note that this chooses most probably assignment, in some case > > > > + * it can be incorrect. > > > > > > In which cases would it be incorrect? I can imagine varargs causing > > > problems, but are there others? > > > > As far as I can read "Procedure Call Standard for the ARM 64-bit > > Architecture(AArch64) 5.4.2 Parameter Passing Rules", it may not return > > correct data if the target function has a parameter which is 16bytes > > or bigger size. Of course that is just a limitation of this interface. > > But anyway, it can return wrong data for the parameter after such big > > parameters. I think, for func(data-struct-128bits p1, u64 p2), p1 > > is stored into r0 and r1, and p2 is stored r2, is that correct? > > Oh, yes, passing things by value that don't fit in the registers will > obviously go wrong. Thanks. Do we do that in the kernel? No, as far as I know. But I can't say it never happens in the kernel. > > Anyway, please resend with the comment expanded a bit and using > pt_regs_read_reg(), then I can queue this up for 5.2. OK, I'll do. Thank you! > > Cheers, > > Will -- Masami Hiramatsu _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel