From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) (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 DFA593C1998 for ; Tue, 16 Jun 2026 04:34:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781584444; cv=none; b=f2+QshB7lU6X5gJEsJEfyPIhwRJEQxijzaGINjapcolqpxmE6nRkuBlU1zkww3X0xzeyR+dEEM+bw14Z9u0AmAPDqV2X559ejXfQHJEL+ELUc/hCpTx2WvRbuz8pEaKqixi643QzdKCVsYYouyYQf5KfzcbZNA2aVvH6TQxcfCo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781584444; c=relaxed/simple; bh=LUKEtGqgxTHViq6iBN8Jg2duqnbgRJYePDpTCKI4HrY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=oqSdC4bb8e07CGiRchcluM3/6YTuWzLEvpwnnAvpfnseFSXk7ULYtJgSV520Q28gP4x9mG0nrnzQXPzG0BZfNZ9dsRzNJVvUrs8t04jn79Kse2zkTBCr4fgzRWPdWJS1Ix/itHTYG3lEbQDqRbTKb+23iHcc4HxNrjxRNjDDmmg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ft8/ERt5; arc=none smtp.client-ip=95.215.58.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ft8/ERt5" Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1781584431; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8Gq0+z1rQrdFQFlUMw8WzxC/rc8erTBIXTVTj5Az1WQ=; b=ft8/ERt5YZeIoJPxdApVC4NzHxWQvvl4MECoVLr2tnBDD1p5in2moBAac77BQNpA88Zm2X KTBocwtr1LScgPRSqjo+FMk7U9UEaZXYugT1HPqfqmXsHgpoPtcz1MSUvySzIZ/6acYFle vvAsLFKyP4xD08dGHYPDHiEqnyLkGN0= Date: Tue, 16 Jun 2026 12:33:35 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH bpf-next v6 11/12] selftests/bpf: Add test to verify xlated insns for global percpu data Content-Language: en-US To: Alexei Starovoitov Cc: bpf , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Kumar Kartikeya Dwivedi , Song Liu , Yonghong Song , Jiri Olsa , John Fastabend , Quentin Monnet , Shuah Khan , LKML , "open list:KERNEL SELFTEST FRAMEWORK" , kernel-patches-bot@fb.com References: <20260615152646.27639-1-leon.hwang@linux.dev> <20260615152646.27639-12-leon.hwang@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Leon Hwang In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On 16/6/26 12:23, Alexei Starovoitov wrote: > On Mon, Jun 15, 2026 at 9:19 PM Leon Hwang wrote: >> >> On 16/6/26 05:29, Alexei Starovoitov wrote: >>> On Mon Jun 15, 2026 at 8:26 AM PDT, Leon Hwang wrote: >> [...] >>>> + ASSERT_EQ(ld_imm64_xlated[0].code, ld_imm64_raw[0].code, "ld_imm64 opcode"); >>>> + ASSERT_TRUE(ld_imm64_xlated[0].dst_reg == ld_imm64_raw[0].dst_reg, "ld_imm64 dst_reg"); >>>> + /* >>>> + * The xlated instruction has the map ID in imm and the offset >>>> + * in the next instruction's imm. The raw instruction just has >>>> + * the offset in its imm. >>>> + */ >>>> + ASSERT_EQ(ld_imm64_xlated[1].imm, ld_imm64_to_u64(ld_imm64_raw), "ld_imm64 off"); >>>> + >>>> + mov64_percpu_reg = BPF_MOV64_PERCPU_REG(ld_imm64_raw[0].dst_reg, ld_imm64_raw[0].dst_reg); >>>> + ASSERT_MEMEQ(&insns[idx + 2], &mov64_percpu_reg, insn_sz, "mov64_percpu_reg"); >>> >>> If the point of the test was to check that percpu_array_map_direct_value_meta() >>> computes 'off' correctly then it failed to achieve that goal. >> >> It was to check the 'off' and the mov64_percpu_reg insn. >> >> To avoid relying on the insns loaded from ELF obj, use raw insns to >> check the 'off' with a percpu_array map: >> >> struct bpf_insn raw_insns[] = { >> BPF_LD_MAP_VALUE(BPF_REG_1, 0, 0), >> BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 0), >> BPF_EXIT_INSN(), >> }; >> >> skel = test_global_percpu_data__open_and_load(); >> exp_off = offsetof(struct test_global_percpu_data__percpu, >> struct_data.nums[6]); >> raw_insns[0].imm = bpf_map__fd(skel->maps.percpu); >> raw_insns[1].imm = exp_off; >> >> prog_fd = bpf_prog_load(...); >> err = get_xlated_program(prog_fd, &insns, &cnt); >> idx = find_percpu_ld_imm64(insns, cnt); >> >> ASSERT_EQ(insns[idx + 1].imm, exp_off, "exp_off"); >> >> Would this achieve that goal? > > Hmm. There is nothing like that in the patch. > What are you talking about? > Some future improvement to the patch? It is future improvement to the patch. Sorry, it is too far from the patch. > My question was about the patch you posted. > What was the point of it? The point of the patch was to check that percpu_array_map_direct_value_meta() computes 'off' correctly against the 'off' encoded in ELF obj, and a mov64_percpu_reg insn should be added after loading the prog. Thanks, Leon