Skip to contentSkip to conversation

exynos: allow SPL to build in thumb mode

PATCH New Guillaume GARDET 3 participants 4 messages Jan 2, 2019 – Jan 4, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 exynos: allow SPL to build in thumb mode

Building peach-pi smdk5420 and peach-pit with thumb mode for SPL ends-up in the following error:

Error: Thumb encoding does not support an immediate here -- `msr cpsr_c,#0x13|0xC0'

Use an intermediate register to be able to use thumb for exynos5 SPL.

Cc Albert Aribaud <[email protected]>
Cc Minkyu Kang <[email protected]>
Cc Tom Rini <[email protected]>
---
 arch/arm/mach-exynos/include/mach/system.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/mach-exynos/include/mach/system.h +2 -1
index 4837781957..81fa9800b4 100644
@@ -58,7 +58,8 @@ struct exynos5_sysreg {
 /* Move 0xd3 value to CPSR register to enable SVC mode */
 #define svc32_mode_en() __asm__ __volatile__				\
 			("@ I&F disable, Mode: 0x13 - SVC\n\t"		\
-			 "msr     cpsr_c, #0x13|0xC0\n\t" : : )
+			 "mov     r0, #0x13|0xC0\n\t"			\
+			 "msr     cpsr_c, r0\n\t" : : )
 
 /* Set program counter with the given value */
 #define set_pc(x) __asm__ __volatile__ ("mov     pc, %0\n\t" : : "r"(x))
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 exynos: allow SPL to build in thumb mode

Quoted 24 lines · Guillaume GARDET

Building peach-pi smdk5420 and peach-pit with thumb mode for SPL ends-up in the following error:

Error: Thumb encoding does not support an immediate here -- `msr cpsr_c,#0x13|0xC0'

Use an intermediate register to be able to use thumb for exynos5 SPL.

Cc Albert Aribaud <[email protected]>
Cc Minkyu Kang <[email protected]>
Cc Tom Rini <[email protected]>
---
 arch/arm/mach-exynos/include/mach/system.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/mach-exynos/include/mach/system.h +0 -0
index 4837781957..81fa9800b4 100644

arch/arm/mach-exynos/include/mach/system.h struct exynos5_sysreg { · line 65

Quoted 9 lines
arch/arm/mach-exynos/include/mach/system.h +2 -1
@@ -58,7 +58,8 @@ struct exynos5_sysreg {
 /* Move 0xd3 value to CPSR register to enable SVC mode */
 #define svc32_mode_en() __asm__ __volatile__				\
 			("@ I&F disable, Mode: 0x13 - SVC\n\t"		\
-			 "msr     cpsr_c, #0x13|0xC0\n\t" : : )
+			 "mov     r0, #0x13|0xC0\n\t"			\
+			 "msr     cpsr_c, r0\n\t" : : )
 
 /* Set program counter with the given value */
 #define set_pc(x) __asm__ __volatile__ ("mov     pc, %0\n\t" : : "r"(x))

applied to u-boot-samsung.

Thanks,
Minkyu Kang.

#2 lore raw

PATCH 1/1 exynos: allow SPL to build in thumb mode

In reply to Guillaume GARDET
Quoted 23 lines · On Wed, 2 Jan 2019 14:31:41 +0100 Guillaume GARDET <[email protected]>…

Building peach-pi smdk5420 and peach-pit with thumb mode for SPL ends-up in the following error:

Error: Thumb encoding does not support an immediate here -- `msr cpsr_c,#0x13|0xC0'

Use an intermediate register to be able to use thumb for exynos5 SPL.

Cc Albert Aribaud <[email protected]>
Cc Minkyu Kang <[email protected]>
Cc Tom Rini <[email protected]>
---
 arch/arm/mach-exynos/include/mach/system.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/mach-exynos/include/mach/system.h +0 -0
index 4837781957..81fa9800b4 100644

arch/arm/mach-exynos/include/mach/system.h struct exynos5_sysreg { · line 62

Quoted 6 lines
arch/arm/mach-exynos/include/mach/system.h +2 -1
@@ -58,7 +58,8 @@ struct exynos5_sysreg {
 /* Move 0xd3 value to CPSR register to enable SVC mode */
 #define svc32_mode_en() __asm__ __volatile__				\
 			("@ I&F disable, Mode: 0x13 - SVC\n\t"		\
-			 "msr     cpsr_c, #0x13|0xC0\n\t" : : )
+			 "mov     r0, #0x13|0xC0\n\t"			\
+			 "msr     cpsr_c, r0\n\t" : : )

This line needs "r0" to be also added to the clobber list. If you don't do this, then you may encounter sporadic r0 corruption problem depending on the compiler version or optimization settings.

This would be:

    "msr     cpsr_c, r0\n\t" : : : "r0")

See https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html for more details.

An even better option is to just use something like this and give the compiler freedom to pick any register:

    "msr     cpsr_c, %0\n\t" : : "r"(0x13|0xC0))
Signature · 2 lines
Best regards,
Siarhei Siamashka
#3 lore raw

Hi,

----- Siarhei Siamashka <[email protected]> a écrit :

Quoted 41 lines
Quoted 23 lines · On Wed, 2 Jan 2019 14:31:41 +0100 Guillaume GARDET <[email protected]>…

Building peach-pi smdk5420 and peach-pit with thumb mode for SPL ends-up in the following error:

Error: Thumb encoding does not support an immediate here -- `msr cpsr_c,#0x13|0xC0'

Use an intermediate register to be able to use thumb for exynos5 SPL.

Cc Albert Aribaud <[email protected]>
Cc Minkyu Kang <[email protected]>
Cc Tom Rini <[email protected]>
---
 arch/arm/mach-exynos/include/mach/system.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/mach-exynos/include/mach/system.h +0 -0
index 4837781957..81fa9800b4 100644

arch/arm/mach-exynos/include/mach/system.h struct exynos5_sysreg { · line 62

Quoted 6 lines
arch/arm/mach-exynos/include/mach/system.h +2 -1
@@ -58,7 +58,8 @@ struct exynos5_sysreg {
 /* Move 0xd3 value to CPSR register to enable SVC mode */
 #define svc32_mode_en() __asm__ __volatile__				\
 			("@ I&F disable, Mode: 0x13 - SVC\n\t"		\
-			 "msr     cpsr_c, #0x13|0xC0\n\t" : : )
+			 "mov     r0, #0x13|0xC0\n\t"			\
+			 "msr     cpsr_c, r0\n\t" : : )

This line needs "r0" to be also added to the clobber list. If you don't do this, then you may encounter sporadic r0 corruption problem depending on the compiler version or optimization settings.

This would be:

    "msr     cpsr_c, r0\n\t" : : : "r0")
Quoted 7 lines

See https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html for more details.

An even better option is to just use something like this and give the compiler freedom to pick any register:

    "msr     cpsr_c, %0\n\t" : : "r"(0x13|0xC0))

Thanks for the report Siarhei.

Minkyu, please merge also this patch: https://lists.denx.de/pipermail/u-boot/2019-January/353533.html

Thanks,
Guillaume

Quoted 4 lines
Signature · 3 lines
-- 
Best regards,
Siarhei Siamashka