vexpress: disable cci ace slave ports when booting in non-sec/hyp mode
PATCH 1/1 vexpress: disable cci ace slave ports when booting in non-sec/hyp mode
Commit f225d39d3093 ("vexpress: Check TC2 firmware support before defaulting to nonsec booting") added support to check if the firmware on TC2 is configured appropriately before booting in nonsec/hyp mode.
However when booting in non-secure/hyp mode, CCI control must be done in secure firmware and can't be done in non-secure/hyp mode. In order to ensure that, this patch disables the cci slave port inteface so that it is not accessed at all.
--- board/armltd/vexpress/vexpress_tc2.c | 47 ++++++++++++++++++++++++++++++++++++ configs/vexpress_ca15_tc2_defconfig | 1 + 2 files changed, 48 insertions(+)
Hi,
This change is needed to avoid the kernel panic while attempting to access CCI ports when booting in non-sec/HYP mode. The kernel patches to fix this are available @[1]
Regards,
Sudeep
[1] http://www.spinics.net/lists/arm-kernel/msg533715.html
board/armltd/vexpress/vexpress_tc2.c +47 -0
@@ -8,6 +8,9 @@*/ #include <asm/io.h> +#include <asm/u-boot.h> +#include <common.h> +#include <libfdt.h> #define SCC_BASE 0x7fff0000
@@ -31,3 +34,47 @@ bool armv7_boot_nonsec_default(void)return (readl ((u32 *)(SCC_BASE +0x700 )) & ((1 <<12 ) | (1 <<13 ))) ==0 ;#endif } + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *fdt,bd_t *bd) +{ +int offset, tmp, len; +const struct fdt_property *prop; +const char *cci_compatible ="arm,cci-400-ctrl-if" ; + +if (!armv7_boot_nonsec_default ()) +return 0 ;/* Do nothing */ + + offset =fdt_path_offset (fdt,"/cpus" ); +if (offset <0 ) { +printf ("couldn't find /cpus\n" ); +return offset; + } + +/* delete cci-control-port in each cpu node */ +for (tmp =fdt_first_subnode (fdt, offset); tmp >=0 ; + tmp =fdt_next_subnode (fdt, tmp)) +fdt_delprop (fdt, tmp,"cci-control-port" ); + +/* disable all ace cci slave ports */ + offset =fdt_node_offset_by_prop_value (fdt, offset,"compatible" , + cci_compatible,20 ); +while (offset >0 ) { + prop =fdt_get_property (fdt, offset,"interface-type" , + &len); +if (!prop) +continue ; +if (len <4 ) +continue ; +if (strcmp (prop->data,"ace" )) +continue ; + +fdt_setprop_string (fdt, offset,"status" ,"disabled" ); + + offset =fdt_node_offset_by_prop_value (fdt, offset,"compatible" , + cci_compatible,20 ); + } + +return 0 ; +} +#endif /* CONFIG_OF_BOARD_SETUP */
configs/vexpress_ca15_tc2_defconfig +1 -0
@@ -1,5 +1,6 @@ CONFIG_ARM=y CONFIG_TARGET_VEXPRESS_CA15_TC2=y +CONFIG_OF_BOARD_SETUP=y CONFIG_HUSH_PARSER=y # CONFIG_CMD_CONSOLE is not set # CONFIG_CMD_BOOTD is not set
--
2.7.4
PATCH 1/1 vexpress: disable cci ace slave ports when booting in non-sec/hyp mode
Quoted 11 lines · Sudeep Holla
Commit
f225d39d3093("vexpress: Check TC2 firmware support before defaulting to nonsec booting") added support to check if the firmware on TC2 is configured appropriately before booting in nonsec/hyp mode.However when booting in non-secure/hyp mode, CCI control must be done in secure firmware and can't be done in non-secure/hyp mode. In order to ensure that, this patch disables the cci slave port inteface so that it is not accessed at all.
Cc Jon Medhurst <[email protected]>Signed-off-by Sudeep Holla <[email protected]>
Ah, that'd be a great reason for me to update the 2.5 year old u-boot that lives on my TC2!
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
PATCH 1/1 vexpress: disable cci ace slave ports when booting in non-sec/hyp mode
In reply to Sudeep Hollaboard/armltd/vexpress/vexpress_tc2.c bool armv7_boot_nonsec_default(void) · line 47
Quoted 10 lines · Sudeep Holla
board/armltd/vexpress/vexpress_tc2.c +10
-0+#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *fdt,bd_t *bd) +{ +int offset, tmp, len; +const struct fdt_property *prop; +const char *cci_compatible ="arm,cci-400-ctrl-if" ; + +if (!armv7_boot_nonsec_default ()) +return 0 ;/* Do nothing */ +
That's just testing the default not whether the board is actually going to boot in nonsec (hyp) mode or not, which also also depends on environment variables. So you probably want instead to call armv7_boot_nonsec() here. That function only exists if CONFIG_ARMV7_NONSEC is defined, so the 'if' statement above probably wants to be something like...
#ifdef CONFIG_ARMV7_NONSEC if (!armv7_boot_nonsec()) return 0; #else return 0; #endif /* We only get here if board will boot in nonsec mode */
Signature · 1 line
Tixy
PATCH 1/1 vexpress: disable cci ace slave ports when booting in non-sec/hyp mode
Quoted 15 lines · Jon Medhurst (Tixy)
board/armltd/vexpress/vexpress_tc2.c bool armv7_boot_nonsec_default(void) · line 47
Quoted 10 lines · Sudeep Holla
board/armltd/vexpress/vexpress_tc2.c +10
-0+#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *fdt,bd_t *bd) +{ +int offset, tmp, len; +const struct fdt_property *prop; +const char *cci_compatible ="arm,cci-400-ctrl-if" ; + +if (!armv7_boot_nonsec_default ()) +return 0 ;/* Do nothing */ +That's just testing the default not whether the board is actually going to boot in nonsec (hyp) mode or not, which also also depends on environment variables.
Ah ok, wasn't aware of that. Thanks for pointing that out.
Quoted 5 lines
So you probably want instead to call
armv7_boot_nonsec()here. That function only exists ifCONFIG_ARMV7_NONSECis defined, so the 'if' statement above probably wants to be something like...
Quoted 8 lines
#ifdef CONFIG_ARMV7_NONSEC if (!armv7_boot_nonsec()) return 0; #else return 0; #endif /* We only get here if board will boot in nonsec mode */
OK, will update accordingly.
Signature · 2 lines
Regards, Sudeep
PATCH v2 1/1 vexpress: disable cci ace slave ports when booting in non-sec/hyp mode
In reply to Sudeep HollaCommit f225d39d3093 ("vexpress: Check TC2 firmware support before defaulting to nonsec booting") added support to check if the firmware on TC2 is configured appropriately before booting in nonsec/hyp mode.
However when booting in non-secure/hyp mode, CCI control must be done in secure firmware and can't be done in non-secure/hyp mode. In order to ensure that, this patch disables the cci slave port inteface so that it is not accessed at all.
--- board/armltd/vexpress/vexpress_tc2.c | 52 ++++++++++++++++++++++++++++++++++++ configs/vexpress_ca15_tc2_defconfig | 1 + 2 files changed, 53 insertions(+)
Hi,
This change is needed to avoid the kernel panic while attempting to access CCI ports when booting in non-sec/HYP mode. The kernel patches to fix this are available @[1]
Regards,
Sudeep
v1->v2:
- Fix compilation with !CONFIG_ARMV7_NONSEC(Thanks to Tixy)
[1] http://www.spinics.net/lists/arm-kernel/msg533715.html
board/armltd/vexpress/vexpress_tc2.c +52 -0
@@ -7,7 +7,11 @@* SPDX-License-Identifier: GPL-2.0+ */ +#include <asm/armv7.h> #include <asm/io.h> +#include <asm/u-boot.h> +#include <common.h> +#include <libfdt.h> #define SCC_BASE 0x7fff0000
@@ -31,3 +35,51 @@ bool armv7_boot_nonsec_default(void)return (readl ((u32 *)(SCC_BASE +0x700 )) & ((1 <<12 ) | (1 <<13 ))) ==0 ;#endif } + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *fdt,bd_t *bd) +{ +int offset, tmp, len; +const struct fdt_property *prop; +const char *cci_compatible ="arm,cci-400-ctrl-if" ; + +#ifdef CONFIG_ARMV7_NONSEC +if (!armv7_boot_nonsec ()) +return 0 ; +#else +return 0 ; +#endif +/* Booting in nonsec mode, disable CCI access */ + offset =fdt_path_offset (fdt,"/cpus" ); +if (offset <0 ) { +printf ("couldn't find /cpus\n" ); +return offset; + } + +/* delete cci-control-port in each cpu node */ +for (tmp =fdt_first_subnode (fdt, offset); tmp >=0 ; + tmp =fdt_next_subnode (fdt, tmp)) +fdt_delprop (fdt, tmp,"cci-control-port" ); + +/* disable all ace cci slave ports */ + offset =fdt_node_offset_by_prop_value (fdt, offset,"compatible" , + cci_compatible,20 ); +while (offset >0 ) { + prop =fdt_get_property (fdt, offset,"interface-type" , + &len); +if (!prop) +continue ; +if (len <4 ) +continue ; +if (strcmp (prop->data,"ace" )) +continue ; + +fdt_setprop_string (fdt, offset,"status" ,"disabled" ); + + offset =fdt_node_offset_by_prop_value (fdt, offset,"compatible" , + cci_compatible,20 ); + } + +return 0 ; +} +#endif /* CONFIG_OF_BOARD_SETUP */
configs/vexpress_ca15_tc2_defconfig +1 -0
@@ -1,5 +1,6 @@ CONFIG_ARM=y CONFIG_TARGET_VEXPRESS_CA15_TC2=y +CONFIG_OF_BOARD_SETUP=y CONFIG_HUSH_PARSER=y # CONFIG_CMD_CONSOLE is not set # CONFIG_CMD_BOOTD is not set
--
2.7.4
PATCH v2 1/1 vexpress: disable cci ace slave ports when booting in non-sec/hyp mode
Quoted 9 lines · Sudeep Holla
Commit
f225d39d3093("vexpress: Check TC2 firmware support before defaulting to nonsec booting") added support to check if the firmware on TC2 is configured appropriately before booting in nonsec/hyp mode.However when booting in non-secure/hyp mode, CCI control must be done in secure firmware and can't be done in non-secure/hyp mode. In order to ensure that, this patch disables the cci slave port inteface so that it is not accessed at all.
Quoted 4 lines
Cc Jon Medhurst <[email protected]>Acked-by Marc Zyngier <[email protected]>Signed-off-by Sudeep Holla <[email protected]>---
This works for me (unsurprisingly) when booting in secure mode. What kernel and firmware config do I need to use for non-sec mode? I tried vexpress_defconfig, with bits 12 and 13 cleared in SCC: 0x700 but I get nothing out the console after "Starting kernel ..."
Signature · 1 line
Tixy
PATCH v2 1/1 vexpress: disable cci ace slave ports when booting in non-sec/hyp mode
Quoted 15 lines · Jon Medhurst (Tixy)
Quoted 9 lines · Sudeep Holla
Commit
f225d39d3093("vexpress: Check TC2 firmware support before defaulting to nonsec booting") added support to check if the firmware on TC2 is configured appropriately before booting in nonsec/hyp mode.However when booting in non-secure/hyp mode, CCI control must be done in secure firmware and can't be done in non-secure/hyp mode. In order to ensure that, this patch disables the cci slave port inteface so that it is not accessed at all.
Quoted 4 lines
Cc Jon Medhurst <[email protected]>Acked-by Marc Zyngier <[email protected]>Signed-off-by Sudeep Holla <[email protected]>---
Quoted 5 lines
This works for me (unsurprisingly) when booting in secure mode. What kernel and firmware config do I need to use for non-sec mode? I tried
vexpress_defconfig, with bits 12 and 13 cleared in SCC:0x700but I get nothing out the console after "Starting kernel ..."
I just flipped bit 12 and 13 in SCC: 0x700 to switch between MCPM/secure and HYP/non-secure mode. All other images/settings remain the same.
So IIUC, with vexpress_defconfig + above SCC change you are seeing a hand, I will check that. I am using multi_v7_defconfig.
Signature · 2 lines
Regards, Sudeep
PATCH v2 1/1 vexpress: disable cci ace slave ports when booting in non-sec/hyp mode
Quoted 25 lines · Sudeep Holla
Quoted 16 lines · Jon Medhurst (Tixy)
Quoted 10 lines · Sudeep Holla
Commit
f225d39d3093("vexpress: Check TC2 firmware support before defaulting
to nonsec booting") added support to check if the firmware on TC2 is configured appropriately before booting in nonsec/hyp mode.However when booting in non-secure/hyp mode, CCI control must be done in secure firmware and can't be done in non-secure/hyp mode. In order to ensure that, this patch disables the cci slave port inteface so that it is not accessed at all.
Quoted 4 lines
Cc Jon Medhurst <[email protected]>Acked-by Marc Zyngier <[email protected]>Signed-off-by Sudeep Holla <[email protected]>---
Quoted 5 lines
This works for me (unsurprisingly) when booting in secure mode. What kernel and firmware config do I need to use for non-sec mode? I tried
vexpress_defconfig, with bits 12 and 13 cleared in SCC:0x700but I get nothing out the console after "Starting kernel ..."
Quoted 6 lines
I just flipped bit 12 and 13 in SCC:
0x700to switch between MCPM/secure and HYP/non-secure mode. All other images/settings remain the same.So IIUC, with
vexpress_defconfig+ above SCC change you are seeing a hand, I will check that. I am usingmulti_v7_defconfig.
+ the patches from Lorenzo fixing MCPM code in the kernel [1] as mentioned first email carrying this patch.
Signature · 4 lines
Regards, Sudeep [1] http://www.spinics.net/lists/arm-kernel/msg533715.html
PATCH v2 1/1 vexpress: disable cci ace slave ports when booting in non-sec/hyp mode
In reply to Sudeep HollaQuoted 9 lines · Sudeep Holla
Commit
f225d39d3093("vexpress: Check TC2 firmware support before defaulting to nonsec booting") added support to check if the firmware on TC2 is configured appropriately before booting in nonsec/hyp mode.However when booting in non-secure/hyp mode, CCI control must be done in secure firmware and can't be done in non-secure/hyp mode. In order to ensure that, this patch disables the cci slave port inteface so that it is not accessed at all.
Quoted 4 lines
Cc Jon Medhurst <[email protected]>Acked-by Marc Zyngier <[email protected]>Signed-off-by Sudeep Holla <[email protected]>---
Quoted 100 lines
board/armltd/vexpress/vexpress_tc2.c | 52 ++++++++++++++++++++++++++++++++++++ configs/vexpress_ca15_tc2_defconfig | 1 + 2 files changed, 53 insertions(+)Hi,
This change is needed to avoid the kernel panic while attempting to access CCI ports when booting in non-sec/HYP mode. The kernel patches to fix this are available @[1]
Regards,
Sudeep
v1->v2:
- Fix compilation with !CONFIG_ARMV7_NONSEC(Thanks to Tixy)[1] http://www.spinics.net/lists/arm-kernel/msg533715.html
board/armltd/vexpress/vexpress_tc2.c +52
-0@@ -7,7 +7,11 @@* SPDX-License-Identifier: GPL-2.0+ */ +#include <asm/armv7.h> #include <asm/io.h> +#include <asm/u-boot.h> +#include <common.h> +#include <libfdt.h> #define SCC_BASE 0x7fff0000@@ -31,3 +35,51 @@ bool armv7_boot_nonsec_default(void)return (readl ((u32 *)(SCC_BASE +0x700 )) & ((1 <<12 ) | (1 <<13 ))) ==0 ;#endif } + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *fdt,bd_t *bd) +{ +int offset, tmp, len; +const struct fdt_property *prop; +const char *cci_compatible ="arm,cci-400-ctrl-if" ; + +#ifdef CONFIG_ARMV7_NONSEC +if (!armv7_boot_nonsec ()) +return 0 ; +#else +return 0 ; +#endif +/* Booting in nonsec mode, disable CCI access */ + offset =fdt_path_offset (fdt,"/cpus" ); +if (offset <0 ) { +printf ("couldn't find /cpus\n" ); +return offset; + } + +/* delete cci-control-port in each cpu node */ +for (tmp =fdt_first_subnode (fdt, offset); tmp >=0 ; + tmp =fdt_next_subnode (fdt, tmp)) +fdt_delprop (fdt, tmp,"cci-control-port" ); + +/* disable all ace cci slave ports */ + offset =fdt_node_offset_by_prop_value (fdt, offset,"compatible" , + cci_compatible,20 ); +while (offset >0 ) { + prop =fdt_get_property (fdt, offset,"interface-type" , + &len); +if (!prop) +continue ; +if (len <4 ) +continue ; +if (strcmp (prop->data,"ace" )) +continue ; + +fdt_setprop_string (fdt, offset,"status" ,"disabled" ); + + offset =fdt_node_offset_by_prop_value (fdt, offset,"compatible" , + cci_compatible,20 ); + } + +return 0 ; +} +#endif /* CONFIG_OF_BOARD_SETUP */ configs/vexpress_ca15_tc2_defconfig +1
-1@@ -1,5 +1,6 @@ CONFIG_ARM=y CONFIG_TARGET_VEXPRESS_CA15_TC2=y +CONFIG_OF_BOARD_SETUP=y CONFIG_HUSH_PARSER=y # CONFIG_CMD_CONSOLE is not set # CONFIG_CMD_BOOTD is not set --2.7.4
PATCH v2 1/1 vexpress: disable cci ace slave ports when booting in non-sec/hyp mode
Quoted 10 lines · Jon Medhurst (Tixy)
Quoted 9 lines · Sudeep Holla
Commit
f225d39d3093("vexpress: Check TC2 firmware support before defaulting to nonsec booting") added support to check if the firmware on TC2 is configured appropriately before booting in nonsec/hyp mode.However when booting in non-secure/hyp mode, CCI control must be done in secure firmware and can't be done in non-secure/hyp mode. In order to ensure that, this patch disables the cci slave port inteface so that it is not accessed at all.
Quoted 7 lines
Quoted 4 lines
Cc Jon Medhurst <[email protected]>Acked-by Marc Zyngier <[email protected]>Signed-off-by Sudeep Holla <[email protected]>---
Acked-by Jon Medhurst <[email protected]>Tested-by Jon Medhurst <[email protected]>
So, can I assume the missing kernel patches to be reason for boot hang ? Just wanted to know if I need to investigate that any further ?
Signature · 2 lines
Regards, Sudeep
PATCH v2 1/1 vexpress: disable cci ace slave ports when booting in non-sec/hyp mode
Quoted 17 lines · Sudeep Holla
Quoted 15 lines · Jon Medhurst (Tixy)
Quoted 13 lines · Sudeep Holla
Commit
f225d39d3093("vexpress: Check TC2 firmware support before defaulting to nonsec booting") added support to check if the firmware on TC2 is configured appropriately before booting in nonsec/hyp mode.However when booting in non-secure/hyp mode, CCI control must be done in secure firmware and can't be done in non-secure/hyp mode. In order to ensure that, this patch disables the cci slave port inteface so that it is not accessed at all.
Cc Jon Medhurst <[email protected]>Acked-by Marc Zyngier <[email protected]>Signed-off-by Sudeep Holla <[email protected]>---
Quoted 5 lines
Quoted 2 lines
Acked-by Jon Medhurst <[email protected]>Tested-by Jon Medhurst <[email protected]>So, can I assume the missing kernel patches to be reason for boot hang ? Just wanted to know if I need to investigate that any further ?
Sorry, yes they were the reason and no further investigation needed. I remembered getting nonsec mode working some month's ago without such patches, but I remember now that was by disabling MCPM in the kernel.
This morning I tried these U-Boot patches successfully with:
- Upstream vexpress_defconfig kernel booting with 'sec' mode
- That kernel with Lorenzo's patches in both 'sec' and 'nonsec'
- As above with CONFIG_BL_SWITCHER enabled
When booting in nonsec I also verified the device-tree modifications made by this patch by seeing the following files existed and contained the word 'disabled'...
/proc/device-tree/cci at 2c090000/slave-if at 4000/status /proc/device-tree/cci at 2c090000/slave-if at 5000/status
Signature · 1 line
Tixy
PATCH v2 1/1 vexpress: disable cci ace slave ports when booting in non-sec/hyp mode
Quoted 33 lines · Jon Medhurst (Tixy)
Quoted 17 lines · Sudeep Holla
Quoted 15 lines · Jon Medhurst (Tixy)
Quoted 13 lines · Sudeep Holla
Commit
f225d39d3093("vexpress: Check TC2 firmware support before defaulting to nonsec booting") added support to check if the firmware on TC2 is configured appropriately before booting in nonsec/hyp mode.However when booting in non-secure/hyp mode, CCI control must be done in secure firmware and can't be done in non-secure/hyp mode. In order to ensure that, this patch disables the cci slave port inteface so that it is not accessed at all.
Cc Jon Medhurst <[email protected]>Acked-by Marc Zyngier <[email protected]>Signed-off-by Sudeep Holla <[email protected]>---
Quoted 5 lines
Quoted 2 lines
Acked-by Jon Medhurst <[email protected]>Tested-by Jon Medhurst <[email protected]>So, can I assume the missing kernel patches to be reason for boot hang ? Just wanted to know if I need to investigate that any further ?
Sorry, yes they were the reason and no further investigation needed. I remembered getting nonsec mode working some month's ago without such patches, but I remember now that was by disabling MCPM in the kernel.
This morning I tried these U-Boot patches successfully with:
- Upstreamvexpress_defconfigkernel booting with 'sec' mode
- That kernel with Lorenzo's patches in both 'sec' and 'nonsec'
- As above withCONFIG_BL_SWITCHERenabled
Quoted 7 lines
When booting in nonsec I also verified the device-tree modifications made by this patch by seeing the following files existed and contained the word 'disabled'...
/proc/device-tree/cciat 2c090000/slave-if at 4000/status/proc/device-tree/cciat 2c090000/slave-if at 5000/status
That was very detailed :), thanks for testing and confirming. I too did similar examination and didn't find anything odd so far.
Signature · 2 lines
Regards, Sudeep
PATCH v2 1/1 vexpress: disable cci ace slave ports when booting in non-sec/hyp mode
In reply to Sudeep HollaQuoted 9 lines · Sudeep Holla
Commit
f225d39d3093("vexpress: Check TC2 firmware support before defaulting to nonsec booting") added support to check if the firmware on TC2 is configured appropriately before booting in nonsec/hyp mode.However when booting in non-secure/hyp mode, CCI control must be done in secure firmware and can't be done in non-secure/hyp mode. In order to ensure that, this patch disables the cci slave port inteface so that it is not accessed at all.
Quoted 5 lines
Cc Jon Medhurst <[email protected]>Acked-by Marc Zyngier <[email protected]>Signed-off-by Sudeep Holla <[email protected]>Acked-by Jon Medhurst <[email protected]>Tested-by Jon Medhurst <[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/20161008/851f83d8/attachment.sig>