All of lore.kernel.org
 help / color / mirror / Atom feed
From: taras.kondratiuk@linaro.org (Taras Kondratiuk)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 9/9] ARM: asm/opcodes.h: use ARM_HAVE_INST to use .inst to build instructions
Date: Fri, 29 Nov 2013 19:57:32 +0200	[thread overview]
Message-ID: <5298D58C.1030605@linaro.org> (raw)
In-Reply-To: <1383935832-20865-10-git-send-email-ben.dooks@codethink.co.uk>

On 11/08/2013 08:37 PM, Ben Dooks wrote:
> Currently the <asm/opcodes.h> header uses .work and .short to build
> instructions. This means the output data does not get marked as an
> instruction which can cause issues such as BE8 code failures.
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
>  arch/arm/include/asm/opcodes.h | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/arch/arm/include/asm/opcodes.h b/arch/arm/include/asm/opcodes.h
> index e796c59..4c7cac1 100644
> --- a/arch/arm/include/asm/opcodes.h
> +++ b/arch/arm/include/asm/opcodes.h
> @@ -103,9 +103,15 @@ extern asmlinkage unsigned int arm_check_condition(u32 opcode, u32 psr);
>  #define __opcode_to_mem_arm(x) ___opcode_swab32(x)
>  #define __opcode_to_mem_thumb16(x) ___opcode_swab16(x)
>  #define __opcode_to_mem_thumb32(x) ___opcode_swahb32(x)
> +#ifdef ARM_HAVE_INST
>  #define ___asm_opcode_to_mem_arm(x) ___asm_opcode_swab32(x)
>  #define ___asm_opcode_to_mem_thumb16(x) ___asm_opcode_swab16(x)
>  #define ___asm_opcode_to_mem_thumb32(x) ___asm_opcode_swahb32(x)
> +#else
> +#define ___asm_opcode_to_mem_arm(x) ___asm_opcode_identity32(x)
> +#define ___asm_opcode_to_mem_thumb16(x) ___asm_opcode_identity16(x)
> +#define ___asm_opcode_to_mem_thumb32(x) ___asm_opcode_identity32(x)
> +#endif /* !ARM_HAVE_INST */
>  
>  #else /* ! CONFIG_CPU_ENDIAN_BE8 */
>  
> @@ -218,14 +224,27 @@ extern asmlinkage unsigned int arm_check_condition(u32 opcode, u32 psr);
>  
>  /* Helpers for the helpers.  Don't use these directly. */
>  #ifdef __ASSEMBLY__
> +#ifdef ARM_HAVE_INST
> +#define ___inst_arm(x) .inst x
> +#define ___inst_thumb16(x) .inst.w x
> +#define ___inst_thumb32(first, second) .inst.w first, second
> +#else
>  #define ___inst_arm(x) .long x
>  #define ___inst_thumb16(x) .short x
>  #define ___inst_thumb32(first, second) .short first, second
> +#endif /* !ARM_HAVE_INST */
> +#else
> +#ifdef ARM_HAVE_INST
> +#define ___inst_arm(x) ".inst " __stringify(x) "\n\t"
> +#define ___inst_thumb16(x) ".inst.w " __stringify(x) "\n\t"

It should be .inst.n instead of .inst.w

> +#define ___inst_thumb32(first, second) \
> +	".inst.w " __stringify(first) ", " __stringify(second) "\n\t"

I have not checked, but I think .inst.w will not combine two 16-bit
arguments into one 32-bit instruction, but instead it will generate two
wrong 32-bit instructions here.

>  #else
>  #define ___inst_arm(x) ".long " __stringify(x) "\n\t"
>  #define ___inst_thumb16(x) ".short " __stringify(x) "\n\t"
>  #define ___inst_thumb32(first, second) \
>  	".short " __stringify(first) ", " __stringify(second) "\n\t"
> +#endif /* !ARM_HAVE_INST */
>  #endif
>  
>  #endif /* __ASM_ARM_OPCODES_H */
> 


-- 
Taras Kondratiuk

  parent reply	other threads:[~2013-11-29 17:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-08 18:37 [RFC] kprobes/kprobes-test fixes, .inst updates Ben Dooks
2013-11-08 18:37 ` [PATCH 1/9] ARM: fix missed big-endian fix in traps.c Ben Dooks
2013-11-08 18:37 ` [PATCH 2/9] ARM: kprobes: fix instruction fetch order with <asm/opcodes.h> Ben Dooks
2013-11-29 13:01   ` Taras Kondratiuk
2013-11-29 17:55     ` Ben Dooks
2013-11-08 18:37 ` [PATCH 3/9] ARM: kprobes-test: use <asm/opcodes.h> for instruction accesses Ben Dooks
2013-11-08 18:37 ` [PATCH 4/9] ARM: kprobes-test: Use <asm/opcodes.h> for ARM instruction building Ben Dooks
2013-11-29 11:55   ` Taras Kondratiuk
2013-11-08 18:37 ` [PATCH 5/9] ARM: kprobes-test: Use <asm/opcodes.h> for thumb instruction nuilding Ben Dooks
2013-11-08 18:37 ` [PATCH 6/9] ARM: kprobes-test: Workaround GAS .align bug Ben Dooks
2013-11-08 18:37 ` [PATCH 7/9] ARM: kprobes-test: fix next_instruction() Ben Dooks
2013-11-08 18:37 ` [PATCH 8/9] ARM: add test for as supporting '.inst' Ben Dooks
2013-11-11 18:16   ` Dave Martin
2013-11-08 18:37 ` [PATCH 9/9] ARM: asm/opcodes.h: use ARM_HAVE_INST to use .inst to build instructions Ben Dooks
2013-11-11 16:18   ` Dave Martin
2013-11-11 18:40     ` Dave Martin
2013-11-29 17:57   ` Taras Kondratiuk [this message]
2013-11-29 18:00 ` [RFC] kprobes/kprobes-test fixes, .inst updates Taras Kondratiuk

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=5298D58C.1030605@linaro.org \
    --to=taras.kondratiuk@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.