From patchwork Mon Mar 18 07:59:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 10856955 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35A3C15AC for ; Mon, 18 Mar 2019 07:59:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 075C12874E for ; Mon, 18 Mar 2019 07:59:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDAE6287FB; Mon, 18 Mar 2019 07:59:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EAC03286C1 for ; Mon, 18 Mar 2019 07:59:11 +0000 (UTC) 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:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=OuIerHtQbNUlimD8Awf6qEE/p4zMwSAlAzk3ObR03kA=; b=Z5hSkGBdCYkcQD VZiu8arFeL4k659prWH0mXZZbU9hxNT8NDbvrI+Csu/87Agqx3YYfnWHWdNic2NQLfKmtemzXuuQX y2ggS6UQUGi2/yr56NL8fUYzAp07/oU4GzS4hMFnbj/TTzbfI0PBsitCURPB3057/CVBtQwePe2W8 f4nwBENPWzOKWMPK4J/LnaFXoRFLW7UNPmN9pdjGSohelSpm4oad6Vlt4xkC6d+pzQBKWchFiO2pT IvK4zNlAij8Bw2hh0qLJNdGaQOtBveiroSGB/3BXV9j9tDji9c7QpZric4w0G4FaxLD05wdrLZelt dY+y9LyWNKvKeq7ZwLqw==; 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 1h5nAs-0006Uc-K0; Mon, 18 Mar 2019 07:59:10 +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 1h5nAp-0006UI-Ka for linux-arm-kernel@lists.infradead.org; Mon, 18 Mar 2019 07:59:08 +0000 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8669B20835; Mon, 18 Mar 2019 07:59:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552895945; bh=673SMqkAlXA8cblGV2cyAlD79kgMIFkPnnhL+OUh9L8=; h=From:To:Cc:Subject:Date:From; b=lsBGQbEDhW3pXZVrhWEEE2thxVdaCWqiX1o+Eno5RlYa/YPmlTf9gVIDDH0dWi3D+ U3rBHsNjm/hpFoYA8PNjfZlBNRrXwbwa2eBIPnY1uO0gq71TowJw/MqRPq16fSCRpn w/424whUBcCviOPpYxVDUi3AGNEcAzIIOrktCP5c= From: Masami Hiramatsu To: Catalin Marinas , Will Deacon Subject: [PATCH] arm64: ptrace: Add function argument access API Date: Mon, 18 Mar 2019 16:59:02 +0900 Message-Id: <155289594227.10570.1879705446198840331.stgit@devnote2> X-Mailer: git-send-email 2.17.1 User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190318_005907_700262_E5065F4A X-CRM114-Status: GOOD ( 11.29 ) 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, linux-kernel@vger.kernel.org, mhiramat@kernel.org, Steven Rostedt , Oleg Nesterov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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. + */ +static inline unsigned long regs_get_kernel_argument(struct pt_regs *regs, + unsigned int n) +{ +#define NR_REG_ARGUMENTS 8 + if (n < NR_REG_ARGUMENTS) + return regs_get_register(regs, n << 3); + return 0; +} + /* We must avoid circular header include via sched.h */ struct task_struct; int valid_user_regs(struct user_pt_regs *regs, struct task_struct *task);