From nobody Mon Feb 9 09:33:08 2026 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) (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 1C503337BB4 for ; Wed, 24 Dec 2025 13:09:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766581743; cv=none; b=FO+N8ue0P2TpELisNJM1TFR0kOiz1WkMNksJ+YA3u8nvtFKiw1T16yDRMP1KPnvjE5zfyMEzKAJfhu2odeoJZjHX45+pH/dgoXNKywDQdOMaBShCFbdruN1V6YhFEGdYwwkeycAAXJAyNlBDwCu4Wb2LrOLJKNla3ivE2XLhpnI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766581743; c=relaxed/simple; bh=8UjztYwJ3V5glcGLXb6BENiANc0oStuVeMSUdlMadWU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=db5qThMf6/J+/NFay/wQnjBFSc5FRirV8gNCYCaAXYP4aGatjvtwNwA7vs0rIJpwJLIpji/AjBe3Z7/xr+jqrRhWZW/C2Nc2cqlwpyUDd1G8hn+lnsxJzdnViAQM2j5KEBrGyUG+UQQ0bilAA0wg+7v+wMfk9xHhktdX/wSnXN0= 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=JwtpgmU+; arc=none smtp.client-ip=209.85.210.196 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="JwtpgmU+" Received: by mail-pf1-f196.google.com with SMTP id d2e1a72fcca58-8035e31d834so3329048b3a.2 for ; Wed, 24 Dec 2025 05:09:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766581740; x=1767186540; 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=zYyVRjly71IVaO9XpSMOkg3chszPFkxF2ByaNmXFw0U=; b=JwtpgmU+axPMV354GF5rKyQGBuMCnvO7N/YiVvTY9Gvi5haZ+KeyoE/RJX1R480w7p eOMpAikR650ghga+M22qQW7vWrC9oE1MxO1rlGwokPLPSWAlsfLGSRM5nslPHfEF0XSa qv128otBSgCNSj4JvwfcG7Sa2odfUvUWTgv6XH6PxMoHXNkCHGAm/b9ee27Z351g4brb 9JLJXanDDw8enyXOxOQG4VjLOVBA48U2xfYOQxei4Veat75blsetkOJmBhV/ilvZDcCB jHWCI3ZJ+WiVp3hWn31uoI91Z/FABeBhP32ECR/ZRhFRm1Js0M9mIgxeHkeM9iTndoOd T3Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766581740; x=1767186540; 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=zYyVRjly71IVaO9XpSMOkg3chszPFkxF2ByaNmXFw0U=; b=fpk1JbJkXf2KI1rgm/viSw0BU+Xnq9yoiHdZPa5P9KLhwHjgCfVdm5b1q589QvPBXk v86PGFg6J9uh3D9/ZupjtW0Dk18DU6StT15XFYfDoi2qIdI5CMB7TP8ky7Vpi9a7CQby 60xcSjNm73OdlOJbJ/KtX3EqUKkiSFawL9n0ixQPlrCNP5O2Uct85i/d7e9Gb0AihXp3 WWaWF5C6fwqPx9A/2Hs3JzCLawl1p3Gvn7FSqRnn72sISpXGfDrnI00NNIofBstyb9NJ hJEXKdlnBaFYZFgk7mXywHk1GfmtV+8nM73MOvC832zsKiUsI17f8ykabW7SqniCrP9L izmw== X-Forwarded-Encrypted: i=1; AJvYcCXD/Jeoxnh4j/bG1CoHn1tf60d9bIxVY0wVNMXhXXV4HXYO3lSzDcVa7WWLLX0DzKtfbxCV3esbUQif9bo=@vger.kernel.org X-Gm-Message-State: AOJu0YwYKSLXreyEGQMk2t4ziiwtynoNJZqy2cLrGbGvqcmmrle/izLM HFCKus5kGWJ6Fejm/ozUrxILEBBoFCtirwbPYmN8a7FEzjqHe9qtBg9a X-Gm-Gg: AY/fxX765H7zYl5IwEXrlFZRGjM5saiAjwC1euh2cjC0V94b1eqSbn/0HEuV9ZyF5p4 upj8eTW6dSTMepPev6ehLQeHCaHrArlSxjvNBtqcuPzAhtkhR9DLtosMoh62hz7lWekkJsA/vl0 RJ1n4iRuXjfONUwNLFPwmjtvdX3o6baDHRgjl97+inMQchivQzZI/ddSR0lSH9AKjf/1vEmxsYR 6cOcpMgmbuj2NF5GOj8h4npOoYGVlMSCU41KvHFZ4yoyWNSrT2xyhC+n2QVJ45dOES1ssnqI0kj 0rsRQHIIqflNM8MW0rJbKvBZUn1xGbPXCjOxm4DJTU48jibC/foSUP7yZfKka0Q43Vr3sc4aDWy 6IK1Ij21Xis2X445ryllu7xqaD/vqct9Tm9yzSpu964LmOWQIUhHCNTJJlnBrKOVbiC7va6tHGi KG8lmubcw= X-Google-Smtp-Source: AGHT+IErd7vAfIB+irZQwkzQ1fQaxD1AvOnZrKvCeFIJ2E1PWYMiRCEblW/NltGYCB7XCuuAuIDylg== X-Received: by 2002:a05:6a00:bb84:b0:7fb:c6ce:a863 with SMTP id d2e1a72fcca58-7ff650c8297mr17244641b3a.13.1766581740390; Wed, 24 Dec 2025 05:09:00 -0800 (PST) Received: from 7950hx ([160.187.0.149]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7ff7dfac28fsm16841173b3a.32.2025.12.24.05.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Dec 2025 05:09:00 -0800 (PST) From: Menglong Dong X-Google-Original-From: Menglong Dong To: ast@kernel.org, andrii@kernel.org Cc: daniel@iogearbox.net, 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, davem@davemloft.net, dsahern@kernel.org, tglx@linutronix.de, mingo@redhat.com, jiang.biao@linux.dev, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next v5 05/10] bpf,x86: introduce emit_st_r0_imm64() for trampoline Date: Wed, 24 Dec 2025 21:07:30 +0800 Message-ID: <20251224130735.201422-6-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251224130735.201422-1-dongml2@chinatelecom.cn> References: <20251224130735.201422-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 the helper emit_st_r0_imm64(), which is used to store a imm64 to the stack with the help of r0. Signed-off-by: Menglong Dong --- arch/x86/net/bpf_jit_comp.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index b69dc7194e2c..8cbeefb26192 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c @@ -1300,6 +1300,15 @@ static void emit_st_r12(u8 **pprog, u32 size, u32 ds= t_reg, int off, int imm) emit_st_index(pprog, size, dst_reg, X86_REG_R12, off, imm); } =20 +static void emit_st_r0_imm64(u8 **pprog, u64 value, int off) +{ + /* mov rax, value + * mov QWORD PTR [rbp - off], rax + */ + emit_mov_imm64(pprog, BPF_REG_0, value >> 32, (u32) value); + emit_stx(pprog, BPF_DW, BPF_REG_FP, BPF_REG_0, -off); +} + static int emit_atomic_rmw(u8 **pprog, u32 atomic_op, u32 dst_reg, u32 src_reg, s16 off, u8 bpf_size) { @@ -3341,16 +3350,14 @@ static int __arch_prepare_bpf_trampoline(struct bpf= _tramp_image *im, void *rw_im * mov rax, nr_regs * mov QWORD PTR [rbp - nregs_off], rax */ - emit_mov_imm64(&prog, BPF_REG_0, 0, (u32) nr_regs); - emit_stx(&prog, BPF_DW, BPF_REG_FP, BPF_REG_0, -nregs_off); + emit_st_r0_imm64(&prog, nr_regs, nregs_off); =20 if (flags & BPF_TRAMP_F_IP_ARG) { /* Store IP address of the traced function: * movabsq rax, func_addr * mov QWORD PTR [rbp - ip_off], rax */ - emit_mov_imm64(&prog, BPF_REG_0, (long) func_addr >> 32, (u32) (long) fu= nc_addr); - emit_stx(&prog, BPF_DW, BPF_REG_FP, BPF_REG_0, -ip_off); + emit_st_r0_imm64(&prog, (long)func_addr, ip_off); } =20 save_args(m, &prog, regs_off, false, flags); --=20 2.52.0