All of lore.kernel.org
 help / color / mirror / Atom feed
From: nicolas.pitre@linaro.org (Nicolas Pitre)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] ARM: teach __asmeq that r11 == fp and r12 == ip
Date: Thu, 29 Jan 2015 11:49:48 -0500 (EST)	[thread overview]
Message-ID: <alpine.LFD.2.11.1501291147480.1322@knanqh.ubzr> (raw)
In-Reply-To: <1422524686-30462-1-git-send-email-ard.biesheuvel@linaro.org>

On Thu, 29 Jan 2015, Ard Biesheuvel wrote:

> The __asmeq macro is used inside inline asm statements to ensure that
> register asm variables that explicitly specify a register are mapped
> correctly onto those registers when used in inline asm input and output
> constraints. However, the string based matching fails to take into account
> that 'fp' is often referred to as 'r11' and 'ip' is often referred to as
> 'r12', (e.g., by clang), causing false negatives.
> 
> Fix this by making __asmeq consider the ("fp","r11"), ("r11","fp"),
> ("ip","r12") and ("r12","ip") cases specifically.
> 
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> v2:
> Added r11 but not r10, as the latter is only referred to as 'sl' in
> objdump output, but GCC emitted inline asm substitutes the references
> with 'r10' instead. sp/lr/pc are unambiguous between GCC and clang.
> 
> Primary purpose of this patch is to fix the incompatibility between clang
> and GCC, but the side effect is that it relaxes the requirement imposed on
> the programmer to refer to a register by the same name as the compiler does.
> If that is seen as a substantial upside by some, we could indeed still decide
> to add r10, r13, r14 and r15 (for which no such incompatibility exists) as well.
> However, those are not currently used in __asmeq invocations anywhere under
> arch/arm
> 
>  arch/arm/include/asm/compiler.h | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/include/asm/compiler.h b/arch/arm/include/asm/compiler.h
> index 8155db2f7fa1..29fe85e59439 100644
> --- a/arch/arm/include/asm/compiler.h
> +++ b/arch/arm/include/asm/compiler.h
> @@ -8,8 +8,21 @@
>   * This string is meant to be concatenated with the inline asm string and
>   * will cause compilation to stop on mismatch.
>   * (for details, see gcc PR 15089)
> + * For compatibility with clang, we have to specifically take the equivalence
> + * of 'r11' <-> 'fp' and 'r12' <-> 'ip' into account as well.
>   */
> -#define __asmeq(x, y)  ".ifnc " x "," y " ; .err ; .endif\n\t"
> +#define __asmeq(x, y)				\
> +	".ifnc " x "," y "; "			\
> +	  ".ifnc " x y ",fpr11; " 		\
> +	    ".ifnc " x y ",r11fp; "		\
> +	      ".ifnc " x y ",ipr12; " 		\
> +	        ".ifnc " x y ",r12ip; "		\
> +	          ".err; "			\
> +	        ".endif; "			\
> +	      ".endif; "			\
> +	    ".endif; "				\
> +	  ".endif; "				\
> +	".endif\n\t"

I share RMK's yuck reaction, but for lack of a better idea:

Acked-by: Nicolas Pitre <nico@linaro.org>



Nicolas

      parent reply	other threads:[~2015-01-29 16:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-29  9:44 [PATCH v2] ARM: teach __asmeq that r11 == fp and r12 == ip Ard Biesheuvel
2015-01-29 11:48 ` Russell King - ARM Linux
2015-01-30  7:21   ` Ard Biesheuvel
2015-01-30 10:18     ` Russell King - ARM Linux
2015-01-29 12:44 ` Alex Elder
2015-01-29 16:49 ` Nicolas Pitre [this message]

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=alpine.LFD.2.11.1501291147480.1322@knanqh.ubzr \
    --to=nicolas.pitre@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.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 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.