From patchwork Wed Apr 5 18:02:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florent Revest X-Patchwork-Id: 13202345 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 541B2C76188 for ; Wed, 5 Apr 2023 18:03:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :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=vGwSJOWoHAeuSSL3StVltGztID8blyJc/KYCxtZbFV0=; b=tiK8V9V6bN7NdG RFsBtg8l2xNdd1cwjCL4OW/gxvRJTMz9ipQcWMFpdb5F024j7DMAF3BUKhr8NPLwOjOMkx5AwM95Z FVC2+gC8+XiAi9lSlc5fY9WhNb2msTrfPJ1n9vRPSl9OGe90XIxRKm4+luoCHR8VC8D+ErJr0kutR wMyYrmEv0VAb70ijEX7NEotI/Z9lbmXHRtaJjnstfKJPpLXR52KE9Rg55lk3XoYcJHE3aAheqtaGg cbu1MNXwS1v6sKfgwnRK0ffW1HCcjFYcohzgnjnFiAbOipUaxNZld2h/XAFD6JKOR/vU+J3JR7tJp aJe9ucA6/S1IRE+qw2CQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pk7TK-005KdJ-0F; Wed, 05 Apr 2023 18:03:02 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pk7TH-005KZF-0D for linux-arm-kernel@lists.infradead.org; Wed, 05 Apr 2023 18:03:00 +0000 Received: by mail-wm1-x336.google.com with SMTP id v14-20020a05600c470e00b003f06520825fso1585669wmo.0 for ; Wed, 05 Apr 2023 11:02:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1680717774; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=7hqsBVLdt1RQMl9kEJsLC6YcZN3etO5DgEUxKtvbSwU=; b=j3Q8s0GCJ+n56KzJcYwFXN+d48HkCrg3fkCyfWHeMKrRtBKD2ueyFtvyEXsv+/qxE5 jwiGzKfL/EazWk+HiTQxOUOxan/kzGsAwjav1OxkNnmDsJh3e+M1QSk61tXcFG4Xam3V C4gkRzN6vqghm0nPva4lnaOdGCFlnarpEev58= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680717774; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7hqsBVLdt1RQMl9kEJsLC6YcZN3etO5DgEUxKtvbSwU=; b=Lx3UzBAm730Iq4LsrCYgWk4ZTLU+nqDiKkMrYvVsh2ar5xY6blvia5WFnArAOKqaXi zlgWbvO5rdS49DbiodWsZKmtx7Vvx83BSs8/HOl5ru/Ur+60Nl0axwHD/FT5hvaNVQ1Z dtJcJ06KljuxO1pFzutJ07i/bev4BPuGSvUmyiZIrDg+FXZpYNDoWLFqmKipvYgrNoEw uxT8woamC+27XvT0JcVadFN7wvRqvZVihstAUnwzjxXIOr1Pmcan65w6BnFe5ApRq8J5 vAiJnZogMrPIGXEfxRVogE3CVr9Io7PayoyEytJT1XROOXCQ5X65B0D9Hc3WJMLDhFPr xiHg== X-Gm-Message-State: AAQBX9c76mULBYnUkz1zLdvFRxoz7NOjhYY+9WyHzxtJcYNWpdjbjpSW 9GzZCCG8Bhu0uMkVi09fCIFHCsskjSXlfqopwY8= X-Google-Smtp-Source: AKy350YH/mhjtDihEd5vUnb3kVxk6Inr0Er3ixvxTityy7XhCLfLoxSJyjKpbmEMRPwkZzBYSEA4Kg== X-Received: by 2002:a05:600c:1d98:b0:3f0:5403:57ae with SMTP id p24-20020a05600c1d9800b003f0540357aemr2176475wms.20.1680717774540; Wed, 05 Apr 2023 11:02:54 -0700 (PDT) Received: from revest.zrh.corp.google.com ([2a00:79e0:9d:6:cf6a:9ae6:15f1:4213]) by smtp.gmail.com with ESMTPSA id bd5-20020a05600c1f0500b003f0472ffc7csm2913233wmb.11.2023.04.05.11.02.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 11:02:54 -0700 (PDT) From: Florent Revest To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org Cc: catalin.marinas@arm.com, will@kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, mark.rutland@arm.com, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kpsingh@kernel.org, jolsa@kernel.org, xukuohai@huaweicloud.com, lihuafei1@huawei.com, Florent Revest Subject: [PATCH v6 0/5] Add ftrace direct call for arm64 Date: Wed, 5 Apr 2023 20:02:45 +0200 Message-Id: <20230405180250.2046566-1-revest@chromium.org> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230405_110259_119328_98838D27 X-CRM114-Status: GOOD ( 11.84 ) 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 This series adds ftrace direct call support to arm64. This makes BPF tracing programs (fentry/fexit/fmod_ret/lsm) work on arm64. It is meant to be taken by the arm64 tree but it depends on the trace-direct-v6.3-rc3 tag of the linux-trace tree: git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git That tag was created by Steven Rostedt so the arm64 tree can pull the prior work this depends on. [1] Thanks to the ftrace refactoring under that tag, an ftrace_ops backing a ftrace direct call will only ever point to *one* direct call. This means we can look up the direct called trampoline address stored in the ops from the ftrace_caller trampoline in the case when the destination would be out of reach of a BL instruction at the ftrace callsite. This fixes limitations of previous attempts such as [2]. This series has been tested on arm64 with: 1- CONFIG_FTRACE_SELFTEST 2- samples/ftrace/*.ko (cf: patch 4) 3- tools/testing/selftests/bpf/test_progs (cf: patch 5) Changes since v5 [3]: - Fixed saving the fourth argument of handle_mm_fault in both the x86 (patch 3) and arm64 (as part of patch 4) "ftrace-direct-too" sample trampolines - Fixed the address of the traced function logged by some direct call samples (ftrace-direct-multi and ftrace-direct-multi-modify) by moving lr into x0 1: https://lore.kernel.org/all/ZB2Nl7fzpHoq5V20@FVFF77S0Q05N/ 2: https://lore.kernel.org/all/20220913162732.163631-1-xukuohai@huaweicloud.com/ 3: https://lore.kernel.org/bpf/20230403113552.2857693-1-revest@chromium.org/ Florent Revest (5): arm64: ftrace: Add direct call support arm64: ftrace: Simplify get_ftrace_plt samples: ftrace: Save required argument registers in sample trampolines arm64: ftrace: Add direct call trampoline samples support selftests/bpf: Update the tests deny list on aarch64 arch/arm64/Kconfig | 6 ++ arch/arm64/include/asm/ftrace.h | 22 +++++ arch/arm64/kernel/asm-offsets.c | 6 ++ arch/arm64/kernel/entry-ftrace.S | 90 ++++++++++++++++---- arch/arm64/kernel/ftrace.c | 46 +++++++--- samples/ftrace/ftrace-direct-modify.c | 34 ++++++++ samples/ftrace/ftrace-direct-multi-modify.c | 40 +++++++++ samples/ftrace/ftrace-direct-multi.c | 24 ++++++ samples/ftrace/ftrace-direct-too.c | 40 +++++++-- samples/ftrace/ftrace-direct.c | 24 ++++++ tools/testing/selftests/bpf/DENYLIST.aarch64 | 82 ++---------------- 11 files changed, 306 insertions(+), 108 deletions(-)