ti: clocks: Fix do_enable_clocks() to accept NULL pointers as input parameters
PATCH 1/1 ti: clocks: Fix do_enable_clocks() to accept NULL pointers as input parameters
Up till this commit passing NULL as input parameter was allowed, but not handled properly.
When one passed NULL to one of this function parameters, the code was executed causing data abort.
However, what is more interesting, the abort was not caught because of code execution in HYP mode with masked CPSR A bit ("Imprecise Data Abort mask bit). The TI's AM57xx SoC switch to HYP mode with A bit masked in lowlevel_init.S due to SMC call. Such operation (by default) is performed in SoC ROM code.
The problem would pop up when one:
- Switch back to SVC mode after disabling LPAE support
- Somebody enables A bit (by executing cpsie a asm instruction)
and then the previously described exception would be caught.
--- arch/arm/cpu/armv7/omap-common/clocks-common.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/arm/cpu/armv7/omap-common/clocks-common.c +6 -4
@@ -822,27 +822,29 @@ void do_enable_clocks(u32 const *clk_domains,u32 i, max =100 ;/* Put the clock domains in SW_WKUP mode */ -for (i =0 ; (i < max) && clk_domains[i]; i++) { +for (i =0 ; (i < max) && clk_domains && clk_domains[i]; i++) {enable_clock_domain (clk_domains[i],CD_CLKCTRL_CLKTRCTRL_SW_WKUP ); }/* Clock modules that need to be put in HW_AUTO */ -for (i =0 ; (i < max) && clk_modules_hw_auto[i]; i++) { +for (i =0 ; (i < max) && clk_modules_hw_auto && + clk_modules_hw_auto[i]; i++) {enable_clock_module (clk_modules_hw_auto[i],MODULE_CLKCTRL_MODULEMODE_HW_AUTO , wait_for_enable); };/* Clock modules that need to be put in SW_EXPLICIT_EN mode */ -for (i =0 ; (i < max) && clk_modules_explicit_en[i]; i++) { +for (i =0 ; (i < max) && clk_modules_explicit_en && + clk_modules_explicit_en[i]; i++) {enable_clock_module (clk_modules_explicit_en[i],MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN , wait_for_enable); };/* Put the clock domains in HW_AUTO mode now */ -for (i =0 ; (i < max) && clk_domains[i]; i++) { +for (i =0 ; (i < max) && clk_domains && clk_domains[i]; i++) {enable_clock_domain (clk_domains[i],CD_CLKCTRL_CLKTRCTRL_HW_AUTO ); }
Signature · 1 line
2.1.4
PATCH 1/1 ti: clocks: Fix do_enable_clocks() to accept NULL pointers as input parameters
Quoted 15 lines · Lukasz Majewski
Up till this commit passing NULL as input parameter was allowed, but not handled properly.
When one passed NULL to one of this function parameters, the code was executed causing data abort.
However, what is more interesting, the abort was not caught because of code execution in HYP mode with masked CPSR A bit ("Imprecise Data Abort mask bit). The TI's AM57xx SoC switch to HYP mode with A bit masked in
lowlevel_init.Sdue to SMC call. Such operation (by default) is performed in SoC ROM code.The problem would pop up when one:
- Switch back to SVC mode after disabling LPAE support
- Somebody enables A bit (by executing cpsie a asm instruction)
Quoted 5 lines
and then the previously described exception would be caught.
Signed-off-by Lukasz Majewski <[email protected]>--- arch/arm/cpu/armv7/omap-common/clocks-common.c | 10 ++++++----
This has been moved to arch/arm/mach-omap2/clocks-common.c Please use the latest U-Boot.
arch/arm/cpu/armv7/omap-common/clocks-common.c void do_enable_clocks(u32 const *clk_domains, · line 825
Quoted 12 lines
1 file changed, 6 insertions(+), 4 deletions(-)arch/arm/cpu/armv7/omap-common/clocks-common.c +1
-1@@ -822,27 +822,29 @@ void do_enable_clocks(u32 const *clk_domains,u32 i, max =100 ;/* Put the clock domains in SW_WKUP mode */ -for (i =0 ; (i < max) && clk_domains[i]; i++) { +for (i =0 ; (i < max) && clk_domains && clk_domains[i]; i++) {
Instead of checking for clk_domains every time, can we use max as ARRAY_SIZE(clk_domains)? Similarly other places.
Thanks and regards,
Lokesh
Quoted 29 lines
arch/arm/cpu/armv7/omap-common/clocks-common.c +5
-3enable_clock_domain (clk_domains[i],CD_CLKCTRL_CLKTRCTRL_SW_WKUP ); }/* Clock modules that need to be put in HW_AUTO */ -for (i =0 ; (i < max) && clk_modules_hw_auto[i]; i++) { +for (i =0 ; (i < max) && clk_modules_hw_auto && + clk_modules_hw_auto[i]; i++) {enable_clock_module (clk_modules_hw_auto[i],MODULE_CLKCTRL_MODULEMODE_HW_AUTO , wait_for_enable); };/* Clock modules that need to be put in SW_EXPLICIT_EN mode */ -for (i =0 ; (i < max) && clk_modules_explicit_en[i]; i++) { +for (i =0 ; (i < max) && clk_modules_explicit_en && + clk_modules_explicit_en[i]; i++) {enable_clock_module (clk_modules_explicit_en[i],MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN , wait_for_enable); };/* Put the clock domains in HW_AUTO mode now */ -for (i =0 ; (i < max) && clk_domains[i]; i++) { +for (i =0 ; (i < max) && clk_domains && clk_domains[i]; i++) {enable_clock_domain (clk_domains[i],CD_CLKCTRL_CLKTRCTRL_HW_AUTO ); }
PATCH 1/1 ti: clocks: Fix do_enable_clocks() to accept NULL pointers as input parameters
Hi Lokesh,
Quoted 19 lines · Lukasz Majewski
Quoted 16 lines
Up till this commit passing NULL as input parameter was allowed, but not handled properly.
When one passed NULL to one of this function parameters, the code was executed causing data abort.
However, what is more interesting, the abort was not caught because of code execution in HYP mode with masked CPSR A bit ("Imprecise Data Abort mask bit). The TI's AM57xx SoC switch to HYP mode with A bit masked in
lowlevel_init.Sdue to SMC call. Such operation (by default) is performed in SoC ROM code.The problem would pop up when one:
- Switch back to SVC mode after disabling LPAE support
- Somebody enables A bit (by executing cpsie a asm instruction)
Quoted 8 lines
Quoted 5 lines
and then the previously described exception would be caught.
Signed-off-by Lukasz Majewski <[email protected]>--- arch/arm/cpu/armv7/omap-common/clocks-common.c | 10 ++++++----This has been moved to
arch/arm/mach-omap2/clocks-common.cPlease use the latest U-Boot.
Ok. I'm not working on a cutting-edge u-boot.
Quoted 10 lines
Quoted 10 lines
1 file changed, 6 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/arch/arm/cpu/armv7/omap-common/clocks-common.cindex 097b8e3..157155a 100644 ---a/arch/arm/cpu/armv7/omap-common/clocks-common.c+++b/arch/arm/cpu/armv7/omap-common/clocks-common.c@@ -822,27 +822,29 @@ void do_enable_clocks(u32 const*clk_domains, u32 i, max = 100;
Quoted 7 lines
Quoted 4 lines
arch/arm/cpu/armv7/omap-common/clocks-common.c +1
-1/* Put the clock domains in SW_WKUP mode */ -for (i =0 ; (i < max) && clk_domains[i]; i++) { + for (i = 0; (i < max) && clk_domains && clk_domains[i];i++) {
Instead of checking for
clk_domainsevery time, can we use max asARRAY_SIZE(clk_domains)?
do_enable_clocks() accepts pointer to u32 as an argument (clk_domains). IMHO the ARRAY_SIZE(clk_domains) would be 1 - always.
Quoted 28 lines
Similarly other places.
Thanks and regards,
LokeshQuoted 23 lines
arch/arm/cpu/armv7/omap-common/clocks-common.c +2
-1enable_clock_domain (clk_domains[i],CD_CLKCTRL_CLKTRCTRL_SW_WKUP ); }/* Clock modules that need to be put in HW_AUTO */ -for (i =0 ; (i < max) && clk_modules_hw_auto[i]; i++) { +for (i =0 ; (i < max) && clk_modules_hw_auto && + clk_modules_hw_auto[i]; i++) {enable_clock_module (clk_modules_hw_auto[i],MODULE_CLKCTRL_MODULEMODE_HW_AUTO , wait_for_enable); };/* Clock modules that need to be put in SW_EXPLICIT_EN mode */
arch/arm/cpu/armv7/omap-common/clocks-common.c +2
-1-for (i =0 ; (i < max) && clk_modules_explicit_en[i]; i++) { +for (i =0 ; (i < max) && clk_modules_explicit_en && + clk_modules_explicit_en[i]; i++) {enable_clock_module (clk_modules_explicit_en[i],MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN , wait_for_enable); };
Quoted 7 lines
arch/arm/cpu/armv7/omap-common/clocks-common.c void do_enable_clocks(u32 const *clk_domains, · line 850
Quoted 7 lines
arch/arm/cpu/armv7/omap-common/clocks-common.c +1
-1/* Put the clock domains in HW_AUTO mode now */ -for (i =0 ; (i < max) && clk_domains[i]; i++) { + for (i = 0; (i < max) && clk_domains && clk_domains[i];i++) { enable_clock_domain(clk_domains[i],
arch/arm/cpu/armv7/omap-common/clocks-common.c +0
-0CD_CLKCTRL_CLKTRCTRL_HW_AUTO); }
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
PATCH 1/1 ti: clocks: Fix do_enable_clocks() to accept NULL pointers as input parameters
Quoted 50 lines · Lukasz Majewski
Hi Lokesh,
Quoted 19 lines · Lukasz Majewski
Quoted 16 lines
Up till this commit passing NULL as input parameter was allowed, but not handled properly.
When one passed NULL to one of this function parameters, the code was executed causing data abort.
However, what is more interesting, the abort was not caught because of code execution in HYP mode with masked CPSR A bit ("Imprecise Data Abort mask bit). The TI's AM57xx SoC switch to HYP mode with A bit masked in
lowlevel_init.Sdue to SMC call. Such operation (by default) is performed in SoC ROM code.The problem would pop up when one:
- Switch back to SVC mode after disabling LPAE support
- Somebody enables A bit (by executing cpsie a asm instruction)Quoted 8 lines
Quoted 5 lines
and then the previously described exception would be caught.
Signed-off-by Lukasz Majewski <[email protected]>--- arch/arm/cpu/armv7/omap-common/clocks-common.c | 10 ++++++----This has been moved to
arch/arm/mach-omap2/clocks-common.cPlease use the latest U-Boot.Ok. I'm not working on a cutting-edge u-boot.
Quoted 10 lines
Quoted 10 lines
1 file changed, 6 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/arch/arm/cpu/armv7/omap-common/clocks-common.cindex 097b8e3..157155a 100644 ---a/arch/arm/cpu/armv7/omap-common/clocks-common.c+++b/arch/arm/cpu/armv7/omap-common/clocks-common.c@@ -822,27 +822,29 @@ void do_enable_clocks(u32 const*clk_domains, u32 i, max = 100;Quoted 7 lines
Quoted 4 lines
arch/arm/cpu/armv7/omap-common/clocks-common.c +1
-1/* Put the clock domains in SW_WKUP mode */ -for (i =0 ; (i < max) && clk_domains[i]; i++) { + for (i = 0; (i < max) && clk_domains && clk_domains[i];i++) {
Instead of checking for
clk_domainsevery time, can we use max asARRAY_SIZE(clk_domains)?
Quoted 3 lines
do_enable_clocks()accepts pointer to u32 as an argument (clk_domains). IMHO theARRAY_SIZE(clk_domains)would be 1 - always.
you are right. Discard my comment.
Thanks and regards,
Lokesh
PATCH v2 1/1 ti: clocks: Fix do_enable_clocks() to accept NULL pointers as input parameters
In reply to Lukasz MajewskiUp till this commit passing NULL as input parameter was allowed, but not handled properly.
When one passed NULL to one of this function parameters, the code was executed causing data abort.
However, what is more interesting, the abort was not caught because of code execution in HYP mode with masked CPSR A bit ("Imprecise Data Abort mask bit). The TI's AM57xx SoC switch to HYP mode with A bit masked in lowlevel_init.S due to SMC call. Such operation (by default) is performed in SoC ROM code.
The problem would pop up when one:
- Switch back to SVC mode after disabling LPAE support
- Somebody enables A bit (by executing cpsie a asm instruction)
and then the previously described exception would be caught.
---
Changes for v2:
- Rebase to the newest "master" branch
--- arch/arm/mach-omap2/clocks-common.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/arm/mach-omap2/clocks-common.c +6 -4
@@ -828,27 +828,29 @@ void do_enable_clocks(u32 const *clk_domains,u32 i, max =100 ;/* Put the clock domains in SW_WKUP mode */ -for (i =0 ; (i < max) && clk_domains[i]; i++) { +for (i =0 ; (i < max) && clk_domains && clk_domains[i]; i++) {enable_clock_domain (clk_domains[i],CD_CLKCTRL_CLKTRCTRL_SW_WKUP ); }/* Clock modules that need to be put in HW_AUTO */ -for (i =0 ; (i < max) && clk_modules_hw_auto[i]; i++) { +for (i =0 ; (i < max) && clk_modules_hw_auto && + clk_modules_hw_auto[i]; i++) {enable_clock_module (clk_modules_hw_auto[i],MODULE_CLKCTRL_MODULEMODE_HW_AUTO , wait_for_enable); };/* Clock modules that need to be put in SW_EXPLICIT_EN mode */ -for (i =0 ; (i < max) && clk_modules_explicit_en[i]; i++) { +for (i =0 ; (i < max) && clk_modules_explicit_en && + clk_modules_explicit_en[i]; i++) {enable_clock_module (clk_modules_explicit_en[i],MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN , wait_for_enable); };/* Put the clock domains in HW_AUTO mode now */ -for (i =0 ; (i < max) && clk_domains[i]; i++) { +for (i =0 ; (i < max) && clk_domains && clk_domains[i]; i++) {enable_clock_domain (clk_domains[i],CD_CLKCTRL_CLKTRCTRL_HW_AUTO ); }
Signature · 1 line
2.1.4
PATCH v2 1/1 ti: clocks: Fix do_enable_clocks() to accept NULL pointers as input parameters
Quoted 11 lines · Lukasz Majewski
Up till this commit passing NULL as input parameter was allowed, but not handled properly.
When one passed NULL to one of this function parameters, the code was executed causing data abort.
However, what is more interesting, the abort was not caught because of code execution in HYP mode with masked CPSR A bit ("Imprecise Data Abort mask bit). The TI's AM57xx SoC switch to HYP mode with A bit masked in
lowlevel_init.Sdue to SMC call. Such operation (by default) is performed in SoC ROM code.
Quoted 7 lines
The problem would pop up when one:
- Switch back to SVC mode after disabling LPAE support
- Somebody enables A bit (by executing cpsie a asm instruction)and then the previously described exception would be caught.
Signed-off-by Lukasz Majewski <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170404/4c75993a/attachment.sig>
PATCH v2 1/1 ti: clocks: Fix do_enable_clocks() to accept NULL pointers as input parameters
In reply to Lukasz MajewskiQuoted 11 lines · Lukasz Majewski
Up till this commit passing NULL as input parameter was allowed, but not handled properly.
When one passed NULL to one of this function parameters, the code was executed causing data abort.
However, what is more interesting, the abort was not caught because of code execution in HYP mode with masked CPSR A bit ("Imprecise Data Abort mask bit). The TI's AM57xx SoC switch to HYP mode with A bit masked in
lowlevel_init.Sdue to SMC call. Such operation (by default) is performed in SoC ROM code.
Quoted 8 lines
The problem would pop up when one:
- Switch back to SVC mode after disabling LPAE support
- Somebody enables A bit (by executing cpsie a asm instruction)and then the previously described exception would be caught.
Signed-off-by Lukasz Majewski <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170410/a1c6b171/attachment.sig>