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=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT 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 27145C10F0E for ; Fri, 12 Apr 2019 14:22:23 +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 ED2F920850 for ; Fri, 12 Apr 2019 14:22:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pgULjTKc"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="PY366o9/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ED2F920850 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: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=Q46OQst5zovmaPgK/G3azOUwrMEvxaoMlWe4liFljiw=; b=pgULjTKcFft+LJ iijGnCwEDJhsBUCoKyX5Hfk+7uZL8ntuoHtqTKACmADOk8V46W9IaHLOHIgB3qdlfdU2OAhZiWbB9 2+n2CzDHH1i6TO+uyf8NIu0b6S+dhxMLCktOLKjEG6sKOBJ3nNKmhdYgWx0efVhOmGU5gMwaSlBAZ Ug02wQCi7xzXaXBTDdv7Q1AU+894DRibiBXzCP9Mg8ItqaCewog1bBpmEDdYG5w8YANzFWqV+Q/vG 6Ej1NxU8M6McRzXVQlHHytndljmwB2Wp9YHNMI8d91AHjFp2PFri6m7eSP0c1v89+/+IbUvex/gyn mZeOoQzziJHGa95sJmdw==; 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 1hEx4M-0001Ga-Qt; Fri, 12 Apr 2019 14:22:18 +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 1hEx4J-0001GH-Vs for linux-arm-kernel@lists.infradead.org; Fri, 12 Apr 2019 14:22:17 +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 4A96720818; Fri, 12 Apr 2019 14:22:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555078935; bh=mi+DUCtbq6rqfEJEbag8BIlmPlnfRJ9C7A7zk90Khk0=; h=From:To:Cc:Subject:Date:From; b=PY366o9/zzcJs1ULv8vt780nLvoF18zBPy+DJeDBAqZxhrUJTgS3mSHLmEibQh82s 3XdegsOJXmdF3a+/MdHoPzO01ht5Ed1dZtwM8Jk5KdLeXm/yS3WVmEAwMl3wKphksc t9jmnGoUvGoDwGzQXpFYIisLdkNiHO1CjofeOkf4= From: Masami Hiramatsu To: Catalin Marinas , Will Deacon Subject: [PATCH v2] arm64: ptrace: Add function argument access API Date: Fri, 12 Apr 2019 23:22:01 +0900 Message-Id: <155507892154.27222.12993546518496163452.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-20190412_072216_045795_008A35BE X-CRM114-Status: GOOD ( 12.33 ) 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 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 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 --- Changes in v2: - Use pt_regs_read_reg() - Update comment for the incorrect corner case. --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/ptrace.h | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 7e34b9eba5de..dad972cb8b65 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..2038dca1e2c2 100644 --- a/arch/arm64/include/asm/ptrace.h +++ b/arch/arm64/include/asm/ptrace.h @@ -305,6 +305,28 @@ 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 very rare case + * this may not return correct data, for example, one of the function + * parameter is 16bytes (128bits) or bigger. In such case, we can not + * get that big parameter correctly, but also register assignment of + * parameters after that will be shifted. + */ +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 pt_regs_read_reg(regs, n); + 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); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel