diff mbox

ARM: tegra: remove board_init_funcs array

Message ID 20160622124052.1263574-1-arnd@arndb.de
State Accepted
Headers show

Commit Message

Arnd Bergmann June 22, 2016, 12:39 p.m. UTC
In a configuration that enables CONFIG_UBSAN_SANITIZE_ALL, I am getting
a section mismatch warning for tegra20:

WARNING: arch/arm/mach-tegra/built-in.o(.data+0x6e0): Section mismatch in reference from the variable board_init_funcs to the function .init.text:paz00_init()

The array is no longer useful here since there is only one entry,
so we can simply call the function directly after checking
of_machine_is_compatible(). This fixes the section mismatch
and is easier to read.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/arm/mach-tegra/tegra.c | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

Comments

Thierry Reding June 22, 2016, 12:50 p.m. UTC | #1
On Wed, Jun 22, 2016 at 02:39:41PM +0200, Arnd Bergmann wrote:
> In a configuration that enables CONFIG_UBSAN_SANITIZE_ALL, I am getting
> a section mismatch warning for tegra20:
> 
> WARNING: arch/arm/mach-tegra/built-in.o(.data+0x6e0): Section mismatch in reference from the variable board_init_funcs to the function .init.text:paz00_init()
> 
> The array is no longer useful here since there is only one entry,
> so we can simply call the function directly after checking
> of_machine_is_compatible(). This fixes the section mismatch
> and is easier to read.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  arch/arm/mach-tegra/tegra.c | 24 +++---------------------
>  1 file changed, 3 insertions(+), 21 deletions(-)

Shouldn't these section mismatches show up with default builds? I
haven't seen any when building Tegra configurations.

I'm going to apply this patch because I think it's useful, but it sure
would be nice to know why I need to enable this new UBSAN stuff to get
these warnings now.

Thierry
Arnd Bergmann June 22, 2016, 1:05 p.m. UTC | #2
On Wednesday, June 22, 2016 2:50:13 PM CEST Thierry Reding wrote:
> 
> Not enough information to check signature validity.
> On Wed, Jun 22, 2016 at 02:39:41PM +0200, Arnd Bergmann wrote:
> > In a configuration that enables CONFIG_UBSAN_SANITIZE_ALL, I am getting
> > a section mismatch warning for tegra20:
> > 
> > WARNING: arch/arm/mach-tegra/built-in.o(.data+0x6e0): Section mismatch in reference from the variable board_init_funcs to the function .init.text:paz00_init()
> > 
> > The array is no longer useful here since there is only one entry,
> > so we can simply call the function directly after checking
> > of_machine_is_compatible(). This fixes the section mismatch
> > and is easier to read.
> > 
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > ---
> >  arch/arm/mach-tegra/tegra.c | 24 +++---------------------
> >  1 file changed, 3 insertions(+), 21 deletions(-)
> 
> Shouldn't these section mismatches show up with default builds? I
> haven't seen any when building Tegra configurations.
> 
> I'm going to apply this patch because I think it's useful, but it sure
> would be nice to know why I need to enable this new UBSAN stuff to get
> these warnings now.

It depends on the how aggressive the inlining works. Without UBSAN,
gcc seems to completely optimze away the loop and just the function
directly, which it can do because 'board_init_funcs' is static.

I assume that the UBSAN object overflow check has the effect of
not dropping the symbol so it can check the size.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Thierry Reding June 22, 2016, 1:34 p.m. UTC | #3
On Wed, Jun 22, 2016 at 03:05:35PM +0200, Arnd Bergmann wrote:
> On Wednesday, June 22, 2016 2:50:13 PM CEST Thierry Reding wrote:
> > 
> > Not enough information to check signature validity.
> > On Wed, Jun 22, 2016 at 02:39:41PM +0200, Arnd Bergmann wrote:
> > > In a configuration that enables CONFIG_UBSAN_SANITIZE_ALL, I am getting
> > > a section mismatch warning for tegra20:
> > > 
> > > WARNING: arch/arm/mach-tegra/built-in.o(.data+0x6e0): Section mismatch in reference from the variable board_init_funcs to the function .init.text:paz00_init()
> > > 
> > > The array is no longer useful here since there is only one entry,
> > > so we can simply call the function directly after checking
> > > of_machine_is_compatible(). This fixes the section mismatch
> > > and is easier to read.
> > > 
> > > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > > ---
> > >  arch/arm/mach-tegra/tegra.c | 24 +++---------------------
> > >  1 file changed, 3 insertions(+), 21 deletions(-)
> > 
> > Shouldn't these section mismatches show up with default builds? I
> > haven't seen any when building Tegra configurations.
> > 
> > I'm going to apply this patch because I think it's useful, but it sure
> > would be nice to know why I need to enable this new UBSAN stuff to get
> > these warnings now.
> 
> It depends on the how aggressive the inlining works. Without UBSAN,
> gcc seems to completely optimze away the loop and just the function
> directly, which it can do because 'board_init_funcs' is static.
> 
> I assume that the UBSAN object overflow check has the effect of
> not dropping the symbol so it can check the size.

Ah, I see. Thanks.

Thierry
diff mbox

Patch

diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c
index 2378fa560a21..42d7ee9658fa 100644
--- a/arch/arm/mach-tegra/tegra.c
+++ b/arch/arm/mach-tegra/tegra.c
@@ -118,32 +118,14 @@  out:
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, parent);
 }
 
-static void __init paz00_init(void)
-{
-	if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC))
-		tegra_paz00_wifikill_init();
-}
-
-static struct {
-	char *machine;
-	void (*init)(void);
-} board_init_funcs[] = {
-	{ "compal,paz00", paz00_init },
-};
-
 static void __init tegra_dt_init_late(void)
 {
-	int i;
-
 	tegra_init_suspend();
 	tegra_cpuidle_init();
 
-	for (i = 0; i < ARRAY_SIZE(board_init_funcs); i++) {
-		if (of_machine_is_compatible(board_init_funcs[i].machine)) {
-			board_init_funcs[i].init();
-			break;
-		}
-	}
+	if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) &&
+	    of_machine_is_compatible("compal,paz00"))
+		tegra_paz00_wifikill_init();
 }
 
 static const char * const tegra_dt_board_compat[] = {