diff mbox

[02/17] ARM: set BE8 if LE in head code

Message ID 1360365467-25056-3-git-send-email-ben.dooks@codethink.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Ben Dooks Feb. 8, 2013, 11:17 p.m. UTC
If we are booting in LE and compiled for BE8, then change the processor
state in the head code. Since the instruction stream is always LE, we
do not need to do anything special.

Also ensure that the secondary processors are started in the same mode.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 arch/arm/boot/compressed/head.S |    3 +++
 arch/arm/kernel/head.S          |    3 +++
 2 files changed, 6 insertions(+)

Comments

Nicolas Pitre Feb. 9, 2013, 3:33 a.m. UTC | #1
On Fri, 8 Feb 2013, Ben Dooks wrote:

> If we are booting in LE and compiled for BE8, then change the processor
> state in the head code. Since the instruction stream is always LE, we
> do not need to do anything special.
> 
> Also ensure that the secondary processors are started in the same mode.
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
>  arch/arm/boot/compressed/head.S |    3 +++
>  arch/arm/kernel/head.S          |    3 +++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
> index fe4d9c3..39940a7 100644
> --- a/arch/arm/boot/compressed/head.S
> +++ b/arch/arm/boot/compressed/head.S
> @@ -134,6 +134,9 @@ start:
>  		.word	_edata			@ zImage end address
>   THUMB(		.thumb			)
>  1:
> +#ifdef CONFIG_CPU_BE8_BOOT_LE
> +		setend	be			@ go BE-8 if we booted LE / no-op if already BE-8
> +#endif
>  		mrs	r9, cpsr
>  #ifdef CONFIG_ARM_VIRT_EXT
>  		bl	__hyp_stub_install	@ get into SVC mode, reversibly
> diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
> index 486a15a..f1ab279 100644
> --- a/arch/arm/kernel/head.S
> +++ b/arch/arm/kernel/head.S
> @@ -333,6 +333,9 @@ ENTRY(secondary_startup)
>  	 * the processor type - there is no need to check the machine type
>  	 * as it has already been validated by the primary processor.
>  	 */
> +#ifdef CONFIG_CPU_BE8_BOOT_LE
> +	setend	be				@ if system starts LE, go to BE-8
> +#endif
>  #ifdef CONFIG_ARM_VIRT_EXT
>  	bl	__hyp_stub_install_secondary
>  #endif

For consistency, you should add a setend on the primary CPU entry path 
in kernel/head.S and not rely on the decompressor.  Some people don't 
use the compressed image.


Nicolas
Ben Dooks Feb. 9, 2013, 4:47 p.m. UTC | #2
On 09/02/2013 03:33, Nicolas Pitre wrote:
> On Fri, 8 Feb 2013, Ben Dooks wrote:
>
>> If we are booting in LE and compiled for BE8, then change the 
>> processor
>> state in the head code. Since the instruction stream is always LE, 
>> we
>> do not need to do anything special.
>>
>> Also ensure that the secondary processors are started in the same 
>> mode.
>>
>> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
>> ---
>>  arch/arm/boot/compressed/head.S |    3 +++
>>  arch/arm/kernel/head.S          |    3 +++
>>  2 files changed, 6 insertions(+)
>>
>> diff --git a/arch/arm/boot/compressed/head.S 
>> b/arch/arm/boot/compressed/head.S
>> index fe4d9c3..39940a7 100644
>> --- a/arch/arm/boot/compressed/head.S
>> +++ b/arch/arm/boot/compressed/head.S
>> @@ -134,6 +134,9 @@ start:
>>  		.word	_edata			@ zImage end address
>>   THUMB(		.thumb			)
>>  1:
>> +#ifdef CONFIG_CPU_BE8_BOOT_LE
>> +		setend	be			@ go BE-8 if we booted LE / no-op if already BE-8
>> +#endif
>>  		mrs	r9, cpsr
>>  #ifdef CONFIG_ARM_VIRT_EXT
>>  		bl	__hyp_stub_install	@ get into SVC mode, reversibly
>> diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
>> index 486a15a..f1ab279 100644
>> --- a/arch/arm/kernel/head.S
>> +++ b/arch/arm/kernel/head.S
>> @@ -333,6 +333,9 @@ ENTRY(secondary_startup)
>>  	 * the processor type - there is no need to check the machine type
>>  	 * as it has already been validated by the primary processor.
>>  	 */
>> +#ifdef CONFIG_CPU_BE8_BOOT_LE
>> +	setend	be				@ if system starts LE, go to BE-8
>> +#endif
>>  #ifdef CONFIG_ARM_VIRT_EXT
>>  	bl	__hyp_stub_install_secondary
>>  #endif
>
> For consistency, you should add a setend on the primary CPU entry 
> path
> in kernel/head.S and not rely on the decompressor.  Some people don't
> use the compressed image.

Thank you for spotting this, will sort it out for the next round.
Rob Herring Feb. 9, 2013, 9:38 p.m. UTC | #3
On 02/08/2013 05:17 PM, Ben Dooks wrote:
> If we are booting in LE and compiled for BE8, then change the processor
> state in the head code. Since the instruction stream is always LE, we
> do not need to do anything special.
> 
> Also ensure that the secondary processors are started in the same mode.
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
>  arch/arm/boot/compressed/head.S |    3 +++
>  arch/arm/kernel/head.S          |    3 +++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
> index fe4d9c3..39940a7 100644
> --- a/arch/arm/boot/compressed/head.S
> +++ b/arch/arm/boot/compressed/head.S
> @@ -134,6 +134,9 @@ start:
>  		.word	_edata			@ zImage end address
>   THUMB(		.thumb			)
>  1:
> +#ifdef CONFIG_CPU_BE8_BOOT_LE

