linux-debuggers.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Brennan <stephen.s.brennan@oracle.com>
To: Eduard Zingerman <eddyz87@gmail.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Alan Maguire <alan.maguire@oracle.com>,
	dwarves@vger.kernel.org, linux-debuggers@vger.kernel.org
Subject: Re: [PATCH 0/3] Fix duplicated VAR and secinfo
Date: Mon, 24 Feb 2025 17:16:16 -0800	[thread overview]
Message-ID: <87h64i6cyn.fsf@oracle.com> (raw)
In-Reply-To: <d3c1201ab0ff7831b03cf9cd00afb09696e6e40b.camel@gmail.com>

Eduard Zingerman <eddyz87@gmail.com> writes:

> On Thu, 2025-02-20 at 17:05 -0800, Stephen Brennan wrote:
>
> [...]
>
>> Thank you for the testing (and the review). I haven't yet been able to
>> reproduce this. But I see you're using clang. I'll spend the morning
>> building & running selftests with clang to see whether that is the
>> issue.
>
> Right, should have pointed that out in the email.
> Clang version is 19.1.7.
> Just tried with gcc, and `./test_progs -n 1` indeed works.
> Then re-tried with clang, same result as yesterday, test fails.

So I've set-up a Fedora 41 environment with the same clang version, and
the plot thickens, at least for me. I haven't even gotten to the BPF
self-tests, because clang is giving other duplicate variables!
(To get these values, I uncommented the error return from my pahole
patch)

From vmlinux:

error: encountered variable "fs_ftype_by_dtype" (type 149818) at offset "3d7500" which duplicates variable "ext4_type_by_mode" at the same offset
error: encountered variable "fs_dtype_by_ftype" (type 149814) at offset "3d8c60" which duplicates variable "ext4_filetype_table" at the same offset
error: encountered variable "pt_regoff" (type 52d893) at offset "3d8e50" which duplicates variable "addrmode_regoffs" at the same offset

And from modules:

error: encountered variable "evergreen_dp_offsets" (type 4e9b6) at offset "19760" which duplicates variable "crtc_offsets" at the same offset
error: encountered variable "ni_dig_offsets" (type 4e9b6) at offset "19760" which duplicates variable "crtc_offsets" at the same offset
error: encountered variable "rv770_smc_int_vectors" (type 5cd3d) at offset "2f220" which duplicates variable "rv740_smc_int_vectors" at the same offset
error: encountered variable "cypress_smc_int_vectors" (type 5cd3d) at offset "2f260" which duplicates variable "cedar_smc_int_vectors" at the same offset
error: encountered variable "juniper_smc_int_vectors" (type 5cd3d) at offset "2f260" which duplicates variable "cedar_smc_int_vectors" at the same offset
error: encountered variable "redwood_smc_int_vectors" (type 5cd3d) at offset "2f260" which duplicates variable "cedar_smc_int_vectors" at the same offset
error: encountered variable "caicos_smc_int_vectors" (type 5cd3d) at offset "2f2a0" which duplicates variable "barts_smc_int_vectors" at the same offset
error: encountered variable "turks_smc_int_vectors" (type 5cd3d) at offset "2f2a0" which duplicates variable "barts_smc_int_vectors" at the same offset
error: encountered variable "caicos_cgcg_cgls_default" (type 5e61d) at offset "2f550" which duplicates variable "barts_cgcg_cgls_default" at the same offset
error: encountered variable "turks_cgcg_cgls_default" (type 5e61d) at offset "2f550" which duplicates variable "barts_cgcg_cgls_default" at the same offset
error: encountered variable "turks_sysls_default" (type 5e622) at offset "30660" which duplicates variable "barts_sysls_default" at the same offset
error: encountered variable "caicos_cgcg_cgls_enable" (type 5e624) at offset "30920" which duplicates variable "barts_cgcg_cgls_enable" at the same offset
error: encountered variable "turks_cgcg_cgls_enable" (type 5e624) at offset "30920" which duplicates variable "barts_cgcg_cgls_enable" at the same offset
error: encountered variable "caicos_cgcg_cgls_disable" (type 5e625) at offset "30b70" which duplicates variable "barts_cgcg_cgls_disable" at the same offset
error: encountered variable "turks_cgcg_cgls_disable" (type 5e625) at offset "30b70" which duplicates variable "barts_cgcg_cgls_disable" at the same offset
error: encountered variable "caicos_mgcg_disable" (type 5e626) at offset "30f50" which duplicates variable "barts_mgcg_disable" at the same offset
error: encountered variable "turks_mgcg_disable" (type 5e626) at offset "30f50" which duplicates variable "barts_mgcg_disable" at the same offset
error: encountered variable "turks_sysls_enable" (type 5e622) at offset "30fd0" which duplicates variable "barts_sysls_enable" at the same offset
error: encountered variable "turks_sysls_disable" (type 5e622) at offset "31140" which duplicates variable "barts_sysls_disable" at the same offset
error: encountered variable "sumo_utc" (type 5f2dc) at offset "313f0" which duplicates variable "sumo_dtc" at the same offset
error: encountered variable "dte_data_curacao_xt" (type 63dee) at offset "38f00" which duplicates variable "dte_data_curacao_pro" at the same offset

From what I can tell, these are all const arrays thrown into the r/o
data section. Their data are duplicated, so it looks like clang has
mapped them to the same addresses. Which is a pretty neat optimization!

As far as I can tell, this is perfectly valid, and I think BTF should
allow these variables to be aliased. So we may need to revisit the
approach more: (1) pahole should still deduplicate identically-named
variables at the same address due to the weak symbol issue. That would
just save space and avoid silliness. But (2), I think we'll need the
verifier to allow variables to overlap.

I'll do that and continue testing.

Stephen

>
> Thanks,
> Eduard

      reply	other threads:[~2025-02-25  1:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-12  0:49 [PATCH 0/3] Fix duplicated VAR and secinfo Stephen Brennan
2025-02-12  0:49 ` [PATCH 1/3] btf_encoder: move btf_encoder__add_decl_tag() Stephen Brennan
2025-02-12  0:49 ` [PATCH 2/3] btf_encoder: postpone VARs until encoding DATASEC Stephen Brennan
2025-02-19 23:51   ` Eduard Zingerman
2025-02-12  0:49 ` [PATCH 3/3] btf_encoder: don't encode duplicate variables Stephen Brennan
2025-02-12 17:57   ` Alan Maguire
2025-02-12 18:21     ` Stephen Brennan
2025-02-18 10:36 ` [PATCH 0/3] Fix duplicated VAR and secinfo Alan Maguire
2025-02-18 16:54   ` Stephen Brennan
2025-02-19  7:48     ` Eduard Zingerman
2025-02-20  2:26 ` Eduard Zingerman
2025-02-21  1:05   ` Stephen Brennan
2025-02-21  1:30     ` Eduard Zingerman
2025-02-25  1:16       ` Stephen Brennan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h64i6cyn.fsf@oracle.com \
    --to=stephen.s.brennan@oracle.com \
    --cc=acme@kernel.org \
    --cc=alan.maguire@oracle.com \
    --cc=dwarves@vger.kernel.org \
    --cc=eddyz87@gmail.com \
    --cc=linux-debuggers@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).