Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3557687ybk; Tue, 19 May 2020 07:34:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzX5VuNqHyXYmTXv7IXnDH3BAUBNNXRa/9VPt7I/TlXcg8ELu+AmyzpckqWR4icma9yeJkD X-Received: by 2002:a17:906:724f:: with SMTP id n15mr6477924ejk.266.1589898841693; Tue, 19 May 2020 07:34:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589898841; cv=none; d=google.com; s=arc-20160816; b=CjlbHTN/rtNC/o4G478zilGqjCskguBJaDVGNnnD3iftblgoI/3+kyriE0N3/S80a6 W46dPHULjuztKXtW/eU7ayZL2Owtntt0BJbXiTgKZTfjxpZekwA++8UcM5Vcmbw91VKw 8uyJGC9CfJc99KCKWq41PDtv4gOP5pqj7Uu7/R/u7SSCpXY2wSxaIu7QvBf66WZaAexB 14NI4FBOUzk6cODF2gosGuwKM1fdgNR3Fv4CbFYPfEzuNjczMOW+bTNuSFZwRGgMs5wg gu9GPhgDZkznx8gNaDoDrHOmcNG61enEuilxQZhQkm0RWei2mQBJsUaWIga3IWHEFuZZ HjJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=Rlk4qrJ6yWazVdgX1ne5EXVV/Tv1KNqa9KLIo1m4QFs=; b=GOgvwHQgLXAejLviyKWnDbKtm8oMnmkh4SzVc8RQJx6MVx1vQnIzqWj4/wjzqYc/mY XopdvQ7IVli5z+ylFpBQBXZpboWlnNk10pn6/Qefey+kPQ9/NCJiFdqsxzgw9z2AqV2s oOIvJiFNK64IIYvqqADCAmG1ldY5MhDtEq2cHQwx0xe1UaJBAVLpGfnvhz5BTtvdQYaQ IKsK0J7/lHXnonNhfoGizWo27VDxelojYB1h+OI/DOKmMyyC/YH4TzPIef7hgMbM0Ds+ 5djSQzaq4Xqq893VUdK2feSFUFxfeiTyet0Xyikhv+UGedJgFPl7O/TN3pjop3jCPF2j 7MHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aj.id.au header.s=fm2 header.b=wdbszZvB; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=4MiZn6qI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 13si8068137ejz.499.2020.05.19.07.33.36; Tue, 19 May 2020 07:34:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@aj.id.au header.s=fm2 header.b=wdbszZvB; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=4MiZn6qI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728905AbgESOcK (ORCPT + 99 others); Tue, 19 May 2020 10:32:10 -0400 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:34727 "EHLO wout1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726203AbgESOcJ (ORCPT ); Tue, 19 May 2020 10:32:09 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 7D7E52A9; Tue, 19 May 2020 10:32:08 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Tue, 19 May 2020 10:32:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aj.id.au; h=from :to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm2; bh=Rlk4qrJ6yWazVdgX1ne5EXVV/T v1KNqa9KLIo1m4QFs=; b=wdbszZvBkVf/nGSHTzPyqOPN9vPvKgqox6+6Tx8Q8Q vldSNqDpSAy8AguSyRpGRAwnETiPMR/HJTM6FhVJ047t1XPYNlJWCnuVNgMMncJp 9uI946ogGknuw2J9KzuSTSTZgBQKZXM9Jr3IOftMKrxS7bgcek5PSaYyUH8CUsci aBVLaJv698vNiGw7y6v0gVdNZZctKw5ctQsUJaiWG8WF9lJtFAr/HegUKA6mIZcB E0akyQx4xNj+JyvXT4fu/vuXPuul/4X9CMZjn3CxvpvPAFUsdI/aXTUVklUjJe+B wjhIQq8TZ59M+YqaxB4Bu+bkuA4IZ15unSVvzQN/FtKg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=Rlk4qrJ6yWazVdgX1 ne5EXVV/Tv1KNqa9KLIo1m4QFs=; b=4MiZn6qI92hnePjRBoF1j7N/HJM+eV94u CnkYFrQDzmlB38HcO8//yxFPSFz/dYrXxb1DeEl4jORXYBjXC65tCuQIBf2PXTdc UriYVntEtQbAvQTVSVibrBNI8UiMmYuF6iiAWkNc0Bu19YxF59OmNNYMc057OKoT IJKW+ncflE9A28DQIv+/8B0aRyT6AWVSvFRu7qw5ukATgKXsjg0E+RXnb7Id0t5M JnvqGIChl8Ya9/OCiFKpp7p53bHEOWC2bEVuq5G4vthB8+NXD62KsoNlASvm/ZAr GTIT9oW0P4y5/ejWbBnJmAaa7Zfh+Co8jG6eB8MfWnIdhkVveriNw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedruddtjedgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdekredtre dttdenucfhrhhomheptehnughrvgifucflvghffhgvrhihuceorghnughrvgifsegrjhdr ihgurdgruheqnecuggftrfgrthhtvghrnhepkefhieffjeevfeevhedtieeihfefvdejle dvvddthefftedujeethfeuueelfedtnecukfhppedugedrvddrieeirdduvddvnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghnughrvgifse grjhdrihgurdgruh X-ME-Proxy: Received: from localhost.localdomain (ppp14-2-66-122.adl-apt-pir-bras31.tpg.internode.on.net [14.2.66.122]) by mail.messagingengine.com (Postfix) with ESMTPA id 218AD3066429; Tue, 19 May 2020 10:32:05 -0400 (EDT) From: Andrew Jeffery To: linux-arm-kernel@lists.infradead.org Cc: linux@armlinux.org.uk, oleg@redhat.com, linux-kernel@vger.kernel.org Subject: [PATCH] ARM: Implement functions for HAVE_FUNCTION_ARG_ACCESS_API Date: Wed, 20 May 2020 00:01:32 +0930 Message-Id: <20200519143132.603579-1-andrew@aj.id.au> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This allows extraction of kernel function arguments via kprobes on ARM. Based on the arm64 implementation and adapted for the 32-bit AAPCS. Signed-off-by: Andrew Jeffery --- The description for HAVE_FUNCTION_ARG_ACCESS_API was pretty vague on what was required. I've implemented enough to enable argument extraction for kprobes; is there anything else needed to satisfy HAVE_FUNCTION_ARG_ACCESS_API? arch/arm/Kconfig | 1 + arch/arm/include/asm/ptrace.h | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index c77c93c485a0..d82f80845e03 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -82,6 +82,7 @@ config ARM select HAVE_EXIT_THREAD select HAVE_FAST_GUP if ARM_LPAE select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL + select HAVE_FUNCTION_ARG_ACCESS_API select HAVE_FUNCTION_GRAPH_TRACER if !THUMB2_KERNEL && !CC_IS_CLANG select HAVE_FUNCTION_TRACER if !XIP_KERNEL && (CC_IS_GCC || CLANG_VERSION >= 100000) select HAVE_GCC_PLUGINS diff --git a/arch/arm/include/asm/ptrace.h b/arch/arm/include/asm/ptrace.h index 91d6b7856be4..71e7649deac9 100644 --- a/arch/arm/include/asm/ptrace.h +++ b/arch/arm/include/asm/ptrace.h @@ -149,6 +149,30 @@ static inline unsigned long regs_get_register(struct pt_regs *regs, return *(unsigned long *)((unsigned long)regs + offset); } +/* + * Read a register given an architectural register index r. + */ +static inline unsigned long pt_regs_read_reg(const struct pt_regs *regs, int r) +{ + return regs->uregs[r]; +} + +/** + * 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. + */ +static inline unsigned long regs_get_kernel_argument(struct pt_regs *regs, + unsigned int n) +{ +#define NR_REG_ARGUMENTS 4 + if (n < NR_REG_ARGUMENTS) + return pt_regs_read_reg(regs, n); + return 0; +} + /* Valid only for Kernel mode traps. */ static inline unsigned long kernel_stack_pointer(struct pt_regs *regs) { -- 2.25.1