Can't you use CONFIG_CPU_BIG_ENDIAN here rather than a new config option?

> +		setend	be			@ go BE-8 if we booted LE / no-op if already BE-8
> +#endif
>  		mrs	r9, cpsr
>  #ifdef CONFIG_ARM_VIRT_EXT
>  		bl	__hyp_stub_install	@ get into SVC mode, reversibly
> diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
> index 486a15a..f1ab279 100644
> --- a/arch/arm/kernel/head.S
> +++ b/arch/arm/kernel/head.S
> @@ -333,6 +333,9 @@ ENTRY(secondary_startup)
>  	 * the processor type - there is no need to check the machine type
>  	 * as it has already been validated by the primary processor.
>  	 */
> +#ifdef CONFIG_CPU_BE8_BOOT_LE
> +	setend	be				@ if system starts LE, go to BE-8
> +#endif
>  #ifdef CONFIG_ARM_VIRT_EXT
>  	bl	__hyp_stub_install_secondary
>  #endif
>
Ben Dooks Feb. 9, 2013, 9:56 p.m. UTC | #4
On 09/02/2013 21:38, Rob Herring wrote:
> On 02/08/2013 05:17 PM, Ben Dooks wrote:
>> If we are booting in LE and compiled for BE8, then change the 
>> processor
>> state in the head code. Since the instruction stream is always LE, 
>> we
>> do not need to do anything special.
>>
>> Also ensure that the secondary processors are started in the same 
>> mode.
>>
>> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
>> ---
>>  arch/arm/boot/compressed/head.S |    3 +++
>>  arch/arm/kernel/head.S          |    3 +++
>>  2 files changed, 6 insertions(+)
>>
>> diff --git a/arch/arm/boot/compressed/head.S 
>> b/arch/arm/boot/compressed/head.S
>> index fe4d9c3..39940a7 100644
>> --- a/arch/arm/boot/compressed/head.S
>> +++ b/arch/arm/boot/compressed/head.S
>> @@ -134,6 +134,9 @@ start:
>>  		.word	_edata			@ zImage end address
>>   THUMB(		.thumb			)
>>  1:
>> +#ifdef CONFIG_CPU_BE8_BOOT_LE
>
> Can't you use CONFIG_CPU_BIG_ENDIAN here rather than a new config 
> option?

For this, we can probably do this as it is a no-op, however other parts
of the patch series do need this to allow it to boot from a little 
endian
booting environment.
Ben Dooks Feb. 11, 2013, 7:35 p.m. UTC | #5
On 09/02/13 21:38, Rob Herring wrote:
> On 02/08/2013 05:17 PM, Ben Dooks wrote:
>> If we are booting in LE and compiled for BE8, then change the processor
>> state in the head code. Since the instruction stream is always LE, we
>> do not need to do anything special.
>>
>> Also ensure that the secondary processors are started in the same mode.
>>
>> Signed-off-by: Ben Dooks<ben.dooks@codethink.co.uk>
>> ---
>>   arch/arm/boot/compressed/head.S |    3 +++
>>   arch/arm/kernel/head.S          |    3 +++
>>   2 files changed, 6 insertions(+)
>>
>> diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
>> index fe4d9c3..39940a7 100644
>> --- a/arch/arm/boot/compressed/head.S
>> +++ b/arch/arm/boot/compressed/head.S
>> @@ -134,6 +134,9 @@ start:
>>   		.word	_edata			@ zImage end address
>>    THUMB(		.thumb			)
>>   1:
>> +#ifdef CONFIG_CPU_BE8_BOOT_LE
>
> Can't you use CONFIG_CPU_BIG_ENDIAN here rather than a new config option?

Actually, no as not all big endian CPUs will be BE8 (which should
guarnatee us the 'setend be' to be available) as we could still
build for BE32 systems where we would not want this.

I was considering doing the following:

ARM_BE8(	setend	be )

What do people think? It is a waste of 16 bytes if our system is already
in BE8 mode, but is going to look cleaner than

ARM_BE8_LEBOOT( setend be )

Any thoughts?
diff mbox

Patch

diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index fe4d9c3..39940a7 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -134,6 +134,9 @@  start:
 		.word	_edata			@ zImage end address
  THUMB(		.thumb			)
 1:
+#ifdef CONFIG_CPU_BE8_BOOT_LE
+		setend	be			@ go BE-8 if we booted LE / no-op if already BE-8
+#endif
 		mrs	r9, cpsr
 #ifdef CONFIG_ARM_VIRT_EXT
 		bl	__hyp_stub_install	@ get into SVC mode, reversibly
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index 486a15a..f1ab279 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -333,6 +333,9 @@  ENTRY(secondary_startup)
 	 * the processor type - there is no need to check the machine type
 	 * as it has already been validated by the primary processor.
 	 */
+#ifdef CONFIG_CPU_BE8_BOOT_LE
+	setend	be				@ if system starts LE, go to BE-8
+#endif
 #ifdef CONFIG_ARM_VIRT_EXT
 	bl	__hyp_stub_install_secondary
 #endif