Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1052852rwl; Wed, 5 Apr 2023 11:04:55 -0700 (PDT) X-Google-Smtp-Source: AKy350azbCRFCpN8E5xsgDhKkdj0kTNvsY+TZ/yxWOTBjXXB2Oy0ntx/BctyX1LsaARctiNI9GuL X-Received: by 2002:a17:90a:1d46:b0:23b:4439:4179 with SMTP id u6-20020a17090a1d4600b0023b44394179mr7754697pju.28.1680717895302; Wed, 05 Apr 2023 11:04:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680717895; cv=none; d=google.com; s=arc-20160816; b=B/i8QaGDJpF/i2K8pz4wjvAZDFF3ENuoYIImukoFvMcOjbblns+Ga7tOKCyyql8vQt KQudMJUU3fjR4GwK9PmmOjY5RY45J93XVyLyCrCQuxW4a+O78MHcQwGHZmQwDFKaSG4G 1CrergoxFFRU4UW3DKNAIwh01qGZkUggTV1GBzNI5ko7Rb8iEXsqmzPw63PtXdGVl0O5 5MlHQ+C+kQO1rMHRByyJcF5DsBkPEboo6haXkWBmRRZSkwD0EFmR5FzQOl5EuJ0HE9tt gr9gU5dPT7cntuuaPrDA9CwBSvMqrpyGD4MJJYMY/fGgWpZAX/X1NDhyx/iLEmArFpr8 3JHQ== 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=7hqsBVLdt1RQMl9kEJsLC6YcZN3etO5DgEUxKtvbSwU=; b=LH8bd83M3n3OdODpYJyJZ7XMzi/fZj73ALAb1tWy2+QlQakTXol25eg6AKihqbfPY2 C4QH5MMBMz5/OMovmKlTar8+sf8bzDihA01KBZdoQYE2XVWnBSZ1ksgn+5Y953Qf6Fnd le/RpnqkYm4X7K8ukgfuj9vKksBvYap7hqL/jNRib4kAgFoIqje7leCUo6sKgqdZKhOs F+/rzIzsOJUBABFamcMNrxKPBLDVzq1dg6iCpuckFUkyuHt6aVneslopB54w/gbWZ4ke b1W9kR9tVpU/GmYlpOpHZ6pLSZLLjRqUg8buwRpZuNJZaRxeipRO3dPX1tXvTQR+fFVE u90Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=j3Q8s0GC; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m1-20020a655301000000b0050fb7c5a656si12536322pgq.190.2023.04.05.11.04.43; Wed, 05 Apr 2023 11:04:55 -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=j3Q8s0GC; 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 S233074AbjDESDw (ORCPT + 99 others); Wed, 5 Apr 2023 14:03:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232866AbjDESDt (ORCPT ); Wed, 5 Apr 2023 14:03:49 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD7E56EB7 for ; Wed, 5 Apr 2023 11:03:07 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id l15-20020a05600c4f0f00b003ef6d684102so18934005wmq.3 for ; Wed, 05 Apr 2023 11:03:07 -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=tpz+/yZfoj+znyZDpC/Empp2UIRcptdNepAxP9lrfw4a/fOutjPu79FeNGLRk+2aoq TQOrm1QxgOWWUXzvAVwUEciNoBVIvDnXwcoYvGg8Y9MVevn4ducGFiEmCWsxEzfVhfhv HL+hmnifC0++afvhZaAeIyRTYKp0jxaxO8tjB6ArvM325jXjP4xQs+YpR82q9C7bw3uk nCk06Y6rMtMIV8K+Ky/YBAaxRC84CQmiO/SfRnSICBT1wEdHryKWrsB2VTT9MrULSbCQ i7AcIHV1PonKfuuwq5Rhubfd2mFilgljRxzVbtiy51af/Uta/Jkl51BNuPlY/7jy44RZ 6gKQ== X-Gm-Message-State: AAQBX9e+a4KhDKN5/b5oAgHuw6dD/dOignUFzh0FnNtCjWNz7c2VmiRm I/my/oh+NeuTgaGjbboEG7s+ew== 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 Content-Transfer-Encoding: 8bit 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 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(-) -- 2.40.0.577.gac1e443424-goog