Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp719603rwd; Wed, 7 Jun 2023 06:08:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ78+PJZ+xa0ILUCTnfuKTA1X7GE5WUYQJJB6XRNbuoAUo0aVqmaXuZj6Fta0ablaEl/ii67 X-Received: by 2002:a17:903:113:b0:1ad:d995:54a with SMTP id y19-20020a170903011300b001add995054amr2814327plc.46.1686143296839; Wed, 07 Jun 2023 06:08:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686143296; cv=none; d=google.com; s=arc-20160816; b=cXt/W1Y369skE0zgRHUXTo1yddTwV3daa/O+cPgcyQUy3ZZWTrlR0rH06GEHTOuMM1 qflcoQGYemJRo5GYKz7o5h0iIOJQErVEXCYQJP55X7IPqcdH62kIHeSsvvl431oZwAp/ 886y4qORvigVNVE3qleTAoWmE4Gga/M4kX5eNer+R9QkAz86H6X8jNDihEONeRE8VSne YeFrU2cuc07eBYilx5eAB2HWCyLizMgi2KMEJqwuia4ZQ/TToKt8exaiyPUWIq8F902Z hQ+OQukrHDnpHS1EPpNTAwG6i6MMFyxdP1kWVgyBesTtYIsZ0bJJqe5ng7A9O4j6G+Fd eDJA== 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=txvj5oWtc/P31GV0Uh1xo1g1fJq1FY4eNv//yMt29W4=; b=BvhNX1Q4CxRbnK5HDN68vlVK9yOPirHj2gPtjpnTq3BnaDdGwd2BK+M3lKRS4y542r JbRoBh/LG6xNK0/b8D6CFM0XD3uArf0edZhsC472YKPJNok2NiTJ99GvZIqY7s+s/P3z xxtMe3qCYwF0gSKdAQjR8d2eFzQ1jkxu7gqQHCpDjG8XMGRylKUX26IYOSKWOosSEhaH A7Le2BrDEs9d/dhB7Yi+T2FRQ+6y341g8m6QfKJFcmiTnyElQyUIb+mGtBVfqFR2K9FK t6WEpROYmD+lh3ymLSZQh99pP1X3BhRqWt5pwiS3b8W/2WrbxmpAKeI6Z/yKUfxFrxS0 kd/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=YEmcdpxF; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id je10-20020a170903264a00b001ab29399c72si8660070plb.502.2023.06.07.06.08.00; Wed, 07 Jun 2023 06:08:16 -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=@gmail.com header.s=20221208 header.b=YEmcdpxF; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238985AbjFGM7Y (ORCPT + 99 others); Wed, 7 Jun 2023 08:59:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234402AbjFGM7X (ORCPT ); Wed, 7 Jun 2023 08:59:23 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01980173A; Wed, 7 Jun 2023 05:59:22 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id d2e1a72fcca58-651ffcc1d3dso4220980b3a.3; Wed, 07 Jun 2023 05:59:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686142761; x=1688734761; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=txvj5oWtc/P31GV0Uh1xo1g1fJq1FY4eNv//yMt29W4=; b=YEmcdpxFcB9I3H+YO71oKMJvqeEPaPcKcpdXTTDvzrTc7gGD8VD4dGMLnaMfPGrlEK kgd/2SmEYn0uauk1LiXglu9G5fkPmtGTQwBYi3Vh5UJHui64HY8Y7OxkJqq5NsUksjDV SuNMs7eTRqhxTk47UMXzVWZPdGWghqJ9+cG21kmfzB3Exxa+3WN8XUBC/AlI7mWZWZhT wifR3esCLt84eJqCP+UOTIEcd0MymXErhnLDIZOEYH0aDMMuvippZcq3LG5QtjEYl6Ag +XVOgenvomX9fmzX+rjQTVMR5NbrX9UeLMe6O1O1SlEsbKMcTMsWnU620A84ovYMLUhP 2MvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686142761; x=1688734761; 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=txvj5oWtc/P31GV0Uh1xo1g1fJq1FY4eNv//yMt29W4=; b=VOAWvqZmrv8J4RXRGWW2OBsUFdXKv55AK1daE/6/fayEF1Iz4DIC9ltcoGSy7Uy/uB 3twsOsG5OYBtO4B+GuuhTL+DV7yIXIid8+F6mR9G+RN0DdsnB66mWOFHLWq+BMrzHrAJ 2gw3cmDLvyJlxBuKq5Tvr9ph85tm0tOdO7UQDyAH98rB0mb2GoQktcqJZcAOz1YLj6D+ BXYidzSSmP29Y2VEFmNCCxzigGfzBv0kiZYft3tqbtMJLjdJphQVAdO+HGsbq14VdG/b UaV25d9mJ83JBxsQO60bQ4e2y7l2I+Wh7oNBQCc17sKg2R08V3Ri9rHTdxcHvwEJ8SV9 WP5Q== X-Gm-Message-State: AC+VfDy7XqIVxM0aAhEXxVK7BB3Lb/QIo3E93SwI/To49eduWn4+8Kqc d57N/aoMh0Wjw1o9M/IaoGU= X-Received: by 2002:a05:6a00:14d4:b0:646:b165:1b29 with SMTP id w20-20020a056a0014d400b00646b1651b29mr4246139pfu.23.1686142761234; Wed, 07 Jun 2023 05:59:21 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.83]) by smtp.gmail.com with ESMTPSA id p1-20020a62ab01000000b0065434edd521sm7094982pff.196.2023.06.07.05.59.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 05:59:20 -0700 (PDT) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: alexei.starovoitov@gmail.com Cc: davem@davemloft.net, dsahern@kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, x86@kernel.org, imagedong@tencent.com, benbjiang@tencent.com, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH bpf-next v3 0/3] bpf, x86: allow function arguments up to 12 for TRACING Date: Wed, 7 Jun 2023 20:59:08 +0800 Message-Id: <20230607125911.145345-1-imagedong@tencent.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 From: Menglong Dong For now, the BPF program of type BPF_PROG_TYPE_TRACING can only be used on the kernel functions whose arguments count less than 6. This is not friendly at all, as too many functions have arguments count more than 6. Therefore, let's enhance it by increasing the function arguments count allowed in arch_prepare_bpf_trampoline(), for now, only x86_64. In the 1st patch, we make arch_prepare_bpf_trampoline() support to copy function arguments in stack for x86 arch. Therefore, the maximum arguments can be up to MAX_BPF_FUNC_ARGS for FENTRY and FEXIT. In the 2nd patch, we clean garbage value in upper bytes of the trampoline when we store the arguments from regs into stack. And the 3rd patches are for the testcases of the 1st patch. Changes since v2: - keep MAX_BPF_FUNC_ARGS still - clean garbage value in upper bytes in the 2nd patch - move bpf_fentry_test{7,12} to bpf_testmod.c and rename them to bpf_testmod_fentry_test{7,12} meanwhile in the 3rd patch Changes since v1: - change the maximun function arguments to 14 from 12 - add testcases (Jiri Olsa) - instead EMIT4 with EMIT3_off32 for "lea" to prevent overflow Menglong Dong (3): bpf, x86: allow function arguments up to 12 for TRACING bpf, x86: clean garbage value in the stack of trampoline selftests/bpf: add testcase for FENTRY/FEXIT with 6+ arguments arch/x86/net/bpf_jit_comp.c | 105 +++++++++++++++--- .../selftests/bpf/bpf_testmod/bpf_testmod.c | 19 +++- .../selftests/bpf/prog_tests/fentry_fexit.c | 4 +- .../selftests/bpf/prog_tests/fentry_test.c | 2 + .../selftests/bpf/prog_tests/fexit_test.c | 2 + .../testing/selftests/bpf/progs/fentry_test.c | 21 ++++ .../testing/selftests/bpf/progs/fexit_test.c | 33 ++++++ 7 files changed, 169 insertions(+), 17 deletions(-) -- 2.40.1