[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAFULd4Zu+XhAboEss2GfBuQPXJEgxA-dQ7JX415q_Y=9fFNFoQ@mail.gmail.com>
Date: Tue, 19 Mar 2024 14:24:04 +0100
From: Uros Bizjak <ubizjak@...il.com>
To: Brian Gerst <brgerst@...il.com>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org,
Andy Lutomirski <luto@...nel.org>, Denys Vlasenko <dvlasenk@...hat.com>, "H . Peter Anvin" <hpa@...or.com>,
Linus Torvalds <torvalds@...ux-foundation.org>, Ingo Molnar <mingo@...nel.org>,
Josh Poimboeuf <jpoimboe@...hat.com>, Sean Christopherson <seanjc@...gle.com>
Subject: Re: [PATCH -tip 0/3] x86/asm: Use generic asm operand modifiers
instead of %P in asm templates
On Tue, Mar 19, 2024 at 2:10 PM Brian Gerst <brgerst@...il.com> wrote:
>
> On Tue, Mar 19, 2024 at 6:44 AM Uros Bizjak <ubizjak@...il.com> wrote:
> >
> > The "P" asm operand modifier is a x86 target-specific modifier.
> >
> > For x86_64, when used with a symbol reference, the "P" modifier
> > emits "sym" instead of "sym(%rip)". When used with a constant, the
> > "P" modifier emits "cst" instead of "$cst". This property is used to
> > emit bare symbol references and bare constants without all
> > syntax-specific prefixes.
> >
> > The generic "c", "n" and "a" operand modifiers should be used instead.
> > The following table shows the modifiers supported by all targets and
> > their effects:
> >
> > Modifier Description
> > -----------------------------------------------------------
> > 'c' Require a constant operand and print the
> > constant expression with no punctuation.
> > 'n' Like '%c' except that the value of the constant
> > is negated before printing.
> > 'a' Substitute a memory reference, with the actual
> > operand treated as the address. This may be
> > useful when outputting a "load address"
> > instruction, because often the assembler syntax
> > for such an instruction requires you to write
> > the operand as if it were a memory reference.
> >
> > Also note that unlike GCC, clang emits %rip-relative symbol
> > reference with "P" asm operand modifier, so the patch also unifies
> > symbol handling with both compilers.
> >
> > No functional changes intended.
> >
> > Signed-off-by: Uros Bizjak <ubizjak@...il.com>
> > Cc: Andy Lutomirski <luto@...nel.org>
> > Cc: Brian Gerst <brgerst@...il.com>
> > Cc: Denys Vlasenko <dvlasenk@...hat.com>
> > Cc: H. Peter Anvin <hpa@...or.com>
> > Cc: Linus Torvalds <torvalds@...ux-foundation.org>
> > Cc: Ingo Molnar <mingo@...nel.org>
> > Cc: Josh Poimboeuf <jpoimboe@...hat.com>
> > Cc: Sean Christopherson <seanjc@...gle.com>
> >
> > Uros Bizjak (3):
> > x86/asm: Remove %P operand modifier from altinstr asm templates
> > x86/asm: Use %c/%n instead of %P operand modifier in asm templates
> > x86/asm: Use %a instead of %P operand modifier in asm templates
> >
> > arch/x86/boot/main.c | 4 ++--
> > arch/x86/include/asm/alternative.h | 22 +++++++++++-----------
> > arch/x86/include/asm/apic.h | 2 +-
> > arch/x86/include/asm/atomic64_32.h | 2 +-
> > arch/x86/include/asm/cpufeature.h | 4 ++--
> > arch/x86/include/asm/irq_stack.h | 2 +-
> > arch/x86/include/asm/processor.h | 6 +++---
> > arch/x86/include/asm/special_insns.h | 4 ++--
> > arch/x86/include/asm/uaccess.h | 4 ++--
> > 9 files changed, 25 insertions(+), 25 deletions(-)
> >
> > --
> > 2.44.0
> >
>
> My one concern is does this work with older compilers? Technically,
> GCC 5.1 is still supported. I seem to recall some issues around these
> modifiers in the past, but don't remember any details. Otherwise,
> it's a nice cleanup.
It will work. Please see [1] for a testcase.
[1] https://godbolt.org/z/eb6rcz8YW
Uros.
Powered by blists - more mailing lists