Skip to contentSkip to conversation

ARM: zii-vf610-dev: Use -fno-tree-switch-conversion -fno-jump-tables

PATCH Applied Andrey Smirnov 2 participants 4 messages Apr 15, 2019 – Apr 23, 2019

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

PATCH 1/3 ARM: zii-vf610-dev: Use -fno-tree-switch-conversion -fno-jump-tables

Original and very poor workaround no longer works against GCC8, so drop it and replace with a proper solution that should've been used in the first place - specifying -fno-tree-switch-conversion -fno-jump-tables as CFLAGS when building lowlevel.c

Tested to work with:

- GCC 8.2.1 (arm-none-eabi)
- GCC 7.1.0 (arm-none-eabi)
- GCC 4.8.4 (armv7l-timesys-linux-gnueabihf)

Cc Heiner Kallweit <[email protected]>
Cc Chris Healy <[email protected]>
---
 arch/arm/boards/zii-vf610-dev/Makefile   |  1 +
 arch/arm/boards/zii-vf610-dev/lowlevel.c | 17 -----------------
 2 files changed, 1 insertion(+), 17 deletions(-)
arch/arm/boards/zii-vf610-dev/Makefile +1 -0
index 1297d815e..3c3a3f238 100644
@@ -1,3 +1,4 @@
 obj-y += board.o
+CFLAGS_pbl-lowlevel.o := -fno-tree-switch-conversion -fno-jump-tables
 lwl-y += lowlevel.o
 bbenv-y += defaultenv-zii-vf610-dev
arch/arm/boards/zii-vf610-dev/lowlevel.c +0 -17
index a1859eeae..b320fbc0c 100644
@@ -95,23 +95,6 @@ ENTRY_FUNCTION(start_zii_vf610_dev, r0, r1, r2)
 
 	switch (system_type) {
 	default:
-		/*
-		 * GCC can be smart enough to, when DEBUG_LL is
-		 * disabled, reduce this switch statement to a LUT
-		 * fetch. Unfortunately here, this early in the boot
-		 * process before any relocation/address fixups could
-		 * happen, the address of that LUT used by the code is
-		 * incorrect and any access to it would result in
-		 * bogus values.
-		 *
-		 * Adding the following barrier() statement seem to
-		 * force the compiler to always translate this block
-		 * to a sequence of consecutive checks and jumps with
-		 * relative fetches, which should work with or without
-		 * relocation/fixups.
-		 */
-		barrier();
-
 		if (IS_ENABLED(CONFIG_DEBUG_LL)) {
 			relocate_to_current_adr();
 			setup_c();
Signature · 7 lines
2.20.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 2/3 ARM: zii-imx51-rdu1: Use -fno-tree-switch-conversion -fno-jump-tables

Original and very poor workaround no longer works against GCC8, so drop it and replace with a proper solution that should've been used in the first place - specifying -fno-tree-switch-conversion -fno-jump-tables as CFLAGS when building lowlevel.c

Tested to work with:

- GCC 8.2.1 (arm-none-eabi)
- GCC 7.1.0 (arm-none-eabi)
- GCC 4.8.4 (armv7l-timesys-linux-gnueabihf)

Cc Heiner Kallweit <[email protected]>
Cc Chris Healy <[email protected]>
---
 arch/arm/boards/zii-imx51-rdu1/Makefile   | 1 +
 arch/arm/boards/zii-imx51-rdu1/lowlevel.c | 7 -------
 2 files changed, 1 insertion(+), 7 deletions(-)
arch/arm/boards/zii-imx51-rdu1/Makefile +1 -0
index 7f2569bda..a17cf5684 100644
@@ -1,3 +1,4 @@
 obj-y += board.o
+CFLAGS_pbl-lowlevel.o := -fno-tree-switch-conversion -fno-jump-tables
 lwl-y += lowlevel.o
 bbenv-y += defaultenv-rdu1
arch/arm/boards/zii-imx51-rdu1/lowlevel.c +0 -7
index 849c5624c..da05b0564 100644
@@ -84,13 +84,6 @@ ENTRY_FUNCTION(start_imx51_zii_rdu1, r0, r1, r2)
 
 	switch (system_type) {
 	default:
-		/*
-		 * see similar code in
-		 * arch/arm/boards/zii-vf610-dev/lowlevel.c for
-		 * reasoning for placing barrier() below.
-		 */
-		barrier();
-
 		if (IS_ENABLED(CONFIG_DEBUG_LL)) {
 			relocate_to_current_adr();
 			setup_c();
Signature · 7 lines
2.20.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 3/3 ARM: zii-imx8mq-dev: Drop unnecessary barrier() in switch statement

In reply to Andrey Smirnov

AArch64 uses PC-relative addressing instead of absolute one for data lookups, so compiling switch statement into a LUT shouldn't be a problem regardless if relocation happened or not. Disassembly of PBL code looks almost exactly the same with or without this workaround, so it is clearly not needed. Drop it.

Cc Heiner Kallweit <[email protected]>
Cc Chris Healy <[email protected]>
---
 arch/arm/boards/zii-imx8mq-dev/lowlevel.c | 7 -------
 1 file changed, 7 deletions(-)
arch/arm/boards/zii-imx8mq-dev/lowlevel.c +0 -7
index 0fd2ddfca..33c007e05 100644
@@ -179,13 +179,6 @@ ENTRY_FUNCTION(start_zii_imx8mq_dev, r0, r1, r2)
 
 	switch (system_type) {
 	default:
-		/*
-		 * see similar code in
-		 * arch/arm/boards/zii-vf610-dev/lowlevel.c for
-		 * reasoning for placing barrier() below.
-		 */
-		barrier();
-
 		if (IS_ENABLED(CONFIG_DEBUG_LL)) {
 			relocate_to_current_adr();
 			setup_c();
Signature · 7 lines
2.20.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
maintainer Applied
#3 lore raw
In reply to Andrey Smirnov
Quoted 7 lines · Andrey Smirnov

Original and very poor workaround no longer works against GCC8, so drop it and replace with a proper solution that should've been used in the first place - specifying -fno-tree-switch-conversion -fno-jump-tables as CFLAGS when building lowlevel.c

Tested to work with:

Quoted 7 lines

- GCC 8.2.1 (arm-none-eabi)
- GCC 7.1.0 (arm-none-eabi)
- GCC 4.8.4 (armv7l-timesys-linux-gnueabihf)

Cc Heiner Kallweit <[email protected]>
Cc Chris Healy <[email protected]>

Applied, thanks

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox