From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ingo Molnar <mingo@kernel.org>,
the arch/x86 maintainers <x86@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Andy Lutomirski <luto@kernel.org>,
Alexander Potapenko <glider@google.com>,
Dmitriy Vyukov <dvyukov@google.com>,
Matthias Kaehlcke <mka@chromium.org>,
Arnd Bergmann <arnd@arndb.de>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [RFC PATCH 3/4] x86/asm: Make alternative macro interfaces more clear and consistent
Date: Fri, 15 Sep 2017 11:10:41 -0500 [thread overview]
Message-ID: <20170915161041.26lefip66zwjtrn4@treble> (raw)
In-Reply-To: <20170914184529.6k3q6yz3rnhlatsj@treble>
On Thu, Sep 14, 2017 at 01:45:29PM -0500, Josh Poimboeuf wrote:
> On Thu, Sep 14, 2017 at 11:28:30AM -0700, Linus Torvalds wrote:
> > On Thu, Sep 14, 2017 at 10:33 AM, Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> > >>
> > >> a) uglifying the 15 or so relevant inline asm locations with ifdefs; or
> > >
> > > Actually I guess we could put the "sp" in a macro... I'll try it.
> >
> > Exactly. Do something like
> >
> > #ifdef CONFIG_FRAME_POINTER
> > # define EXTRA_ASM_CLOBBERS "rsp"
> > #else
> > # define EXTRA_ASM_CLOBBERS
> > #endif
> >
> > and then replace the nasty
> >
> > register void *__sp asm(_ASM_SP);
> > ..
> > "+r" (__sp)
> >
> > games with just that EXTRA_ASM_CLOBBERS thing at the end of the clobbers.
> >
> > Yes, you'd probably have to document that the alternative_call_2()
> > thing doesn't take a "input" argument, but a input_and_clobbers, but
> > all users do that anyway.
> >
> > I dunno.
>
> There's also alternative_call(), which doesn't yet have the '__rsp'
> annotation, but it probably should. It has some callers which pass
> clobbers and some which don't, so its conversion would be trickier.
>
> So my plan is to keep patch 3 of this series, which clarifies those
> alternative macro interfaces, and also separates the inputs from the
> clobbers. That'll make it really easy to add something like
> EXTRA_ASM_CLOBBERS above.
>
> In fact I'll probably keep patches 1-3, because they're all
> improvements. Then I'll replace the original patch 4 (ASM_CALL) with
> the "sp" clobbers thing.
So I couldn't figure out how to make it any simpler than this:
#ifdef CONFIG_FRAME_POINTER
# define ASM_CALL_CLOBBERS "sp"
# define ASM_CALL_CLOBBERS_APPEND , ASM_CALL_CLOBBERS
# define ASM_CALL_CLOBBERS_ARGS(args...) ASM_CALL_CLOBBERS, ## args
#else
# define ASM_CALL_CLOBBERS
# define ASM_CALL_CLOBBERS_APPEND
# define ASM_CALL_CLOBBERS_ARGS(args...) args
#endif
ASM_CALL_CLOBBERS is the normal one:
asm volatile("call foo" : : : ASM_CALL_CLOBBERS);
ASM_CALL_CLOBBERS_APPEND is needed when combining the option with other
clobbers options, like:
asm volatile("call foo" : : : "memory" ASM_CALL_CLOBBERS_APPEND);
ASM_CALL_CLOBBERS_ARGS is needed for the pesky alternative_call() macro
so it can work with the variadic argument:
#define alternative_call(oldfunc, newfunc, feature, outputs, inputs, \
clobbers...) \
asm volatile (ALTERNATIVE("call %P[old]", "call %P[new]", \
feature), \
: outputs \
: [old] "i" (oldfunc), [new] "i" (newfunc) \
ARGS_APPEND(inputs) \
: ASM_CALL_CLOBBERS_ARGS(clobbers))
So I *was* about ready to post something like the above. But, of
course, the kbuild robot found that the new version of my patches
manages to crash GCC with a certain randconfig.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82221
So the saga continues. Now I've managed to break clang, sparse, and GCC
with each consecutive iteration of these patches... I'm starting to
lose my faith in compilers.
--
Josh
next prev parent reply other threads:[~2017-09-15 16:10 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-31 14:11 [RFC PATCH 0/4] x86/asm: Add ASM_CALL() macro for inline asms with call instructions Josh Poimboeuf
2017-08-31 14:11 ` [RFC PATCH 1/4] x86/paravirt: Fix output constraint macro names Josh Poimboeuf
2017-08-31 14:11 ` [RFC PATCH 2/4] x86/asm: Convert some inline asm positional operands to named operands Josh Poimboeuf
2017-08-31 14:11 ` [RFC PATCH 3/4] x86/asm: Make alternative macro interfaces more clear and consistent Josh Poimboeuf
2017-08-31 16:11 ` Linus Torvalds
2017-08-31 17:25 ` Josh Poimboeuf
2017-08-31 17:31 ` Josh Poimboeuf
2017-09-02 10:32 ` Ingo Molnar
2017-09-14 14:48 ` Josh Poimboeuf
2017-09-14 17:16 ` Linus Torvalds
2017-09-14 17:26 ` Josh Poimboeuf
2017-09-14 17:33 ` Josh Poimboeuf
2017-09-14 18:28 ` Linus Torvalds
2017-09-14 18:45 ` Josh Poimboeuf
2017-09-15 16:10 ` Josh Poimboeuf [this message]
2017-09-15 16:53 ` Andrey Ryabinin
2017-09-15 17:20 ` Josh Poimboeuf
2017-09-15 18:01 ` Linus Torvalds
2017-09-15 23:29 ` Josh Poimboeuf
2017-09-16 22:22 ` Andrey Ryabinin
2017-09-18 17:40 ` Josh Poimboeuf
2017-09-19 16:02 ` Josh Poimboeuf
2017-08-31 14:11 ` [RFC PATCH 4/4] x86/asm: Use ASM_CALL() macro for inline asm statements with call instructions Josh Poimboeuf
2017-08-31 14:50 ` Peter Zijlstra
2017-08-31 15:21 ` Josh Poimboeuf
2017-08-31 15:36 ` Dmitry Vyukov
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=20170915161041.26lefip66zwjtrn4@treble \
--to=jpoimboe@redhat.com \
--cc=arnd@arndb.de \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=mka@chromium.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--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
all inboxes | Powered by JetHome®