mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] ARM: zii-vf610-dev: Use -fno-tree-switch-conversion -fno-jump-tables
@ 2019-04-15  0:21 Andrey Smirnov
  2019-04-15  0:21 ` [PATCH 2/3] ARM: zii-imx51-rdu1: " Andrey Smirnov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andrey Smirnov @ 2019-04-15  0:21 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov, Chris Healy, Heiner Kallweit

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)

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Chris Healy <cphealy@gmail.com>
---
 arch/arm/boards/zii-vf610-dev/Makefile   |  1 +
 arch/arm/boards/zii-vf610-dev/lowlevel.c | 17 -----------------
 2 files changed, 1 insertion(+), 17 deletions(-)

diff --git a/arch/arm/boards/zii-vf610-dev/Makefile b/arch/arm/boards/zii-vf610-dev/Makefile
index 1297d815e..3c3a3f238 100644
--- a/arch/arm/boards/zii-vf610-dev/Makefile
+++ b/arch/arm/boards/zii-vf610-dev/Makefile
@@ -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
diff --git a/arch/arm/boards/zii-vf610-dev/lowlevel.c b/arch/arm/boards/zii-vf610-dev/lowlevel.c
index a1859eeae..b320fbc0c 100644
--- a/arch/arm/boards/zii-vf610-dev/lowlevel.c
+++ b/arch/arm/boards/zii-vf610-dev/lowlevel.c
@@ -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();
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/3] ARM: zii-imx51-rdu1: Use -fno-tree-switch-conversion -fno-jump-tables
  2019-04-15  0:21 [PATCH 1/3] ARM: zii-vf610-dev: Use -fno-tree-switch-conversion -fno-jump-tables Andrey Smirnov
@ 2019-04-15  0:21 ` Andrey Smirnov
  2019-04-15  0:21 ` [PATCH 3/3] ARM: zii-imx8mq-dev: Drop unnecessary barrier() in switch statement Andrey Smirnov
  2019-04-23  9:33 ` [PATCH 1/3] ARM: zii-vf610-dev: Use -fno-tree-switch-conversion -fno-jump-tables Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Andrey Smirnov @ 2019-04-15  0:21 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov, Chris Healy, Heiner Kallweit

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)

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Chris Healy <cphealy@gmail.com>
---
 arch/arm/boards/zii-imx51-rdu1/Makefile   | 1 +
 arch/arm/boards/zii-imx51-rdu1/lowlevel.c | 7 -------
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/arch/arm/boards/zii-imx51-rdu1/Makefile b/arch/arm/boards/zii-imx51-rdu1/Makefile
index 7f2569bda..a17cf5684 100644
--- a/arch/arm/boards/zii-imx51-rdu1/Makefile
+++ b/arch/arm/boards/zii-imx51-rdu1/Makefile
@@ -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
diff --git a/arch/arm/boards/zii-imx51-rdu1/lowlevel.c b/arch/arm/boards/zii-imx51-rdu1/lowlevel.c
index 849c5624c..da05b0564 100644
--- a/arch/arm/boards/zii-imx51-rdu1/lowlevel.c
+++ b/arch/arm/boards/zii-imx51-rdu1/lowlevel.c
@@ -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();
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 3/3] ARM: zii-imx8mq-dev: Drop unnecessary barrier() in switch statement
  2019-04-15  0:21 [PATCH 1/3] ARM: zii-vf610-dev: Use -fno-tree-switch-conversion -fno-jump-tables Andrey Smirnov
  2019-04-15  0:21 ` [PATCH 2/3] ARM: zii-imx51-rdu1: " Andrey Smirnov
@ 2019-04-15  0:21 ` Andrey Smirnov
  2019-04-23  9:33 ` [PATCH 1/3] ARM: zii-vf610-dev: Use -fno-tree-switch-conversion -fno-jump-tables Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Andrey Smirnov @ 2019-04-15  0:21 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov, Chris Healy, Heiner Kallweit

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.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Chris Healy <cphealy@gmail.com>
---
 arch/arm/boards/zii-imx8mq-dev/lowlevel.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/arch/arm/boards/zii-imx8mq-dev/lowlevel.c b/arch/arm/boards/zii-imx8mq-dev/lowlevel.c
index 0fd2ddfca..33c007e05 100644
--- a/arch/arm/boards/zii-imx8mq-dev/lowlevel.c
+++ b/arch/arm/boards/zii-imx8mq-dev/lowlevel.c
@@ -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();
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/3] ARM: zii-vf610-dev: Use -fno-tree-switch-conversion -fno-jump-tables
  2019-04-15  0:21 [PATCH 1/3] ARM: zii-vf610-dev: Use -fno-tree-switch-conversion -fno-jump-tables Andrey Smirnov
  2019-04-15  0:21 ` [PATCH 2/3] ARM: zii-imx51-rdu1: " Andrey Smirnov
  2019-04-15  0:21 ` [PATCH 3/3] ARM: zii-imx8mq-dev: Drop unnecessary barrier() in switch statement Andrey Smirnov
@ 2019-04-23  9:33 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2019-04-23  9:33 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox, Chris Healy, Heiner Kallweit

On Sun, Apr 14, 2019 at 05:21:19PM -0700, Andrey Smirnov wrote:
> 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)
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> Cc: Heiner Kallweit <hkallweit1@gmail.com>
> Cc: Chris Healy <cphealy@gmail.com>

Applied, thanks

Sascha

-- 
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2019-04-23  9:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-15  0:21 [PATCH 1/3] ARM: zii-vf610-dev: Use -fno-tree-switch-conversion -fno-jump-tables Andrey Smirnov
2019-04-15  0:21 ` [PATCH 2/3] ARM: zii-imx51-rdu1: " Andrey Smirnov
2019-04-15  0:21 ` [PATCH 3/3] ARM: zii-imx8mq-dev: Drop unnecessary barrier() in switch statement Andrey Smirnov
2019-04-23  9:33 ` [PATCH 1/3] ARM: zii-vf610-dev: Use -fno-tree-switch-conversion -fno-jump-tables Sascha Hauer

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