[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210216220619.GL28121@gate.crashing.org>
Date: Tue, 16 Feb 2021 16:06:19 -0600
From: Segher Boessenkool <segher@...nel.crashing.org>
To: Michael Ellerman <mpe@...erman.id.au>
Cc: Feng Tang <feng.tang@...el.com>,
Christophe Leroy <christophe.leroy@...roup.eu>,
lkp <lkp@...el.com>,
"kbuild-all@...ts.01.org" <kbuild-all@...ts.01.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: {standard input}:577: Error: unsupported relocation against base
Hi!
On Tue, Feb 16, 2021 at 08:36:02PM +1100, Michael Ellerman wrote:
> Feng Tang <feng.tang@...el.com> writes:
> > {standard input}:577: Error: unsupported relocation against base
> > {standard input}:580: Error: unsupported relocation against base
> > {standard input}:583: Error: unsupported relocation against base
> > The reason is macro 'mfdcr' requirs an instant number as parameter,
> > which is not met by show_plbopb_regs().
>
> It doesn't require a constant, it checks if the argument is constant:
>
> #define mfdcr(rn) \
> ({unsigned int rval; \
> if (__builtin_constant_p(rn) && rn < 1024) \
> asm volatile("mfdcr %0," __stringify(rn) \
> : "=r" (rval)); \
> else if (likely(cpu_has_feature(CPU_FTR_INDEXED_DCR))) \
> rval = mfdcrx(rn); \
> else \
> rval = __mfdcr(rn); \
> rval;})
It requires a constant number with known (at compile time) value, while
__builtin_constant_p checks for any constant. The address of some
defined symbol is a constant as well normally, for example.
It's better to write that asm as
asm volatile("mfdcr %0,%1" : "=r" (rval) : "n"(rn));
btw (the "n" constraint means "constant integer with known value" (it
stands for "numeric"), while the "i" constraint means just "constant
integer").
> But the error you're seeing implies the compiler is choosing the first
> leg of the if, even when rn == "base + x", which is surprising.
>
> We've had cases in the past of __builtin_constant_p() returning false
> for things that a human can see are constant at build time, but I've
> never seen the reverse.
And it doesn't here :-)
But, you need some way to figure out an arg is a constant known number
here. We don't have a builtin for that I think. Maybe some trick can
be done? Maybe simply test "rn >= 0" as well, does that work?
Segher
Powered by blists - more mailing lists