From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f48.google.com (mail-dl1-f48.google.com [74.125.82.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E697261B8D for ; Thu, 9 Apr 2026 01:33:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775698408; cv=none; b=aSniHSMg2STDOe900x7NpbgC6aGB6ewAywT7O0oxUajal1i8tbSUFeSXt1T7m5/UbQq3piJumsgwnFY9L6/C00fOTdkP80sbY9vqD01zqGncj/oPvQc6kRYBh9ZiP95J+oBHisfrWn4A2UTVxENay3Kfh6jou4RMaw+IoO1hnYY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775698408; c=relaxed/simple; bh=SCCR/Gf0nul7Zaf0Nv9r0CSW3xvjvY5IlOLeuG0kXmI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ah2hbTZFbUHQcvXnxxKSF/QCdEJY/cxoCItTAf6uHJIIAh4vNRkt3IAvd9WSMYsVAxKBS0Sbdvarp/IrZdqNiSiMVGYXc3CFTo0E0uUbyKYTtfEnaQRMkrE6eycni1Ftm2peOrvLelK8YO3rMt66Z+6AHe8Vfj8ht7G19m7GM8c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=k3FD11h7; arc=none smtp.client-ip=74.125.82.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="k3FD11h7" Received: by mail-dl1-f48.google.com with SMTP id a92af1059eb24-12c15414820so142342c88.0 for ; Wed, 08 Apr 2026 18:33:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775698405; x=1776303205; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=waCGVzvAnVgFsnz4MjOaxG3zma2vtbNTziRhQ8KluO4=; b=k3FD11h7rey1G2YCKKlUl71beV4nWtgK9hswzKilvbuJ/bv0+oUkLG3VE3rOULDqsH mzJ52UUuz5LI3LJuifUqYR6fw9+8hJNKOjauakxD1etW79CucbyJdIVux3Hju+H1Mzv7 2Tl2Msem6uEUuZWw6m1upbG1+D9Loa8x3ByGI3LBI+gbDyLBwqMl6VVeqUUmWUMIBOnK qUnGy0cF7NuVkSpk1xTdEr/DNMKiK1yi6teUAHP7nV4r3lQU9kQK3YbaE595sGXQmGQU vITO3oYx+DhvgKq145XsiTfqakQNNfIV9PzUB5C3MRlSukmqGhVtiJeL7aI3i4Qt6C6k hbQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775698405; x=1776303205; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=waCGVzvAnVgFsnz4MjOaxG3zma2vtbNTziRhQ8KluO4=; b=HvxLSOza75+0xDl2CaOOcYIK9GojVtYzv4VJT2o6KF8ZUNrDluHDuAB/OAYBWwSf8R UsLTbzHfKQjIjUscj62GQ58Ocrl+m95eYgoPMVG8T9lk5zEJqOgTiTab9JExEfLanabV v6LZf9QBY9VamyM0etw7AL4zQ/xnkFp2S5dICJgmwAAGtGfJegWKEdw/Mv0MWS612G8p 52oOzv/iJo0Ld4ojdTnJ5OCFgaEHfLlIJEMjMIJt6AeJHgRloRtraTitESwPxbLcZEre sc05IP/TFDqJ+lbcreHD9a0R3JGKi/2jcdQ278gTg/I+CsaMo4MdvW7M9OiRmc1QGZfL 3Xqw== X-Gm-Message-State: AOJu0Yw5FrLhu9XPBobf0By1DgdcLKDicfwvuSFFxDFNmC9ptgUl0M1v uXUODVckDH2A3FmlzC1FsZrn8e2bukf2AzPLajEtoI2qLytxq8NWrbUeeODZNlbd X-Gm-Gg: AeBDiesYunOsOmp3kCzBbEvUjaL/8ARm6bdWniFAyUj9dcxgc6SvxfFRRrUMUeVFkrH yjUXJmZBMbaan5L+xM479KPM2XyETLfSIvWJ21aEBA+QUN7/oMx67erByy/ieUgJYlf/ub7wabT j+FNjVX8uecN68D67KPH9htR8zRYcNFU+1NNnacSyJlTq1DnsBTAyQgQkatxBJ9B9yBQzVmSm4z LOmJInB9VkE53G3oHJ7U5X2Q+eqNTku5HxpNdOpro0/8gwKFFe17yY+FnylKpr66Z8brc1MZSPn UNm4Ryhmu+ZNrJEzDBM/g1aT5HhTiGBU2N0jGESDyHgxxwTUa005KgNXojCfOMvYV806XFzXSto y3qBmQU6h4uSTyGsriYNf+ZOrJ8p8EE/+jNyckK87aL4epnUNBvp0+U08OxbE9+lVOlpfiX9K7s I3gskWkOH9SoQH1S2WeD7QSmKXjBkoRAva3zd9UzmuO/y1pQ1RujoiSE3MojVWh3mkxxSeOAxKN iE= X-Received: by 2002:a05:7022:4182:b0:119:e569:f84d with SMTP id a92af1059eb24-12c28bf351bmr736324c88.4.1775698404672; Wed, 08 Apr 2026 18:33:24 -0700 (PDT) Received: from ezingerman-fedora-PF4V722J.thefacebook.com ([2620:10d:c090:500::c05]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12c0ce7dfe8sm15943230c88.3.2026.04.08.18.33.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 18:33:24 -0700 (PDT) From: Eduard Zingerman To: bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org Cc: daniel@iogearbox.net, martin.lau@linux.dev, kernel-team@fb.com, yonghong.song@linux.dev, eddyz87@gmail.com Subject: [PATCH bpf-next 01/14] bpf: share several utility functions as internal API Date: Wed, 8 Apr 2026 18:33:03 -0700 Message-ID: <20260408-patch-set-v1-1-1a666e860d42@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408-patch-set-v1-0-1a666e860d42@gmail.com> References: <20260408-patch-set-v1-0-1a666e860d42@gmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Namely: - bpf_subprog_is_global - bpf_vlog_alignment Signed-off-by: Eduard Zingerman --- include/linux/bpf_verifier.h | 2 ++ kernel/bpf/log.c | 4 ++-- kernel/bpf/verifier.c | 10 +++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h index 36bfd96d4563087209d73dfcfe43786df0184256..15f7f9f35be98f6f30c46cdf03cf5c0249a8ac38 100644 --- a/include/linux/bpf_verifier.h +++ b/include/linux/bpf_verifier.h @@ -1121,12 +1121,14 @@ void print_verifier_state(struct bpf_verifier_env *env, const struct bpf_verifie u32 frameno, bool print_all); void print_insn_state(struct bpf_verifier_env *env, const struct bpf_verifier_state *vstate, u32 frameno); +u32 bpf_vlog_alignment(u32 pos); struct bpf_subprog_info *bpf_find_containing_subprog(struct bpf_verifier_env *env, int off); int bpf_jmp_offset(struct bpf_insn *insn); struct bpf_iarray *bpf_insn_successors(struct bpf_verifier_env *env, u32 idx); void bpf_fmt_stack_mask(char *buf, ssize_t buf_sz, u64 stack_mask); bool bpf_calls_callback(struct bpf_verifier_env *env, int insn_idx); +bool bpf_subprog_is_global(const struct bpf_verifier_env *env, int subprog); int bpf_find_subprog(struct bpf_verifier_env *env, int off); int bpf_compute_const_regs(struct bpf_verifier_env *env); diff --git a/kernel/bpf/log.c b/kernel/bpf/log.c index 37d72b0521920daf6f3274ad77d055c8b3aafa1b..f0902ecb7df69b6d43deaf808b4c0f00cc3438f2 100644 --- a/kernel/bpf/log.c +++ b/kernel/bpf/log.c @@ -847,7 +847,7 @@ void print_verifier_state(struct bpf_verifier_env *env, const struct bpf_verifie mark_verifier_state_clean(env); } -static inline u32 vlog_alignment(u32 pos) +u32 bpf_vlog_alignment(u32 pos) { return round_up(max(pos + BPF_LOG_MIN_ALIGNMENT / 2, BPF_LOG_ALIGNMENT), BPF_LOG_MIN_ALIGNMENT) - pos - 1; @@ -859,7 +859,7 @@ void print_insn_state(struct bpf_verifier_env *env, const struct bpf_verifier_st if (env->prev_log_pos && env->prev_log_pos == env->log.end_pos) { /* remove new line character */ bpf_vlog_reset(&env->log, env->prev_log_pos - 1); - verbose(env, "%*c;", vlog_alignment(env->prev_insn_print_pos), ' '); + verbose(env, "%*c;", bpf_vlog_alignment(env->prev_insn_print_pos), ' '); } else { verbose(env, "%d:", env->insn_idx); } diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 84699a428077d66f68203cdcccddee5f8207cd34..dd81cfbad680712e4d871163b8ee179fafe8587c 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -421,7 +421,7 @@ static struct btf_record *reg_btf_record(const struct bpf_reg_state *reg) return rec; } -static bool subprog_is_global(const struct bpf_verifier_env *env, int subprog) +bool bpf_subprog_is_global(const struct bpf_verifier_env *env, int subprog) { struct bpf_func_info_aux *aux = env->prog->aux->func_info_aux; @@ -4610,7 +4610,7 @@ static int backtrack_insn(struct bpf_verifier_env *env, int idx, int subseq_idx, if (subprog < 0) return -EFAULT; - if (subprog_is_global(env, subprog)) { + if (bpf_subprog_is_global(env, subprog)) { /* check that jump history doesn't have any * extra instructions from subprog; the next * instruction after call to global subprog @@ -6971,7 +6971,7 @@ static int check_max_stack_depth_subprog(struct bpf_verifier_env *env, int idx, if (subprog[idx].has_tail_call) tail_call_reachable = true; - frame = subprog_is_global(env, idx) ? 0 : frame + 1; + frame = bpf_subprog_is_global(env, idx) ? 0 : frame + 1; if (frame >= MAX_CALL_FRAMES) { verbose(env, "the call stack of %d frames is too deep !\n", frame); @@ -11040,7 +11040,7 @@ static int check_func_call(struct bpf_verifier_env *env, struct bpf_insn *insn, err = btf_check_subprog_call(env, subprog, caller->regs); if (err == -EFAULT) return err; - if (subprog_is_global(env, subprog)) { + if (bpf_subprog_is_global(env, subprog)) { const char *sub_name = subprog_name(env, subprog); if (env->cur_state->active_locks) { @@ -25186,7 +25186,7 @@ static int do_check_subprogs(struct bpf_verifier_env *env) again: new_cnt = 0; for (i = 1; i < env->subprog_cnt; i++) { - if (!subprog_is_global(env, i)) + if (!bpf_subprog_is_global(env, i)) continue; sub_aux = subprog_aux(env, i); -- 2.53.0