watchdog: Move watchdog_dev to data section (BSS may not be cleared)
Subsystems (3)
PATCH 1/1 watchdog: Move watchdog_dev to data section (BSS may not be cleared)
This patch moves all instances of static "watchdog_dev" declarations to the "data" section. This may be needed, as the BSS may not be cleared in the early U-Boot phase, where watchdog_reset() is already beeing called. This may result in incorrect pointer access, as the check to "!watchdog_dev" in watchdog_reset() may not be true and the function may continue to run.
--- arch/mips/mach-mt7620/cpu.c | 2 +- board/CZ.NIC/turris_mox/turris_mox.c | 2 +- board/CZ.NIC/turris_omnia/turris_omnia.c | 2 +- board/xilinx/microblaze-generic/microblaze-generic.c | 2 +- board/xilinx/zynq/board.c | 2 +- board/xilinx/zynqmp/zynqmp.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-)
arch/mips/mach-mt7620/cpu.c +1 -1
@@ -70,7 +70,7 @@ int print_cpuinfo(void) }#ifdef CONFIG_WATCHDOG -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;/* Called by macro WATCHDOG_RESET */ void watchdog_reset (void )
board/CZ.NIC/turris_mox/turris_mox.c +1 -1
@@ -120,7 +120,7 @@ int board_fix_fdt(void *blob)#endif #ifdef CONFIG_WDT_ARMADA_37XX -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;void watchdog_reset (void ) {
board/CZ.NIC/turris_omnia/turris_omnia.c +1 -1
@@ -365,7 +365,7 @@ static bool disable_mcu_watchdog(void)#endif #if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT_ORION ) -static struct udevice *watchdog_dev =NULL ; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif int board_init (void )
board/xilinx/microblaze-generic/microblaze-generic.c +1 -1
@@ -25,7 +25,7 @@DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT ) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif /* !CONFIG_SPL_BUILD && CONFIG_WDT */ ulong ram_base;
board/xilinx/zynq/board.c +1 -1
@@ -19,7 +19,7 @@DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT ) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif #if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_BOARD_EARLY_INIT_F )
board/xilinx/zynqmp/zynqmp.c +1 -1
@@ -25,7 +25,7 @@DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT ) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif #if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) && \
Signature · 1 line
2.21.0
PATCH 1/1 watchdog: Move watchdog_dev to data section (BSS may not be cleared)
Quoted 93 lines · Stefan Roese
This patch moves all instances of static "
watchdog_dev" declarations to the "data" section. This may be needed, as the BSS may not be cleared in the early U-Boot phase, wherewatchdog_reset()is already beeing called. This may result in incorrect pointer access, as the check to "!watchdog_dev" inwatchdog_reset()may not be true and the function may continue to run.Signed-off-by Stefan Roese <[email protected]>Cc Heiko Schocher <[email protected]>Cc Tom Rini <[email protected]>Cc Michal Simek <[email protected]>Cc "Marek Behún" <[email protected]>Cc Daniel Schwierzeck <[email protected]>--- arch/mips/mach-mt7620/cpu.c | 2 +- board/CZ.NIC/turris_mox/turris_mox.c | 2 +- board/CZ.NIC/turris_omnia/turris_omnia.c | 2 +- board/xilinx/microblaze-generic/microblaze-generic.c | 2 +- board/xilinx/zynq/board.c | 2 +- board/xilinx/zynqmp/zynqmp.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-)arch/mips/mach-mt7620/cpu.c +1
-1@@ -70,7 +70,7 @@ int print_cpuinfo(void) }#ifdef CONFIG_WATCHDOG -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;/* Called by macro WATCHDOG_RESET */ void watchdog_reset (void )board/CZ.NIC/turris_mox/turris_mox.c +1
-1@@ -120,7 +120,7 @@ int board_fix_fdt(void *blob)#endif #ifdef CONFIG_WDT_ARMADA_37XX -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;void watchdog_reset (void ) {board/CZ.NIC/turris_omnia/turris_omnia.c +1
-1@@ -365,7 +365,7 @@ static bool disable_mcu_watchdog(void)#endif #if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT_ORION ) -static struct udevice *watchdog_dev =NULL ; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif int board_init (void )board/xilinx/microblaze-generic/microblaze-generic.c +1
-1@@ -25,7 +25,7 @@DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT ) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif /* !CONFIG_SPL_BUILD && CONFIG_WDT */ ulong ram_base;board/xilinx/zynq/board.c +1
-1@@ -19,7 +19,7 @@DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT ) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif #if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_BOARD_EARLY_INIT_F )board/xilinx/zynqmp/zynqmp.c +0
-0
board/xilinx/zynqmp/zynqmp.c line 31
Quoted 8 lines
board/xilinx/zynqmp/zynqmp.c +1
-1@@ -25,7 +25,7 @@DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT ) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif #if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) && \
If you want to do it for all then please remove the same from this file
http://git.denx.de/?p=u-boot.git;a=commitdiff;h=4490e013ee4f2a4b9b6ca9224221fed2788b6940
+#if defined(CONFIG_WDT) && !defined(CONFIG_SPL_BUILD)
+ /* bss is not cleared at time when watchdog_reset() is called */
+ watchdog_dev = NULL;
+#endif
And also from zynq file.board/xilinx/zynq/board.c
Thanks,
Michal
PATCH 1/1 watchdog: Move watchdog_dev to data section (BSS may not be cleared)
Quoted 113 lines · Michal Simek
Quoted 93 lines · Stefan Roese
This patch moves all instances of static "
watchdog_dev" declarations to the "data" section. This may be needed, as the BSS may not be cleared in the early U-Boot phase, wherewatchdog_reset()is already beeing called. This may result in incorrect pointer access, as the check to "!watchdog_dev" inwatchdog_reset()may not be true and the function may continue to run.Signed-off-by Stefan Roese <[email protected]>Cc Heiko Schocher <[email protected]>Cc Tom Rini <[email protected]>Cc Michal Simek <[email protected]>Cc "Marek Behún" <[email protected]>Cc Daniel Schwierzeck <[email protected]>--- arch/mips/mach-mt7620/cpu.c | 2 +- board/CZ.NIC/turris_mox/turris_mox.c | 2 +- board/CZ.NIC/turris_omnia/turris_omnia.c | 2 +- board/xilinx/microblaze-generic/microblaze-generic.c | 2 +- board/xilinx/zynq/board.c | 2 +- board/xilinx/zynqmp/zynqmp.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-)arch/mips/mach-mt7620/cpu.c +1
-1@@ -70,7 +70,7 @@ int print_cpuinfo(void) }#ifdef CONFIG_WATCHDOG -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;/* Called by macro WATCHDOG_RESET */ void watchdog_reset (void )board/CZ.NIC/turris_mox/turris_mox.c +1
-1@@ -120,7 +120,7 @@ int board_fix_fdt(void *blob)#endif #ifdef CONFIG_WDT_ARMADA_37XX -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;void watchdog_reset (void ) {board/CZ.NIC/turris_omnia/turris_omnia.c +1
-1@@ -365,7 +365,7 @@ static bool disable_mcu_watchdog(void)#endif #if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT_ORION ) -static struct udevice *watchdog_dev =NULL ; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif int board_init (void )board/xilinx/microblaze-generic/microblaze-generic.c +1
-1@@ -25,7 +25,7 @@DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT ) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif /* !CONFIG_SPL_BUILD && CONFIG_WDT */ ulong ram_base;board/xilinx/zynq/board.c +1
-1@@ -19,7 +19,7 @@DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT ) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif #if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_BOARD_EARLY_INIT_F )board/xilinx/zynqmp/zynqmp.c +0
-0board/xilinx/zynqmp/zynqmp.c line 31
Quoted 8 lines
board/xilinx/zynqmp/zynqmp.c +1
-1@@ -25,7 +25,7 @@DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT ) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif #if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) && \If you want to do it for all then please remove the same from this file
http://git.denx.de/?p=u-boot.git;a=commitdiff;h=4490e013ee4f2a4b9b6ca9224221fed2788b6940
(quoted diff) +4
-0+#if defined(CONFIG_WDT) && !defined(CONFIG_SPL_BUILD) + /* bss is not cleared at time when watchdog_reset() is called */ + watchdog_dev = NULL; +#endif
Quoted 2 lines
And also from zynq file.
board/xilinx/zynq/board.c
Thanks for spotting. I'll remove it in v2.
Thanks,
Stefan
PATCH v2 1/1 watchdog: Move watchdog_dev to data section (BSS may not be cleared)
In reply to Stefan RoeseThis patch moves all instances of static "watchdog_dev" declarations to the "data" section. This may be needed, as the BSS may not be cleared in the early U-Boot phase, where watchdog_reset() is already beeing called. This may result in incorrect pointer access, as the check to "!watchdog_dev" in watchdog_reset() may not be true and the function may continue to run.
---
v2:
- Remove now superfluous explicit clearing of watchdog_dev in Xilinx zynq and zynqmp board_early_init_f() as suggested by Michal
arch/mips/mach-mt7620/cpu.c | 2 +- board/CZ.NIC/turris_mox/turris_mox.c | 2 +- board/CZ.NIC/turris_omnia/turris_omnia.c | 2 +- board/xilinx/microblaze-generic/microblaze-generic.c | 2 +- board/xilinx/zynq/board.c | 7 +------ board/xilinx/zynqmp/zynqmp.c | 7 +------ 6 files changed, 6 insertions(+), 16 deletions(-)
arch/mips/mach-mt7620/cpu.c +1 -1
@@ -70,7 +70,7 @@ int print_cpuinfo(void) }#ifdef CONFIG_WATCHDOG -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;/* Called by macro WATCHDOG_RESET */ void watchdog_reset (void )
board/CZ.NIC/turris_mox/turris_mox.c +1 -1
@@ -120,7 +120,7 @@ int board_fix_fdt(void *blob)#endif #ifdef CONFIG_WDT_ARMADA_37XX -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;void watchdog_reset (void ) {
board/CZ.NIC/turris_omnia/turris_omnia.c +1 -1
@@ -365,7 +365,7 @@ static bool disable_mcu_watchdog(void)#endif #if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT_ORION ) -static struct udevice *watchdog_dev =NULL ; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif int board_init (void )
board/xilinx/microblaze-generic/microblaze-generic.c +1 -1
@@ -25,7 +25,7 @@DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT ) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif /* !CONFIG_SPL_BUILD && CONFIG_WDT */ ulong ram_base;
board/xilinx/zynq/board.c +1 -6
@@ -19,17 +19,12 @@DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT ) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif #if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_BOARD_EARLY_INIT_F )int board_early_init_f (void ) { -# if defined(CONFIG_WDT ) -/* bss is not cleared at time when watchdog_reset() is called */ - watchdog_dev =NULL ; -# endif -return 0 ; }#endif
board/xilinx/zynqmp/zynqmp.c +1 -6
@@ -25,7 +25,7 @@DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT ) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif #if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) && \
@@ -322,11 +322,6 @@ int board_early_init_f(void) ret =psu_init ();#endif -#if defined(CONFIG_WDT ) && !defined(CONFIG_SPL_BUILD ) -/* bss is not cleared at time when watchdog_reset() is called */ - watchdog_dev =NULL ; -#endif -return ret; }
Signature · 1 line
2.21.0
PATCH v2 1/1 watchdog: Move watchdog_dev to data section (BSS may not be cleared)
Quoted 117 lines · Stefan Roese
This patch moves all instances of static "
watchdog_dev" declarations to the "data" section. This may be needed, as the BSS may not be cleared in the early U-Boot phase, wherewatchdog_reset()is already beeing called. This may result in incorrect pointer access, as the check to "!watchdog_dev" inwatchdog_reset()may not be true and the function may continue to run.Signed-off-by Stefan Roese <[email protected]>Cc Heiko Schocher <[email protected]>Cc Tom Rini <[email protected]>Cc Michal Simek <[email protected]>Cc "Marek Behún" <[email protected]>Cc Daniel Schwierzeck <[email protected]>---
v2:
- Remove now superfluous explicit clearing ofwatchdog_devin Xilinx zynq and zynqmpboard_early_init_f()as suggested by Michalarch/mips/mach-mt7620/cpu.c | 2 +- board/CZ.NIC/turris_mox/turris_mox.c | 2 +- board/CZ.NIC/turris_omnia/turris_omnia.c | 2 +- board/xilinx/microblaze-generic/microblaze-generic.c | 2 +- board/xilinx/zynq/board.c | 7 +------ board/xilinx/zynqmp/zynqmp.c | 7 +------ 6 files changed, 6 insertions(+), 16 deletions(-)arch/mips/mach-mt7620/cpu.c +1
-1@@ -70,7 +70,7 @@ int print_cpuinfo(void) }#ifdef CONFIG_WATCHDOG -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;/* Called by macro WATCHDOG_RESET */ void watchdog_reset (void )board/CZ.NIC/turris_mox/turris_mox.c +1
-1@@ -120,7 +120,7 @@ int board_fix_fdt(void *blob)#endif #ifdef CONFIG_WDT_ARMADA_37XX -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;void watchdog_reset (void ) {board/CZ.NIC/turris_omnia/turris_omnia.c +1
-1@@ -365,7 +365,7 @@ static bool disable_mcu_watchdog(void)#endif #if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT_ORION ) -static struct udevice *watchdog_dev =NULL ; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif int board_init (void )board/xilinx/microblaze-generic/microblaze-generic.c +1
-1@@ -25,7 +25,7 @@DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT ) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif /* !CONFIG_SPL_BUILD && CONFIG_WDT */ ulong ram_base;board/xilinx/zynq/board.c +1
-6@@ -19,17 +19,12 @@DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT ) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif #if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_BOARD_EARLY_INIT_F )int board_early_init_f (void ) { -# if defined(CONFIG_WDT ) -/* bss is not cleared at time when watchdog_reset() is called */ - watchdog_dev =NULL ; -# endif -return 0 ; }#endif board/xilinx/zynqmp/zynqmp.c +1
-1@@ -25,7 +25,7 @@DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT ) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif #if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) && \@@ -322,11 +322,6 @@ int board_early_init_f(void) ret =psu_init ();
board/xilinx/zynqmp/zynqmp.c int board_early_init_f(void) · line 327
Quoted 10 lines
board/xilinx/zynqmp/zynqmp.c +0
-5#endif -#if defined(CONFIG_WDT ) && !defined(CONFIG_SPL_BUILD ) -/* bss is not cleared at time when watchdog_reset() is called */ - watchdog_dev =NULL ; -#endif -return ret; }
Thanks,
Michal
PATCH v2 1/1 watchdog: Move watchdog_dev to data section (BSS may not be cleared)
In reply to Stefan RoeseAm 03.04.19 um 09:12 schrieb Stefan Roese:
Quoted 31 lines
This patch moves all instances of static "
watchdog_dev" declarations to the "data" section. This may be needed, as the BSS may not be cleared in the early U-Boot phase, wherewatchdog_reset()is already beeing called. This may result in incorrect pointer access, as the check to "!watchdog_dev" inwatchdog_reset()may not be true and the function may continue to run.Signed-off-by Stefan Roese <[email protected]>Cc Heiko Schocher <[email protected]>Cc Tom Rini <[email protected]>Cc Michal Simek <[email protected]>Cc "Marek Behún" <[email protected]>Cc Daniel Schwierzeck <[email protected]>---
v2:
- Remove now superfluous explicit clearing ofwatchdog_devin Xilinx zynq and zynqmpboard_early_init_f()as suggested by Michalarch/mips/mach-mt7620/cpu.c | 2 +- board/CZ.NIC/turris_mox/turris_mox.c | 2 +- board/CZ.NIC/turris_omnia/turris_omnia.c | 2 +- board/xilinx/microblaze-generic/microblaze-generic.c | 2 +- board/xilinx/zynq/board.c | 7 +------ board/xilinx/zynqmp/zynqmp.c | 7 +------ 6 files changed, 6 insertions(+), 16 deletions(-)arch/mips/mach-mt7620/cpu.c +0
-0
arch/mips/mach-mt7620/cpu.c int print_cpuinfo(void) · line 73
Quoted 5 lines
arch/mips/mach-mt7620/cpu.c +1
-1@@ -70,7 +70,7 @@ int print_cpuinfo(void) }#ifdef CONFIG_WATCHDOG -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;
to simplify that line you could use __section(".data")
Quoted 91 lines
arch/mips/mach-mt7620/cpu.c +0
-0/* Called by macro WATCHDOG_RESET */ void watchdog_reset (void )board/CZ.NIC/turris_mox/turris_mox.c +1
-1@@ -120,7 +120,7 @@ int board_fix_fdt(void *blob)#endif #ifdef CONFIG_WDT_ARMADA_37XX -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;void watchdog_reset (void ) {board/CZ.NIC/turris_omnia/turris_omnia.c +1
-1@@ -365,7 +365,7 @@ static bool disable_mcu_watchdog(void)#endif #if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT_ORION ) -static struct udevice *watchdog_dev =NULL ; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif int board_init (void )board/xilinx/microblaze-generic/microblaze-generic.c +1
-1@@ -25,7 +25,7 @@DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT ) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif /* !CONFIG_SPL_BUILD && CONFIG_WDT */ ulong ram_base;board/xilinx/zynq/board.c +1
-6@@ -19,17 +19,12 @@DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT ) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif #if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_BOARD_EARLY_INIT_F )int board_early_init_f (void ) { -# if defined(CONFIG_WDT ) -/* bss is not cleared at time when watchdog_reset() is called */ - watchdog_dev =NULL ; -# endif -return 0 ; }#endif board/xilinx/zynqmp/zynqmp.c +1
-6@@ -25,7 +25,7 @@DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT ) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif #if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) && \@@ -322,11 +322,6 @@ int board_early_init_f(void) ret =psu_init ();#endif -#if defined(CONFIG_WDT ) && !defined(CONFIG_SPL_BUILD ) -/* bss is not cleared at time when watchdog_reset() is called */ - watchdog_dev =NULL ; -#endif -return ret; }
Signature · 1 line
- Daniel
PATCH v2 1/1 watchdog: Move watchdog_dev to data section (BSS may not be cleared)
Quoted 36 lines · Daniel Schwierzeck
Am 03.04.19 um 09:12 schrieb Stefan Roese:
Quoted 33 lines
This patch moves all instances of static "
watchdog_dev" declarations to the "data" section. This may be needed, as the BSS may not be cleared in the early U-Boot phase, wherewatchdog_reset()is already beeing called. This may result in incorrect pointer access, as the check to "!watchdog_dev" inwatchdog_reset()may not be true and the function may continue to run.Signed-off-by Stefan Roese <[email protected]>Cc Heiko Schocher <[email protected]>Cc Tom Rini <[email protected]>Cc Michal Simek <[email protected]>Cc "Marek Behún" <[email protected]>Cc Daniel Schwierzeck <[email protected]>---
v2:
- Remove now superfluous explicit clearing ofwatchdog_devin Xilinx zynq and zynqmpboard_early_init_f()as suggested by Michalarch/mips/mach-mt7620/cpu.c | 2 +- board/CZ.NIC/turris_mox/turris_mox.c | 2 +- board/CZ.NIC/turris_omnia/turris_omnia.c | 2 +- board/xilinx/microblaze-generic/microblaze-generic.c | 2 +- board/xilinx/zynq/board.c | 7 +------ board/xilinx/zynqmp/zynqmp.c | 7 +------ 6 files changed, 6 insertions(+), 16 deletions(-)arch/mips/mach-mt7620/cpu.c +0
-0@@ -70,7 +70,7 @@ int print_cpuinfo(void) }
Quoted 5 lines
arch/mips/mach-mt7620/cpu.c int print_cpuinfo(void) · line 73
Quoted 3 lines
arch/mips/mach-mt7620/cpu.c +1
-1#ifdef CONFIG_WATCHDOG -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;to simplify that line you could use
__section(".data")
Yes, thanks for the suggestions. But as you might have noticed, this patch is only meant as a temporary fix for this upcoming release. This code will get removed with the generic watchdog implementation that I'm currently working on. So to not disturb this release, I would prefer to use this patch as-is.
Thanks,
Stefan
Quoted 82 lines
Quoted 82 lines
arch/mips/mach-mt7620/cpu.c +0
-0/* Called by macro WATCHDOG_RESET */ void watchdog_reset (void )board/CZ.NIC/turris_mox/turris_mox.c +1
-1@@ -120,7 +120,7 @@ int board_fix_fdt(void *blob)#endif #ifdef CONFIG_WDT_ARMADA_37XX -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;void watchdog_reset (void ) {board/CZ.NIC/turris_omnia/turris_omnia.c +1
-1@@ -365,7 +365,7 @@ static bool disable_mcu_watchdog(void)#endif #if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT_ORION ) -static struct udevice *watchdog_dev =NULL ; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif int board_init (void )board/xilinx/microblaze-generic/microblaze-generic.c +1
-1@@ -25,7 +25,7 @@DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT ) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif /* !CONFIG_SPL_BUILD && CONFIG_WDT */ ulong ram_base;board/xilinx/zynq/board.c +1
-6@@ -19,17 +19,12 @@DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT ) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif #if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_BOARD_EARLY_INIT_F )int board_early_init_f (void ) { -# if defined(CONFIG_WDT ) -/* bss is not cleared at time when watchdog_reset() is called */ - watchdog_dev =NULL ; -# endif -return 0 ; }#endif board/xilinx/zynqmp/zynqmp.c +1
-1@@ -25,7 +25,7 @@DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_WDT ) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL;#endif #if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) && \@@ -322,11 +322,6 @@ int board_early_init_f(void) ret =psu_init ();#endif
Quoted 10 lines
board/xilinx/zynqmp/zynqmp.c int board_early_init_f(void) · line 327
Quoted 9 lines
board/xilinx/zynqmp/zynqmp.c +0
-5-#if defined(CONFIG_WDT ) && !defined(CONFIG_SPL_BUILD ) -/* bss is not cleared at time when watchdog_reset() is called */ - watchdog_dev =NULL ; -#endif -return ret; }
Viele Grüße,
Stefan
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de