public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Sami Tolvanen <samitolvanen@google.com>,
	Ard Biesheuvel <ardb+git@google.com>,
	linux-kbuild@vger.kernel.org, brgerst@gmail.com, x86@kernel.org,
	masahiroy@kernel.org, nathan@kernel.org,
	linux-kernel@vger.kernel.org, nogikh@google.com,
	syzbot+06fd1a3613c50d36129e@syzkaller.appspotmail.com
Subject: Re: [PATCH] gendwarfksyms: define __GENKSYMS__ when processing asm-protoypes.h
Date: Thu, 20 Mar 2025 21:00:02 +0100	[thread overview]
Message-ID: <Z9xzwpBiIEJGQk0g@gmail.com> (raw)
In-Reply-To: <CAMj1kXHCX9oinqQ6xSMgKHdVqp16svPrs9bZu0tX_iD6h76NtA@mail.gmail.com>


* Ard Biesheuvel <ardb@kernel.org> wrote:

> On Thu, 20 Mar 2025 at 17:22, Sami Tolvanen <samitolvanen@google.com> wrote:
> >
> > On Thu, Mar 20, 2025 at 9:09 AM Ard Biesheuvel <ardb@kernel.org> wrote:
> > >
> > > On Thu, 20 Mar 2025 at 15:48, Sami Tolvanen <samitolvanen@google.com> wrote:
> > > >
> > > > Hi Ard,
> > > >
> > > > On Thu, Mar 20, 2025 at 12:07 AM Ard Biesheuvel <ardb+git@google.com> wrote:
> > > > >
> > > > > From: Ard Biesheuvel <ardb@kernel.org>
> > > > >
> > > > > Ensure that __GENKSYMS__ is #define'd when passing asm/asm-prototypes.h
> > > > > through the compiler to capture the exported symbols. This ensures that
> > > > > exported symbols such as __ref_stack_chk_guard on x86, which is declared
> > > > > conditionally, is visible to the tool.
> > > > >
> > > > > Otherwise, an error such as the below may be raised, breaking the build
> > > > > when CONFIG_GENDWARFKSYMS=y
> > > > >
> > > > >   <stdin>:4:15: error: use of undeclared identifier '__ref_stack_chk_guard'
> > > > >
> > > > > Cc: Sami Tolvanen <samitolvanen@google.com>
> > > > > Reported-by: syzbot+06fd1a3613c50d36129e@syzkaller.appspotmail.com
> > > > > Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> > > > > ---
> > > > >  scripts/Makefile.build | 1 +
> > > > >  1 file changed, 1 insertion(+)
> > > > >
> > > > > diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> > > > > index 993708d11874..7855cdc4e763 100644
> > > > > --- a/scripts/Makefile.build
> > > > > +++ b/scripts/Makefile.build
> > > > > @@ -305,6 +305,7 @@ $(obj)/%.rs: $(obj)/%.rs.S FORCE
> > > > >  getasmexports =                                                                \
> > > > >     { echo "\#include <linux/kernel.h>" ;                               \
> > > > >       echo "\#include <linux/string.h>" ;                               \
> > > > > +     echo "\#define  __GENKSYMS__" ;                                   \
> > > > >       echo "\#include <asm/asm-prototypes.h>" ;                         \
> > > > >       $(call getexportsymbols,EXPORT_SYMBOL(\1);) ; }
> > > >
> > > > This works with gendwarfksyms since __GENKSYMS__ is defined after the
> > > > EXPORT_SYMBOL() definition, but I'm now getting warnings with
> > > > genksyms:
> > > >
> > > >   AS      arch/x86/lib/clear_page_64.o
> > > > <stdin>:3:10: warning: "__GENKSYMS__" redefined
> > > > <command-line>: note: this is the location of the previous definition
> > > >
> > >
> > > Oops.
> > >
> > > Do you think the fix below should be sufficient?
> > >
> > > --- a/scripts/Makefile.build
> > > +++ b/scripts/Makefile.build
> > > @@ -314,7 +314,7 @@
> > >  else
> > >  cmd_gensymtypes_S =                                                    \
> > >         $(getasmexports) |                                              \
> > > -       $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | $(genksyms)
> > > +       $(CPP) $(c_flags) -xc - | $(genksyms)
> > >  endif # CONFIG_GENDWARFKSYMS
> > >
> > >  quiet_cmd_cpp_s_S = CPP $(quiet_modtag) $@
> >
> > EXPORT_SYMBOL() has a different definition when __GENKSYMS__ is
> > defined, so I think with genksyms we actually do need this on the
> > command line. I suppose you could wrap the getasmexports definition in
> > #ifndef __GENKSYMS__ to avoid the warning, or just use
> > __GENDWARFKSYMS__ like you suggested earlier.
> >
> 
> Yeah, on second thought, we could just do what Masahiro suggested, and
> drop the conditional from asm/asm-prototypes.h
> 
> The issue in question only affects definitions, not declarations, and
> so having the declaration visible shouldn't be a problem.
> 
> Ingo, mind dropping this patch again? We'll do the below instead (I'll
> send out the patch in a minute)

Yeah, done & thanks!

	Ingo



      reply	other threads:[~2025-03-20 20:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-20  7:07 [PATCH] gendwarfksyms: define __GENKSYMS__ when processing asm-protoypes.h Ard Biesheuvel
2025-03-20  8:22 ` Ard Biesheuvel
2025-03-20  9:01 ` [tip: x86/core] gendwarfksyms: Define __GENKSYMS__ when processing <asm/asm-protoypes.h> tip-bot2 for Ard Biesheuvel
2025-03-20 14:40 ` [PATCH] gendwarfksyms: define __GENKSYMS__ when processing asm-protoypes.h Masahiro Yamada
2025-03-20 14:45   ` Ard Biesheuvel
2025-03-20 14:47 ` Sami Tolvanen
2025-03-20 16:08   ` Ard Biesheuvel
2025-03-20 16:22     ` Sami Tolvanen
2025-03-20 16:41       ` Ard Biesheuvel
2025-03-20 20:00         ` Ingo Molnar [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=Z9xzwpBiIEJGQk0g@gmail.com \
    --to=mingo@kernel.org \
    --cc=ardb+git@google.com \
    --cc=ardb@kernel.org \
    --cc=brgerst@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nogikh@google.com \
    --cc=samitolvanen@google.com \
    --cc=syzbot+06fd1a3613c50d36129e@syzkaller.appspotmail.com \
    --cc=x86@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