mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1] ARM: compressed/head.S: fix __nop macro rept number for ARMv7M
@ 2017-04-25  9:01 patrice.chotard
  2017-05-12  7:22 ` Patrice CHOTARD
  0 siblings, 1 reply; 5+ messages in thread
From: patrice.chotard @ 2017-04-25  9:01 UTC (permalink / raw)
  To: linux, linux-arm-kernel, linux-kernel
  Cc: vikas.manocha, patrice.chotard, patrick.delaunay,
	christophe.kerello, christophe.priouzeau

From: Patrice Chotard <patrice.chotard@st.com>

In zImage, _magic_sig is located at offset 0x24.
But for ARMv7M architecture which enable CPU_THUMBONLY
and !EFI_STUB kernel flag, _magic_sig is located at offset 0x14

00000000  00 46 00 46 00 46 00 46  00 46 00 46 00 46 0f f2  |.F.F.F.F.F.F.F.ò|
00000010  15 0c 60 47 18 28 6f 01  00 00 00 00 28 5c 0e 00  |..`G.(o.....(\..|
00000020  01 02 03 04 0f 46 90 46  00 00 00 00 00 00 00 00  |.....F.F........|

Reproduced with stm32_defconfig with XIP_KERNEL flag disabled.

To restore correct _magic_sig offset at 0x24, we add 8 additional
"mov r0, r0" instruction.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---
 arch/arm/boot/compressed/head.S | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 9150f97..5d9cda3 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -127,7 +127,8 @@
  AR_CLASS(	.arm	)
 start:
 		.type	start,#function
-		.rept	7
+   ARM(		.rept	7)
+ THUMB(		.rept	15)
 		__nop
 		.endr
    ARM(		mov	r0, r0		)
-- 
1.9.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] ARM: compressed/head.S: fix __nop macro rept number for ARMv7M
  2017-04-25  9:01 [PATCH 1/1] ARM: compressed/head.S: fix __nop macro rept number for ARMv7M patrice.chotard
@ 2017-05-12  7:22 ` Patrice CHOTARD
  2017-05-18 11:16   ` Ard Biesheuvel
  0 siblings, 1 reply; 5+ messages in thread
From: Patrice CHOTARD @ 2017-05-12  7:22 UTC (permalink / raw)
  To: linux, linux-arm-kernel, linux-kernel
  Cc: Vikas MANOCHA, Patrick DELAUNAY, Christophe KERELLO,
	Christophe PRIOUZEAU

Hi all

It's a gentle reminder to not forgot this patch.

Thanks

Patrice

On 04/25/2017 11:01 AM, patrice.chotard@st.com wrote:
> From: Patrice Chotard <patrice.chotard@st.com>
>
> In zImage, _magic_sig is located at offset 0x24.
> But for ARMv7M architecture which enable CPU_THUMBONLY
> and !EFI_STUB kernel flag, _magic_sig is located at offset 0x14
>
> 00000000  00 46 00 46 00 46 00 46  00 46 00 46 00 46 0f f2  |.F.F.F.F.F.F.F.ò|
> 00000010  15 0c 60 47 18 28 6f 01  00 00 00 00 28 5c 0e 00  |..`G.(o.....(\..|
> 00000020  01 02 03 04 0f 46 90 46  00 00 00 00 00 00 00 00  |.....F.F........|
>
> Reproduced with stm32_defconfig with XIP_KERNEL flag disabled.
>
> To restore correct _magic_sig offset at 0x24, we add 8 additional
> "mov r0, r0" instruction.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> ---
>  arch/arm/boot/compressed/head.S | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
> index 9150f97..5d9cda3 100644
> --- a/arch/arm/boot/compressed/head.S
> +++ b/arch/arm/boot/compressed/head.S
> @@ -127,7 +127,8 @@
>   AR_CLASS(	.arm	)
>  start:
>  		.type	start,#function
> -		.rept	7
> +   ARM(		.rept	7)
> + THUMB(		.rept	15)
>  		__nop
>  		.endr
>     ARM(		mov	r0, r0		)
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] ARM: compressed/head.S: fix __nop macro rept number for ARMv7M
  2017-05-12  7:22 ` Patrice CHOTARD
@ 2017-05-18 11:16   ` Ard Biesheuvel
  2017-05-19 13:41     ` Patrice CHOTARD
  0 siblings, 1 reply; 5+ messages in thread
From: Ard Biesheuvel @ 2017-05-18 11:16 UTC (permalink / raw)
  To: Patrice CHOTARD
  Cc: linux, linux-arm-kernel, linux-kernel, Christophe PRIOUZEAU,
	Christophe KERELLO, Vikas MANOCHA, Patrick DELAUNAY

On 12 May 2017 at 08:22, Patrice CHOTARD <patrice.chotard@st.com> wrote:
> Hi all
>
> It's a gentle reminder to not forgot this patch.
>
> Thanks
>
> Patrice
>
> On 04/25/2017 11:01 AM, patrice.chotard@st.com wrote:
>> From: Patrice Chotard <patrice.chotard@st.com>
>>
>> In zImage, _magic_sig is located at offset 0x24.
>> But for ARMv7M architecture which enable CPU_THUMBONLY
>> and !EFI_STUB kernel flag, _magic_sig is located at offset 0x14
>>
>> 00000000  00 46 00 46 00 46 00 46  00 46 00 46 00 46 0f f2  |.F.F.F.F.F.F.F.ò|
>> 00000010  15 0c 60 47 18 28 6f 01  00 00 00 00 28 5c 0e 00  |..`G.(o.....(\..|
>> 00000020  01 02 03 04 0f 46 90 46  00 00 00 00 00 00 00 00  |.....F.F........|
>>
>> Reproduced with stm32_defconfig with XIP_KERNEL flag disabled.
>>
>> To restore correct _magic_sig offset at 0x24, we add 8 additional
>> "mov r0, r0" instruction.
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
>> ---
>>  arch/arm/boot/compressed/head.S | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
>> index 9150f97..5d9cda3 100644
>> --- a/arch/arm/boot/compressed/head.S
>> +++ b/arch/arm/boot/compressed/head.S
>> @@ -127,7 +127,8 @@
>>   AR_CLASS(   .arm    )
>>  start:
>>               .type   start,#function
>> -             .rept   7
>> +   ARM(              .rept   7)
>> + THUMB(              .rept   15)
>>

Could you try using W(mov) instead of mov in the definition of __nop ?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] ARM: compressed/head.S: fix __nop macro rept number for ARMv7M
  2017-05-18 11:16   ` Ard Biesheuvel
@ 2017-05-19 13:41     ` Patrice CHOTARD
  2017-05-23  1:06       ` Vikas MANOCHA
  0 siblings, 1 reply; 5+ messages in thread
From: Patrice CHOTARD @ 2017-05-19 13:41 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux, linux-arm-kernel, linux-kernel, Christophe PRIOUZEAU,
	Christophe KERELLO, Vikas MANOCHA, Patrick DELAUNAY

Hi Ard

On 05/18/2017 01:16 PM, Ard Biesheuvel wrote:
> On 12 May 2017 at 08:22, Patrice CHOTARD <patrice.chotard@st.com> wrote:
>> Hi all
>>
>> It's a gentle reminder to not forgot this patch.
>>
>> Thanks
>>
>> Patrice
>>
>> On 04/25/2017 11:01 AM, patrice.chotard@st.com wrote:
>>> From: Patrice Chotard <patrice.chotard@st.com>
>>>
>>> In zImage, _magic_sig is located at offset 0x24.
>>> But for ARMv7M architecture which enable CPU_THUMBONLY
>>> and !EFI_STUB kernel flag, _magic_sig is located at offset 0x14
>>>
>>> 00000000  00 46 00 46 00 46 00 46  00 46 00 46 00 46 0f f2  |.F.F.F.F.F.F.F.ò|
>>> 00000010  15 0c 60 47 18 28 6f 01  00 00 00 00 28 5c 0e 00  |..`G.(o.....(\..|
>>> 00000020  01 02 03 04 0f 46 90 46  00 00 00 00 00 00 00 00  |.....F.F........|
>>>
>>> Reproduced with stm32_defconfig with XIP_KERNEL flag disabled.
>>>
>>> To restore correct _magic_sig offset at 0x24, we add 8 additional
>>> "mov r0, r0" instruction.
>>>
>>> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
>>> ---
>>>   arch/arm/boot/compressed/head.S | 3 ++-
>>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
>>> index 9150f97..5d9cda3 100644
>>> --- a/arch/arm/boot/compressed/head.S
>>> +++ b/arch/arm/boot/compressed/head.S
>>> @@ -127,7 +127,8 @@
>>>    AR_CLASS(   .arm    )
>>>   start:
>>>                .type   start,#function
>>> -             .rept   7
>>> +   ARM(              .rept   7)
>>> + THUMB(              .rept   15)
>>>
> 
> Could you try using W(mov) instead of mov in the definition of __nop ?

If i use W(mov) instead of mov in __nop macro, i need to add one 
additional "mov r0,r0" in THUMB case as following :


  start:
  		.type	start,#function
  		.rept	7
  		__nop
  		.endr
     ARM(		mov	r0, r0		)
     ARM(		b	1f		)
+ THUMB(		mov	r0, r0		)
   THUMB(		badr	r12, 1f		)
   THUMB(		bx	r12		)

  		.word	_magic_sig	@ Magic numbers to help the loader
  		.word	_magic_start	@ absolute load/run zImage address
  		.word	_magic_end	@ zImage end address
  		.word	0x04030201	@ endianness flag


Which implementation do you prefer ?

Thanks

Patrice

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH 1/1] ARM: compressed/head.S: fix __nop macro rept number for ARMv7M
  2017-05-19 13:41     ` Patrice CHOTARD
@ 2017-05-23  1:06       ` Vikas MANOCHA
  0 siblings, 0 replies; 5+ messages in thread
From: Vikas MANOCHA @ 2017-05-23  1:06 UTC (permalink / raw)
  To: Patrice CHOTARD, Ard Biesheuvel
  Cc: linux, linux-arm-kernel, linux-kernel, Christophe PRIOUZEAU,
	Christophe KERELLO, Patrick DELAUNAY

Hi Patrice,

> -----Original Message-----
> From: Patrice CHOTARD
> Sent: Friday, May 19, 2017 6:41 AM
> To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: linux@armlinux.org.uk; linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; Christophe PRIOUZEAU
> <christophe.priouzeau@st.com>; Christophe KERELLO <christophe.kerello@st.com>; Vikas MANOCHA <vikas.manocha@st.com>;
> Patrick DELAUNAY <patrick.delaunay@st.com>
> Subject: Re: [PATCH 1/1] ARM: compressed/head.S: fix __nop macro rept number for ARMv7M
> 
> Hi Ard
> 
> On 05/18/2017 01:16 PM, Ard Biesheuvel wrote:
> > On 12 May 2017 at 08:22, Patrice CHOTARD <patrice.chotard@st.com> wrote:
> >> Hi all
> >>
> >> It's a gentle reminder to not forgot this patch.
> >>
> >> Thanks
> >>
> >> Patrice
> >>
> >> On 04/25/2017 11:01 AM, patrice.chotard@st.com wrote:
> >>> From: Patrice Chotard <patrice.chotard@st.com>
> >>>
> >>> In zImage, _magic_sig is located at offset 0x24.
> >>> But for ARMv7M architecture which enable CPU_THUMBONLY and !EFI_STUB
> >>> kernel flag, _magic_sig is located at offset 0x14
> >>>
> >>> 00000000  00 46 00 46 00 46 00 46  00 46 00 46 00 46 0f f2
> >>> |.F.F.F.F.F.F.F.ò|
> >>> 00000010  15 0c 60 47 18 28 6f 01  00 00 00 00 28 5c 0e 00
> >>> |..`G.(o.....(\..|
> >>> 00000020  01 02 03 04 0f 46 90 46  00 00 00 00 00 00 00 00
> >>> |.....F.F........|
> >>>
> >>> Reproduced with stm32_defconfig with XIP_KERNEL flag disabled.
> >>>
> >>> To restore correct _magic_sig offset at 0x24, we add 8 additional
> >>> "mov r0, r0" instruction.
> >>>
> >>> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> >>> ---
> >>>   arch/arm/boot/compressed/head.S | 3 ++-
> >>>   1 file changed, 2 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/arch/arm/boot/compressed/head.S
> >>> b/arch/arm/boot/compressed/head.S index 9150f97..5d9cda3 100644
> >>> --- a/arch/arm/boot/compressed/head.S
> >>> +++ b/arch/arm/boot/compressed/head.S
> >>> @@ -127,7 +127,8 @@
> >>>    AR_CLASS(   .arm    )
> >>>   start:
> >>>                .type   start,#function
> >>> -             .rept   7
> >>> +   ARM(              .rept   7)
> >>> + THUMB(              .rept   15)
> >>>
> >
> > Could you try using W(mov) instead of mov in the definition of __nop ?
> 
> If i use W(mov) instead of mov in __nop macro, i need to add one additional "mov r0,r0" in THUMB case as following :
> 
> 
>   start:
>   		.type	start,#function
>   		.rept	7
>   		__nop
>   		.endr
>      ARM(		mov	r0, r0		)
>      ARM(		b	1f		)
> + THUMB(		mov	r0, r0		)

No need of extra THUMB instruction, compiling previous mov r0,r0 should be good for both arm & thumb :

   		__nop
   		.endr
      			mov	r0, r0		/* 32 bit for arm & 16 bit for thumb */
      ARM(		b	1f		)
     THUMB(		badr	r12, 1f		)

Cheers,
Vikas

>    THUMB(		badr	r12, 1f		)
>    THUMB(		bx	r12		)
> 
>   		.word	_magic_sig	@ Magic numbers to help the loader
>   		.word	_magic_start	@ absolute load/run zImage address
>   		.word	_magic_end	@ zImage end address
>   		.word	0x04030201	@ endianness flag
> 
> 
> Which implementation do you prefer ?
> 
> Thanks
> 
> Patrice

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-05-23  1:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-25  9:01 [PATCH 1/1] ARM: compressed/head.S: fix __nop macro rept number for ARMv7M patrice.chotard
2017-05-12  7:22 ` Patrice CHOTARD
2017-05-18 11:16   ` Ard Biesheuvel
2017-05-19 13:41     ` Patrice CHOTARD
2017-05-23  1:06       ` Vikas MANOCHA

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®