Re: arch/x86/include/asm/cmpxchg_32.h:149:9: error: inline assembly requires more registers than available
From: Uros Bizjak
Date: Mon Jun 24 2024 - 11:42:49 EST
On Mon, Jun 24, 2024 at 4:18 PM Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Mon, 24 Jun 2024 at 09:59, Linus Torvalds
> <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > On Mon, 24 Jun 2024 at 03:36, Uros Bizjak <ubizjak@xxxxxxxxx> wrote:
> > >
> > > A real fix, not only a workaround, is to rewrite asm arguments to
> > > something like (untested, but "should work"TM):
> >
> > Sadly, I already tried that, and it didn't help.
>
> Bah. I _had_ tried that, but I had tried it on __arch_cmpxchg64_emu(),
> not on the "try" version.
>
> And no, it hadn't helped.
>
> But doing it *right*, and also doing __arch_try_cmpxchg64_emu() *does*
> actually help.
>
> Well, at least the attached patch compiles with the bad config and clang.
>
> I'm not certain it does the right thing, because I did more than just
> the %esi games to try to simplify it.
>
> It's *ENTIRELY* possible that I screwed up. Just in this thread, I
> have looked at the wrong inline asm at least twice now, so I'm not
> feeling super-competent right now.
>
> I'm sending the patch out in the hope that another set of eyes will
> make it actually better.
+ _lock "cmpxchg8b 0(%[ptr])", X86_FEATURE_CX8) \
This can be just:
+ _lock "cmpxchg8b %a[ptr]", X86_FEATURE_CX8) \
- if (unlikely(!ret)) \
- *(_oldp) = o.full; \
+ *(_oldp) = o; \
This one should really update only when cmpxchg fails. The relation
between cmpxchg and try_cmpxchg is documented in
Documentation/atomic_t.txt, section CMPXCHG vs TRY_CMPXCHG.
Does the compilation still crash with the condition?
Uros.