All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@linux-mips.org>
To: Paul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	James Hogan <james.hogan@imgtec.com>,
	"Maciej W. Rozycki" <macro@linux-mips.org>
Subject: Re: [PATCH] MIPS: Stop using dla in 32 bit kernels
Date: Thu, 4 Feb 2016 16:18:34 +0100	[thread overview]
Message-ID: <20160204151833.GE18491@linux-mips.org> (raw)
In-Reply-To: <1454596317-5042-1-git-send-email-paul.burton@imgtec.com>

On Thu, Feb 04, 2016 at 02:31:57PM +0000, Paul Burton wrote:

>       CC      arch/mips/mm/c-r4k.o
>     {standard input}: Assembler messages:
>     {standard input}:4105: Warning: dla used to load 32-bit register;
>         recommend using la instead
>     {standard input}:4129: Warning: dla used to load 32-bit register;
>         recommend using la instead

Sigh.  Another new binutils warning?

> Avoid this by instead making use of the PTR_LA macro which defines the
> appropriate variant of the "la" instruction to use.
> 
> Tested with Codescape GNU Tools 2015.06-05 for MIPS IMG Linux, which
> includes binutils 2.24.90 & gcc 4.9.2.

> @@ -54,22 +55,16 @@
>  
>  /*
>   * gcc has a tradition of misscompiling the previous construct using the
> - * address of a label as argument to inline assembler.	Gas otoh has the
> - * annoying difference between la and dla which are only usable for 32-bit
> - * rsp. 64-bit code, so can't be used without conditional compilation.
> - * The alterantive is switching the assembler to 64-bit code which happens
> - * to work right even for 32-bit code ...
> + * address of a label as argument to inline assembler.
>   */
>  #define instruction_hazard()						\
>  do {									\
>  	unsigned long tmp;						\
>  									\
>  	__asm__ __volatile__(						\
> -	"	.set "MIPS_ISA_LEVEL"				\n"	\
> -	"	dla	%0, 1f					\n"	\
> -	"	jr.hb	%0					\n"	\
> -	"	.set	mips0					\n"	\
> -	"1:							\n"	\
> +	__stringify(PTR_LA) "	%0, 1f\n\t"				\
> +	"jr.hb	%0\n\t"							\
> +	"1:"								\
>  	: "=r" (tmp));							\
>  } while (0)


The .set will need to stay or this will fail up on older processors
with

/tmp/ccKNXiPT.s:21: Error: opcode not supported on this processor: mips1 (mips1) `jr.hb '

The opcode of JR.HB will by older processors be treated as just a JR afair.

Or with less inline assembler obscurities something like:

void foo(void)
{
        void *jr = &&jr;

        __asm__ __volatile__(
	"       .set	"MIPS_ISA_LEVEL"				\n"
        "       jr.hb							\n"
	"	.set	mips0						\n"
        : /* no outputs */
        : "r" (jr));
jr:     ;
}

Now GCC can even schedule loading the address or do other clever things.

  Ralf

  reply	other threads:[~2016-02-04 15:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-04 14:31 [PATCH] MIPS: Stop using dla in 32 bit kernels Paul Burton
2016-02-04 14:31 ` Paul Burton
2016-02-04 15:18 ` Ralf Baechle [this message]
2016-02-04 15:49   ` Paul Burton
2016-02-04 15:49     ` Paul Burton
2016-02-04 16:15   ` Maciej W. Rozycki
2016-02-04 16:15     ` Maciej W. Rozycki

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=20160204151833.GE18491@linux-mips.org \
    --to=ralf@linux-mips.org \
    --cc=james.hogan@imgtec.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=macro@linux-mips.org \
    --cc=paul.burton@imgtec.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.