Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3649107pxb; Mon, 24 Jan 2022 14:24:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7BLVMVGUpN9zm9BlnO3UBnxpxKelGQRIMeFvFdqR/hgVdSSMaYYRc2VvgYzTvYFgCRh1v X-Received: by 2002:a05:6a00:1745:b0:4c8:b982:d500 with SMTP id j5-20020a056a00174500b004c8b982d500mr8322122pfc.59.1643063055151; Mon, 24 Jan 2022 14:24:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643063055; cv=none; d=google.com; s=arc-20160816; b=pj3nPEL78Rv4t6ppLjBWvhv/OnqAhLc51ScC/uFa7Fe74vtWQXA5I01BDpgFh2NMWJ vEwVyMqYo4rhqQAiHtE8wYGvQi7L8O7+T5dXXYkEwAQU8O4xi6+JD8iCmbgm2MPaDYh8 gEvhZcsGgjQFvL0fDTbx7JSTUsdIfKWhKUua+XL9DNN5lEyAB1pbhmjiPNZoMptY2M8t xXToYuI0AorM11hYRz+wZC+WZ+mgOhlg3NL1U10RVkkUDWap+rOSsffnMRtD2q0hYYwT KtC28enmUmIVtWJrvkGGh7AC6YlZQxnmvzvp8K+ndSOYnqynmW8KBnAmOGDosP0R5Q93 a5Qw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FzO5yPxKs0Gs4TnWRc1l0joGUv+mrIoGfVTz9Lds3Vg=; b=i1gGW4ZnXWLhLl9SMBL1tYLdL2qeAAR7lT6B4DCxunEqdo+5FyURMOBpNJRtEF+tbB Jf2n9Tmog5D0qzPfB9WxyIVNyKIu2QPgU1pPvvfOkEI6ScD9kr+4zyvJtSCZknpO+64W XuXK419C0fEYYf44BKG/SCSmYTG7TfKtCJnDRE5eV4rdu13zBiTEDDrBsChqKzKuGCnC OGCDYFEhsJvoBj378HqK2pMlUeueqQG7LO6Wrl/N7iS7dfGdKrdDEruKNhe6RoGvTe2+ plEgwhtXtGepq6obc/I/QpyrXrUma4bBBUdqUwueASmKoStj4qT/XkcOEHPS6chiuLa/ pGOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IkJK1YTA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i29si14476161pgb.636.2022.01.24.14.24.03; Mon, 24 Jan 2022 14:24:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IkJK1YTA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1582919AbiAXWQI (ORCPT + 99 others); Mon, 24 Jan 2022 17:16:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1453887AbiAXVbI (ORCPT ); Mon, 24 Jan 2022 16:31:08 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 304CCC0AD1AD; Mon, 24 Jan 2022 12:20:00 -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 ams.source.kernel.org (Postfix) with ESMTPS id C9822B811F9; Mon, 24 Jan 2022 20:19:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07AF6C340E5; Mon, 24 Jan 2022 20:19:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643055598; bh=vHsytlRuhEniNKYDf87eMNzzcRoTpH3g1LK1qlpI8Lw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IkJK1YTAszWW44OV2qJss/MjH3RAadO1t/2rbK1XXw3US1SLbwD9Uvd0RuGWGkB7p 9U6yPO9g5sbUcjBAPyQWu36ZNl7SVqktHqhhzrF1yY4Krif/qFUJx7upwgECNWAyqb SpPXeeEuMJmyUYj4dbx0a1IjWYTCyk6uVJ6Uy6uQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Zijlstra , Kajol Jain , Daniel Borkmann , Sasha Levin Subject: [PATCH 5.15 203/846] bpf: Remove config check to enable bpf support for branch records Date: Mon, 24 Jan 2022 19:35:20 +0100 Message-Id: <20220124184107.938110220@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kajol Jain [ Upstream commit db52f57211b4e45f0ebb274e2c877b211dc18591 ] Branch data available to BPF programs can be very useful to get stack traces out of userspace application. Commit fff7b64355ea ("bpf: Add bpf_read_branch_records() helper") added BPF support to capture branch records in x86. Enable this feature also for other architectures as well by removing checks specific to x86. If an architecture doesn't support branch records, bpf_read_branch_records() still has appropriate checks and it will return an -EINVAL in that scenario. Based on UAPI helper doc in include/uapi/linux/bpf.h, unsupported architectures should return -ENOENT in such case. Hence, update the appropriate check to return -ENOENT instead. Selftest 'perf_branches' result on power9 machine which has the branch stacks support: - Before this patch: [command]# ./test_progs -t perf_branches #88/1 perf_branches/perf_branches_hw:FAIL #88/2 perf_branches/perf_branches_no_hw:OK #88 perf_branches:FAIL Summary: 0/1 PASSED, 0 SKIPPED, 1 FAILED - After this patch: [command]# ./test_progs -t perf_branches #88/1 perf_branches/perf_branches_hw:OK #88/2 perf_branches/perf_branches_no_hw:OK #88 perf_branches:OK Summary: 1/2 PASSED, 0 SKIPPED, 0 FAILED Selftest 'perf_branches' result on power9 machine which doesn't have branch stack report: - After this patch: [command]# ./test_progs -t perf_branches #88/1 perf_branches/perf_branches_hw:SKIP #88/2 perf_branches/perf_branches_no_hw:OK #88 perf_branches:OK Summary: 1/1 PASSED, 1 SKIPPED, 0 FAILED Fixes: fff7b64355eac ("bpf: Add bpf_read_branch_records() helper") Suggested-by: Peter Zijlstra Signed-off-by: Kajol Jain Signed-off-by: Daniel Borkmann Link: https://lore.kernel.org/bpf/20211206073315.77432-1-kjain@linux.ibm.com Signed-off-by: Sasha Levin --- kernel/trace/bpf_trace.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 6c1038526d1fc..5a18b861fcf75 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -1322,9 +1322,6 @@ static const struct bpf_func_proto bpf_perf_prog_read_value_proto = { BPF_CALL_4(bpf_read_branch_records, struct bpf_perf_event_data_kern *, ctx, void *, buf, u32, size, u64, flags) { -#ifndef CONFIG_X86 - return -ENOENT; -#else static const u32 br_entry_size = sizeof(struct perf_branch_entry); struct perf_branch_stack *br_stack = ctx->data->br_stack; u32 to_copy; @@ -1333,7 +1330,7 @@ BPF_CALL_4(bpf_read_branch_records, struct bpf_perf_event_data_kern *, ctx, return -EINVAL; if (unlikely(!br_stack)) - return -EINVAL; + return -ENOENT; if (flags & BPF_F_GET_BRANCH_RECORDS_SIZE) return br_stack->nr * br_entry_size; @@ -1345,7 +1342,6 @@ BPF_CALL_4(bpf_read_branch_records, struct bpf_perf_event_data_kern *, ctx, memcpy(buf, br_stack->entries, to_copy); return to_copy; -#endif } static const struct bpf_func_proto bpf_read_branch_records_proto = { -- 2.34.1