Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4711441pxb; Tue, 22 Feb 2022 04:45:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJyxLtErusVfgKgoTPlbSd2BVsMUcfSn0hDjjB3Kiz1ceIt24667QJQJeWYCt5wgwv8fgC40 X-Received: by 2002:a17:903:2d0:b0:14d:8a8d:cb1 with SMTP id s16-20020a17090302d000b0014d8a8d0cb1mr22594457plk.50.1645533902552; Tue, 22 Feb 2022 04:45:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645533902; cv=none; d=google.com; s=arc-20160816; b=ADcxqwf/n0+GnMD31t1j0VmK7fBEqsRHp8VOY1WpWyMgfkbJK+ozxH/4BXWAM4sQIp w6ajpKsGH2TXoh0xLN7Ox6/Vek9rTduJTbNwpggn28PdQ26kZGIuNFchYerEjHbRfE3L c8xpXh3iQ3qVu0o1cwcg6TF1ZIuBcxvCFMJTkMrS1oGMfRRv2Fygj/N2uXko6o5S10ed x310rPoUuboRfmuU62fKWH7fQ7wjQP4LC6JuWpcFYO5SbBHRq/19ZRw55yG+x27g3MT+ vjxhDkaJgHJIEW0R8xDJm/YB5Adb038uH27vnseejSIg6RMoEbDn2nMpJKJ2hrSnAqN1 tN+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=SjTF90D7jglZZSWgieWQkTF5wriUjeqm7vuG3osccpg=; b=YldlRg446ebVkgaA5OMP3fQKBfJNxrz3ked7BQoVvVsdwRd9kC2CieYIW5eRHD2swb X5parlwdjfioI6xA8mWvBXumW/wsJ0llFNtM2FRyGcvSDPF92WXy4IHQLzAImfyaofkb rWiJbEzzXG6SZbJBm+/MwzOt/W1OoycZkbOK7va8I9WRGM+Dnohx9MlUA6tauH1mLLAW EvbCi1I9iUOgEld4JLL9+cr0P+DO2yLdp8o1YxkgYJSvQLv3Jcu1BBoxF9A68QPqLwXu BriTWekDi0fbNbGH3P3SM3lxNWPZhdYI0NoF/uKMsmGBo/tw/FX+ZYCP9m92CIYII07r DwEw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 4si10804584pgx.345.2022.02.22.04.44.48; Tue, 22 Feb 2022 04:45:02 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230401AbiBVJ5y (ORCPT + 99 others); Tue, 22 Feb 2022 04:57:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230397AbiBVJ5l (ORCPT ); Tue, 22 Feb 2022 04:57:41 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 862BCD2249; Tue, 22 Feb 2022 01:57:14 -0800 (PST) Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9DxmMhzsxRiHa8EAA--.4515S4; Tue, 22 Feb 2022 17:57:08 +0800 (CST) From: Tiezhu Yang To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh Cc: Xuefeng Li , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next v3 2/2] bpf: Make BPF_JIT_DEFAULT_ON selectable in Kconfig Date: Tue, 22 Feb 2022 17:57:06 +0800 Message-Id: <1645523826-18149-3-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1645523826-18149-1-git-send-email-yangtiezhu@loongson.cn> References: <1645523826-18149-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf9DxmMhzsxRiHa8EAA--.4515S4 X-Coremail-Antispam: 1UD129KBjvJXoW7KF1kuw4UKw13uFykAF1rtFb_yoW8Zw4Dpw 4jqw1rKr92gr1fKayxCa47WF45G34UWr1UCFsxJ347ZF93AasrZr4ktr12qF17Zr92ga1Y qrZ5uF1kXa1Uu37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPG14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jryl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UM2 8EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwCY02Avz4vE14v_GFWl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l x2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14 v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IY x2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87 Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIF yTuYvjfUYJ5rUUUUU X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, 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 Currently, only x86, arm64 and s390 select ARCH_WANT_DEFAULT_BPF_JIT, the other archs do not select ARCH_WANT_DEFAULT_BPF_JIT. On the archs without ARCH_WANT_DEFAULT_BPF_JIT, if we want to set bpf_jit_enable to 1 by default, the only way is to enable CONFIG_BPF_JIT_ALWAYS_ON, then the users can not change it to 0 or 2, it seems bad for some users. We can select ARCH_WANT_DEFAULT_BPF_JIT for those archs if it is proper, but at least for now, make BPF_JIT_DEFAULT_ON selectable can give them a chance. Additionally, with this patch, under !BPF_JIT_ALWAYS_ON, we can disable BPF_JIT_DEFAULT_ON on the archs with ARCH_WANT_DEFAULT_BPF_JIT when make menuconfig, it seems flexible for some developers. Signed-off-by: Tiezhu Yang --- kernel/bpf/Kconfig | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/Kconfig b/kernel/bpf/Kconfig index f3db15a..8521874 100644 --- a/kernel/bpf/Kconfig +++ b/kernel/bpf/Kconfig @@ -54,6 +54,7 @@ config BPF_JIT config BPF_JIT_ALWAYS_ON bool "Permanently enable BPF JIT and remove BPF interpreter" depends on BPF_SYSCALL && HAVE_EBPF_JIT && BPF_JIT + select BPF_JIT_DEFAULT_ON help Enables BPF JIT and removes BPF interpreter to avoid speculative execution of BPF instructions by the interpreter. @@ -63,8 +64,16 @@ config BPF_JIT_ALWAYS_ON failure. config BPF_JIT_DEFAULT_ON - def_bool ARCH_WANT_DEFAULT_BPF_JIT || BPF_JIT_ALWAYS_ON - depends on HAVE_EBPF_JIT && BPF_JIT + bool "Enable BPF JIT by default" + default y if ARCH_WANT_DEFAULT_BPF_JIT + depends on BPF_SYSCALL && HAVE_EBPF_JIT && BPF_JIT + help + Enables BPF JIT by default to avoid speculative execution of BPF + instructions by the interpreter. + + When CONFIG_BPF_JIT_DEFAULT_ON is enabled but CONFIG_BPF_JIT_ALWAYS_ON + is disabled, /proc/sys/net/core/bpf_jit_enable is set to 1 by default + and can be changed to 0 or 2. config BPF_UNPRIV_DEFAULT_OFF bool "Disable unprivileged BPF by default" -- 2.1.0