Re: linux-next: build failure after merge of the vfs tree

From: Josh Poimboeuf
Date: Tue Sep 29 2020 - 00:11:12 EST


On Fri, Sep 25, 2020 at 02:38:20PM +0100, Al Viro wrote:
> On Fri, Sep 25, 2020 at 10:01:28PM +1000, Stephen Rothwell wrote:
> > $ x86_64-linux-gnu-gcc --version
> > x86_64-linux-gnu-gcc (Debian 10.2.0-9) 10.2.0
> > $ x86_64-linux-gnu-ld --version
> > GNU ld (GNU Binutils for Debian) 2.35
> >
> > and the gcc plugins don't get built for the allnoconfig builds.
>
> > I reverted my Revert commit after I finished linux-next today and built
> > the x86_64 allnoconfig verion of lib/iov_iter.s:
> >
> > $ grep -A 1 '41 "/home/sfr/next/next/arch/x86/include/asm/barrier.h"' lib/iov_iter.s
> > # 41 "/home/sfr/next/next/arch/x86/include/asm/barrier.h" 1
> > cmp $140737488351232,%rdx; sbb %rcx,%rcx; #, uaddr, mask
>
> Wait a sec...
> static inline unsigned long array_index_mask_nospec(unsigned long index,
> unsigned long size)
> {
> unsigned long mask;
>
> asm volatile ("cmp %1,%2; sbb %0,%0;"
> :"=r" (mask)
> :"g"(size),"r" (index)
> :"cc");
> return mask;
> }
>
> used with large constant size will blow up - "g" is wrong, since cmp allows
> 64bit arguments to be register or memory ones; immediates can't go past
> 32bit.
>
> Looks like on the configs where it builds we end up with not seeing it's
> a constant...
>
> Josh, any ideas? We could, of course, make it "r"(size), but that would
> be unpleasant in all existing callers...

Sorry, I've been traveling. I'd just vote for making it "r".

array_index_nospec() is always called after a usercopy. I don't think
anyone will notice the extra mov, for the cases where it would be
propagated as an immediate. And the argument *is* an unsigned long
after all.

Stephen, can you confirm this fixes it?

diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h
index d158ea1fa250..69045ac62f58 100644
--- a/arch/x86/include/asm/barrier.h
+++ b/arch/x86/include/asm/barrier.h
@@ -40,7 +40,7 @@ static inline unsigned long array_index_mask_nospec(unsigned long index,

asm volatile ("cmp %1,%2; sbb %0,%0;"
:"=r" (mask)
- :"g"(size),"r" (index)
+ :"r"(size), "r"(index)
:"cc");
return mask;
}