From nobody Tue Feb 10 05:17:17 2026 Received: from mail-qv1-f65.google.com (mail-qv1-f65.google.com [209.85.219.65]) (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 24CD7202F65 for ; Tue, 3 Feb 2026 05:52:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770097980; cv=none; b=Ez3RDhmczFbtSCbEVNJZeqMJrKg9smVTe/0WdD3I7epP6IVRGFt7+tRT1274F0AyFJNCqFpRshBCVXg4zl6IR7PhVJB1kNihYorHXnHQ594gRtGOHaGuYY7mXhb6eV30Z2H0A+uKzWPgehQDCuCy8vkdnv6oOkW00NN4FtNdNmM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770097980; c=relaxed/simple; bh=070F55rMJkahswIvT4jf6jx3vQtTz2wLV+jQ3NAeigI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t30dbRCCaVkw52r+O01k5+E6zIxOQfRKKOTxOjpYDqhJwJvwnTt7ucqmhCBcCQA06db0VfcNFj4UQJWbSDLRJhV1gVhTMEYg4J5LQk12Bg/OoLNPckVUBjJELXrTcNrNuf0aNLDsy+rC7CCnWU7ZRsMWDUR/oPEOI3o/mpCX2XU= 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=IbDqcrEq; arc=none smtp.client-ip=209.85.219.65 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="IbDqcrEq" Received: by mail-qv1-f65.google.com with SMTP id 6a1803df08f44-88888c41a13so67497996d6.3 for ; Mon, 02 Feb 2026 21:52:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770097978; x=1770702778; 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=PzVkfCKgUCL7plixo/BQ6/TFm6BL7pd9AJ8r1pM28SI=; b=IbDqcrEq+9tiqyfkS40tPk90jEukTVjGONCcb/6W1iwcBDlkHoZkpxzT08KzMsqjUA Qla1cOx/U5BI9YgsAsLur2zUYvcgEfXaRdugWzrDa/F4DPa3g4lbmTpEYZvTfVsxXLHv 3LxXwy6B0jQ0EgXgZogYYMKh2gsEBmDPStRUzYm8IYeOF+iRQ1MXzbQJ0K20ik9fQfFX jiq7WFWWkySrixU9ycDjsk6eEbEBsmDGggdAIC0MzW7hzm2u/6h99C4qfeIi0lpTfl14 KlfNO2GSE06mm6vcDDx/nxm2qrsH+gch8I4H1BAkxpcHfy7z7MuGwMD95LrfB9qqWkpK DmUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770097978; x=1770702778; 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=PzVkfCKgUCL7plixo/BQ6/TFm6BL7pd9AJ8r1pM28SI=; b=qdj1Tz/CiUaKN6ULaU8ULZG2OjuIhwKDuR6iotIOpE49aQrf0hEEHiRf0slEa5MNNC 8Ng4pRSl5y7VKFPzjqz6cbKu2ZTe9KT0Q+rSI3w6doojnlAmVPh57BcArjzgGt/aIexZ NvOLJYfr5f1FW6RUFcHWdEccCUADPEpmzwVOxKM8nEsRXs5v+Uh6oapqB18P10MwoU1H XHuCTiaUGMyNk9ONwu7ngfc5g1fESWh09JpbQWial5/fXKvp1mLwkugeMuda8oAvZ7C8 Wc39UjN3mAOBWmYffGuV4xeuJJ6WHUhrhvGvV6jhAu8mPi3RV9Mi5WkhlJm4f3s0/c4B JG7Q== X-Forwarded-Encrypted: i=1; AJvYcCWML7kcyahguJ7j92GTNx3NmX9CiKLYjJqVaHbJSR1+nKmlK28kf9IXzHqyqhoCMgvTgx2WpGWtsJrYdEg=@vger.kernel.org X-Gm-Message-State: AOJu0YyMVaM5Qeashk1i5ecsAzUXQx4EI/dtUFpd5VlZyuQY7MnvoEmq IlObQtPwctDayVyOeJj2rpRiopGGzuWdBZ60n++hh2hGV/8xFZwoxhPC X-Gm-Gg: AZuq6aL5hMVcCdY8DLmuXXKnCrnO9sqqvwd4fDMBu8AGWVCCEBzLoBBukJhFuqturEi 6Q3FwYmf7V5537bJM0GR+aT9g8nIZISmnrrIg+gCgOPK5nViHC3oehHGDMpvC0dQf53rQHzTEYk N5I5OaJTQJZu5xlzaDXBzwUnK1RBh/90mzl3G84sxLlXLe1v03smZdMtjOfcNheti1+/FDntIrK L9kqmwUga3ZkKhCSbr87rwSDCECGyG5qMHaMHQHxOk1DA8Qd4sPKWPRJ5YuenPo6lr1qGgRsYsR Idgokl9oUFg/votb1jVkERtwdrcqwd1dU0LlBXwW2WS03MlQY1HwwvyXO+P3XLMicLSefK2MgWF pH0yQ6H2wr6peUoF0/Mzr/wcU8d4L6ZZmaK/QpFKHwA/oTxrib1DPUpGEoeB8B0+Kq/K43oJPhS 9/WlUGVmE= X-Received: by 2002:ac8:5a0d:0:b0:4f4:e15d:f220 with SMTP id d75a77b69052e-505d2183d83mr151199911cf.25.1770097978028; Mon, 02 Feb 2026 21:52:58 -0800 (PST) Received: from 7940hx ([23.94.188.235]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-894d376e65bsm129844996d6.55.2026.02.02.21.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Feb 2026 21:52:57 -0800 (PST) From: Menglong Dong X-Google-Original-From: Menglong Dong To: ast@kernel.org Cc: daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com, jolsa@kernel.org, bjorn@kernel.org, pulehui@huawei.com, puranjay@kernel.org, pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr, jiang.biao@linux.dev, bpf@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next 1/3] bpf, riscv: introduce emit_store_stack_imm64() for trampoline Date: Tue, 3 Feb 2026 13:52:29 +0800 Message-ID: <20260203055231.1088479-2-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260203055231.1088479-1-dongml2@chinatelecom.cn> References: <20260203055231.1088479-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce a helper to store 64-bit immediate on the trampoline stack with a help of a register. Signed-off-by: Menglong Dong --- arch/riscv/net/bpf_jit_comp64.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp6= 4.c index 37888abee70c..e4f45e2e7e2f 100644 --- a/arch/riscv/net/bpf_jit_comp64.c +++ b/arch/riscv/net/bpf_jit_comp64.c @@ -926,6 +926,14 @@ static void restore_stack_args(int nr_stack_args, int = args_off, int stk_arg_off, } } =20 +static void emit_store_stack_imm64(u8 reg, int stack_off, u64 imm64, + struct rv_jit_context *ctx) +{ + /* Load imm64 into reg and store it at [FP + stack_off]. */ + emit_imm(reg, (s64)imm64, ctx); + emit_sd(RV_REG_FP, stack_off, reg, ctx); +} + static int invoke_bpf_prog(struct bpf_tramp_link *l, int args_off, int ret= val_off, int run_ctx_off, bool save_ret, struct rv_jit_context *ctx) { @@ -933,12 +941,10 @@ static int invoke_bpf_prog(struct bpf_tramp_link *l, = int args_off, int retval_of struct bpf_prog *p =3D l->link.prog; int cookie_off =3D offsetof(struct bpf_tramp_run_ctx, bpf_cookie); =20 - if (l->cookie) { - emit_imm(RV_REG_T1, l->cookie, ctx); - emit_sd(RV_REG_FP, -run_ctx_off + cookie_off, RV_REG_T1, ctx); - } else { + if (l->cookie) + emit_store_stack_imm64(RV_REG_T1, -run_ctx_off + cookie_off, l->cookie, = ctx); + else emit_sd(RV_REG_FP, -run_ctx_off + cookie_off, RV_REG_ZERO, ctx); - } =20 /* arg1: prog */ emit_imm(RV_REG_A0, (const s64)p, ctx); @@ -1123,13 +1129,10 @@ static int __arch_prepare_bpf_trampoline(struct bpf= _tramp_image *im, emit_sd(RV_REG_FP, -sreg_off, RV_REG_S1, ctx); =20 /* store ip address of the traced function */ - if (flags & BPF_TRAMP_F_IP_ARG) { - emit_imm(RV_REG_T1, (const s64)func_addr, ctx); - emit_sd(RV_REG_FP, -ip_off, RV_REG_T1, ctx); - } + if (flags & BPF_TRAMP_F_IP_ARG) + emit_store_stack_imm64(RV_REG_T1, -ip_off, (u64)func_addr, ctx); =20 - emit_li(RV_REG_T1, nr_arg_slots, ctx); - emit_sd(RV_REG_FP, -nregs_off, RV_REG_T1, ctx); + emit_store_stack_imm64(RV_REG_T1, -nregs_off, nr_arg_slots, ctx); =20 store_args(nr_arg_slots, args_off, ctx); =20 --=20 2.52.0