Re: [PATCH] x86/percpu: Enable named address spaces for all capable GCC versions

From: Uros Bizjak
Date: Tue May 21 2024 - 05:14:27 EST


On Tue, May 21, 2024 at 10:18 AM Ingo Molnar <mingo@xxxxxxxxxx> wrote:
>
>
> * Uros Bizjak <ubizjak@xxxxxxxxx> wrote:
>
> > Enable named address spaces also for GCC 6, GCC 7 and GCC 8
> > releases. These compilers all produce kernel images that boot
> > without problems.
> >
> > Use compile-time test to detect compiler support for named
> > address spaces. The test passes with GCC 6 as the earliest
> > compiler version where the support for named address spaces
> > was introduced.
> >
> > Signed-off-by: Uros Bizjak <ubizjak@xxxxxxxxx>
> > Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> > Cc: Andy Lutomirski <luto@xxxxxxxxxx>
> > Cc: Brian Gerst <brgerst@xxxxxxxxx>
> > Cc: Denys Vlasenko <dvlasenk@xxxxxxxxxx>
> > Cc: H. Peter Anvin <hpa@xxxxxxxxx>
> > Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> > Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> > Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> > Cc: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
> > ---
> > arch/x86/Kconfig | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> > index 9d16fee6bdb8..c9e0a54f469e 100644
> > --- a/arch/x86/Kconfig
> > +++ b/arch/x86/Kconfig
> > @@ -2430,7 +2430,8 @@ source "kernel/livepatch/Kconfig"
> > endmenu
> >
> > config CC_HAS_NAMED_AS
> > - def_bool CC_IS_GCC && GCC_VERSION >= 90100
> > + def_bool $(success,echo 'int __seg_fs fs; int __seg_gs gs;' | $(CC) -x c - -S -o /dev/null)
> > + depends on CC_IS_GCC
>
> So ... will this test also trigger on Clang, which might have a
> __seg_fs/__seg_gs work-alike definition?

Yes, but please note the dependence on CC_IS_GCC. This dependence can
be removed once CLANG is tested to create correct code for named AS.

Thanks,
Uros.