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 1136DD0E6CF for ; Mon, 21 Oct 2024 08:48:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: Message-ID:Date:References:In-Reply-To:Subject:Cc:To:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VkndY7kyzgww9sLNjYbJiINlOlZMorLDdpyRRN4SeMw=; b=EXFxphjpQfQkkKSzYSMRC9BL7G yFD+r/Jwu0if+AIJEVojocA/WS7Qye0QektLybkUKlFR90nY70bsySr+xg485KMEMMwmwF9IgMsdq d7fsw6Z0PuRhssabHmCT7uaDE7hhhJSOFHu2eRJWKT8wOOMB2aNHNGeXadkchm3/5dEcuO9Gz09Qb li/8jhSsYp/d6OydMvlq7WCfyvVcqq9ZBg6/dBk7OuqcFImVy2ETPWoc1Q2SGgBS3N9404JVHAOuq 58MZuiP4jFFZPaX8oWaiOIrO8JohV7/1qvKoX1qCUG8J6UZL3plqhZHzutqtuviul9H9bf8zI8uHD XZuuMR1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t2o5C-00000006c2e-0pru; Mon, 21 Oct 2024 08:48:10 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t2o2S-00000006bEG-39pf for linux-arm-kernel@lists.infradead.org; Mon, 21 Oct 2024 08:45:21 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 387FB5C5B85; Mon, 21 Oct 2024 08:45:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C771C4CEC3; Mon, 21 Oct 2024 08:45:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729500319; bh=5FzE/0BLnnxuZ1FYPWCfLYlRYhMxhNmkZxMdynZNq+o=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=jPh3uqZ3ccNy38q2S22/20N/t558HrYwek3angjZKspOU0j/JPH8TEFdFf5AXPt3v fFVAIwDKVsxuzuVLk/uQ8SQAyOA8uATkHnMShNnR5fMgFg7Y7j2qtWClAyt8Ekp1EM oJp6b97ahilC+WkO7LvCIz+GJpqE3TaFvHij+DS38VYFw4h4veFJYdeE0gjvCCQmC5 j/dBbCmL0LqJB4uc4+TPDREaT/pdjvGnNI5xHVOZRxpU1r33w0CUfnSdpO8BI/H6CI tLvUZlWZ5XzimXmPBhjqIxwFqB4udyqxjgwhhF9swgnEavuxhvHkQ4kq6lw1Y/j3b7 jmBVNPJ/6ynFw== From: Puranjay Mohan To: Xu Kuohai , bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Alexei Starovoitov , Daniel Borkmann , Catalin Marinas , Will Deacon Subject: Re: [PATCH bpf] bpf, arm64: Fix stack frame construction for struct_ops trampoline In-Reply-To: <20241019092709.128359-1-xukuohai@huaweicloud.com> References: <20241019092709.128359-1-xukuohai@huaweicloud.com> Date: Mon, 21 Oct 2024 08:44:59 +0000 Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241021_014520_854742_9D44B951 X-CRM114-Status: GOOD ( 13.71 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --=-=-= Content-Type: text/plain Xu Kuohai writes: > From: Xu Kuohai > > The callsite layout for arm64 fentry is: > > mov x9, lr > nop > > When a bpf prog is attached, the nop instruction is patched to a call > to bpf trampoline: > > mov x9, lr > bl > > This passes two return addresses to bpf trampoline: the return address > for the traced function/prog, stored in x9, and the return address for > the bpf trampoline, stored in lr. To ensure stacktrace works properly, > the bpf trampoline constructs two fake function stack frames using x9 > and lr. > > However, struct_ops progs are used as function callbacks and are invoked > directly, without x9 being set as the fentry callsite does. Therefore, > only one stack frame should be constructed using lr for struct_ops. > > Fixes: efc9909fdce0 ("bpf, arm64: Add bpf trampoline for arm64") > Signed-off-by: Xu Kuohai Acked-by: Puranjay Mohan > --- > arch/arm64/net/bpf_jit_comp.c | 47 +++++++++++++++++++++++------------ > 1 file changed, 31 insertions(+), 16 deletions(-) > [...] --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iIoEARYKADIWIQQ3wHGvVs/5bdl78BKwwPkjG3B2nQUCZxYUjBQccHVyYW5qYXlA a2VybmVsLm9yZwAKCRCwwPkjG3B2nTzqAQCheSKtCWZA+DUPWWXtvx+SnjkUNgt4 hIaoB/Vmo+wnHAEAhU0kVtv6kTodVwpkWTJXSnVvkLnPl+M5AQKDCVxh+QA= =0hsB -----END PGP SIGNATURE----- --=-=-=--