From nobody Tue Sep 29 02:33:43 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4A3F352015; Thu, 13 Aug 2026 07:19:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786605554; cv=none; b=KWOmQqbKzukGIkvtBV3wN2OE++seVUldb4ZGn84M8oZXpqFm3+s76rGFi6NWtFAesQahYWUgaoeXpAQuM0R9fFoANtktVLwW6sFymi94ctohNbC4zMcWlZ+nQ3Fie7hgELVq13jiu4A+RQNEJE4pn5iqwkk44javAiLdWL+8Rzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786605554; c=relaxed/simple; bh=0kS+/pvdCQGVYJfx53V964WwBqdInsQldAZzKhWH7cg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PxiY+p9XeN0ZYylyxseUy3vAuOCEt5lJ05KluvW5w0sE/xWKWkbvYTDafF0rIdNGsKBInHDJXbhUZe2s60M6jWPheSycS4pIBqaoKMtHAQk4onelx0cu/65GNTD8qA1tZb6CgJKjfgoAEcW5qzWLikEFwfRkwvdXWs9tMFk0gQo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 43d09f8096e711f1aa26b74ffac11d73-20260813 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.12,REQID:bfa4271e-d950-4b3f-b761-8033f5158399,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:e7bac3a,CLOUDID:104495b2bb17de7876dcd231f2122c1a,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|136|850|865|898,TC:nil,Content :0|15|50,EDM:-3|-100,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil, COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 43d09f8096e711f1aa26b74ffac11d73-20260813 X-User: jiangfeng@kylinos.cn Received: from [127.0.0.1] [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 1018791147; Thu, 13 Aug 2026 15:19:04 +0800 From: Feng Jiang Date: Thu, 13 Aug 2026 07:18:42 +0000 Subject: [PATCH bpf-next v2 1/2] bpf, riscv: Add BPF stack arguments support for RV64 JIT Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260813-bpf-riscv-stack-args-v2-1-efea8f9b3fe1@kylinos.cn> References: <20260813-bpf-riscv-stack-args-v2-0-efea8f9b3fe1@kylinos.cn> In-Reply-To: <20260813-bpf-riscv-stack-args-v2-0-efea8f9b3fe1@kylinos.cn> To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Ihor Solodrai , Luke Nelson , Xi Wang , =?utf-8?q?Bj=C3=B6rn_T=C3=B6pel?= , Pu Lehui , Puranjay Mohan , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Shuah Khan , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: bpf@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Feng Jiang X-Mailer: b4 0.14.3 Add bpf_jit_supports_stack_args() for the RV64 JIT so BPF subprograms and kfuncs can receive more than 5 arguments via the stack (BPF_REG_PARAMS / r11). For BPF-to-BPF calls the caller writes outgoing arguments at the bottom of its frame (SP-relative). The callee reads them with FP-relative loads. Its FP is set to the caller SP in the prologue, so the offsets match. The RISC-V ABI puts arguments 6-8 in A5-A7 and arguments 9+ at SP+0. Before each kfunc call, load arguments 6-8 from the outgoing area into A5-A7 and copy any remaining arguments down so argument 9 lands at SP+0. A5 (BPF_REG_0), A6 (TCC) and A7 are safe to clobber here: R0 is not live before a call, TCC is backed up on the stack, and A7 is unused by the JIT. Limit the existing kfunc sign-extension loop to MAX_BPF_FUNC_REG_ARGS iterations; otherwise idx >=3D 5 resolves to S1-S5 (BPF_R6-FP) and corrupts callee-saved registers. Signed-off-by: Feng Jiang --- arch/riscv/net/bpf_jit.h | 1 + arch/riscv/net/bpf_jit_comp64.c | 79 +++++++++++++++++++++++++++++++++++++= ++-- arch/riscv/net/bpf_jit_core.c | 4 +++ 3 files changed, 81 insertions(+), 3 deletions(-) diff --git a/arch/riscv/net/bpf_jit.h b/arch/riscv/net/bpf_jit.h index 419b9d795f2a..9eb4e149505d 100644 --- a/arch/riscv/net/bpf_jit.h +++ b/arch/riscv/net/bpf_jit.h @@ -82,6 +82,7 @@ struct rv_jit_context { unsigned long flags; int stack_size; int tcc_offset; + u16 stack_arg_size; u64 arena_vm_start; u64 user_vm_start; }; diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp6= 4.c index 6b9972b07c1b..58cb3e5ff6b4 100644 --- a/arch/riscv/net/bpf_jit_comp64.c +++ b/arch/riscv/net/bpf_jit_comp64.c @@ -1815,18 +1815,43 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, = struct rv_jit_context *ctx, =20 if (insn->src_reg =3D=3D BPF_PSEUDO_KFUNC_CALL) { const struct btf_func_model *fm; - int idx; + int idx, nargs; =20 fm =3D bpf_jit_find_kfunc_model(ctx->prog, insn); if (!fm) return -EINVAL; =20 - for (idx =3D 0; idx < fm->nr_args; idx++) { + nargs =3D min_t(int, fm->nr_args, MAX_BPF_FUNC_REG_ARGS); + for (idx =3D 0; idx < nargs; idx++) { u8 reg =3D bpf_to_rv_reg(BPF_REG_1 + idx, ctx); =20 if (fm->arg_size[idx] =3D=3D sizeof(int)) emit_sextw(reg, reg, ctx); } + + /* BPF stack args -> RISC-V ABI: args 6-8 in A5-A7, 9+ at SP+0 */ + if (fm->nr_args > MAX_BPF_FUNC_REG_ARGS) { + int n_stack =3D fm->nr_args - MAX_BPF_FUNC_REG_ARGS; + int n_reg =3D min_t(int, n_stack, + RV_MAX_REG_ARGS - MAX_BPF_FUNC_REG_ARGS); + + for (idx =3D 0; idx < n_reg; idx++) { + int sz =3D fm->arg_size[MAX_BPF_FUNC_REG_ARGS + idx]; + + emit_ld(RV_REG_A5 + idx, idx * 8, RV_REG_SP, ctx); + if (sz =3D=3D sizeof(int)) + emit_sextw(RV_REG_A5 + idx, RV_REG_A5 + idx, ctx); + } + + for (idx =3D n_reg; idx < n_stack; idx++) { + int sz =3D fm->arg_size[MAX_BPF_FUNC_REG_ARGS + idx]; + + emit_ld(RV_REG_T1, idx * 8, RV_REG_SP, ctx); + if (sz =3D=3D sizeof(int)) + emit_sextw(RV_REG_T1, RV_REG_T1, ctx); + emit_sd(RV_REG_SP, (idx - n_reg) * 8, RV_REG_T1, ctx); + } + } } =20 /* restore TCC to RV_REG_TCC before bpf2bpf call */ @@ -1891,6 +1916,21 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, s= truct rv_jit_context *ctx, case BPF_LDX | BPF_MEM | BPF_H: case BPF_LDX | BPF_MEM | BPF_W: case BPF_LDX | BPF_MEM | BPF_DW: + if (insn->src_reg =3D=3D BPF_REG_PARAMS) { + int idx =3D off / 8 - 1; + + if (is_12b_int(idx * 8)) { + emit_ldx_insn(rd, idx * 8, RV_REG_FP, BPF_SIZE(code), false, ctx); + } else { + emit_imm(RV_REG_T1, idx * 8, ctx); + emit_add(RV_REG_T1, RV_REG_T1, RV_REG_FP, ctx); + emit_ldx_insn(rd, 0, RV_REG_T1, BPF_SIZE(code), false, ctx); + } + if (BPF_SIZE(code) !=3D BPF_DW && insn_is_zext(&insn[1])) + return 1; + break; + } + fallthrough; case BPF_LDX | BPF_PROBE_MEM | BPF_B: case BPF_LDX | BPF_PROBE_MEM | BPF_H: case BPF_LDX | BPF_PROBE_MEM | BPF_W: @@ -1938,6 +1978,20 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, s= truct rv_jit_context *ctx, case BPF_ST | BPF_MEM | BPF_H: case BPF_ST | BPF_MEM | BPF_W: case BPF_ST | BPF_MEM | BPF_DW: + if (insn->dst_reg =3D=3D BPF_REG_PARAMS) { + int idx =3D -off / 8 - 1; + + emit_imm(RV_REG_T1, imm, ctx); + if (is_12b_int(idx * 8)) { + emit_stx_insn(RV_REG_SP, idx * 8, RV_REG_T1, BPF_SIZE(code), ctx); + } else { + emit_imm(RV_REG_T2, idx * 8, ctx); + emit_add(RV_REG_T2, RV_REG_SP, RV_REG_T2, ctx); + emit_stx_insn(RV_REG_T2, 0, RV_REG_T1, BPF_SIZE(code), ctx); + } + break; + } + fallthrough; /* ST | PROBE_MEM32: *(size *)(dst + RV_REG_ARENA + off) =3D imm */ case BPF_ST | BPF_PROBE_MEM32 | BPF_B: case BPF_ST | BPF_PROBE_MEM32 | BPF_H: @@ -1960,6 +2014,19 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, s= truct rv_jit_context *ctx, case BPF_STX | BPF_MEM | BPF_H: case BPF_STX | BPF_MEM | BPF_W: case BPF_STX | BPF_MEM | BPF_DW: + if (insn->dst_reg =3D=3D BPF_REG_PARAMS) { + int idx =3D -off / 8 - 1; + + if (is_12b_int(idx * 8)) { + emit_stx_insn(RV_REG_SP, idx * 8, rs, BPF_SIZE(code), ctx); + } else { + emit_imm(RV_REG_T1, idx * 8, ctx); + emit_add(RV_REG_T1, RV_REG_SP, RV_REG_T1, ctx); + emit_stx_insn(RV_REG_T1, 0, rs, BPF_SIZE(code), ctx); + } + break; + } + fallthrough; /* STX | PROBE_MEM32: *(size *)(dst + RV_REG_ARENA + off) =3D src */ case BPF_STX | BPF_PROBE_MEM32 | BPF_B: case BPF_STX | BPF_PROBE_MEM32 | BPF_H: @@ -2036,6 +2103,7 @@ void bpf_jit_build_prologue(struct rv_jit_context *ct= x, bool is_subprog) =20 stack_adjust =3D round_up(stack_adjust, STACK_ALIGN); stack_adjust +=3D bpf_stack_adjust; + stack_adjust +=3D ctx->stack_arg_size; =20 store_offset =3D stack_adjust - 8; =20 @@ -2093,7 +2161,7 @@ void bpf_jit_build_prologue(struct rv_jit_context *ct= x, bool is_subprog) emit_addi(RV_REG_FP, RV_REG_SP, stack_adjust, ctx); =20 if (bpf_stack_adjust) - emit_addi(RV_REG_S5, RV_REG_SP, bpf_stack_adjust, ctx); + emit_addi(RV_REG_S5, RV_REG_SP, ctx->stack_arg_size + bpf_stack_adjust, = ctx); =20 ctx->stack_size =3D stack_adjust; =20 @@ -2171,3 +2239,8 @@ bool bpf_jit_supports_timed_may_goto(void) { return true; } + +bool bpf_jit_supports_stack_args(void) +{ + return true; +} diff --git a/arch/riscv/net/bpf_jit_core.c b/arch/riscv/net/bpf_jit_core.c index cbfcd287ea16..844a0f3e0fa9 100644 --- a/arch/riscv/net/bpf_jit_core.c +++ b/arch/riscv/net/bpf_jit_core.c @@ -72,6 +72,10 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier= _env *env, struct bpf_pr ctx->arena_vm_start =3D bpf_arena_get_kern_vm_start(prog->aux->arena); ctx->user_vm_start =3D bpf_arena_get_user_vm_start(prog->aux->arena); ctx->prog =3D prog; + + ctx->stack_arg_size =3D round_up(bpf_out_stack_arg_cnt(env, prog) * + sizeof(u64), STACK_ALIGN); + ctx->offset =3D kvzalloc_objs(int, prog->len); if (!ctx->offset) goto out_offset; --=20 2.53.0 From nobody Tue Sep 29 02:33:43 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB2F943552D; Thu, 13 Aug 2026 07:19:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786605556; cv=none; b=c09p9ESaNNlKvPTBy638JRGmJbyVaUkCBEhCZoAFDDWIGSSRoPPzQHBisrJtcrhTcLPBQR+yI3m45WRhE6gtMeaDK7E1WUprhrP79UJVFSCSBODIO+h6b3zULLtBHvidxQVivAa22gy3r7+nDh0TI8baJmMdNKww+ZRCR7ErIw4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786605556; c=relaxed/simple; bh=KWz+L9i/5ad8zP6uJONMdmHEOgaQtA4jtYt5bvetSqA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FUQ9tgyRDwdVThhxZTTsK0KER/+csTB/o4d8I8VRN0JOgs1PBsKoaVIQimC5RjPXjbObuh5LYCdD8BDubp4Sq32rggRRecmXjSkho4dLyQwKgITM5po5KFQjwuClWmteewWeEigAPcGkLIjZmPGHXuDlRRyyF642eowWqSqCrzE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 447f0eb296e711f1aa26b74ffac11d73-20260813 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.12,REQID:95322ea6-7878-4845-8c38-0209cc6e8cdb,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:e7bac3a,CLOUDID:59b30b4614b8c76a0be7e304c058fcd7,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|850|865|898,TC:nil,Content:0|1 5|50,EDM:-3,IP:nil,URL:1,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI :0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_ULS X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 447f0eb296e711f1aa26b74ffac11d73-20260813 X-User: jiangfeng@kylinos.cn Received: from [127.0.0.1] [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 1220298982; Thu, 13 Aug 2026 15:19:05 +0800 From: Feng Jiang Date: Thu, 13 Aug 2026 07:18:43 +0000 Subject: [PATCH bpf-next v2 2/2] selftests/bpf: Enable stack argument tests for RV64 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260813-bpf-riscv-stack-args-v2-2-efea8f9b3fe1@kylinos.cn> References: <20260813-bpf-riscv-stack-args-v2-0-efea8f9b3fe1@kylinos.cn> In-Reply-To: <20260813-bpf-riscv-stack-args-v2-0-efea8f9b3fe1@kylinos.cn> To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Ihor Solodrai , Luke Nelson , Xi Wang , =?utf-8?q?Bj=C3=B6rn_T=C3=B6pel?= , Pu Lehui , Puranjay Mohan , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Shuah Khan , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: bpf@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Feng Jiang X-Mailer: b4 0.14.3 Enable the stack argument selftests for RV64. The riscv guard is restricted to __riscv_xlen =3D=3D 64 since stack arguments are only supported by the RV64 JIT. Keep the __BPF_FEATURE_STACK_ARGUMENT gate, defined by clang with BPF stack argument support [1]. [1] https://github.com/llvm/llvm-project/pull/189060 Signed-off-by: Feng Jiang --- tools/testing/selftests/bpf/progs/btf__stack_arg_precision.c | 3 ++- tools/testing/selftests/bpf/progs/btf__verifier_stack_arg_order.c | 3 ++- tools/testing/selftests/bpf/progs/exceptions.c | 5 +++-- tools/testing/selftests/bpf/progs/stack_arg.c | 3 ++- tools/testing/selftests/bpf/progs/stack_arg_kfunc.c | 3 ++- tools/testing/selftests/bpf/progs/stack_arg_precision.c | 3 ++- tools/testing/selftests/bpf/progs/verifier_stack_arg.c | 3 ++- tools/testing/selftests/bpf/progs/verifier_stack_arg_order.c | 3 ++- 8 files changed, 17 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/btf__stack_arg_precision.c b= /tools/testing/selftests/bpf/progs/btf__stack_arg_precision.c index 8d38aafe66a2..ab12397a9b52 100644 --- a/tools/testing/selftests/bpf/progs/btf__stack_arg_precision.c +++ b/tools/testing/selftests/bpf/progs/btf__stack_arg_precision.c @@ -4,7 +4,8 @@ #include #include "../test_kmods/bpf_testmod_kfunc.h" =20 -#if (defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64)) && \ +#if (defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64) || \ + (defined(__TARGET_ARCH_riscv) && __riscv_xlen =3D=3D 64)) && \ defined(__BPF_FEATURE_STACK_ARGUMENT) =20 long subprog_call_mem_kfunc(long a, long b, long c, long d, long e, long s= ize) diff --git a/tools/testing/selftests/bpf/progs/btf__verifier_stack_arg_orde= r.c b/tools/testing/selftests/bpf/progs/btf__verifier_stack_arg_order.c index 99bc115f8380..a980a3a399d3 100644 --- a/tools/testing/selftests/bpf/progs/btf__verifier_stack_arg_order.c +++ b/tools/testing/selftests/bpf/progs/btf__verifier_stack_arg_order.c @@ -3,7 +3,8 @@ #include #include =20 -#if (defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64)) && \ +#if (defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64) || \ + (defined(__TARGET_ARCH_riscv) && __riscv_xlen =3D=3D 64)) && \ defined(__BPF_FEATURE_STACK_ARGUMENT) =20 int subprog_bad_order_6args(int a, int b, int c, int d, int e, int f) diff --git a/tools/testing/selftests/bpf/progs/exceptions.c b/tools/testing= /selftests/bpf/progs/exceptions.c index c8d716fbd419..bae20f0f247e 100644 --- a/tools/testing/selftests/bpf/progs/exceptions.c +++ b/tools/testing/selftests/bpf/progs/exceptions.c @@ -379,8 +379,9 @@ int exception_bad_assert_range_with(struct __sk_buff *c= tx) return 1; } =20 -#if (defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64)) \ - && defined(__BPF_FEATURE_STACK_ARGUMENT) +#if (defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64) || \ + (defined(__TARGET_ARCH_riscv) && __riscv_xlen =3D=3D 64)) && \ + defined(__BPF_FEATURE_STACK_ARGUMENT) =20 const volatile bool has_stack_arg =3D true; =20 diff --git a/tools/testing/selftests/bpf/progs/stack_arg.c b/tools/testing/= selftests/bpf/progs/stack_arg.c index 944e3bb603e7..3e9ed37c57bb 100644 --- a/tools/testing/selftests/bpf/progs/stack_arg.c +++ b/tools/testing/selftests/bpf/progs/stack_arg.c @@ -21,7 +21,8 @@ struct { =20 int timer_result; =20 -#if (defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64)) && \ +#if (defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64) || \ + (defined(__TARGET_ARCH_riscv) && __riscv_xlen =3D=3D 64)) && \ defined(__BPF_FEATURE_STACK_ARGUMENT) =20 const volatile bool has_stack_arg =3D true; diff --git a/tools/testing/selftests/bpf/progs/stack_arg_kfunc.c b/tools/te= sting/selftests/bpf/progs/stack_arg_kfunc.c index 345f2da2e361..b6b1a8aa7f44 100644 --- a/tools/testing/selftests/bpf/progs/stack_arg_kfunc.c +++ b/tools/testing/selftests/bpf/progs/stack_arg_kfunc.c @@ -6,7 +6,8 @@ #include "bpf_kfuncs.h" #include "../test_kmods/bpf_testmod_kfunc.h" =20 -#if (defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64)) && \ +#if (defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64) || \ + (defined(__TARGET_ARCH_riscv) && __riscv_xlen =3D=3D 64)) && \ defined(__BPF_FEATURE_STACK_ARGUMENT) =20 const volatile bool has_stack_arg =3D true; diff --git a/tools/testing/selftests/bpf/progs/stack_arg_precision.c b/tool= s/testing/selftests/bpf/progs/stack_arg_precision.c index bee2eeec021d..6eebafe7f2f8 100644 --- a/tools/testing/selftests/bpf/progs/stack_arg_precision.c +++ b/tools/testing/selftests/bpf/progs/stack_arg_precision.c @@ -6,7 +6,8 @@ #include "../test_kmods/bpf_testmod_kfunc.h" #include "bpf_misc.h" =20 -#if (defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64)) && \ +#if (defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64) || \ + (defined(__TARGET_ARCH_riscv) && __riscv_xlen =3D=3D 64)) && \ defined(__BPF_FEATURE_STACK_ARGUMENT) =20 /* Force kfunc extern BTF generation for inline asm call below. diff --git a/tools/testing/selftests/bpf/progs/verifier_stack_arg.c b/tools= /testing/selftests/bpf/progs/verifier_stack_arg.c index 7e0ce5db28a0..e8cd296fe763 100644 --- a/tools/testing/selftests/bpf/progs/verifier_stack_arg.c +++ b/tools/testing/selftests/bpf/progs/verifier_stack_arg.c @@ -12,7 +12,8 @@ struct { __type(value, long long); } map_hash_8b SEC(".maps"); =20 -#if (defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64)) && \ +#if (defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64) || \ + (defined(__TARGET_ARCH_riscv) && __riscv_xlen =3D=3D 64)) && \ defined(__BPF_FEATURE_STACK_ARGUMENT) =20 __noinline __used diff --git a/tools/testing/selftests/bpf/progs/verifier_stack_arg_order.c b= /tools/testing/selftests/bpf/progs/verifier_stack_arg_order.c index c9fe4857da3f..562e8319ffc2 100644 --- a/tools/testing/selftests/bpf/progs/verifier_stack_arg_order.c +++ b/tools/testing/selftests/bpf/progs/verifier_stack_arg_order.c @@ -5,7 +5,8 @@ #include #include "bpf_misc.h" =20 -#if (defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64)) && \ +#if (defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64) || \ + (defined(__TARGET_ARCH_riscv) && __riscv_xlen =3D=3D 64)) && \ defined(__BPF_FEATURE_STACK_ARGUMENT) =20 __noinline __used __naked --=20 2.53.0