From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f193.google.com (mail-yw1-f193.google.com [209.85.128.193]) (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 1870D274B3B for ; Wed, 7 Jan 2026 06:45:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.193 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767768312; cv=none; b=Dn7cmd28AjSzEGvP7Jcff7xfOvqFx8Y9Fgl/bKmLrYT4E8Xf/Mz7lK3yhYsHh9q2kx0P5hNyhA2ONv49bpYf5TtnBslEqED5IwqylaHgTXQ0ehxRJReGIKCsu3T6b3DwS2BbMnjnR0xiBwT4aKcJWk9PSGCTHXR7ZhLL992aiyU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767768312; c=relaxed/simple; bh=Vk+W6eyr2IUQD5U+QNmcmmn6L3jEBra1Cbetb1uK2cc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rN5n8sAUYTO34X76vSHCLJShZDdelawV/uc0rHjKenEPG2T56uQzYsyrjTlAbwtRx/ETtMin1EBY7io6m6CQb4scTj52fKUYwBWUN2FyArjnGraGe3V+DY7LrxUJWnlxnidD4w0Otq/BZYQ29++OVUXauJXyAScIzATHJgVhQqU= 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=TIQmiXRt; arc=none smtp.client-ip=209.85.128.193 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="TIQmiXRt" Received: by mail-yw1-f193.google.com with SMTP id 00721157ae682-78fd0cd23faso18715357b3.2 for ; Tue, 06 Jan 2026 22:45:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767768310; x=1768373110; 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=u6UQnELg0jWNEfAf+zm6n+6F3yec3GYQzyGkx+3yxZQ=; b=TIQmiXRt2uTt9qqqe24xt1OcPrx8wiEG84T1EMbMUEtrTXTpfEj/TzPel86mdTSS9z 1E77EK7nDtaGUKoitXHTCjLFrCml/CClfobFAoJvSQxYETzLhhdEfP2TAG2WbD8TjY2/ wo5tR6Z7UARXkQnDexyRmmyZblhvP/7wAFjt6mIkB3HzknPAyCHEKyjePCzHUe9vW0hq C3wHNv5Qb23Ivo0qQofpC82kQTIe2yqhlmyDng8jd6mcDjBxybxh+gIgn/BLGJy+ZnSi 0tsZNYYo6tvtRYdmAgGAyDyCrAQJnoG9pNofKKuVttQbo3rpYz8CCTCL/M8TgtFGiBAZ kbyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767768310; x=1768373110; 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=u6UQnELg0jWNEfAf+zm6n+6F3yec3GYQzyGkx+3yxZQ=; b=vr5YlnWYST3/qm6XSJmKXyelmLsyOcPZIkjT/vttaiFlhWyAjRNy1bJx2w/TWJdbCX dALLhPJWcJPQJcy7k5lZWzc1IptrSo+8VDoBM3AEBU0r53tY09vJq8YmqqqxVQZU6+ZX 4kxPxprFpFWHUPTTAl4t/9JoqQjzSVsx7LYDfhsurdToIFTsnz/9S/97BGv44G8uLY1N QxaQN9WnyeySatMupVmvppPmcu87XsAV/9RuEal5lFEPnLaRb5DxZjppt2WA9ruXP6OD aGp8jj33Xlvnvxd1YbzVg2Vu/ZHG8Yf60yfbiWxMA+iH5qbUxPtJ0U2uKFwsYIt+iR3d TTVQ== X-Forwarded-Encrypted: i=1; AJvYcCW8lJdPukEySICdslStHe4S726gRkCBAubX8xE+mZRIMt8geFAkTu8GQXFY/YNrrX3x4Rvxews=@vger.kernel.org X-Gm-Message-State: AOJu0YyeRAJ8A2qowcCeys9clqjL0PRdf8L1bNhS0biuhC1JD4i2gec9 fsBIgcm3F4gKFBZsPW5+xj7RCfqXH/DArBgGtnxDZZNjZGhYmD0MPc11 X-Gm-Gg: AY/fxX5kqaa8l8X9X+wseaD+oSjIARGnJGCGJcxb8KMUjmROiUI3EsGflgcL7ObToBV Ikp6absq1+0541Ur8OTCwDA5040oY5Ncu3d5igWHrjoKPxm8uqB0B0hOLDdsxPLmRwI2v7T3O3+ fm9RQl7DOKFVpaCx7/+sh87HKVsb50OLh4H3QpNj/M18jug57rHtrWQlUbmF6z/9FtPlGGkw8UO DfyOmlOKE890SXTxrI7piCp2xru0dZB60kIO/SBxWXYbx7Dj8kcn2RKK1/a2Oe4kq8hc32OP961 zbWmR5zp5S9iQFubtvEuo+bfwEPpElcud24EjToKKfOZcEBEgrTYN1osABqes4x8i67UyH6enaP xG3yNYBBt/Q0/cH53Vgo26ud+WRTdNcQrqaMg5OFjSa6PU1SwUzahWYekzPV4cwVumBGXbZ9OF+ L2aYQlBDk= X-Google-Smtp-Source: AGHT+IEMEpmQuL+oH9KFsNmHO15vbwb5Xx/PixbITk1O1HYp4iN8g0LfMEdYn9psD97qbs1NmY/NYQ== X-Received: by 2002:a05:690c:3686:b0:788:f56:afa7 with SMTP id 00721157ae682-790b56a5bcbmr14262217b3.40.1767768309834; Tue, 06 Jan 2026 22:45:09 -0800 (PST) Received: from 7940hx ([23.94.188.235]) by smtp.gmail.com with ESMTPSA id 00721157ae682-790b1be88dcsm9635047b3.47.2026.01.06.22.44.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jan 2026 22:45:09 -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 v7 06/11] bpf,x86: introduce emit_st_r0_imm64() for trampoline Date: Wed, 7 Jan 2026 14:43:47 +0800 Message-ID: <20260107064352.291069-7-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260107064352.291069-1-dongml2@chinatelecom.cn> References: <20260107064352.291069-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 e3b1c4b1d550..a87304161d45 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 dst_reg, int off, int imm) emit_st_index(pprog, size, dst_reg, X86_REG_R12, off, imm); } +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) { @@ -3352,16 +3361,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); 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) func_addr); - emit_stx(&prog, BPF_DW, BPF_REG_FP, BPF_REG_0, -ip_off); + emit_st_r0_imm64(&prog, (long)func_addr, ip_off); } save_args(m, &prog, regs_off, false, flags); -- 2.52.0