Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp380459pxm; Tue, 22 Feb 2022 12:51:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6ZFLdGj0N1+E5Ye3S6ghO77+UH06jQFS+VD8vmLBhHb333g2Nw7bd7YLHIgQ/UwQZ7gZP X-Received: by 2002:a17:902:f54a:b0:14f:47:a452 with SMTP id h10-20020a170902f54a00b0014f0047a452mr24653235plf.87.1645563106334; Tue, 22 Feb 2022 12:51:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645563106; cv=none; d=google.com; s=arc-20160816; b=Ds74/Y18bIhNXElRHTzk5TswWt5yujmEvW0o/GR236gG6SIgvdUfb6dFUfMbCKdsex JjniQGi8bU8/gB/jqkA+XygdQicU9Fj4Mw4aiBwLtLnT5Z8/FcmAsYIclOz2k5IK3R7t IFa0fOQW/3GBuLNthFP0anBCNoNK/zsghn+xSV0busVn/w1ioIEpsj0NKDqIUXqnFIcC Z1g87cFZyfwuUn7Yna8rTZm0YF8vsWJsXjuy43ul4qP7tZIOfJKMkcsi2d3rumh0FLA0 to1LfqAcBphm9qyUg3aa4IRdwyEjP6VB4ZCFID6ycZmKnx5WzPra9YjmgYIYRaQl3u7u HUDg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WiPpLY6TdyOxNarhRInHaxA0CwcGeIe0L7xXnLbA+F8=; b=cMd+ART/wQnfvVjJBSsdlV7FM+jGOLRRqHPtCCbfGs6Oi0SQ5SoEJe/Lw9XJ2qi441 2neKmwDKVVM+51TBn0UNA75DfUCFfV3i4EKSorSvs5GVKg3147qP92tBxqg7RTzaQqTh 2yVEp9WKEBqqlgdnwna6pfo1yz5uKr+taEeNWw0O8yrLgYnbwf2QkmtaQ21LKeZkviS9 Ad346RRkloYJfnrNKX2/Zu7bng10/aiWwsB3Ho/R5deHtfFbiP5hPwpTiB4iCNdBKRCM sdTAN8Vk5qsgb1lr3d8g6AEq/lTTCjyA7roB9lYDCcpyG6t5Z9ZIu5TkkCPGsMcIKOjU lrwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OdsWzxzJ; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d8si11674861pfl.206.2022.02.22.12.51.28; Tue, 22 Feb 2022 12:51:46 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=OdsWzxzJ; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234540AbiBVRHX (ORCPT + 99 others); Tue, 22 Feb 2022 12:07:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234539AbiBVRHV (ORCPT ); Tue, 22 Feb 2022 12:07:21 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CC0E5FE9; Tue, 22 Feb 2022 09:06:52 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2A14761275; Tue, 22 Feb 2022 17:06:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97465C340E8; Tue, 22 Feb 2022 17:06:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645549611; bh=p5PicBOIuVA+SoWxZQRqV4TOwd/YJ2sG+ZPpG5D+684=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OdsWzxzJx2xkyGyAmYZTmZ38Reg/3AiKowy5ly4yX0yJr7Cq8G3elHagDPWyGAJJL y+ZPhGuhJ+T3tItIbE/IJtBXso/4rxm1f0mYLJ+VLApKsKeqtjDTKsCowOo0ZY8pty r3vrsTsnX2iR5MwUxUxguH7rO3QkiXxf1CpxAjnlnpH3UNKp7AizTD7LoBYXGcmaEr hJyKlrfB9b2LqcWPH5EnK1HylpFCejlSr0n/qjK/z3LtKJ+9T6ByQQhOampXFMwbWp x1ianJ7B27x+dm9Z5S7W9CYoJCpFi0RfcM98Y5YA+ryNRN3t3MqkAzDmNef7hzOHV3 /TrXOfaO+S/LQ== From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Masami Hiramatsu Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, lkml , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Steven Rostedt Subject: [PATCH 03/10] bpf: Add bpf_get_func_ip kprobe helper for multi kprobe link Date: Tue, 22 Feb 2022 18:05:53 +0100 Message-Id: <20220222170600.611515-4-jolsa@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220222170600.611515-1-jolsa@kernel.org> References: <20220222170600.611515-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Adding support to call bpf_get_func_ip helper from kprobe programs attached by multi kprobe link. Signed-off-by: Jiri Olsa --- kernel/trace/bpf_trace.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index df3771bfd6e5..64891b7b0885 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -1037,6 +1037,18 @@ static const struct bpf_func_proto bpf_get_func_ip_proto_kprobe = { .arg1_type = ARG_PTR_TO_CTX, }; +BPF_CALL_1(bpf_get_func_ip_kprobe_multi, struct pt_regs *, regs) +{ + return instruction_pointer(regs); +} + +static const struct bpf_func_proto bpf_get_func_ip_proto_kprobe_multi = { + .func = bpf_get_func_ip_kprobe_multi, + .gpl_only = false, + .ret_type = RET_INTEGER, + .arg1_type = ARG_PTR_TO_CTX, +}; + BPF_CALL_1(bpf_get_attach_cookie_trace, void *, ctx) { struct bpf_trace_run_ctx *run_ctx; @@ -1280,7 +1292,9 @@ kprobe_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) return &bpf_override_return_proto; #endif case BPF_FUNC_get_func_ip: - return &bpf_get_func_ip_proto_kprobe; + return prog->expected_attach_type == BPF_TRACE_KPROBE_MULTI ? + &bpf_get_func_ip_proto_kprobe_multi : + &bpf_get_func_ip_proto_kprobe; case BPF_FUNC_get_attach_cookie: return &bpf_get_attach_cookie_proto_trace; default: -- 2.35.1