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: 7166 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp791295vqo; Fri, 24 Mar 2023 10:23:44 -0700 (PDT) X-Google-Smtp-Source: AK7set+r0cP+ByZeUeljVkqnO7ZFv6HutA9Y9sRGl+fjIxp2beHh6u7lDajOMl38UOmjkbOiN3ZJ X-Received: by 2002:a05:6a20:4904:b0:d9:162d:98e8 with SMTP id ft4-20020a056a20490400b000d9162d98e8mr3679114pzb.13.1679678624636; Fri, 24 Mar 2023 10:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679678624; cv=none; d=google.com; s=arc-20160816; b=iTrWG5mDwFP6yk8PhxN3ghX1FlUbOoYRyFOC69C7KySSekqdh2oGTWQyEbwlXwXFvA WLahgYrbTANUcQyQaVXRk139gKUf/vPCJKZsO+GJtb9yvmyjxZeNIs/JCZPZh5F4QsiU UTsBFiLbpIeh01exvH6soC1aO8Fo6nbWKp/WWZ21EHMTw1wMqzQ0l89IQFxnJlxL76qD yRR5MHhh6VszgZyvi3f7yAiOPI/vBBnI64sOES0VoEwB34vEFbBOxjU+OxRYSOmADmIk vh6dvj+nR1OIpu7gCRpnQECUFcpRh9s5vj57rz7qna6x0XVKwPni5mvLNbH3GUV6U8qb cH5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=RegTj6ZIebUQPA8rcD0vl5uPS+26g2Sm5QVA1mqn3kI=; b=H2rxy//OEiafrItfg65ZhGQp79K463TqEGvVmXcfQzQj2az0xFGMXBVL2F0we4t7/U FpAVgbzz6NXrHhdHZxlA77um3flIZmrlPVs2rlZFG4Nf3p072prGe9DuUw3bkQqSRjL6 +OukE2Toh1+eQUbP9zRICXOxc3DIc7NrNlwkQn8Q86cDIasJI65oo3eRA26V2VZcWfri z0eToHizOIud69kLtpXvlY0B+3yy4vGyhWibGyHOe4b51U9rK1rWkatccufYDII6ua3O iegnkuGxaoePJ8eOfnMiStYzJjsYpLGtnR0DNTJi+C1M2+fbV9K0ku400t4R0DBf4hqP jKtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=AsEFpNhI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l10-20020a056a0016ca00b00625c2bd736asi22636658pfc.20.2023.03.24.10.23.31; Fri, 24 Mar 2023 10:23:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=AsEFpNhI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232153AbjCXRPr (ORCPT + 99 others); Fri, 24 Mar 2023 13:15:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231272AbjCXRPd (ORCPT ); Fri, 24 Mar 2023 13:15:33 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44C8BCC15 for ; Fri, 24 Mar 2023 10:15:02 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id fm20-20020a05600c0c1400b003ead37e6588so3607081wmb.5 for ; Fri, 24 Mar 2023 10:15:02 -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=2jACtLezCUcgqqfxjqx/hy6tRxEAAFxSfj27qfcJsr2/GT6Dh158+nABJtuKV5gP9L /kCndkKVnfWdrJjcpEDn0mpb82AVN7gkTCX0BroZxdMlftNUlOa96nBg0q14vrPzAQzD r30JkK//ka8wf8K+2KVciYvfTD0Z52i3V5YPpYmfJiuHZkizZY8m4PyY3LCkKiw1gQJf BYytYKIVkVqwtiYPUjmr1l/U+tC5eLavTmWiocsLrjBqZBXDt3Nlz79dapEvQgOGrg70 a7+tX9WyKW5V/j9DMKpXZYLyAVJj0otcyNKmU+PZUG71AvH64GBQDVipHPDgjL9b6l3x g/wg== X-Gm-Message-State: AO0yUKXJMkcGive8jJjLPiYt0FnKps6gm9Z71XPVoD0EguVSrfxkRzZL gwNgPgreBw4B/nUo3SqZwAIunw== 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-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761270693179293924?= X-GMAIL-MSGID: =?utf-8?q?1761270693179293924?= 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(-)