From patchwork Fri Mar 24 17:14:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florent Revest X-Patchwork-Id: 13187046 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 50175C76196 for ; Fri, 24 Mar 2023 17:15:57 +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=eMTV3Ckf1NvhstkxyvMog6SpB9fmN4ukRIC1EHg1yW8=; b=vv87+Co7Or+nsL 6dWiYXG6z2U1pxYFqrUjATAGdmIzUJAmXP9fOsR8rUAz6OxBftk3V7Qg8qCg/FmSTYqrCkZfWLL0Z E2iS5ewVNGwZb1AF0hi0jE7kBZ2506x+XCeNVn3rjBNTWbDm4HgseRGDmyemuapTYLVAnNOEF26zg YwZx87ZddkfEPHUlSJhBjKrR+oJMTDerEmu0b0koSei0zLFeok2GBIK712cmnlyzls+j0I3c+Jil8 a4SZn2Ve0Riu3hS4SfcE2ajoZlWjRzsZ6a/y8n+MsLroeKsuqA3y1z/BsCUSnoRCZ6CFMAfrvtvsV Y1PnwKf+QN1UNnTqkr6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pfl0J-0054Ci-1l; Fri, 24 Mar 2023 17:15:03 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pfl0F-0054BL-36 for linux-arm-kernel@lists.infradead.org; Fri, 24 Mar 2023 17:15:01 +0000 Received: by mail-wm1-x32c.google.com with SMTP id r19-20020a05600c459300b003eb3e2a5e7bso1477128wmo.0 for ; Fri, 24 Mar 2023 10:14:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679678097; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=RegTj6ZIebUQPA8rcD0vl5uPS+26g2Sm5QVA1mqn3kI=; b=AsEFpNhIC31p7EY+r3N6BmQ0k/tTWIhol6uk5hJCrx+qN5EgWZx2jMqSPeYt3/KOZM rKXSmLCp4ikMxij1pQzXGiuBNjpcpSvMp54tsTBEXtiqeUmYUMfjjWn148rAVlmS/FlO hdWMzBIAiLcYSSKeFfP64Qq4eGQ0iOwiSLD+s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679678097; 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=RegTj6ZIebUQPA8rcD0vl5uPS+26g2Sm5QVA1mqn3kI=; b=0y7tqJfY186C+WfN7DCelUoGFxASNtpGyHqbZPN3CMl2Fz36ewQLAY1QVocr1fkR12 VEazD9t0xWnsLHW8e49xpgY/QtuMoqxEOByoJXwOOJAqJkgGBiZHfzOBcfMYkqskUU6M IWzGOBwwbd+fl0E83mXdQomdX9OVIB6/6E2jaYGHN9CTNhgkhfoLUHsG4OQvpHW0Pw4W dDT3XlH4NAuw9JZAXyjKYWS4H0N0zXaEYLKL8mSZd0QpiDrKISfQMrX78QvqViIHRYkZ +Dw7fhvFqyvl7SfdYTIoOCpjiUAjgx+jKER6l1pkwOQmqBHJglOKfT/xCGj/X7j0uIBB yV4g== X-Gm-Message-State: AO0yUKUiLYkS5qr5t75dbiN90gF7vY/+tOCHPdaqgqc0gDq2cefkh2ic PF41jS+hVy7Bnk5Z2y6vyftngvyY8m6aaXmUeqE= X-Google-Smtp-Source: AK7set+RzbeIy+ik1zAtmcE5ClYFAskZBrekDO+igxhK9XPkVFmRtsLXkpwpOngDkYj0K19uCjvm3A== X-Received: by 2002:a05:600c:218d:b0:3ed:5a12:5641 with SMTP id e13-20020a05600c218d00b003ed5a125641mr3325142wme.36.1679678097171; Fri, 24 Mar 2023 10:14:57 -0700 (PDT) Received: from revest.zrh.corp.google.com ([2a00:79e0:9d:6:ffb1:35ba:1031:ba71]) by smtp.gmail.com with ESMTPSA id 26-20020a05600c231a00b003dc522dd25esm5385107wmo.30.2023.03.24.10.14.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 10:14:56 -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 v3 0/4] Add ftrace direct call for arm64 Date: Fri, 24 Mar 2023 18:14:47 +0100 Message-Id: <20230324171451.2752302-1-revest@chromium.org> X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230324_101500_023529_D5264B98 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 3) 3- tools/testing/selftests/bpf/test_progs (cf: patch 4) Changes since v2 [3]: - Dropped the first 6 patches which got merged separately in the tracing tree - Minor rebase changes when switching to v6.3-rc3 - Fixed a typo in a comment (trmapoline -> trampoline) 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/all/20230207182135.2671106-1-revest@chromium.org/ Florent Revest (4): arm64: ftrace: Add direct call support arm64: ftrace: Simplify get_ftrace_plt 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 | 32 +++++++ samples/ftrace/ftrace-direct-multi-modify.c | 36 ++++++++ samples/ftrace/ftrace-direct-multi.c | 22 +++++ samples/ftrace/ftrace-direct-too.c | 25 ++++++ samples/ftrace/ftrace-direct.c | 23 +++++ tools/testing/selftests/bpf/DENYLIST.aarch64 | 82 ++---------------- 11 files changed, 288 insertions(+), 102 deletions(-)