Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1188381 > unrolled thread

Re: [PATCH v2 1/5] arm64: alternative: Provide if/else/endif assembler macros

Started byWill Deacon <will.deacon@arm.com>
First post2015-07-20 19:20 +0200
Last post2015-07-22 13:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v2 1/5] arm64: alternative: Provide if/else/endif  assembler macros Will Deacon <will.deacon@arm.com> - 2015-07-20 19:20 +0200
    Re: [PATCH v2 1/5] arm64: alternative: Provide if/else/endif  assembler macros Daniel Thompson <daniel.thompson@linaro.org> - 2015-07-22 13:10 +0200

#1188381 — Re: [PATCH v2 1/5] arm64: alternative: Provide if/else/endif assembler macros

FromWill Deacon <will.deacon@arm.com>
Date2015-07-20 19:20 +0200
SubjectRe: [PATCH v2 1/5] arm64: alternative: Provide if/else/endif assembler macros
Message-ID<pOmTo-7FW-11@gated-at.bofh.it>
Hi Daniel,

Couple of really small comments.

On Mon, Jul 20, 2015 at 04:10:00PM +0100, Daniel Thompson wrote:
> The existing alternative_insn macro has some limitations that make it
> hard to work with. In particular the fact it takes instructions from it
> own macro arguments means it doesn't play very nicely with C pre-processor
> macros because the macro arguments look like a string to the C
> pre-processor. Workarounds are (probably) possible but things start to
> look ugly.
> 
> Introduce an alternative set of macros that allows instructions to be
> presented to the assembler as normal and switch everything over to the
> new macros.
> 
> Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
> ---
>  arch/arm64/include/asm/alternative.h | 40 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h
> index c385a0c4057f..31b19ad18f7e 100644
> --- a/arch/arm64/include/asm/alternative.h
> +++ b/arch/arm64/include/asm/alternative.h
> @@ -77,6 +77,46 @@ void free_alternatives_memory(void);
>  	.org	. - (662b-661b) + (664b-663b)
>  .endm
>  
> +/*
> + * Begin an alternative code sequence.
> + *
> + * The code that follows this marco will be assembled and linked as
> + * normal. There are no restrictions on this code.

s/marco/macro/

> + */
> +.macro alternative_if_not cap
> +	.pushsection .altinstructions, "a"
> +	altinstruction_entry 661f, 663f, \cap, 662f-661f, 664f-663f
> +	.popsection
> +661:
> +.endm
> +
> +/*
> + * Provide the alternative code sequence.
> + *
> + * The code that follows this macro is assembled into a special
> + * section to be used for dynamic patching. Code that follows this
> + * macro must:
> + *
> + * 1. Be exactly the same length (in bytes) as the default code
> + *    sequence.
> + *
> + * 2. Not jump to local labels defined outside of the alternative
> + *    sequence.

Actually, we fix up the branch target during patching. What you can't do
is jump into *another* alternative sequence.

Will
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1189825

FromDaniel Thompson <daniel.thompson@linaro.org>
Date2015-07-22 13:10 +0200
Message-ID<pP04p-51o-3@gated-at.bofh.it>
In reply to#1188381
On 20/07/15 18:12, Will Deacon wrote:
>> diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h
>> index c385a0c4057f..31b19ad18f7e 100644
>> --- a/arch/arm64/include/asm/alternative.h
>> +++ b/arch/arm64/include/asm/alternative.h
>> @@ -77,6 +77,46 @@ void free_alternatives_memory(void);
>>   	.org	. - (662b-661b) + (664b-663b)
>>   .endm
>>
>> +/*
>> + * Begin an alternative code sequence.
>> + *
>> + * The code that follows this marco will be assembled and linked as
>> + * normal. There are no restrictions on this code.
>
> s/marco/macro/

Will fix this.


>
>> + */
>> +.macro alternative_if_not cap
>> +	.pushsection .altinstructions, "a"
>> +	altinstruction_entry 661f, 663f, \cap, 662f-661f, 664f-663f
>> +	.popsection
>> +661:
>> +.endm
>> +
>> +/*
>> + * Provide the alternative code sequence.
>> + *
>> + * The code that follows this macro is assembled into a special
>> + * section to be used for dynamic patching. Code that follows this
>> + * macro must:
>> + *
>> + * 1. Be exactly the same length (in bytes) as the default code
>> + *    sequence.
>> + *
>> + * 2. Not jump to local labels defined outside of the alternative
>> + *    sequence.
>
> Actually, we fix up the branch target during patching. What you can't do
> is jump into *another* alternative sequence.

Ok. I will update this.

I saw that there must be branch target patching (due to branches to 
__save_vgic_v3_state) but got it into my head that branches to local 
labels confused the assembler. I guess I must made an unrelated syntax 
error because I just done a few tests and can't reproduce anything like 
that.


Daniel.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web